remove_hawq_standby_routes.js 7.4 KB

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