activate_hawq_standby_routes.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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._super();
  66. this.fitHeight();
  67. }
  68. });
  69. activateHawqStandbyWizardController.set('popup', popup);
  70. var currentClusterStatus = App.clusterStatus.get('value');
  71. if (currentClusterStatus) {
  72. switch (currentClusterStatus.clusterState) {
  73. case 'ACTIVATE_HAWQ_STANDBY' :
  74. activateHawqStandbyWizardController.setCurrentStep(currentClusterStatus.localdb.ActivateHawqStandbyWizard.currentStep);
  75. break;
  76. default:
  77. var currStep = App.router.get('activateHawqStandbyWizardController.currentStep');
  78. activateHawqStandbyWizardController.setCurrentStep(currStep);
  79. break;
  80. }
  81. }
  82. Em.run.next(function () {
  83. App.router.get('wizardWatcherController').setUser(activateHawqStandbyWizardController.get('name'));
  84. router.transitionTo('step' + activateHawqStandbyWizardController.get('currentStep'));
  85. });
  86. });
  87. },
  88. step1: Em.Route.extend({
  89. route: '/step1',
  90. connectOutlets: function (router) {
  91. var controller = router.get('activateHawqStandbyWizardController');
  92. controller.dataLoading().done(function () {
  93. controller.setCurrentStep('1');
  94. controller.connectOutlet('activateHawqStandbyWizardStep1', controller.get('content'));
  95. })
  96. },
  97. unroutePath: function () {
  98. return false;
  99. },
  100. next: function (router) {
  101. var controller = router.get('activateHawqStandbyWizardController');
  102. var hawqMaster = App.HostComponent.find().findProperty('componentName','HAWQMASTER').get('hostName');
  103. var hawqStandby = App.HostComponent.find().findProperty('componentName','HAWQSTANDBY').get('hostName');
  104. var hawqHosts = {
  105. hawqMaster: hawqMaster,
  106. hawqStandby: hawqStandby
  107. };
  108. controller.saveHawqHosts(hawqHosts);
  109. router.transitionTo('step2');
  110. }
  111. }),
  112. step2: Em.Route.extend({
  113. route: '/step2',
  114. connectOutlets: function (router) {
  115. var controller = router.get('activateHawqStandbyWizardController');
  116. controller.dataLoading().done(function () {
  117. controller.setCurrentStep('2');
  118. controller.loadAllPriorSteps();
  119. controller.connectOutlet('activateHawqStandbyWizardStep2', controller.get('content'));
  120. })
  121. },
  122. unroutePath: function () {
  123. return false;
  124. },
  125. next: function (router) {
  126. App.showConfirmationPopup(function() {
  127. var wizardController = router.get('activateHawqStandbyWizardController');
  128. var stepController = router.get('activateHawqStandbyWizardStep2Controller');
  129. var configs = stepController.get('selectedService.configs');
  130. wizardController.saveConfigs(configs);
  131. router.transitionTo('step3');
  132. }, Em.I18n.t('admin.activateHawqStandby.wizard.step2.confirmPopup.body'));
  133. },
  134. back: Em.Router.transitionTo('step1')
  135. }),
  136. step3: Em.Route.extend({
  137. route: '/step3',
  138. connectOutlets: function (router) {
  139. var controller = router.get('activateHawqStandbyWizardController');
  140. controller.dataLoading().done(function () {
  141. controller.setCurrentStep('3');
  142. controller.setLowerStepsDisable(3);
  143. controller.loadAllPriorSteps();
  144. controller.connectOutlet('activateHawqStandbyWizardStep3', controller.get('content'));
  145. })
  146. },
  147. unroutePath: function (router, path) {
  148. // allow user to leave route if wizard has finished
  149. if (router.get('activateHawqStandbyWizardController').get('isFinished')) {
  150. this._super(router, path);
  151. } else {
  152. return false;
  153. }
  154. },
  155. next: function (router) {
  156. var controller = router.get('activateHawqStandbyWizardController');
  157. controller.finish();
  158. App.clusterStatus.setClusterStatus({
  159. clusterName: controller.get('content.cluster.name'),
  160. clusterState: 'DEFAULT',
  161. localdb: App.db.data
  162. }, {
  163. alwaysCallback: function () {
  164. controller.get('popup').hide();
  165. router.transitionTo('main.services.index');
  166. Em.run.next(function () {
  167. location.reload();
  168. });
  169. }
  170. });
  171. }
  172. })
  173. });