Jelajahi Sumber

AMBARI-1098. Switching services does not update various UI elements, (Srimanth Gunturi via yusaku)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1431765 13f79535-47bb-0310-9956-ffa450edef68
Yusaku Sako 12 tahun lalu
induk
melakukan
593ed9519f

+ 3 - 0
CHANGES.txt

@@ -664,6 +664,9 @@ AMBARI-666 branch (unreleased changes)
 
   BUG FIXES
 
+  AMBARI-1098. Switching services does not update various UI elements.
+  (Srimanth Gunturi via yusaku)
+
   AMBARI-1150. Installer Wizard - Retry feature in Deploy step (Step 9) is
   broken. (yusaku)
 

+ 1 - 1
ambari-web/app/controllers/global/update_controller.js

@@ -38,7 +38,7 @@ App.UpdateController = Em.Controller.extend({
     if(this.get('isWorking')){
       if(timeIntervalId) return;
       this.set('timeIntervalId', setInterval(function(){
-        this.updateAllWrapper();
+        self.updateAllWrapper();
       }, App.contentUpdateInterval));
     } else {
       clearInterval(timeIntervalId);

+ 48 - 14
ambari-web/app/mappers/service_mapper.js

@@ -144,12 +144,6 @@ App.servicesMapper = App.QuickDataMapper.create({
     }
 
     if (json.items) {
-      try{
-        App.store.commit();
-      }catch (e) {
-        console.log("Error committing store before Service mapper maps");
-        console.log(e);
-      }
       var result = [];
       json.items.forEach(function (item) {
         var finalConfig = jQuery.extend({}, this.config);
@@ -188,24 +182,64 @@ App.servicesMapper = App.QuickDataMapper.create({
       result = this.sortByOrder(this.get('servicesSortOrder'), result);
       App.store.loadMany(this.get('model'), result);
 
+      // Service components
       result = [];
-      json.items.forEach(function (item) {
-        item.components.forEach(function (component) {
+      json.items.forEach(function(item){
+        item.components.forEach(function(component){
           result.push(this.parseIt(component, this.config2));
         }, this)
       }, this);
+      var newComponents = [];
+      result.forEach(function(componentJson){
+        var component = App.Component.find(componentJson.id);
+        if (component && component.get('isLoaded')) { // UPDATE
+          if (componentJson.work_status) {
+            component.set('workStatus', componentJson.work_status);
+          }
+          if (componentJson.host_id) {
+            component.set('host', App.Host.find(componentJson.host_id));
+          }
+        } else {
+          newComponents.push(componentJson);
+        }
+      });
+      if (newComponents.length > 0) {
+        App.store.loadMany(this.get('model2'), newComponents);
+      }
 
-      App.store.loadMany(this.get('model2'), result);
-
+      // Host components
       result = [];
-      json.items.forEach(function (item) {
-        item.components.forEach(function (component) {
-          component.host_components.forEach(function (host_component) {
+      json.items.forEach(function(item){
+        item.components.forEach(function(component){
+          component.host_components.forEach(function(host_component){
             result.push(this.parseIt(host_component, this.config3));
           }, this)
         }, this)
       }, this);
-      App.store.loadMany(this.get('model3'), result);
+      var newHostComponents = [];
+      result.forEach(function(hcJson){
+        hcJson.id = hcJson.component_name + '_' + hcJson.host_id;
+        var component = App.HostComponent.find(hcJson.id);
+        if (component && component.get('isLoaded')) { // UPDATE
+          if (hcJson.work_status) {
+            component.set('workStatus', hcJson.work_status);
+          }
+          if (hcJson.component_name) {
+            component.set('componentName', hcJson.component_name);
+          }
+          if (hcJson.host_id) {
+            component.set('host', App.Host.find(hcJson.host_id));
+          }
+          if (hcJson.service_id) {
+            component.set('service', App.Service.find(hcJson.service_id));
+          }
+        } else {
+          newHostComponents.push(hcJson);
+        }
+      });
+      if (newHostComponents.length > 0) {
+        App.store.loadMany(this.get('model3'), newHostComponents);
+      }
     }
   },
   update: function (service) {