rm_high_availability_routes.js 7.6 KB

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