Updated Branches:
  refs/heads/trunk bb280dfdc -> 52e689237

AMBARI-3064. Ambari UI widgets should tolerate addition or removal of services. 
(xiwang via yusaku)


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

Branch: refs/heads/trunk
Commit: 52e689237c34698061c885b43a3e4c3d286999e1
Parents: bb280df
Author: Yusaku Sako <[email protected]>
Authored: Thu Sep 5 13:59:28 2013 -0700
Committer: Yusaku Sako <[email protected]>
Committed: Thu Sep 5 13:59:45 2013 -0700

----------------------------------------------------------------------
 ambari-web/app/views/main/dashboard.js | 47 +++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/52e68923/ambari-web/app/views/main/dashboard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard.js 
b/ambari-web/app/views/main/dashboard.js
index a3953e6..f65c2a6 100644
--- a/ambari-web/app/views/main/dashboard.js
+++ b/ambari-web/app/views/main/dashboard.js
@@ -238,6 +238,7 @@ App.MainDashboardView = Em.View.extend({
           currentPrefObject.dashboardVersion = 'new';
           this.postUserPref(this.get('persistKey'), currentPrefObject);
         }
+        this.hasUpgraded(currentPrefObject);
         this.translateToReal(currentPrefObject);
       } else {
         // post persist then translate init object
@@ -246,6 +247,52 @@ App.MainDashboardView = Em.View.extend({
       }
     }
   },
+  /**
+   * check id stack has upgraded from HDP 1.0 to 2.0. Update the value on 
server if true.
+   */
+  hasUpgraded: function (value) {
+    var visible = value.visible;
+    var hidden = value.hidden;
+    var mapWidgets = ['6', '7', '8', '9', '10', '16', '18'];
+    var yarnWidgets = ['24', '25', '26', '27'];
+
+    // check if cur_value has mapReduce
+    var curhasMapreduce = false;
+    for (var j = 0; j <= visible.length -1; j++) {
+      if (visible[j] == mapWidgets[0]) {
+        curhasMapreduce = true;
+        break;
+      }
+    }
+    for (var j = 0; j <= hidden.length -1; j++) {
+      if ( !curhasMapreduce && hidden[j][0] == mapWidgets[0]) {
+        curhasMapreduce = true;
+        break;
+      }
+    }
+    // check if stack upgrade from 1.0 to 2.0.
+    if ( this.get('yarn_model') != null && curhasMapreduce) {
+      // Remove all Mapreduce widgets and add Yarn widgets as visible
+      mapWidgets.forEach ( function (item) {
+        for (var j = 0; j <= visible.length -1; j++) {
+          if (visible[j] == item) {
+            visible.splice(j, 1);
+          }
+        }
+        for (var j = 0; j <= hidden.length -1; j++) {
+          if (hidden[j][0] == item) {
+            hidden.splice(j, 1);
+          }
+        }
+      }, this);
+      visible = visible.concat (yarnWidgets);
+      //post to server
+      var obj = this.get('currentPrefObject');
+      obj.visible = visible;
+      obj.hidden = hidden;
+      this.postUserPref(this.get('persistKey'), obj);
+    }
+  },
 
   widgetsMapper: function (id) {
     switch(id){

Reply via email to