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 2013/11/15 16:59:02 UTC
git commit: AMBARI-3774 Provide ability to add/remove hosts in
manage-config-groups dialog. (atkach)
Updated Branches:
refs/heads/trunk b5a3f48bc -> 68eef9663
AMBARI-3774 Provide ability to add/remove hosts in manage-config-groups dialog. (atkach)
Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/68eef966
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/68eef966
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/68eef966
Branch: refs/heads/trunk
Commit: 68eef9663c12d3065d327b107f399c7d30f22b3a
Parents: b5a3f48
Author: atkach <an...@gmail.com>
Authored: Fri Nov 15 17:58:51 2013 +0200
Committer: atkach <an...@gmail.com>
Committed: Fri Nov 15 17:58:51 2013 +0200
----------------------------------------------------------------------
.../service/manage_config_groups_controller.js | 35 +++++++++++++++++++-
ambari-web/app/models/config_group.js | 25 +++++++++++++-
.../manage_configuration_groups_popup.hbs | 5 +--
.../main/service/manage_config_groups_view.js | 1 +
4 files changed, 62 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/68eef966/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/manage_config_groups_controller.js b/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
index 549a1cb..1998ce1 100644
--- a/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
+++ b/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
@@ -18,8 +18,9 @@
var App = require('app');
-App.ManageConfigGroupsController = App.WizardController.extend({
+var hostsManagement = require('utils/hosts');
+App.ManageConfigGroupsController = Em.Controller.extend({
name: 'manageConfigGroupsController',
isLoaded: false,
@@ -30,6 +31,8 @@ App.ManageConfigGroupsController = App.WizardController.extend({
selectedConfigGroup: null,
+ selectedHosts: [],
+
loadConfigGroups: function (serviceName) {
this.set('serviceName', serviceName);
App.ajax.send({
@@ -140,5 +143,35 @@ App.ManageConfigGroupsController = App.WizardController.extend({
if (properies) {
App.showAlertPopup(Em.I18n.t('services.service.config_groups_popup.properties'), properies);
}
+ },
+ /**
+ * add hosts to group
+ * @return {Array}
+ */
+ addHosts: function () {
+ var availableHosts = this.get('selectedConfigGroup.availableHosts');
+ var group = this.get('selectedConfigGroup');
+ hostsManagement.launchHostsSelectionDialog(availableHosts, [], false, [], function (selectedHosts) {
+ if (selectedHosts) {
+ var defaultHosts = group.get('parentConfigGroup.hosts');
+ var configGroupHosts = group.get('hosts');
+ selectedHosts.forEach(function (hostName) {
+ configGroupHosts.pushObject(hostName);
+ defaultHosts.removeObject(hostName);
+ });
+ }
+ });
+ },
+ /**
+ * delete hosts from group
+ */
+ deleteHosts: function () {
+ var groupHosts = this.get('selectedConfigGroup.hosts');
+ var defaultGroupHosts = this.get('selectedConfigGroup.parentConfigGroup.hosts');
+ this.get('selectedHosts').forEach(function (hostName) {
+ defaultGroupHosts.pushObject(hostName);
+ groupHosts.removeObject(hostName);
+ });
+ this.set('selectedHosts', []);
}
});
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/68eef966/ambari-web/app/models/config_group.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/config_group.js b/ambari-web/app/models/config_group.js
index 2a70ce4..1248e24 100644
--- a/ambari-web/app/models/config_group.js
+++ b/ambari-web/app/models/config_group.js
@@ -85,8 +85,31 @@ App.ConfigGroup = Ember.Object.extend({
* non-default configuration groups.
*/
availableHosts: function () {
+ if (this.get('isDefault')) return [];
+ var unusedHostsMap = {};
+ var availableHosts = [];
+ // parentConfigGroup.hosts(hosts from default group) - are available hosts, which don't belong to any group
+ this.get('parentConfigGroup.hosts').forEach(function (hostName) {
+ unusedHostsMap[hostName] = true;
+ });
+ App.Host.find().filter(function (host) {
+ if(unusedHostsMap[host.get('id')]) {
+ availableHosts.pushObject(Ember.Object.create({
+ selected: false,
+ host: host
+ }));
+ }
+ });
+ return availableHosts;
+ }.property('isDefault', 'parentConfigGroup', 'childConfigGroups', 'parentConfigGroup.hosts.@each'),
- }.property('isDefault', 'parentConfigGroup', 'childConfigGroups'),
+ isAddHostsDisabled: function () {
+ return (this.get('isDefault') || this.get('availableHosts.length') === 0);
+ }.property('availableHosts.length'),
+
+ isDeleteHostsDisabled: function () {
+ return (this.get('isDefault') || this.get('hosts.length') === 0);
+ }.property('hosts.length'),
/**
* Collection of (site, tag) pairs representing properties.
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/68eef966/ambari-web/app/templates/main/service/manage_configuration_groups_popup.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/service/manage_configuration_groups_popup.hbs b/ambari-web/app/templates/main/service/manage_configuration_groups_popup.hbs
index 073a8d1..49548fa 100644
--- a/ambari-web/app/templates/main/service/manage_configuration_groups_popup.hbs
+++ b/ambari-web/app/templates/main/service/manage_configuration_groups_popup.hbs
@@ -43,11 +43,12 @@
contentBinding="selectedConfigGroup.hosts"
multiple="multiple"
class="group-select"
+ selectionBinding="selectedHosts"
}}
</div>
<div class="button-group pull-right">
- <a class="btn">+</a>
- <a class="btn">-</a>
+ <button class="btn" {{bindAttr disabled="selectedConfigGroup.isAddHostsDisabled"}} {{action addHosts target="controller"}} >+</button>
+ <button class="btn" {{bindAttr disabled="selectedConfigGroup.isDeleteHostsDisabled"}} {{action deleteHosts target="controller"}} >-</button>
</div>
</div>
<div class="row-fluid">
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/68eef966/ambari-web/app/views/main/service/manage_config_groups_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/manage_config_groups_view.js b/ambari-web/app/views/main/service/manage_config_groups_view.js
index 9a50d10..2c16555 100644
--- a/ambari-web/app/views/main/service/manage_config_groups_view.js
+++ b/ambari-web/app/views/main/service/manage_config_groups_view.js
@@ -33,6 +33,7 @@ App.MainServiceManageConfigGroupView = Em.View.extend({
if (selectedConfigGroup.length > 1) {
this.set('selectedConfigGroup', selectedConfigGroup[selectedConfigGroup.length - 1]);
}
+ this.set('controller.selectedHosts', []);
}.observes('selectedConfigGroup'),
onLoad: function () {