ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject ambari git commit: AMBARI-13042 Manage Config Groups: revert changes takes too much time. (atkach)
Date Wed, 09 Sep 2015 14:01:43 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 37f8c88f2 -> 40f2ac2f1


AMBARI-13042 Manage Config Groups: revert changes takes too much time. (atkach)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/40f2ac2f
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/40f2ac2f
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/40f2ac2f

Branch: refs/heads/trunk
Commit: 40f2ac2f17837eec848489478b70db1162267804
Parents: 37f8c88
Author: Andrii Tkach <atkach@hortonworks.com>
Authored: Wed Sep 9 11:50:02 2015 +0300
Committer: Andrii Tkach <atkach@hortonworks.com>
Committed: Wed Sep 9 17:01:19 2015 +0300

----------------------------------------------------------------------
 .../controllers/main/service/info/configs.js    |  2 +-
 .../service/manage_config_groups_controller.js  | 22 ++++++++++++----
 .../main/service/configs/config_overridable.js  | 27 ++++++++++++--------
 .../main/service/manage_config_groups_view.js   | 12 +--------
 .../manage_config_groups_controller_test.js     |  1 +
 5 files changed, 36 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/40f2ac2f/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 978c03b..6e31216 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -51,7 +51,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ConfigsLoader,
A
    */
   configGroups: function() {
     return this.get('groupsStore').filterProperty('serviceName', this.get('content.serviceName'));
-  }.property('content.serviceName', 'groupsStore.length', 'groupStore.@each.name'),
+  }.property('content.serviceName', 'groupsStore'),
 
   dependentConfigGroups: function() {
     if (this.get('dependentServiceNames.length') === 0) return [];

http://git-wip-us.apache.org/repos/asf/ambari/blob/40f2ac2f/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 a2f9628..d580139 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
@@ -95,6 +95,12 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable,
{
   clusterHosts: [],
 
   /**
+   * trigger <code>selectDefaultGroup</code> after group delete
+   * @type {null}
+   */
+  groupDeleteTrigger: null,
+
+  /**
    * List of available service components for <code>serviceName</code>
    * @type {{componentName: string, displayName: string, selected: boolean}[]}
    */
@@ -560,6 +566,7 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable,
{
     this.deleteHosts();
     this.get('configGroups').removeObject(selectedConfigGroup);
     this.set('selectedConfigGroup', this.get('configGroups').findProperty('isDefault'));
+    this.propertyDidChange('groupDeleteTrigger');
   },
 
   /**
@@ -769,20 +776,25 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable,
{
       },
 
       onClose: function () {
-        this.resetGroupChanges();
+        //<code>_super</code> has to be called before <code>resetGroupChanges</code>
+        var originalGroups = this.get('subViewController.originalConfigGroups').slice(0);
         this._super();
+        this.resetGroupChanges(originalGroups);
       },
 
       onSecondary: function () {
-        this.resetGroupChanges();
-        this._super();
+        this.onClose();
       },
 
-      resetGroupChanges: function () {
+      /**
+       * reset group changes made by user
+       * @param {Array} originalGroups
+       */
+      resetGroupChanges: function (originalGroups) {
         if (this.get('subViewController.isHostsModified')) {
           App.ServiceConfigGroup.find().clear();
           App.store.commit();
-          App.store.loadMany(App.ServiceConfigGroup, this.get('subViewController.originalConfigGroups'));
+          App.store.loadMany(App.ServiceConfigGroup, originalGroups);
           App.store.commit();
         }
       },

http://git-wip-us.apache.org/repos/asf/ambari/blob/40f2ac2f/ambari-web/app/mixins/main/service/configs/config_overridable.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/main/service/configs/config_overridable.js b/ambari-web/app/mixins/main/service/configs/config_overridable.js
index d5b733c..1962502 100644
--- a/ambari-web/app/mixins/main/service/configs/config_overridable.js
+++ b/ambari-web/app/mixins/main/service/configs/config_overridable.js
@@ -135,27 +135,27 @@ App.ConfigOverridable = Em.Mixin.create({
         } else {
           var newConfigGroupName = this.get('newConfigGroupName').trim();
           var newConfigGroup = {
-            id: null,
+            id: serviceName + "_NEW_" + configGroups.length,
             name: newConfigGroupName,
             description: Em.I18n.t('config.group.description.default').format(new Date().toDateString()),
             service_id: serviceId,
             hosts: [],
             desired_configs: []
           };
+          App.store.load(App.ServiceConfigGroup, newConfigGroup);
+          App.store.commit();
           if (!isInstaller) {
             self.postNewConfigurationGroup(newConfigGroup);
           }
-          if (newConfigGroup) {
-            newConfigGroup.set('parentConfigGroup', configGroups.findProperty('isDefault'));
-            configGroups.pushObject(newConfigGroup);
-            if (isInstaller) {
-              self.persistConfigGroups();
-            } else {
-              self.saveGroupConfirmationPopup(newConfigGroupName);
-            }
-            this.hide();
-            callback(newConfigGroup);
+          newConfigGroup = App.ServiceConfigGroup.find(newConfigGroup.id);
+          configGroups.pushObject(newConfigGroup);
+          if (isInstaller) {
+            self.persistConfigGroups();
+          } else {
+            self.saveGroupConfirmationPopup(newConfigGroupName);
           }
+          this.hide();
+          callback(newConfigGroup);
         }
       },
       onSecondary: function () {
@@ -235,6 +235,7 @@ App.ConfigOverridable = Em.Mixin.create({
     var sendData = {
       name: 'config_groups.create',
       data: {
+        'mock_id': newConfigGroupData.id,
         'group_name': newConfigGroupData.name,
         'service_id': newConfigGroupData.service_id,
         'description': newConfigGroupData.description,
@@ -243,6 +244,10 @@ App.ConfigOverridable = Em.Mixin.create({
       success: 'successFunction',
       error: 'errorFunction',
       successFunction: function (response, opt, params) {
+        var configGroupData = App.router.get('manageConfigGroupsController').generateOriginalConfigGroups([App.ServiceConfigGroup.find(params.mock_id)]);
+        App.configGroupsMapper.deleteRecord(App.ServiceConfigGroup.find(params.mock_id));
+        configGroupData[0].id = response.resources[0].ConfigGroup.id;
+        App.store.load(App.ServiceConfigGroup, configGroupData[0]);
         App.ServiceConfigGroup.find().clear();
         if (callback) {
           callback();

http://git-wip-us.apache.org/repos/asf/ambari/blob/40f2ac2f/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 f7477ae..d4cb381 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
@@ -135,16 +135,6 @@ App.MainServiceManageConfigGroupView = Em.View.extend({
   }.observes('selectedConfigGroup'),
 
   /**
-   * Select first config group after all groups are loaded
-   * @method onLoad
-   */
-  onLoad: function () {
-    if (this.get('controller.isLoaded')) {
-      this.set('selectedConfigGroup', this.get('controller.configGroups')[0])
-    }
-  }.observes('controller.isLoaded', 'controller.configGroups'),
-
-  /**
    * Select default config group after all config groups are loaded
    * @method selectDefaultGroup
    */
@@ -152,6 +142,6 @@ App.MainServiceManageConfigGroupView = Em.View.extend({
     if (this.get('controller.isLoaded')) {
       this.set('selectedConfigGroup', [this.get('controller.configGroups').findProperty('isDefault')]);
     }
-  }.observes('controller.isLoaded')
+  }.observes('controller.isLoaded', 'controller.groupDeleteTrigger')
 
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/40f2ac2f/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
b/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
index 6d4eec7..4828869 100644
--- a/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
+++ b/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
@@ -183,6 +183,7 @@ describe('App.ManageConfigGroupsController', function() {
 
       c.deleteConfigGroup();
 
+      expect(c.get('configGroups.length')).to.equal(1);
       expect(c.get('selectedConfigGroup.hosts')).to.include.members(['h1','h2','h3']);
       expect(c.get('selectedConfigGroup.isDefault')).to.be.true;
     });


Mime
View raw message