step1_controller.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. App.WizardStep1Controller = Em.Controller.extend({
  20. name: 'wizardStep1Controller',
  21. /**
  22. * Skip repo-validation
  23. * @type {bool}
  24. */
  25. skipValidationChecked: false,
  26. useRedhatSatellite: false,
  27. selectedStack: function() {
  28. return App.Stack.find().findProperty('isSelected');
  29. }.property('content.stacks.@each.isSelected'),
  30. optionsToSelect: {
  31. 'usePublicRepo': {
  32. index: 0,
  33. isSelected: true
  34. },
  35. 'useLocalRepo': {
  36. index: 1,
  37. isSelected: false,
  38. 'uploadFile': {
  39. index: 0,
  40. name: 'uploadFile',
  41. file: '',
  42. hasError: false,
  43. isSelected: true
  44. },
  45. 'enterUrl': {
  46. index: 1,
  47. name: 'enterUrl',
  48. url: 'http://',
  49. hasError: false,
  50. isSelected: false
  51. }
  52. }
  53. },
  54. /**
  55. * Used to set version definition file from FileUploader
  56. * @method setVDFFile
  57. * @param {string} vdf
  58. */
  59. setVDFFile: function (vdf) {
  60. this.set("optionsToSelect.useLocalRepo.uploadFile.file", vdf);
  61. },
  62. /**
  63. * Load selected file to current page content
  64. */
  65. readVersionInfo: function(){
  66. var data = {};
  67. var isXMLdata = false;
  68. if (this.get("optionsToSelect.usePublicRepo.isSelected")) return;
  69. if (this.get("optionsToSelect.useLocalRepo.isSelected") && this.get("optionsToSelect.useLocalRepo.enterUrl.isSelected")) {
  70. var url = this.get("optionsToSelect.useLocalRepo.enterUrl.url");
  71. data = {
  72. "VersionDefinition": {
  73. "version_url": url
  74. }
  75. };
  76. App.db.setLocalRepoVDFData(url);
  77. } else if (this.get("optionsToSelect.useLocalRepo.uploadFile.isSelected")) {
  78. isXMLdata = true;
  79. // load from file browser
  80. data = this.get("optionsToSelect.useLocalRepo.uploadFile.file");
  81. App.db.setLocalRepoVDFData(data);
  82. }
  83. var installerController = App.router.get('installerController');
  84. var self = this;
  85. installerController.postVersionDefinitionFile(isXMLdata, data).done(function (response) {
  86. self.set('latestSelectedLocalRepoId', response.stackNameVersion + "-" + response.actualVersion);
  87. // load successfully, so make this local stack repo as selectedStack
  88. self.get('content.stacks').setEach('isSelected', false);
  89. self.get('content.stacks').findProperty('id', response.stackNameVersion + "-" + response.actualVersion).set('isSelected', true);
  90. Ember.run.next(function () {
  91. $("[rel=skip-validation-tooltip]").tooltip({ placement: 'right'});
  92. $("[rel=use-redhat-tooltip]").tooltip({ placement: 'right'});
  93. });
  94. });
  95. },
  96. /**
  97. * On click handler for removing OS
  98. */
  99. removeOS: function(event) {
  100. var osToRemove = event.context;
  101. Em.set(osToRemove, 'isSelected', false);
  102. },
  103. /**
  104. * On click handler for adding new OS
  105. */
  106. addOS: function(event) {
  107. var osToAdd = event.context;
  108. Em.set(osToAdd, 'isSelected', true);
  109. }
  110. });