step4_controller.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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 db = require('utils/db');
  20. App.InstallerStep4Controller = Em.ArrayController.extend({
  21. name: 'installerStep4Controller',
  22. rawContent: [
  23. {
  24. serviceName: 'HDFS',
  25. displayName: 'HDFS',
  26. isDisabled: true,
  27. description: Em.I18n.t('services.hdfs.description')
  28. },
  29. {
  30. serviceName: 'MAPREDUCE',
  31. displayName: 'MapReduce',
  32. isDisabled: true,
  33. description: Em.I18n.t('services.mapreduce.description')
  34. },
  35. {
  36. serviceName: 'NAGIOS',
  37. displayName: 'Nagios',
  38. isDisabled: true,
  39. description: Em.I18n.t('services.nagios.description')
  40. },
  41. {
  42. serviceName: 'GANGLIA',
  43. displayName: 'Ganglia',
  44. isDisabled: true,
  45. description: Em.I18n.t('services.ganglia.description')
  46. },
  47. {
  48. serviceName: 'HIVE',
  49. displayName: 'Hive + HCatalog',
  50. isDisabled: false,
  51. description: Em.I18n.t('services.hive.description')
  52. },
  53. {
  54. serviceName: 'HBASE',
  55. displayName: 'HBase + ZooKeeper',
  56. isDisabled: false,
  57. description: Em.I18n.t('services.hbase.description')
  58. },
  59. {
  60. serviceName: 'PIG',
  61. displayName: 'Pig',
  62. isDisabled: false,
  63. description: Em.I18n.t('services.pig.description')
  64. },
  65. {
  66. serviceName: 'SQOOP',
  67. displayName: 'Sqoop',
  68. isDisabled: false,
  69. description: Em.I18n.t('services.sqoop.description')
  70. },
  71. {
  72. serviceName: 'OOZIE',
  73. displayName: 'Oozie',
  74. isDisabled: false,
  75. description: Em.I18n.t('services.oozie.description')
  76. },
  77. {
  78. serviceName: 'ZOOKEEPER',
  79. isDisabled: false,
  80. isHidden: true
  81. },
  82. {
  83. serviceName: 'HCATALOG',
  84. isDisabled: false,
  85. isHidden: true
  86. }
  87. ],
  88. content: [],
  89. isAll: function() {
  90. return this.everyProperty('isSelected', true);
  91. }.property('@each.isSelected'),
  92. isMinimum: function() {
  93. return this.filterProperty('isDisabled', false).everyProperty('isSelected', false);
  94. }.property('@each.isSelected'),
  95. checkDependencies: function() {
  96. var hbase = this.findProperty('serviceName', 'HBASE');
  97. var zookeeper = this.findProperty('serviceName', 'ZOOKEEPER');
  98. if (hbase && zookeeper) {
  99. zookeeper.set('isSelected', hbase.get('isSelected'));
  100. }
  101. var hive = this.findProperty('serviceName', 'HIVE');
  102. var hcatalog = this.findProperty('serviceName', 'HCATALOG');
  103. if (hive && hcatalog) {
  104. hcatalog.set('isSelected', hive.get('isSelected'));
  105. }
  106. }.observes('@each.isSelected'),
  107. init: function() {
  108. this._super();
  109. // wrap each item with Ember.Object
  110. this.rawContent.forEach(function(item) {
  111. item.isSelected = true;
  112. this.pushObject(Ember.Object.create(item));
  113. }, this);
  114. },
  115. selectAll: function() {
  116. this.setEach('isSelected', true);
  117. },
  118. selectMinimum: function() {
  119. this.filterProperty('isDisabled', false).setEach('isSelected', false);
  120. },
  121. saveSelectedServiceNamesToDB: function() {
  122. var serviceNames = [];
  123. this.filterProperty('isSelected', true).forEach(function(item){
  124. serviceNames.push(item.serviceName);
  125. });
  126. db.setSelectedServiceNames(serviceNames);
  127. },
  128. submit: function() {
  129. this.saveSelectedServiceNamesToDB();
  130. App.router.send('next');
  131. }
  132. })