installer.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. module.exports = Em.Route.extend({
  19. route: '/installer',
  20. enter: function (router) {
  21. console.log('in /installer:enter');
  22. if (router.getAuthenticated()) {
  23. console.log('In installer and its authenticated!!!');
  24. Ember.run.next(function () {
  25. router.transitionTo('step' + router.getInstallerCurrentStep());
  26. });
  27. } else {
  28. console.log('In installer but its not authenticated');
  29. console.log('value of authenticated is: ' + router.getAuthenticated());
  30. Ember.run.next(function () {
  31. router.transitionTo('login');
  32. });
  33. }
  34. },
  35. connectOutlets: function (router, context) {
  36. console.log('in /installer:connectOutlets');
  37. router.get('applicationController').connectOutlet('installer');
  38. },
  39. step1: Em.Route.extend({
  40. route: '/step1',
  41. connectOutlets: function (router, context) {
  42. console.log('in installer.step1:connectOutlets');
  43. router.setInstallerCurrentStep('1', false);
  44. router.get('installerController').connectOutlet('installerStep1');
  45. },
  46. next: function (router, context) {
  47. console.log('In step1 transiting to step2');
  48. var result = router.get('installerController').evaluateStep1();
  49. if (result === true) {
  50. App.InstallerStep1View.remove;
  51. router.transitionTo('step2');
  52. } else {
  53. router.get('installerController').connectOutlet('installerStep1');
  54. }
  55. }
  56. }),
  57. step2: Em.Route.extend({
  58. route: '/step2',
  59. connectOutlets: function (router, context) {
  60. router.setInstallerCurrentStep('2', false);
  61. router.get('installerController').connectOutlet('installerStep2');
  62. },
  63. back: Em.Router.transitionTo('step1'),
  64. next: function (router, context) {
  65. console.log('In step2 transiting to step3');
  66. var result = router.get('installerController').evaluateStep2();
  67. if (result) {
  68. router.transitionTo('step3');
  69. }
  70. }
  71. }),
  72. step3: Em.Route.extend({
  73. route: '/step3',
  74. connectOutlets: function (router, context) {
  75. router.setInstallerCurrentStep('3', false);
  76. router.get('installerController').connectOutlet('installerStep3');
  77. },
  78. back: Em.Router.transitionTo('step2'),
  79. next: Em.Router.transitionTo('step4')
  80. }),
  81. step4: Em.Route.extend({
  82. route: '/step4',
  83. connectOutlets: function (router, context) {
  84. router.setInstallerCurrentStep('4', false);
  85. router.get('installerController').connectOutlet('installerStep4');
  86. },
  87. back: Em.Router.transitionTo('step3'),
  88. next: Em.Router.transitionTo('step5')
  89. }),
  90. step5: Em.Route.extend({
  91. route: '/step5',
  92. connectOutlets: function (router, context) {
  93. router.setInstallerCurrentStep('5', false);
  94. router.get('installerController').connectOutlet('installerStep5');
  95. },
  96. back: Em.Router.transitionTo('step4'),
  97. next: Em.Router.transitionTo('step6')
  98. }),
  99. step6: Em.Route.extend({
  100. route: '/step6',
  101. connectOutlets: function (router, context) {
  102. router.setInstallerCurrentStep('6', false);
  103. router.get('installerController').connectOutlet('installerStep6');
  104. },
  105. back: Em.Router.transitionTo('step5'),
  106. next: Em.Router.transitionTo('step7')
  107. }),
  108. step7: Em.Route.extend({
  109. route: '/step7',
  110. connectOutlets: function (router, context) {
  111. router.setInstallerCurrentStep('7', false);
  112. router.get('installerController').connectOutlet('installerStep7');
  113. },
  114. back: Em.Router.transitionTo('step6'),
  115. next: Em.Router.transitionTo('step8')
  116. }),
  117. step8: Em.Route.extend({
  118. route: '/step8',
  119. connectOutlets: function (router, context) {
  120. router.setInstallerCurrentStep('8', false);
  121. router.get('installerController').connectOutlet('installerStep8');
  122. },
  123. back: Em.Router.transitionTo('step7'),
  124. complete: function (router, context) {
  125. if (true) { // this function will be moved to installerController where it will validate
  126. router.setInstallerCurrentStep('1', true);
  127. router.setSection('main');
  128. router.transitionTo('main');
  129. } else {
  130. console.log('cluster installation failure');
  131. }
  132. }
  133. }),
  134. gotoStep1: Em.Router.transitionTo('step1'),
  135. gotoStep2: Em.Router.transitionTo('step2'),
  136. gotoStep3: Em.Router.transitionTo('step3'),
  137. gotoStep4: Em.Router.transitionTo('step4'),
  138. gotoStep5: Em.Router.transitionTo('step5'),
  139. gotoStep6: Em.Router.transitionTo('step6'),
  140. gotoStep7: Em.Router.transitionTo('step7'),
  141. gotoStep8: Em.Router.transitionTo('step8')
  142. });