add_security.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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 = Em.Route.extend({
  20. route: '/addSecurity',
  21. enter: function (router) {
  22. console.log('in /security/add:enter');
  23. Ember.run.next(function () {
  24. //after refresh check if the wizard is open then restore it
  25. if (router.get('mainAdminSecurityController').getAddSecurityWizardStatus() === 'RUNNING') {
  26. var mainAdminSecurityController = router.get('mainAdminSecurityController');
  27. var addSecurityController = router.get('addSecurityController');
  28. var currentStep = router.get('addSecurityController').get('currentStep');
  29. App.router.get('updateController').set('isWorking', false);
  30. App.ModalPopup.show({
  31. classNames: ['full-width-modal'],
  32. header: Em.I18n.t('admin.addSecurity.header'),
  33. bodyClass: App.MainAdminSecurityAddMenuView.extend({
  34. controllerBinding: 'App.router.addSecurityController'
  35. }),
  36. primary: Em.I18n.t('form.cancel'),
  37. secondary: null,
  38. showFooter: false,
  39. onClose: function () {
  40. var self = this;
  41. if (router.get('addSecurityController.currentStep') == 4) {
  42. var controller = router.get('mainAdminSecurityAddStep4Controller');
  43. if (!controller.get('isSubmitDisabled')) {
  44. router.get('mainAdminSecurityAddStep4Controller').clearStep();
  45. self.proceedOnClose();
  46. return;
  47. }
  48. var applyingConfigStage = router.get('mainAdminSecurityAddStep4Controller.stages').findProperty('stage', 'stage3');
  49. if (applyingConfigStage) {
  50. if (!applyingConfigStage.get('isCompleted')) {
  51. if (applyingConfigStage.get('isStarted')) {
  52. App.showAlertPopup(Em.I18n.t('admin.security.applying.config.header'), Em.I18n.t('admin.security.applying.config.body'));
  53. } else {
  54. App.showConfirmationPopup(function () {
  55. self.proceedOnClose();
  56. }, Em.I18n.t('admin.addSecurity.enable.onClose'));
  57. }
  58. } else {
  59. App.showConfirmationPopup(function () {},
  60. Em.I18n.t('admin.addSecurity.enable.after.stage2.onClose'),
  61. function () {
  62. self.proceedOnClose();
  63. });
  64. }
  65. return;
  66. }
  67. }
  68. router.get('mainAdminSecurityAddStep4Controller').clearStep();
  69. App.db.setSecurityDeployStages(undefined);
  70. self.proceedOnClose();
  71. },
  72. proceedOnClose: function () {
  73. this.hide();
  74. router.get('mainAdminSecurityAddStep4Controller').clearStep();
  75. router.get('addSecurityController.content.services').clear();
  76. router.set('addSecurityController.content.serviceConfigProperties', null);
  77. App.router.get('updateController').set('isWorking', true);
  78. mainAdminSecurityController.setAddSecurityWizardStatus(null);
  79. App.db.setSecurityDeployStages(undefined);
  80. router.get('addSecurityController').setCurrentStep(1);
  81. App.clusterStatus.setClusterStatus({
  82. clusterName: router.get('content.cluster.name'),
  83. clusterState: 'SECURITY_COMPLETED',
  84. wizardControllerName: router.get('addSecurityController.name'),
  85. localdb: App.db.data.AddSecurity
  86. });
  87. router.transitionTo('adminSecurity.index');
  88. },
  89. didInsertElement: function () {
  90. this.fitHeight();
  91. }
  92. }
  93. );
  94. App.router.transitionTo('step' + currentStep);
  95. } else {
  96. router.transitionTo('adminSecurity.index');
  97. }
  98. });
  99. },
  100. step1: Em.Route.extend({
  101. route: '/start',
  102. enter: function (router) {
  103. router.get('addSecurityController').setCurrentStep('1');
  104. if(!App.testMode){
  105. App.clusterStatus.setClusterStatus({
  106. clusterName: this.get('clusterName'),
  107. clusterState: 'ADD_SECURITY_STEP_1',
  108. wizardControllerName: router.get('addSecurityController.name'),
  109. localdb: App.db.data.AddSecurity
  110. });
  111. }
  112. },
  113. connectOutlets: function (router) {
  114. console.log('in addSecurity.step1:connectOutlets');
  115. var controller = router.get('addSecurityController');
  116. controller.dataLoading().done(function () {
  117. controller.loadAllPriorSteps();
  118. controller.connectOutlet('mainAdminSecurityAddStep1', controller.get('content'));
  119. })
  120. },
  121. unroutePath: function () {
  122. return false;
  123. },
  124. next: function (router) {
  125. var addSecurityController = router.get('addSecurityController');
  126. addSecurityController.get('content').set('serviceConfigProperties', null);
  127. App.db.setSecureConfigProperties(null);
  128. router.transitionTo('step2');
  129. }
  130. }),
  131. step2: Em.Route.extend({
  132. route: '/configure',
  133. enter: function (router) {
  134. router.get('addSecurityController').setCurrentStep('2');
  135. if(!App.testMode){
  136. App.clusterStatus.setClusterStatus({
  137. clusterName: this.get('clusterName'),
  138. clusterState: 'ADD_SECURITY_STEP_2',
  139. wizardControllerName: router.get('addSecurityController.name'),
  140. localdb: App.db.data.AddSecurity
  141. });
  142. }
  143. },
  144. connectOutlets: function (router) {
  145. console.log('in addSecurity.step2:connectOutlets');
  146. var controller = router.get('addSecurityController');
  147. controller.dataLoading().done(function () {
  148. controller.loadAllPriorSteps();
  149. controller.connectOutlet('mainAdminSecurityAddStep2', controller.get('content'));
  150. })
  151. },
  152. unroutePath: function () {
  153. return false;
  154. },
  155. back: Em.Router.transitionTo('step1'),
  156. next: function (router) {
  157. var addSecurityController = router.get('addSecurityController');
  158. var addSecurityStep2Controller = router.get('mainAdminSecurityAddStep2Controller');
  159. addSecurityController.saveServiceConfigProperties(addSecurityStep2Controller);
  160. router.transitionTo('step3');
  161. }
  162. }),
  163. step3: Em.Route.extend({
  164. route: '/principal_keytab',
  165. enter: function (router) {
  166. router.get('addSecurityController').setCurrentStep('3');
  167. if(!App.testMode){
  168. App.clusterStatus.setClusterStatus({
  169. clusterName: this.get('clusterName'),
  170. clusterState: 'ADD_SECURITY_STEP_3',
  171. wizardControllerName: router.get('addSecurityController.name'),
  172. localdb: App.db.data.AddSecurity
  173. });
  174. }
  175. },
  176. connectOutlets: function (router) {
  177. console.log('in addSecurity.step3:connectOutlets');
  178. var controller = router.get('addSecurityController');
  179. controller.dataLoading().done(function () {
  180. controller.loadAllPriorSteps();
  181. controller.connectOutlet('mainAdminSecurityAddStep3', controller.get('content'));
  182. })
  183. },
  184. unroutePath: function () {
  185. return false;
  186. },
  187. back: Em.Router.transitionTo('step2'),
  188. next: function (router) {
  189. App.db.setSecurityDeployStages(undefined);
  190. router.transitionTo('step4');
  191. }
  192. }),
  193. step4: Em.Route.extend({
  194. route: '/apply',
  195. enter: function (router) {
  196. router.get('addSecurityController').setCurrentStep('4');
  197. },
  198. connectOutlets: function (router) {
  199. console.log('in addSecurity.step4:connectOutlets');
  200. var controller = router.get('addSecurityController');
  201. controller.dataLoading().done(function () {
  202. controller.loadAllPriorSteps();
  203. controller.setLowerStepsDisable(4);
  204. controller.connectOutlet('mainAdminSecurityAddStep4', controller.get('content'));
  205. })
  206. },
  207. unroutePath: function () {
  208. return false;
  209. },
  210. back: function (router, context) {
  211. var controller = router.get('mainAdminSecurityAddStep4Controller');
  212. if (!controller.get('isBackBtnDisabled')) {
  213. router.transitionTo('step3');
  214. }
  215. },
  216. done: function (router, context) {
  217. var controller = router.get('mainAdminSecurityAddStep4Controller');
  218. if (!controller.get('isSubmitDisabled')) {
  219. $(context.currentTarget).parents("#modal").find(".close").trigger('click');
  220. }
  221. }
  222. }),
  223. gotoStep1: Em.Router.transitionTo('step1'),
  224. gotoStep2: Em.Router.transitionTo('step2'),
  225. gotoStep3: Em.Router.transitionTo('step3'),
  226. gotoStep4: Em.Router.transitionTo('step4')
  227. });