step4_controller.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. var stringUtils = require('utils/string_utils');
  20. App.WizardStep4Controller = Em.ArrayController.extend({
  21. name: 'wizardStep4Controller',
  22. content: [],
  23. isSubmitDisabled:function(){
  24. return this.filterProperty('isSelected', true).filterProperty('isInstalled', false).length === 0;
  25. }.property("@each.isSelected"),
  26. /**
  27. * Check whether all properties are selected
  28. */
  29. isAll: function () {
  30. return this.filterProperty('canBeSelected', true).everyProperty('isSelected', true);
  31. }.property('@each.isSelected'),
  32. /**
  33. * Check whether none properties(minimum) are selected
  34. */
  35. isMinimum: function () {
  36. return this.filterProperty('isDisabled', false).everyProperty('isSelected', false);
  37. }.property('@each.isSelected'),
  38. /**
  39. * Update hidden services. Make them to have the same status as master ones.
  40. */
  41. checkDependencies: function () {
  42. var hbase = this.findProperty('serviceName', 'HBASE');
  43. var zookeeper = this.findProperty('serviceName', 'ZOOKEEPER');
  44. var hive = this.findProperty('serviceName', 'HIVE');
  45. var hcatalog = this.findProperty('serviceName', 'HCATALOG');
  46. var webhcat = this.findProperty('serviceName', 'WEBHCAT');
  47. // prevent against getting error when not all elements have been loaded yet
  48. if (hbase && zookeeper && hive && hcatalog && webhcat) {
  49. if (stringUtils.compareVersions(App.get('currentStackVersionNumber'), "2.0") === -1) {
  50. zookeeper.set('isSelected', hbase.get('isSelected') || hive.get('isSelected'));
  51. }else{
  52. if (!zookeeper.get('isSelected')) {
  53. zookeeper.set('isSelected', hbase.get('isSelected'));
  54. }
  55. }
  56. hcatalog.set('isSelected', hive.get('isSelected'));
  57. webhcat.set('isSelected', hive.get('isSelected'));
  58. }
  59. }.observes('@each.isSelected'),
  60. /**
  61. * Onclick handler for <code>select all</code> link
  62. */
  63. selectAll: function () {
  64. this.filterProperty('canBeSelected', true).setEach('isSelected', true);
  65. },
  66. /**
  67. * onclick handler for <code>select minimum</code> link
  68. */
  69. selectMinimum: function () {
  70. this.filterProperty('isDisabled', false).setEach('isSelected', false);
  71. },
  72. /**
  73. * Check whether we should turn on <code>MapReduce</code> service
  74. * @return {Boolean}
  75. */
  76. needToAddMapReduce: function () {
  77. if (this.findProperty('serviceName', 'MAPREDUCE') && this.findProperty('serviceName', 'MAPREDUCE').get('isSelected') === false) {
  78. var mapreduceDependentServices = this.filter(function (item) {
  79. return ['PIG', 'OOZIE', 'HIVE'].contains(item.get('serviceName')) && item.get('isSelected', true);
  80. });
  81. return (mapreduceDependentServices.get('length') > 0);
  82. }
  83. return false;
  84. },
  85. /**
  86. * Check do we have any monitoring service turned on
  87. * @return {Boolean}
  88. */
  89. gangliaOrNagiosNotSelected: function () {
  90. return (this.findProperty('serviceName', 'GANGLIA').get('isSelected') === false || this.findProperty('serviceName', 'NAGIOS').get('isSelected') === false);
  91. },
  92. /**
  93. * Check whether user turned on monitoring service and go to next step
  94. */
  95. validateMonitoring: function () {
  96. if (this.gangliaOrNagiosNotSelected()) {
  97. this.monitoringCheckPopup();
  98. } else {
  99. App.router.send('next');
  100. }
  101. },
  102. /**
  103. * Onclick handler for <code>Next</code> button
  104. */
  105. submit: function () {
  106. if(!this.get("isSubmitDisabled")){
  107. if (this.needToAddMapReduce()) {
  108. this.mapReduceCheckPopup();
  109. } else {
  110. this.validateMonitoring();
  111. }
  112. }
  113. },
  114. mapReduceCheckPopup: function () {
  115. var self = this;
  116. App.ModalPopup.show({
  117. header: Em.I18n.t('installer.step4.mapreduceCheck.popup.header'),
  118. body: Em.I18n.t('installer.step4.mapreduceCheck.popup.body'),
  119. onPrimary: function () {
  120. self.findProperty('serviceName', 'MAPREDUCE').set('isSelected', true);
  121. this.hide();
  122. self.validateMonitoring();
  123. },
  124. onSecondary: function () {
  125. this.hide();
  126. }
  127. });
  128. },
  129. monitoringCheckPopup: function () {
  130. App.ModalPopup.show({
  131. header: Em.I18n.t('installer.step4.monitoringCheck.popup.header'),
  132. body: Em.I18n.t('installer.step4.monitoringCheck.popup.body'),
  133. onPrimary: function () {
  134. this.hide();
  135. App.router.send('next');
  136. },
  137. onSecondary: function () {
  138. this.hide();
  139. }
  140. });
  141. }
  142. })