step1_controller.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. selectedStack: function() {
  27. return App.Stack.find().findProperty('isSelected');
  28. }.property('content.stacks.@each.isSelected'),
  29. optionsToSelect: {
  30. 'usePublicRepo': {
  31. index: 0,
  32. isSelected: true
  33. },
  34. 'useLocalRepo': {
  35. index: 1,
  36. isSelected: false,
  37. 'uploadFile': {
  38. index: 0,
  39. name: 'uploadFile',
  40. file: '',
  41. hasError: false,
  42. isSelected: true
  43. },
  44. 'enterUrl': {
  45. index: 1,
  46. name: 'enterUrl',
  47. url: '',
  48. placeholder: 'Enter URL to Version Definition File',
  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. if (this.get('selectedStack.useRedhatSatellite')) {
  101. return;
  102. }
  103. var osToRemove = event.context;
  104. Em.set(osToRemove, 'isSelected', false);
  105. },
  106. /**
  107. * On click handler for adding new OS
  108. */
  109. addOS: function(event) {
  110. var osToAdd = event.context;
  111. Em.set(osToAdd, 'isSelected', true);
  112. },
  113. changeUseRedhatSatellite: function () {
  114. if (this.get('selectedStack.useRedhatSatellite')) {
  115. return App.ModalPopup.show({
  116. header: Em.I18n.t('common.important'),
  117. secondary: false,
  118. bodyClass: Ember.View.extend({
  119. template: Ember.Handlebars.compile(Em.I18n.t('installer.step1.advancedRepo.useRedhatSatellite.warning'))
  120. })
  121. });
  122. }
  123. }.observes('selectedStack.useRedhatSatellite')
  124. });