Updated Branches: refs/heads/trunk 929647d93 -> e86e013ea
AMBARI-3850. Config-groups should be sorted in manage config-groups dialog (alexantonenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/60bbb1d5 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/60bbb1d5 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/60bbb1d5 Branch: refs/heads/trunk Commit: 60bbb1d53b1f605096aeab0e1842eb949e60f470 Parents: 929647d Author: Alex Antonenko <[email protected]> Authored: Thu Nov 28 23:18:06 2013 +0200 Committer: Alex Antonenko <[email protected]> Committed: Thu Nov 28 23:18:06 2013 +0200 ---------------------------------------------------------------------- .../controllers/main/service/info/configs.js | 10 +++---- .../service/manage_config_groups_controller.js | 29 ++++++++++++++------ 2 files changed, 25 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/60bbb1d5/ambari-web/app/controllers/main/service/info/configs.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js index 8e7403b..516b362 100644 --- a/ambari-web/app/controllers/main/service/info/configs.js +++ b/ambari-web/app/controllers/main/service/info/configs.js @@ -323,13 +323,11 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({ if (!selectedConfigGroup) { selectedConfigGroup = defaultConfigGroup; } - this.get('configGroups').push(defaultConfigGroup); - this.get('configGroups').sort(function(configGroup){ - if(configGroup.isDefault){ - return false; - } - return true; + + this.get('configGroups').sort(function(configGroupA, configGroupB){ + return (configGroupA.name > configGroupB.name); }); + this.get('configGroups').unshift(defaultConfigGroup); this.set('selectedConfigGroup', selectedConfigGroup); }, http://git-wip-us.apache.org/repos/asf/ambari/blob/60bbb1d5/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 2729bed..9e9d361 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 @@ -38,6 +38,23 @@ App.ManageConfigGroupsController = Em.Controller.extend({ usedConfigGroupNames: [], + resortConfigGroup: function() { + var configGroups = Ember.copy(this.get('configGroups')); + if(configGroups.length < 2){ + return; + } + var defaultConfigGroup = configGroups.findProperty('isDefault'); + configGroups.removeObject(defaultConfigGroup); + var sorted = configGroups.sort(function(configGroupA, configGroupB){ + return String(configGroupA.get('name')) >= String(configGroupB.get('name')); + }); + sorted = [defaultConfigGroup].concat(sorted); + + this.removeObserver('[email protected]', this, 'resortConfigGroup'); + this.set('configGroups', sorted); + this.addObserver('[email protected]', this, 'resortConfigGroup'); + }.observes('[email protected]'), + loadConfigGroups: function (serviceName) { this.set('serviceName', serviceName); App.ajax.send({ @@ -107,12 +124,6 @@ App.ManageConfigGroupsController = Em.Controller.extend({ defaultConfigGroup.set('childConfigGroups', configGroups); defaultConfigGroup.set('hosts', unusedHosts); this.set('configGroups', [defaultConfigGroup].concat(configGroups)); - this.get('configGroups').sort(function(configGroup){ - if(configGroup.isDefault){ - return false; - } - return true; - }); this.loadProperties(groupToTypeToTagMap); this.set('isLoaded', true); } @@ -454,8 +465,10 @@ App.ManageConfigGroupsController = Em.Controller.extend({ }, successLoadingConfigGroup: function (data) { - var confGroup = this.get('configGroups').findProperty('id', data.ConfigGroup.id); - confGroup.set('apiResponse', data.ConfigGroup); + if(data.ConfigGroup) { + var confGroup = this.get('configGroups').findProperty('id', data.ConfigGroup.id); + confGroup.set('apiResponse', data.ConfigGroup); + } }, /**
