|
@@ -43,13 +43,13 @@ App.WizardStep6Controller = Em.Controller.extend({
|
|
|
*/
|
|
|
isMasters: false,
|
|
|
|
|
|
- components:require('data/service_components'),
|
|
|
+ components: require('data/service_components'),
|
|
|
|
|
|
- isAddHostWizard: function(){
|
|
|
+ isAddHostWizard: function () {
|
|
|
return this.get('content.controllerName') === 'addHostController';
|
|
|
}.property('content.controllerName'),
|
|
|
|
|
|
- isInstallerWizard: function(){
|
|
|
+ isInstallerWizard: function () {
|
|
|
return this.get('content.controllerName') === 'installerController';
|
|
|
}.property('content.controllerName'),
|
|
|
|
|
@@ -59,9 +59,9 @@ App.WizardStep6Controller = Em.Controller.extend({
|
|
|
var err = true;
|
|
|
var hosts = this.get('hosts');
|
|
|
var headers = this.get('headers');
|
|
|
- headers.forEach(function(header) {
|
|
|
+ headers.forEach(function (header) {
|
|
|
var all_false = true;
|
|
|
- hosts.forEach(function(host) {
|
|
|
+ hosts.forEach(function (host) {
|
|
|
var checkboxes = host.get('checkboxes');
|
|
|
all_false &= !checkboxes.findProperty('title', header.get('label')).checked;
|
|
|
});
|
|
@@ -72,14 +72,14 @@ App.WizardStep6Controller = Em.Controller.extend({
|
|
|
this.set('errorMessage', '');
|
|
|
}
|
|
|
|
|
|
- if(this.get('isAddHostWizard')) {
|
|
|
+ if (this.get('isAddHostWizard')) {
|
|
|
if (this.get('isMasters')) {
|
|
|
this.set('errorMessage', '');
|
|
|
}
|
|
|
else {
|
|
|
- hosts.forEach(function(host) {
|
|
|
+ hosts.forEach(function (host) {
|
|
|
isError = false;
|
|
|
- headers.forEach(function(header) {
|
|
|
+ headers.forEach(function (header) {
|
|
|
isError |= host.get('checkboxes').findProperty('title', header.get('label')).checked;
|
|
|
});
|
|
|
isError = !isError;
|
|
@@ -113,7 +113,7 @@ App.WizardStep6Controller = Em.Controller.extend({
|
|
|
* Enable some service for all hosts
|
|
|
* @param event
|
|
|
*/
|
|
|
- selectAllNodes: function(event) {
|
|
|
+ selectAllNodes: function (event) {
|
|
|
this.setAllNodes(event.context.label, true);
|
|
|
},
|
|
|
|
|
@@ -121,7 +121,7 @@ App.WizardStep6Controller = Em.Controller.extend({
|
|
|
* Disable some services for all hosts
|
|
|
* @param event
|
|
|
*/
|
|
|
- deselectAllNodes: function(event) {
|
|
|
+ deselectAllNodes: function (event) {
|
|
|
this.setAllNodes(event.context.label, false);
|
|
|
},
|
|
|
|
|
@@ -130,9 +130,9 @@ App.WizardStep6Controller = Em.Controller.extend({
|
|
|
* @param {String} label - service name
|
|
|
* @param {Boolean} checked - true - enable, false - disable
|
|
|
*/
|
|
|
- setAllNodes: function(label, checked) {
|
|
|
- this.get('hosts').forEach(function(host) {
|
|
|
- host.get('checkboxes').forEach(function(checkbox) {
|
|
|
+ setAllNodes: function (label, checked) {
|
|
|
+ this.get('hosts').forEach(function (host) {
|
|
|
+ host.get('checkboxes').forEach(function (checkbox) {
|
|
|
if (checkbox.get('title') === label) {
|
|
|
checkbox.set('checked', checked);
|
|
|
}
|
|
@@ -145,7 +145,7 @@ App.WizardStep6Controller = Em.Controller.extend({
|
|
|
* @param name serviceName
|
|
|
* @return {*}
|
|
|
*/
|
|
|
- isServiceSelected: function(name) {
|
|
|
+ isServiceSelected: function (name) {
|
|
|
return this.get('content.services').findProperty('serviceName', name).get('isSelected');
|
|
|
},
|
|
|
|
|
@@ -153,14 +153,14 @@ App.WizardStep6Controller = Em.Controller.extend({
|
|
|
* Checkbox check callback
|
|
|
* @param {String} title
|
|
|
*/
|
|
|
- checkCallback: function(title) {
|
|
|
+ checkCallback: function (title) {
|
|
|
|
|
|
var header = this.get('headers').findProperty('label', title);
|
|
|
var hosts = this.get('hosts');
|
|
|
var allTrue = true;
|
|
|
var allFalse = true;
|
|
|
- hosts.forEach(function(host) {
|
|
|
- host.get('checkboxes').forEach(function(cb) {
|
|
|
+ hosts.forEach(function (host) {
|
|
|
+ host.get('checkboxes').forEach(function (cb) {
|
|
|
if (cb.get('title') === title) {
|
|
|
allTrue &= cb.get('checked');
|
|
|
allFalse &= !cb.get('checked');
|
|
@@ -172,7 +172,7 @@ App.WizardStep6Controller = Em.Controller.extend({
|
|
|
this.clearError();
|
|
|
},
|
|
|
|
|
|
- getComponentDisplayName: function(componentName) {
|
|
|
+ getComponentDisplayName: function (componentName) {
|
|
|
return this.get('components').findProperty('component_name', componentName).display_name
|
|
|
},
|
|
|
|
|
@@ -194,9 +194,9 @@ App.WizardStep6Controller = Em.Controller.extend({
|
|
|
}
|
|
|
if (this.isServiceSelected('ZOOKEEPER')) {
|
|
|
headers.pushObject(Em.Object.create({
|
|
|
- name:'ZOOKEEPER_SERVER',
|
|
|
- label: self.getComponentDisplayName('ZOOKEEPER_SERVER')
|
|
|
- }));
|
|
|
+ name: 'ZOOKEEPER_SERVER',
|
|
|
+ label: self.getComponentDisplayName('ZOOKEEPER_SERVER')
|
|
|
+ }));
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
@@ -206,13 +206,13 @@ App.WizardStep6Controller = Em.Controller.extend({
|
|
|
}));
|
|
|
if (this.isServiceSelected('MAPREDUCE')) {
|
|
|
headers.pushObject(Em.Object.create({
|
|
|
- name:'TASKTRACKER',
|
|
|
+ name: 'TASKTRACKER',
|
|
|
label: self.getComponentDisplayName('TASKTRACKER')
|
|
|
}));
|
|
|
}
|
|
|
if (this.isServiceSelected('HBASE')) {
|
|
|
headers.pushObject(Em.Object.create({
|
|
|
- name:'HBASE_REGIONSERVER',
|
|
|
+ name: 'HBASE_REGIONSERVER',
|
|
|
label: self.getComponentDisplayName('HBASE_REGIONSERVER')
|
|
|
}));
|
|
|
}
|
|
@@ -222,7 +222,7 @@ App.WizardStep6Controller = Em.Controller.extend({
|
|
|
}));
|
|
|
}
|
|
|
|
|
|
- headers.forEach(function(header) {
|
|
|
+ headers.forEach(function (header) {
|
|
|
header.setProperties({ allChecked: false, noChecked: true });
|
|
|
});
|
|
|
|
|
@@ -230,12 +230,12 @@ App.WizardStep6Controller = Em.Controller.extend({
|
|
|
|
|
|
this.render();
|
|
|
if (this.get('isMasters')) {
|
|
|
- if(this.get('content.skipMasterStep')) {
|
|
|
+ if (this.get('content.skipMasterStep')) {
|
|
|
App.router.send('next');
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
- if(this.get('content.skipSlavesStep')) {
|
|
|
+ if (this.get('content.skipSlavesStep')) {
|
|
|
App.router.send('next');
|
|
|
}
|
|
|
}
|
|
@@ -272,7 +272,7 @@ App.WizardStep6Controller = Em.Controller.extend({
|
|
|
checkboxes: []
|
|
|
});
|
|
|
|
|
|
- self.get('headers').forEach(function(header) {
|
|
|
+ self.get('headers').forEach(function (header) {
|
|
|
obj.checkboxes.pushObject(Em.Object.create({
|
|
|
title: header.label,
|
|
|
checked: false,
|
|
@@ -293,7 +293,7 @@ App.WizardStep6Controller = Em.Controller.extend({
|
|
|
hostsObj.forEach(function (host) {
|
|
|
this.get('hosts').pushObject(host);
|
|
|
}, this);
|
|
|
- this.get('headers').forEach(function(header) {
|
|
|
+ this.get('headers').forEach(function (header) {
|
|
|
self.checkCallback(header.get('label'));
|
|
|
});
|
|
|
},
|
|
@@ -303,14 +303,14 @@ App.WizardStep6Controller = Em.Controller.extend({
|
|
|
* @param hostsObj
|
|
|
* @return {*}
|
|
|
*/
|
|
|
- renderSlaves: function(hostsObj) {
|
|
|
+ renderSlaves: function (hostsObj) {
|
|
|
var self = this;
|
|
|
var allHosts = this.getHostNames();
|
|
|
var headers = this.get('headers');
|
|
|
var slaveComponents = this.get('content.slaveComponentHosts');
|
|
|
if (!slaveComponents) { // we are at this page for the first time
|
|
|
var client_is_set = false;
|
|
|
- hostsObj.forEach(function(host) {
|
|
|
+ hostsObj.forEach(function (host) {
|
|
|
host.isMaster = self.hasMasterComponents(host.hostName);
|
|
|
var checkboxes = host.get('checkboxes');
|
|
|
checkboxes.setEach('checked', !host.isMaster);
|
|
@@ -326,13 +326,13 @@ App.WizardStep6Controller = Em.Controller.extend({
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- if(this.get('isInstallerWizard') && hostsObj.everyProperty('isMaster', true)){
|
|
|
+ if (this.get('isInstallerWizard') && hostsObj.everyProperty('isMaster', true)) {
|
|
|
var lastHost = hostsObj[hostsObj.length - 1];
|
|
|
lastHost.get('checkboxes').setEach('checked', true);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
- this.get('headers').forEach(function(header) {
|
|
|
+ this.get('headers').forEach(function (header) {
|
|
|
var nodes = slaveComponents.findProperty('componentName', header.get('name'));
|
|
|
if (nodes) {
|
|
|
nodes.hosts.forEach(function (_node) {
|
|
@@ -359,17 +359,17 @@ App.WizardStep6Controller = Em.Controller.extend({
|
|
|
* @param hostsObj
|
|
|
* @return {*}
|
|
|
*/
|
|
|
- renderMasters: function(hostsObj) {
|
|
|
+ renderMasters: function (hostsObj) {
|
|
|
var self = this;
|
|
|
var masterComponentHosts = this.get('content.masterComponentHosts');
|
|
|
console.warn('masterComponentHosts', masterComponentHosts);
|
|
|
|
|
|
if (masterComponentHosts) {
|
|
|
- masterComponentHosts.forEach(function(item) {
|
|
|
+ masterComponentHosts.forEach(function (item) {
|
|
|
var host = hostsObj.findProperty('hostName', item.hostName);
|
|
|
if (host) {
|
|
|
var checkbox = host.get('checkboxes').findProperty('title', item.display_name);
|
|
|
- if(checkbox){
|
|
|
+ if (checkbox) {
|
|
|
checkbox.set('checked', true);
|
|
|
}
|
|
|
}
|
|
@@ -394,39 +394,64 @@ App.WizardStep6Controller = Em.Controller.extend({
|
|
|
* @return {Boolean}
|
|
|
*/
|
|
|
validate: function () {
|
|
|
+
|
|
|
+ if (this.get('isAddHostWizard')) {
|
|
|
+ return this.validateEachHost(Em.I18n.t('installer.step6.error.mustSelectOneForHost'));
|
|
|
+ }
|
|
|
+ else if (this.get('isInstallerWizard')) {
|
|
|
+ //this.validateEachComponent() ? this.validateEachHost(Em.I18n.t('installer.step6.error.mustSelectOneForHost') ? return true : return false : return false;
|
|
|
+ return this.validateEachComponent() && this.validateEachHost(Em.I18n.t('installer.step6.error.mustSelectOneForSlaveHost'));
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Validate all components for each host. Return do we have errors or not
|
|
|
+ * @return {Boolean}
|
|
|
+ */
|
|
|
+ validateEachHost: function (errorMsg) {
|
|
|
+
|
|
|
var isError = false;
|
|
|
var hosts = this.get('hosts');
|
|
|
var headers = this.get('headers');
|
|
|
- if(this.get('isAddHostWizard')) {
|
|
|
- for(var i = 0; i < hosts.length; i++) {
|
|
|
- var checkboxes = hosts[i].get('checkboxes');
|
|
|
- isError = false;
|
|
|
- headers.forEach(function(header) {
|
|
|
- isError |= checkboxes.findProperty('title', header.get('label')).checked;
|
|
|
- });
|
|
|
- isError = !isError;
|
|
|
- if (isError) {
|
|
|
- this.set('errorMessage', Em.I18n.t('installer.step6.error.mustSelectOneForHost'));
|
|
|
- break;
|
|
|
- }
|
|
|
+ for (var i = 0; i < hosts.length; i++) {
|
|
|
+ if (this.get('isInstallerWizard') && this.get('content.masterComponentHosts').someProperty('hostName', hosts[i].hostName)) {
|
|
|
+ continue;
|
|
|
}
|
|
|
- }
|
|
|
- else {
|
|
|
-
|
|
|
- headers.forEach(function(header) {
|
|
|
- var all_false = true;
|
|
|
- hosts.forEach(function(host) {
|
|
|
- var checkboxes = host.get('checkboxes');
|
|
|
- all_false = all_false && !checkboxes.findProperty('title', header.get('label')).checked;
|
|
|
- });
|
|
|
- isError = isError || all_false;
|
|
|
+ var checkboxes = hosts[i].get('checkboxes');
|
|
|
+ isError = false;
|
|
|
+ headers.forEach(function (header) {
|
|
|
+ isError |= checkboxes.findProperty('title', header.get('label')).checked;
|
|
|
});
|
|
|
+ isError = !isError;
|
|
|
if (isError) {
|
|
|
- this.set('errorMessage', Em.I18n.t('installer.step6.error.mustSelectOne'));
|
|
|
+ this.set('errorMessage', errorMsg);
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
+ return !isError;
|
|
|
+ },
|
|
|
|
|
|
+ /**
|
|
|
+ * Validate a component for all hosts. Return do we have errors or not
|
|
|
+ * @return {Boolean}
|
|
|
+ */
|
|
|
+ validateEachComponent: function () {
|
|
|
+ var isError = false;
|
|
|
+ var hosts = this.get('hosts');
|
|
|
+ var headers = this.get('headers');
|
|
|
+ headers.forEach(function (header) {
|
|
|
+ var all_false = true;
|
|
|
+ hosts.forEach(function (host) {
|
|
|
+ var checkboxes = host.get('checkboxes');
|
|
|
+ all_false = all_false && !checkboxes.findProperty('title', header.get('label')).checked;
|
|
|
+ });
|
|
|
+ isError = isError || all_false;
|
|
|
+ });
|
|
|
+ if (isError) {
|
|
|
+ this.set('errorMessage', Em.I18n.t('installer.step6.error.mustSelectOne'));
|
|
|
+ }
|
|
|
return !isError;
|
|
|
}
|
|
|
|
|
|
-});
|
|
|
+})
|
|
|
+;
|