Updated Branches: refs/heads/trunk e8a60eb46 -> 95ba3b452
AMBARI-3932 Config Group names can be named without any restriction. (ababiichuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/95ba3b45 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/95ba3b45 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/95ba3b45 Branch: refs/heads/trunk Commit: 95ba3b45225b8b9528d7c57cb8f35b0adaa6039b Parents: e8a60eb Author: aBabiichuk <[email protected]> Authored: Fri Nov 29 17:41:47 2013 +0200 Committer: aBabiichuk <[email protected]> Committed: Fri Nov 29 17:42:01 2013 +0200 ---------------------------------------------------------------------- .../service/manage_config_groups_controller.js | 8 ++++---- ambari-web/app/models/config_group.js | 17 +++++++++++++++-- .../common/configs/overriddenProperty.hbs | 2 +- .../templates/common/configs/service_config.hbs | 4 ++-- .../service/manage_configuration_groups_popup.hbs | 2 +- ambari-web/app/utils/config.js | 2 ++ 6 files changed, 25 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/95ba3b45/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 1e846ba..8e516cf 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 @@ -363,19 +363,19 @@ App.ManageConfigGroupsController = Em.Controller.extend({ warningMessage: '', validate: function () { var warningMessage = ''; - if (self.get('usedConfigGroupNames').concat(self.get('configGroups').mapProperty('name')).contains(this.get('configGroupName'))) { + if (self.get('usedConfigGroupNames').concat(self.get('configGroups').mapProperty('name')).contains(this.get('configGroupName').trim())) { warningMessage = Em.I18n.t("config.group.selection.dialog.err.name.exists"); } this.set('warningMessage', warningMessage); }.observes('configGroupName'), enablePrimary: function () { - return this.get('configGroupName').length > 0 && !this.get('warningMessage'); + return this.get('configGroupName').trim().length > 0 && !this.get('warningMessage'); }.property('warningMessage', 'configGroupName'), onPrimary: function () { if (!this.get('enablePrimary')) { return false; } - this.get('content').set('configGroupName', this.get('configGroupName')); + this.get('content').set('configGroupName', this.get('configGroupName').trim()); this.get('content').set('configGroupDesc', this.get('configGroupDesc')); var desiredConfig = []; if (isDuplicated) { @@ -391,7 +391,7 @@ App.ManageConfigGroupsController = Em.Controller.extend({ }) }, this); } - self.createNewConfigurationGroup(this.get('configGroupName'),this.get('content.serviceName'),this.get('configGroupDesc'), desiredConfig, this.get('content')); + self.createNewConfigurationGroup(this.get('configGroupName').trim(),this.get('content.serviceName'),this.get('configGroupDesc'), desiredConfig, this.get('content')); }, onSecondary: function () { this.hide(); http://git-wip-us.apache.org/repos/asf/ambari/blob/95ba3b45/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 708e1c5..c383c76 100644 --- a/ambari-web/app/models/config_group.js +++ b/ambari-web/app/models/config_group.js @@ -76,9 +76,22 @@ App.ConfigGroup = Ember.Object.extend({ */ hosts: [], + /** + * Provides a display friendly name. This includes trimming + * names to a certain length. + */ displayName: function () { - return this.get('name') + ' (' + this.get('hosts.length') + ')'; - }.property('name', 'hosts.length'), + var name = this.get('name'); + if (name && name.length>App.config.CONFIG_GROUP_NAME_MAX_LENGTH) { + var middle = Math.floor(App.config.CONFIG_GROUP_NAME_MAX_LENGTH / 2); + name = name.substring(0, middle) + "..." + name.substring(name.length-middle); + } + return name; + }.property('name'), + + displayNameHosts: function () { + return this.get('displayName') + ' (' + this.get('hosts.length') + ')'; + }.property('displayName', 'hosts.length'), apiResponse: null, http://git-wip-us.apache.org/repos/asf/ambari/blob/95ba3b45/ambari-web/app/templates/common/configs/overriddenProperty.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/configs/overriddenProperty.hbs b/ambari-web/app/templates/common/configs/overriddenProperty.hbs index 579c0cd..4822629 100644 --- a/ambari-web/app/templates/common/configs/overriddenProperty.hbs +++ b/ambari-web/app/templates/common/configs/overriddenProperty.hbs @@ -21,7 +21,7 @@ <div {{bindAttr class="overriddenSCP.errorMessage:error: :control-group :overrideField"}}> {{view overriddenSCP.viewClass serviceConfigBinding="overriddenSCP" categoryConfigsBinding="view.categoryConfigs"}} {{#if overriddenSCP.group}} - <a class="action" {{action selectConfigGroup overriddenSCP.group target="controller"}}>{{overriddenSCP.group.name}}</a> + <a class="action" {{action selectConfigGroup overriddenSCP.group target="controller"}}>{{overriddenSCP.group.displayName}}</a> {{/if}} {{#if overriddenSCP.isEditable}} {{#if isNotDefaultValue}} http://git-wip-us.apache.org/repos/asf/ambari/blob/95ba3b45/ambari-web/app/templates/common/configs/service_config.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/configs/service_config.hbs b/ambari-web/app/templates/common/configs/service_config.hbs index 718afb0..5776918 100644 --- a/ambari-web/app/templates/common/configs/service_config.hbs +++ b/ambari-web/app/templates/common/configs/service_config.hbs @@ -49,7 +49,7 @@ <div class="alert alert-info"> {{t common.group}} <span class="btn-group"> - <button {{bindAttr disabled="controller.isHostsConfigsPage"}} class="btn">{{selectedConfigGroup.name}}</button> + <button {{bindAttr disabled="controller.isHostsConfigsPage"}} class="btn">{{selectedConfigGroup.displayNameHosts}}</button> <button {{bindAttr disabled="controller.isHostsConfigsPage"}} class="btn dropdown-toggle" data-toggle="dropdown"> <span class="caret"></span> </button> @@ -58,7 +58,7 @@ {{#each configGroup in configGroups}} <li> <a href="#" {{action "selectConfigGroup" configGroup target="controller"}}> - {{configGroup.name}} ({{configGroup.hosts.length}}) + {{configGroup.displayNameHosts}} </a> </li> {{/each}} http://git-wip-us.apache.org/repos/asf/ambari/blob/95ba3b45/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 4edee0f..4accc70 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 @@ -23,7 +23,7 @@ <div class="span5"> {{view Em.Select contentBinding="configGroups" - optionLabelPath="content.displayName" + optionLabelPath="content.displayNameHosts" selectionBinding="view.selectedConfigGroup" multiple="multiple" class="group-select" http://git-wip-us.apache.org/repos/asf/ambari/blob/95ba3b45/ambari-web/app/utils/config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js index 6bbc82f..065e2c1 100644 --- a/ambari-web/app/utils/config.js +++ b/ambari-web/app/utils/config.js @@ -43,6 +43,8 @@ App.config = Em.Object.create({ "'": "'" }, + CONFIG_GROUP_NAME_MAX_LENGTH: 40, + /** * Since values end up in XML files (core-sit.xml, etc.), certain * XML sensitive characters should be escaped. If not we will have
