You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2016/03/10 17:09:54 UTC
ambari git commit: AMBARI-15356 filtering on version not installed
hosts from the versions page does not work. (atkach)
Repository: ambari
Updated Branches:
refs/heads/trunk e1762a428 -> e1686f51a
AMBARI-15356 filtering on version not installed hosts from the versions page does not work. (atkach)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e1686f51
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e1686f51
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e1686f51
Branch: refs/heads/trunk
Commit: e1686f51a47621dce195d805286377470f45c1c9
Parents: e1762a4
Author: Andrii Tkach <at...@hortonworks.com>
Authored: Thu Mar 10 12:52:01 2016 +0200
Committer: Andrii Tkach <at...@hortonworks.com>
Committed: Thu Mar 10 17:48:41 2016 +0200
----------------------------------------------------------------------
ambari-web/app/controllers/main/host.js | 16 +++++++++-----
ambari-web/app/views/common/filter_view.js | 13 ++++++-----
.../stack_upgrade/upgrade_version_box_view.js | 23 ++++++++++----------
ambari-web/test/controllers/main/host_test.js | 6 ++---
.../upgrade_version_box_view_test.js | 3 ++-
5 files changed, 34 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1686f51/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 5d7e268..efc0ba2 100644
--- a/ambari-web/app/controllers/main/host.js
+++ b/ambari-web/app/controllers/main/host.js
@@ -522,12 +522,13 @@ App.MainHostController = Em.ArrayController.extend(App.TableServerMixin, {
/**
* Filter hosts by stack version and state
* @param {String} displayName
- * @param {String} state
+ * @param {Array} states
*/
- filterByStack: function (displayName, state) {
- if (!displayName || !state) return;
+ filterByStack: function (displayName, states) {
+ if (Em.isNone(displayName) || Em.isNone(states) || !states.length) return;
var colPropAssoc = this.get('colPropAssoc');
var map = this.get('labelValueMap');
+ var displayStates = [];
var versionFilter = {
iColumn: 16,
@@ -536,14 +537,17 @@ App.MainHostController = Em.ArrayController.extend(App.TableServerMixin, {
};
var stateFilter = {
iColumn: 17,
- value: state.toUpperCase(),
+ value: states,
type: 'string'
};
map["Stack Version"] = colPropAssoc[versionFilter.iColumn];
map["Version State"] = colPropAssoc[stateFilter.iColumn];
- map[App.HostStackVersion.formatStatus(stateFilter.value)] = stateFilter.value;
+ stateFilter.value.forEach(function(state) {
+ map[App.HostStackVersion.formatStatus(state)] = state;
+ displayStates.push(App.HostStackVersion.formatStatus(state));
+ });
var versionFilterStr = '"Stack Version": "' + versionFilter.value + '"';
- var stateFilterStr = '"Version State": "' + App.HostStackVersion.formatStatus(stateFilter.value) + '"';
+ var stateFilterStr = '"Version State": "' + displayStates.join(',') + '"';
App.db.setFilterConditions(this.get('name'), [versionFilter, stateFilter]);
App.db.setComboSearchQuery(this.get('name'), [versionFilterStr, stateFilterStr].join(' '));
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1686f51/ambari-web/app/views/common/filter_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/filter_view.js b/ambari-web/app/views/common/filter_view.js
index 21c8c0e..be1e1a7 100644
--- a/ambari-web/app/views/common/filter_view.js
+++ b/ambari-web/app/views/common/filter_view.js
@@ -448,8 +448,9 @@ module.exports = {
case false:
case '=':
return compareValue == rowValue;
+ default:
+ return false;
}
- return false;
};
case 'date':
return function (rowValue, rangeExp) {
@@ -472,7 +473,6 @@ module.exports = {
default:
return false;
}
- return false;
};
case 'number':
return function (rowValue, rangeExp) {
@@ -498,12 +498,11 @@ module.exports = {
case '<':
return compareValue > rowValue;
case '>':
- return compareValue < rowValue
+ return compareValue < rowValue;
case '=':
default:
return compareValue === rowValue;
}
- return false;
};
case 'sub-resource':
return function (origin, compareValue) {
@@ -513,8 +512,10 @@ module.exports = {
return origin.some(function (item) {
for (var i = 0, l = compareValue.length; i < l; i++) {
- if(item.get(compareValue[i].property) !== compareValue[i].value) {
- return false;
+ if (Array.isArray(compareValue[i].value)) {
+ if (!compareValue[i].value.contains(item.get(compareValue[i].property))) return false;
+ } else {
+ if (item.get(compareValue[i].property) !== compareValue[i].value) return false;
}
}
return true;
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1686f51/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
index e0c0ae2..9063af3 100644
--- a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
+++ b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
@@ -81,17 +81,17 @@ App.UpgradeVersionBoxView = Em.View.extend({
*/
versionStateMap: {
'current': {
- 'id': 'current',
+ 'value': ['CURRENT'],
'property': 'currentHosts',
'label': Em.I18n.t('admin.stackVersions.hosts.popup.header.current')
},
'installed': {
- 'id': 'installed',
+ 'value': ['INSTALLED'],
'property': 'installedHosts',
'label': Em.I18n.t('admin.stackVersions.hosts.popup.header.installed')
},
'not_installed': {
- 'id': 'installing',
+ 'value': ['INSTALLING', 'INSTALL_FAILED', 'OUT_OF_SYNC'],
'property': 'notInstalledHosts',
'label': Em.I18n.t('admin.stackVersions.hosts.popup.header.not_installed')
}
@@ -400,7 +400,7 @@ App.UpgradeVersionBoxView = Em.View.extend({
if ($('.version-box-popup .modal')) {
$('.version-box-popup .modal .modal-footer .btn-success').click();
}
- self.filterHostsByStack(displayName, status.id);
+ self.filterHostsByStack(displayName, status.value);
}
});
}
@@ -408,14 +408,15 @@ App.UpgradeVersionBoxView = Em.View.extend({
/**
* goes to the hosts page with content filtered by repo_version_name and repo_version_state
- * @param displayName
- * @param state
+ * @param {string} displayName
+ * @param {Array} states
* @method filterHostsByStack
*/
- filterHostsByStack: function (displayName, state) {
- if (!displayName || !state) return;
- App.router.get('mainHostController').filterByStack(displayName, state);
+ filterHostsByStack: function (displayName, states) {
+ if (Em.isNone(displayName) || Em.isNone(states) || !states.length) return;
+ App.router.get('mainHostController').filterByStack(displayName, states);
App.router.get('mainHostController').set('showFilterConditionsFirstLoad', true);
+ App.router.get('mainHostController').set('filterChangeHappened', true);
App.router.transitionTo('hosts.index');
},
@@ -430,7 +431,7 @@ App.UpgradeVersionBoxView = Em.View.extend({
var maintenanceHosts = this.get('maintenanceHosts');
if (notInstalledHosts.length && notRequiredHosts.length) {
notRequiredHosts.forEach(function(not_required) {
- var index = notInstalledHosts.indexOf(not_required)
+ var index = notInstalledHosts.indexOf(not_required);
if (index > -1) {
notInstalledHosts.splice(index, 1);
}
@@ -438,7 +439,7 @@ App.UpgradeVersionBoxView = Em.View.extend({
}
if (notInstalledHosts.length && maintenanceHosts.length) {
maintenanceHosts.forEach(function(mm_host) {
- var index = notInstalledHosts.indexOf(mm_host)
+ var index = notInstalledHosts.indexOf(mm_host);
if (index > -1) {
notInstalledHosts.splice(index, 1);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1686f51/ambari-web/test/controllers/main/host_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/host_test.js b/ambari-web/test/controllers/main/host_test.js
index e2041f3..e4c1a45 100644
--- a/ambari-web/test/controllers/main/host_test.js
+++ b/ambari-web/test/controllers/main/host_test.js
@@ -387,7 +387,7 @@ describe('MainHostController', function () {
});
it("displayName is null", function() {
- hostController.filterByStack(null, 'INSTALLED');
+ hostController.filterByStack(null, ['INSTALLED']);
expect(App.db.setFilterConditions.called).to.be.false;
});
@@ -398,7 +398,7 @@ describe('MainHostController', function () {
it("stack and displayName exist", function() {
hostController.set('name', 'ctrl1');
- hostController.filterByStack('stack1', 'INSTALLED');
+ hostController.filterByStack('stack1', ['INSTALLED']);
expect(App.db.setFilterConditions.calledWith('ctrl1', [
{
iColumn: 16,
@@ -407,7 +407,7 @@ describe('MainHostController', function () {
},
{
iColumn: 17,
- value: 'INSTALLED',
+ value: ['INSTALLED'],
type: 'string'
}])).to.be.true;
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1686f51/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
index 5746d3a..0ff5ce9 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
@@ -296,7 +296,7 @@ describe('App.UpgradeVersionBoxView', function () {
}));
view.set('p1', ['host1']);
var popup = view.showHosts({contexts: [
- {id: 1, 'property': 'p1'}
+ {value: 1, 'property': 'p1'}
]});
expect(App.ModalPopup.show.calledOnce).to.be.true;
popup.onPrimary();
@@ -324,6 +324,7 @@ describe('App.UpgradeVersionBoxView', function () {
it("version and state are valid", function () {
view.filterHostsByStack('version', 'state');
expect(mock.set.calledWith('showFilterConditionsFirstLoad', true)).to.be.true;
+ expect(mock.set.calledWith('filterChangeHappened', true)).to.be.true;
expect(mock.filterByStack.calledWith('version', 'state')).to.be.true;
expect(App.router.transitionTo.calledWith('hosts.index')).to.be.true;
});