activate_hawq_standby_routes.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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/activate',
  21. enter: function (router, transition) {
  22. var activateHawqStandbyWizardController = router.get('activateHawqStandbyWizardController');
  23. activateHawqStandbyWizardController.dataLoading().done(function () {
  24. App.router.set('mainServiceItemController.content', App.Service.find().findProperty('serviceName', 'HAWQ'));
  25. App.router.get('updateController').set('isWorking', false);
  26. var popup = App.ModalPopup.show({
  27. classNames: ['full-width-modal'],
  28. header: Em.I18n.t('admin.activateHawqStandby.wizard.header'),
  29. bodyClass: App.ActivateHawqStandbyWizardView.extend({
  30. controller: activateHawqStandbyWizardController
  31. }),
  32. primary: Em.I18n.t('form.cancel'),
  33. showFooter: false,
  34. secondary: null,
  35. updateClusterStatus: function() {
  36. var controller = router.get('activateHawqStandbyWizardController');
  37. router.get('updateController').set('isWorking', true);
  38. activateHawqStandbyWizardController.finish();
  39. App.clusterStatus.setClusterStatus({
  40. clusterName: App.router.getClusterName(),
  41. clusterState: 'DEFAULT',
  42. localdb: App.db.data
  43. }, {
  44. alwaysCallback: function () {
  45. controller.get('popup').hide();
  46. router.transitionTo('main.services.index');
  47. Em.run.next(function() {
  48. location.reload();
  49. });
  50. }
  51. });
  52. },
  53. onClose: function () {
  54. var activateHawqStandbyWizardController = router.get('activateHawqStandbyWizardController'),
  55. currStep = activateHawqStandbyWizardController.get('currentStep')
  56. if (parseInt(currStep) === 3) {
  57. App.showConfirmationPopup(function () {
  58. popup.updateClusterStatus();
  59. }, Em.I18n.t('admin.activateHawqStandby.closePopup'));
  60. } else {
  61. popup.updateClusterStatus();
  62. }
  63. },
  64. didInsertElement: function () {
  65. this.fitHeight();
  66. }
  67. });
  68. activateHawqStandbyWizardController.set('popup', popup);
  69. var currentClusterStatus = App.clusterStatus.get('value');
  70. if (currentClusterStatus) {
  71. switch (currentClusterStatus.clusterState) {
  72. case 'ACTIVATE_HAWQ_STANDBY' :
  73. activateHawqStandbyWizardController.setCurrentStep(currentClusterStatus.localdb.ActivateHawqStandbyWizard.currentStep);
  74. break;
  75. default:
  76. var currStep = App.router.get('activateHawqStandbyWizardController.currentStep');
  77. activateHawqStandbyWizardController.setCurrentStep(currStep);
  78. break;
  79. }
  80. }
  81. Em.run.next(function () {
  82. App.router.get('wizardWatcherController').setUser(activateHawqStandbyWizardController.get('name'));
  83. router.transitionTo('step' + activateHawqStandbyWizardController.get('currentStep'));
  84. });
  85. });
  86. },
  87. step1: Em.Route.extend({
  88. route: '/step1',
  89. connectOutlets: function (router) {
  90. var controller = router.get('activateHawqStandbyWizardController');
  91. controller.dataLoading().done(function () {
  92. controller.setCurrentStep('1');
  93. controller.connectOutlet('activateHawqStandbyWizardStep1', controller.get('content'));
  94. })
  95. },
  96. unroutePath: function () {
  97. return false;
  98. },
  99. next: function (router) {
  100. var controller = router.get('activateHawqStandbyWizardController');
  101. var hawqMaster = App.HostComponent.find().findProperty('componentName','HAWQMASTER').get('hostName');
  102. var hawqStandby = App.HostComponent.find().findProperty('componentName','HAWQSTANDBY').get('hostName');
  103. var hawqHosts = {
  104. hawqMaster: hawqMaster,
  105. hawqStandby: hawqStandby
  106. };
  107. controller.saveHawqHosts(hawqHosts);
  108. router.transitionTo('step2');
  109. }
  110. }),
  111. step2: Em.Route.extend({
  112. route: '/step2',
  113. connectOutlets: function (router) {
  114. var controller = router.get('activateHawqStandbyWizardController');
  115. controller.dataLoading().done(function () {
  116. controller.setCurrentStep('2');
  117. controller.loadAllPriorSteps();
  118. controller.connectOutlet('activateHawqStandbyWizardStep2', controller.get('content'));
  119. })
  120. },
  121. unroutePath: function () {
  122. return false;
  123. },
  124. next: function (router) {
  125. App.showConfirmationPopup(function() {
  126. var wizardController = router.get('activateHawqStandbyWizardController');
  127. var stepController = router.get('activateHawqStandbyWizardStep2Controller');
  128. var configs = stepController.get('selectedService.configs');
  129. wizardController.saveConfigs(configs);
  130. router.transitionTo('step3');
  131. }, Em.I18n.t('admin.activateHawqStandby.wizard.step2.confirmPopup.body'));
  132. },
  133. back: Em.Router.transitionTo('step1')
  134. }),
  135. step3: Em.Route.extend({
  136. route: '/step3',
  137. connectOutlets: function (router) {
  138. var controller = router.get('activateHawqStandbyWizardController');
  139. controller.dataLoading().done(function () {
  140. controller.setCurrentStep('3');
  141. controller.setLowerStepsDisable(3);
  142. controller.loadAllPriorSteps();
  143. controller.connectOutlet('activateHawqStandbyWizardStep3', controller.get('content'));
  144. })
  145. },
  146. unroutePath: function (router, path) {
  147. // allow user to leave route if wizard has finished
  148. if (router.get('activateHawqStandbyWizardController').get('isFinished')) {
  149. this._super(router, path);
  150. } else {
  151. return false;
  152. }
  153. },
  154. next: function (router) {
  155. var controller = router.get('activateHawqStandbyWizardController');
  156. controller.finish();
  157. App.clusterStatus.setClusterStatus({
  158. clusterName: controller.get('content.cluster.name'),
  159. clusterState: 'DEFAULT',
  160. localdb: App.db.data
  161. }, {
  162. alwaysCallback: function () {
  163. controller.get('popup').hide();
  164. router.transitionTo('main.services.index');
  165. Em.run.next(function () {
  166. location.reload();
  167. });
  168. }
  169. });
  170. }
  171. })
  172. });