step4_controller.js 4.2 KB

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