step4_controller.js 4.8 KB

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