add_hawq_standby_routes.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. module.exports = App.WizardRoute.extend({
  20. route: '/highAvailability/Hawq/add',
  21. enter: function (router, transition) {
  22. var addHawqStandbyWizardController = router.get('addHawqStandbyWizardController');
  23. addHawqStandbyWizardController.dataLoading().done(function () {
  24. //Set HAWQ as current service
  25. App.router.set('mainServiceItemController.content', App.Service.find().findProperty('serviceName', 'HAWQ'));
  26. App.router.get('updateController').set('isWorking', false);
  27. var popup = App.ModalPopup.show({
  28. classNames: ['full-width-modal'],
  29. header: Em.I18n.t('admin.addHawqStandby.wizard.header'),
  30. bodyClass: App.AddHawqStandbyWizardView.extend({
  31. controller: addHawqStandbyWizardController
  32. }),
  33. primary: Em.I18n.t('form.cancel'),
  34. showFooter: false,
  35. secondary: null,
  36. updateClusterStatus: function() {
  37. var controller = router.get('addHawqStandbyWizardController');
  38. router.get('updateController').set('isWorking', true);
  39. addHawqStandbyWizardController.finish();
  40. App.clusterStatus.setClusterStatus({
  41. clusterName: App.router.getClusterName(),
  42. clusterState: 'DEFAULT',
  43. localdb: App.db.data
  44. }, {
  45. alwaysCallback: function () {
  46. controller.get('popup').hide();
  47. router.transitionTo('main.services.index');
  48. Em.run.next(function() {
  49. location.reload();
  50. });
  51. }
  52. });
  53. },
  54. onClose: function () {
  55. var addHawqStandbyWizardController = router.get('addHawqStandbyWizardController'),
  56. currStep = addHawqStandbyWizardController.get('currentStep'),
  57. self = this;
  58. if (parseInt(currStep) === 4) {
  59. App.showConfirmationPopup(function () {
  60. popup.updateClusterStatus();
  61. }, Em.I18n.t('admin.addHawqStandby.closePopup'));
  62. } else {
  63. popup.updateClusterStatus();
  64. }
  65. },
  66. didInsertElement: function () {
  67. this._super();
  68. this.fitHeight();
  69. }
  70. });
  71. addHawqStandbyWizardController.set('popup', popup);
  72. var currentClusterStatus = App.clusterStatus.get('value');
  73. switch (currentClusterStatus.clusterState) {
  74. case 'ADD_HAWQ_STANDBY' :
  75. addHawqStandbyWizardController.setCurrentStep(currentClusterStatus.localdb.AddHawqStandbyWizard.currentStep);
  76. break;
  77. default:
  78. var currStep = App.router.get('addHawqStandbyWizardController.currentStep');
  79. addHawqStandbyWizardController.setCurrentStep(currStep);
  80. break;
  81. }
  82. Em.run.next(function () {
  83. App.router.get('wizardWatcherController').setUser(addHawqStandbyWizardController.get('name'));
  84. router.transitionTo('step' + addHawqStandbyWizardController.get('currentStep'));
  85. });
  86. });
  87. },
  88. step1: Em.Route.extend({
  89. route: '/step1',
  90. connectOutlets: function (router) {
  91. var controller = router.get('addHawqStandbyWizardController');
  92. controller.dataLoading().done(function () {
  93. controller.setCurrentStep('1');
  94. controller.connectOutlet('addHawqStandbyWizardStep1', controller.get('content'));
  95. })
  96. },
  97. unroutePath: function () {
  98. return false;
  99. },
  100. next: function (router) {
  101. var controller = router.get('addHawqStandbyWizardController');
  102. controller.setDBProperty('hawqHosts', undefined);
  103. controller.clearMasterComponentHosts();
  104. router.transitionTo('step2');
  105. }
  106. }),
  107. step2: Em.Route.extend({
  108. route: '/step2',
  109. connectOutlets: function (router) {
  110. var controller = router.get('addHawqStandbyWizardController');
  111. controller.dataLoading().done(function () {
  112. controller.setCurrentStep('2');
  113. controller.loadAllPriorSteps();
  114. controller.connectOutlet('addHawqStandbyWizardStep2', controller.get('content'));
  115. })
  116. },
  117. unroutePath: function () {
  118. return false;
  119. },
  120. next: function (router) {
  121. var controller = router.get('addHawqStandbyWizardController');
  122. var stepController = router.get('addHawqStandbyWizardStep2Controller');
  123. var hawqHost = {
  124. hawqMaster : stepController.get('servicesMasters').filterProperty('component_name', 'HAWQMASTER').findProperty('isInstalled', true).get('selectedHost'),
  125. newHawqStandby : stepController.get('servicesMasters').filterProperty('component_name', 'HAWQSTANDBY').findProperty('isInstalled', false).get('selectedHost')
  126. };
  127. controller.saveHawqHosts(hawqHost);
  128. controller.saveMasterComponentHosts(stepController);
  129. router.transitionTo('step3');
  130. },
  131. back: function (router) {
  132. router.transitionTo('step1');
  133. }
  134. }),
  135. step3: Em.Route.extend({
  136. route: '/step3',
  137. connectOutlets: function (router) {
  138. var controller = router.get('addHawqStandbyWizardController');
  139. controller.dataLoading().done(function () {
  140. controller.setCurrentStep('3');
  141. controller.loadAllPriorSteps();
  142. controller.connectOutlet('addHawqStandbyWizardStep3', controller.get('content'));
  143. })
  144. },
  145. unroutePath: function () {
  146. return false;
  147. },
  148. next: function (router) {
  149. var controller = router.get('addHawqStandbyWizardController');
  150. var stepController = router.get('addHawqStandbyWizardStep3Controller');
  151. var configs = stepController.get('selectedService.configs');
  152. controller.saveConfigs(configs);
  153. router.transitionTo('step4');
  154. },
  155. back: Em.Router.transitionTo('step2')
  156. }),
  157. step4: Em.Route.extend({
  158. route: '/step4',
  159. connectOutlets: function (router) {
  160. var controller = router.get('addHawqStandbyWizardController');
  161. controller.dataLoading().done(function () {
  162. controller.setCurrentStep('4');
  163. controller.setLowerStepsDisable(4);
  164. controller.loadAllPriorSteps();
  165. controller.connectOutlet('addHawqStandbyWizardStep4', controller.get('content'));
  166. })
  167. },
  168. unroutePath: function (router, path) {
  169. // allow user to leave route if wizard has finished
  170. if (router.get('addHawqStandbyWizardController').get('isFinished')) {
  171. this._super(router, path);
  172. } else {
  173. return false;
  174. }
  175. },
  176. next: function (router) {
  177. var controller = router.get('addHawqStandbyWizardController');
  178. controller.finish();
  179. App.clusterStatus.setClusterStatus({
  180. clusterName: controller.get('content.cluster.name'),
  181. clusterState: 'DEFAULT',
  182. localdb: App.db.data
  183. }, {
  184. alwaysCallback: function () {
  185. controller.get('popup').hide();
  186. router.transitionTo('main.services.index');
  187. Em.run.next(function () {
  188. location.reload();
  189. });
  190. }
  191. });
  192. }
  193. })
  194. });