step7_controller.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. /**
  20. * Controller for Step 7 of the Installer Wizard.
  21. * By Step 7, we have the following information stored in App.db (localStorage) and set on this
  22. * controller by the router.
  23. *
  24. * selectedServices: App.db.selectedServices (the services that the user selected in Step 4)
  25. * masterComponentHosts: App.db.masterComponentHosts (master-components-to-hosts mapping the user selected in Step 5)
  26. * slaveComponentHosts: App.db.slaveComponentHosts (slave-components-to-hosts mapping the user selected in Step 6)
  27. *
  28. */
  29. App.InstallerStep7Controller = Em.ArrayController.extend({
  30. name: 'installerStep7Controller',
  31. content: [],
  32. selectedService: null,
  33. slaveHostToGroup: null,
  34. isSubmitDisabled: function() {
  35. return !this.everyProperty('errorCount', 0);
  36. }.property('@each.errorCount'),
  37. // TODO: set attributes from localStorage in router
  38. // var selectedServiceNames = App.db.getSelectedServiceNames();
  39. selectedServiceNames: [ 'HDFS', 'MAPREDUCE', 'GANGLIA', 'NAGIOS', 'HBASE', 'PIG', 'SQOOP', 'OOZIE', 'HIVE', 'ZOOKEEPER'],
  40. masterComponentHosts: '',
  41. slaveComponentHosts: '',
  42. doInit: true,
  43. loadConfigs: function() {
  44. var selectedServiceNamesInDB = App.db.getSelectedServiceNames();
  45. if (selectedServiceNamesInDB !== undefined) {
  46. this.set('selectedServiceNames', selectedServiceNamesInDB);
  47. }
  48. // TODO: check App.db to see if configs have been saved already
  49. if (this.doInit) {
  50. var serviceConfigs = require('data/service_configs');
  51. var self = this;
  52. this.set('content', []);
  53. serviceConfigs.forEach(function(_serviceConfig) {
  54. var serviceConfig = App.ServiceConfig.create({
  55. serviceName: _serviceConfig.serviceName,
  56. displayName: _serviceConfig.displayName,
  57. configCategories: _serviceConfig.configCategories,
  58. configs: []
  59. });
  60. if (self.selectedServiceNames.contains(serviceConfig.serviceName) || serviceConfig.serviceName === 'MISC') {
  61. _serviceConfig.configs.forEach(function(_serviceConfigProperty) {
  62. var serviceConfigProperty = App.ServiceConfigProperty.create(_serviceConfigProperty);
  63. serviceConfigProperty.serviceConfig = serviceConfig;
  64. serviceConfig.configs.pushObject(serviceConfigProperty);
  65. serviceConfigProperty.validate();
  66. });
  67. console.log('pushing ' + serviceConfig.serviceName);
  68. self.content.pushObject(serviceConfig);
  69. } else {
  70. console.log('skipping ' + serviceConfig.serviceName);
  71. }
  72. });
  73. this.set('selectedService', this.objectAt(0));
  74. this.doInit = false;
  75. }
  76. },
  77. submit: function() {
  78. if (!this.get('isSubmitDisabled')) {
  79. // TODO:
  80. // save service configs in App.db (localStorage)
  81. App.get('router').transitionTo('step8');
  82. }
  83. },
  84. showMasterHosts: function(event) {
  85. var serviceConfig = event.context;
  86. App.ModalPopup.show({
  87. header: serviceConfig.category + ' Hosts',
  88. bodyClass: Ember.View.extend({
  89. serviceConfig: serviceConfig,
  90. templateName: require('templates/installer/master_hosts_popup')
  91. })
  92. });
  93. },
  94. showSlaveHosts: function(event) {
  95. var serviceConfig = event.context;
  96. App.ModalPopup.show({
  97. header: serviceConfig.category + ' Hosts',
  98. bodyClass: Ember.View.extend({
  99. serviceConfig: serviceConfig,
  100. templateName: require('templates/installer/slave_hosts_popup')
  101. })
  102. });
  103. }
  104. });
  105. App.SlaveComponentGroupsController = Ember.ArrayController.extend({
  106. name: 'slaveComponentGroupsController',
  107. // TODO: Set up binding to use actual data
  108. //contentBinding: 'App.router.installerStep7Controller.slaveComponentHosts',
  109. content: require('data/mock/slave_component_hosts'),
  110. selectedComponentName: 'DataNode',
  111. showAddSlaveComponentGroup: function (event) {
  112. var componentName = event.context;
  113. this.set('selectedComponentName', componentName);
  114. App.ModalPopup.show({
  115. header: componentName + ' Groups',
  116. bodyClass: Ember.View.extend({
  117. controllerBinding: 'App.router.slaveComponentGroupsController',
  118. templateName: require('templates/installer/slave_hosts_popup')
  119. }),
  120. onPrimary: function() {
  121. }
  122. });
  123. },
  124. showEditSlaveComponentGroups: function(event) {
  125. this.showAddSlaveComponentGroup(event);
  126. },
  127. hosts: function() {
  128. return this.filterProperty('componentName', this.get('selectedComponentName'))[0].hosts;
  129. }.property('@each.hosts'),
  130. groups: function() {
  131. return this.filterProperty('componentName', this.get('selectedComponentName'))[0].hosts.mapProperty('group').uniq();
  132. }.property('@each.hosts')
  133. });