You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by rz...@apache.org on 2016/03/03 23:13:15 UTC
ambari git commit: AMBARI-15268 Combo Search: Add more supported
component states (Joe Wang via rzang)
Repository: ambari
Updated Branches:
refs/heads/trunk 8d4243c61 -> 65724a9b9
AMBARI-15268 Combo Search: Add more supported component states (Joe Wang via rzang)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/65724a9b
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/65724a9b
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/65724a9b
Branch: refs/heads/trunk
Commit: 65724a9b9bf8fd86c602109de581f65479427be1
Parents: 8d4243c
Author: Richard Zang <rz...@apache.org>
Authored: Thu Mar 3 14:11:58 2016 -0800
Committer: Richard Zang <rz...@apache.org>
Committed: Thu Mar 3 14:11:58 2016 -0800
----------------------------------------------------------------------
ambari-web/app/controllers/main/host.js | 7 ++-
.../controllers/main/host/combo_search_box.js | 51 ++++++++++++++++----
.../app/views/main/host/combo_search_box.js | 23 +++++----
3 files changed, 61 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/65724a9b/ambari-web/app/controllers/main/host.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host.js b/ambari-web/app/controllers/main/host.js
index 27f0b41..b473c59 100644
--- a/ambari-web/app/controllers/main/host.js
+++ b/ambari-web/app/controllers/main/host.js
@@ -159,7 +159,12 @@ App.MainHostController = Em.ArrayController.extend(App.TableServerMixin, {
},
{
name: 'componentState',
- key: '(host_components/HostRoles/component_name={0}&host_components/HostRoles/state={1})',
+ key: [
+ '(host_components/HostRoles/component_name={0})',
+ '(host_components/HostRoles/component_name={0}&host_components/HostRoles/state={1})',
+ '(host_components/HostRoles/component_name={0}&host_components/HostRoles/desired_admin_state={1})',
+ '(host_components/HostRoles/component_name={0}&host_components/HostRoles/maintenance_state={1})'
+ ],
type: 'COMBO'
}
],
http://git-wip-us.apache.org/repos/asf/ambari/blob/65724a9b/ambari-web/app/controllers/main/host/combo_search_box.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/combo_search_box.js b/ambari-web/app/controllers/main/host/combo_search_box.js
index 339ddc9..6c75c7a 100644
--- a/ambari-web/app/controllers/main/host/combo_search_box.js
+++ b/ambari-web/app/controllers/main/host/combo_search_box.js
@@ -60,12 +60,9 @@ App.MainHostComboSearchBoxController = Em.Controller.extend({
},
generateQueryParam: function(param) {
- var expression = param.key;
- var filterName = App.router.get('mainHostController.filterProperties').findProperty('key', expression).name;
- if (filterName == 'componentState') {
- var pHash = this.createComboParamHash(param);
- return this.createComboParamURL(pHash, expression);
- }
+ var expressions = param.key;
+ var pHash = this.createComboParamHash(param);
+ return this.createComboParamURL(pHash, expressions);
},
/**
@@ -73,13 +70,15 @@ App.MainHostComboSearchBoxController = Em.Controller.extend({
* @param expression
* @returns {string} 'k1=v1&(k2=v1|k2=v2)'
*/
- createComboParamURL: function(pHash, expression) {
+ createComboParamURL: function(pHash, expressions) {
+ var self = this;
var result = '';
for (key in pHash) {
var v = pHash[key];
if (Em.isArray(v)) {
var ex = '(';
v.forEach(function(item) {
+ var expression = self.getComboParamURL(item, expressions);
var toAdd = expression.replace('{0}', key);
toAdd = toAdd.replace('{1}', item);
ex += toAdd + '|';
@@ -87,6 +86,7 @@ App.MainHostComboSearchBoxController = Em.Controller.extend({
ex = ex.substring(0, ex.length - 1);
result += ex + ')';
} else {
+ var expression = self.getComboParamURL(v, expressions);
var ex = expression.replace('{0}', key);
ex = ex.replace('{1}', v);
result += ex;
@@ -98,6 +98,41 @@ App.MainHostComboSearchBoxController = Em.Controller.extend({
},
/**
+ * @param value //value of component state
+ * @returns expression //url of query of state
+ */
+ getComboParamURL: function(value, expressions) {
+ var expression = expressions[1];
+ switch (value) {
+ case 'ALL':
+ expression = expressions[0];
+ break;
+ case 'STARTED':
+ case 'STARTING':
+ case 'INSTALLED':
+ case 'STOPPING':
+ case 'INSTALL_FAILED':
+ case 'INSTALLING':
+ case 'UPGRADE_FAILED':
+ case 'UNKNOWN':
+ case 'DISABLED':
+ case 'INIT':
+ break;
+ case 'INSERVICE':
+ case 'DECOMMISSIONING':
+ case 'DECOMMISSIONED':
+ case 'RS_DECOMMISSIONED':
+ expression = expressions[2];
+ break;
+ case 'ON':
+ case 'OFF':
+ expression = expressions[3];
+ break;
+ }
+ return expression;
+ },
+
+ /**
* @param param ['k1:v1','k2:v1', 'k2:v2'] or 'k1:v1'
* @returns {k1:v1, k2:[v1,v2], ...}
*/
@@ -108,7 +143,6 @@ App.MainHostComboSearchBoxController = Em.Controller.extend({
var values = item.split(':');
var k = values[0];
var v = values[1];
- if (v == 'STOPPED') { v = 'INSTALLED'; } // 'STOPPED' is not a valid internal state
if (!pHash[k]) {
pHash[k] = v;
} else {
@@ -123,7 +157,6 @@ App.MainHostComboSearchBoxController = Em.Controller.extend({
});
} else {
var values = param.value.split(':');
- if (values[1] == 'STOPPED') { values[1] = 'INSTALLED'; }
pHash[values[0]] = values[1];
}
return pHash;
http://git-wip-us.apache.org/repos/asf/ambari/blob/65724a9b/ambari-web/app/views/main/host/combo_search_box.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host/combo_search_box.js b/ambari-web/app/views/main/host/combo_search_box.js
index 53650ee..e8f21f0 100644
--- a/ambari-web/app/views/main/host/combo_search_box.js
+++ b/ambari-web/app/views/main/host/combo_search_box.js
@@ -61,7 +61,6 @@ App.MainHostComboSearchBoxView = Em.View.extend({
{label: 'Version State', value: 'versionState', category: 'Host'},
{label: 'Rack', value: 'rack', category: 'Host'},
{label: 'Service', value: 'services', category: 'Service'},
- {label: 'Has Component', value: 'hostComponents', category: 'Service'},
];
var hostComponentHash = {};
App.HostComponent.find().toArray().forEach(function(component) {
@@ -112,16 +111,20 @@ App.MainHostComboSearchBoxView = Em.View.extend({
return {label: App.format.role(service.get('serviceName')), value: service.get('serviceName')};
}), {preserveOrder: true});
break;
- case 'hostComponents':
- callback(App.HostComponent.find().toArray().mapProperty('componentName').uniq().map(function (componentName) {
- return {label: App.format.role(componentName), value: componentName};
- }));
- break;
- case 'state':
- callback(App.HostComponentStatus.getStatusesList(), {preserveOrder: true});
- break;
case 'componentState':
- callback(['STARTED', 'STOPPED'], {preserveOrder: true});
+ callback([{label: "All", value: "ALL"}]
+ .concat(App.HostComponentStatus.getStatusesList().map(function (status) {
+ return {label: App.HostComponentStatus.getTextStatus(status), value: status};
+ }))
+ .concat([
+ {label: "Inservice", value: "INSERVICE"},
+ {label: "Decommissioned", value: "DECOMMISSIONED"},
+ {label: "Decommissioning", value: "DECOMMISSIONING"},
+ {label: "RS Decommissioned", value: "RS_DECOMMISSIONED"},
+ {label: "Maintenance Mode On", value: "ON"},
+ {label: "Maintenance Mode Off", value: "OFF"}
+ ]), {preserveOrder: true});
+ break;
}
}
}