add_security.js 9.2 KB

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