ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jai...@apache.org
Subject git commit: AMBARI-6463. Installer wizard not showing service configs for selected services on renavigation. (jaimin)
Date Sat, 26 Jul 2014 00:06:23 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk d7c0d8ae6 -> cb2bb4dbc


AMBARI-6463. Installer wizard not showing service configs for selected services on renavigation.
(jaimin)


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

Branch: refs/heads/trunk
Commit: cb2bb4dbcf132166aff05cb36d48278f9cb851ea
Parents: d7c0d8a
Author: Jaimin Jetly <jaimin@hortonworks.com>
Authored: Fri Jul 25 17:05:55 2014 -0700
Committer: Jaimin Jetly <jaimin@hortonworks.com>
Committed: Fri Jul 25 17:06:09 2014 -0700

----------------------------------------------------------------------
 ambari-web/app/app.js                          |  4 +++-
 ambari-web/app/controllers/wizard.js           | 12 +---------
 ambari-web/app/mappers/stack_service_mapper.js | 24 +++++++++++++++++--
 ambari-web/app/utils/helper.js                 | 26 +++++++++++++++++++++
 4 files changed, 52 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/cb2bb4db/ambari-web/app/app.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/app.js b/ambari-web/app/app.js
index 55d7b46..47aa25b 100644
--- a/ambari-web/app/app.js
+++ b/ambari-web/app/app.js
@@ -28,7 +28,9 @@ module.exports = Em.Application.create({
     revision: 4,
     adapter: DS.FixtureAdapter.create({
       simulateRemoteResponse: false
-    })
+    }),
+    typeMaps: {},
+    recordCache: []
   }),
   isAdmin: false,
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/cb2bb4db/ambari-web/app/controllers/wizard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js
index 2bd9ec5..860a782 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -517,20 +517,10 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
   loadedServiceComponents: null,
 
   /**
-   * Clean store from already loaded data.
-   **/
-  clearStackModels: function () {
-    if (App.StackService.find().get('content').length) {
-      App.StackServiceComponent.find().set('content', []);
-      App.StackService.find().set('content', []);
-    }
-  },
-  /**
    * Generate serviceComponents as pr the stack definition  and save it to localdata
    * called form stepController step4WizardController
    */
   loadServiceComponents: function () {
-    this.clearStackModels();
     return App.ajax.send({
       name: 'wizard.service_components',
       sender: this,
@@ -575,7 +565,7 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
       }, this);
     }
 
-    App.stackServiceMapper.map(jsonData);
+    App.stackServiceMapper.mapStackServices(jsonData);
   },
 
   loadServiceComponentsErrorCallback: function (request, ajaxOptions, error) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/cb2bb4db/ambari-web/app/mappers/stack_service_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/stack_service_mapper.js b/ambari-web/app/mappers/stack_service_mapper.js
index 1577937..9960e14 100644
--- a/ambari-web/app/mappers/stack_service_mapper.js
+++ b/ambari-web/app/mappers/stack_service_mapper.js
@@ -55,6 +55,13 @@ App.stackServiceMapper = App.QuickDataMapper.create({
     }
   },
 
+  mapStackServices: function(json) {
+    this.clearStackModels();
+    App.resetDsStoreTypeMap(App.StackServiceComponent);
+    App.resetDsStoreTypeMap(App.StackService);
+    this.map(json);
+  },
+
   map: function (json) {
     var model = this.get('model');
     var result = [];
@@ -75,12 +82,25 @@ App.stackServiceMapper = App.QuickDataMapper.create({
         result.push(this.parseIt(stackService, this.get('config')));
       }
     }, this);
-    if (!$.mocho)
-      App.store.commit();
     App.store.loadMany(this.get('component_model'), stackServiceComponents);
     App.store.loadMany(model, result);
   },
 
+  /**
+   * Clean store from already loaded data.
+   **/
+  clearStackModels: function () {
+    var models = [App.StackServiceComponent, App.StackService];
+    models.forEach(function (model) {
+      var records = App.get('store').findAll(model).filterProperty('id');
+      records.forEach(function (rec) {
+        Ember.run(this, function () {
+          rec.deleteRecord();
+        });
+      }, this);
+    }, this);
+  },
+
   rearrangeServicesForDisplayOrder: function (array, displayOrderArray) {
     return array.sort(function (a, b) {
       var aValue = displayOrderArray.indexOf(a.StackServices.service_name) != -1 ? displayOrderArray.indexOf(a.StackServices.service_name)
: array.length;

http://git-wip-us.apache.org/repos/asf/ambari/blob/cb2bb4db/ambari-web/app/utils/helper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/helper.js b/ambari-web/app/utils/helper.js
index d9e6136..e6a8060 100644
--- a/ambari-web/app/utils/helper.js
+++ b/ambari-web/app/utils/helper.js
@@ -740,3 +740,29 @@ DS.attr.transforms.array = {
     return deserialized;
   }
 };
+
+/**
+ *  Utility method to delete all existing records of a DS.Model type from the model's associated
map and
+ *  store's persistence layer (recordCache)
+ * @param type DS.Model Class
+ */
+App.resetDsStoreTypeMap = function(type) {
+  var allRecords = App.get('store.recordCache');  //This fetches all records in the ember-data
persistence layer
+  var typeMaps = App.get('store.typeMaps');
+  var guidForType = Em.guidFor(type);
+  var typeMap = typeMaps[guidForType];
+  if (typeMap) {
+    var idToClientIdMap = typeMap.idToCid;
+    for (var id in idToClientIdMap) {
+      if (idToClientIdMap.hasOwnProperty(id) && idToClientIdMap[id]) {
+        delete allRecords[idToClientIdMap[id]];  // deletes the cached copy of the record
from the store
+      }
+    }
+    typeMaps[guidForType] = {
+      idToCid: {},
+      clientIds: [],
+      cidToHash: {},
+      recordArrays: []
+    };
+  }
+};


Mime
View raw message