incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yus...@apache.org
Subject git commit: AMBARI-2590. JS Error when deleting a widget after sorting it on remove/edit sign. (Xi Wang via yusaku)
Date Tue, 09 Jul 2013 21:57:27 GMT
Updated Branches:
  refs/heads/trunk 93cdf494b -> 263592518


AMBARI-2590. JS Error when deleting a widget after sorting it on remove/edit sign. (Xi Wang
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/26359251
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/26359251
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/26359251

Branch: refs/heads/trunk
Commit: 2635925186d917b23da4701510e8986d5334aa80
Parents: 93cdf49
Author: Yusaku Sako <yusaku@hortonworks.com>
Authored: Tue Jul 9 14:57:13 2013 -0700
Committer: Yusaku Sako <yusaku@hortonworks.com>
Committed: Tue Jul 9 14:57:16 2013 -0700

----------------------------------------------------------------------
 ambari-web/app/styles/application.less        |  2 +-
 ambari-web/app/views/main/dashboard.js        | 78 ++++++++++------------
 ambari-web/app/views/main/dashboard/widget.js | 22 +++---
 3 files changed, 47 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/26359251/ambari-web/app/styles/application.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less
index 53f7078..1adf2f9 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -1986,7 +1986,7 @@ table.graphs {
     }
     .filter-components{
       overflow: auto;
-      height: 375px;
+      max-height: 375px;
       color: #333333;
       right: 0;
       left: auto;

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/26359251/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 7a8119b..36d4f83 100644
--- a/ambari-web/app/views/main/dashboard.js
+++ b/ambari-web/app/views/main/dashboard.js
@@ -58,7 +58,7 @@ App.MainDashboardView = Em.View.extend({
             newValue.visible.push(id);
           }
           self.postUserPref(self.get('persistKey'), newValue);
-          // self.translateToReal(newValue);
+          //self.translateToReal(newValue);
         }
       }
     });
@@ -84,39 +84,39 @@ App.MainDashboardView = Em.View.extend({
   },
   setInitPrefObject: function() {
     //in case of some service not installed
-    var visible_full = [
+    var visibleFull = [
       '2', '4', '8', '10',
       '17', '11', '12', '13', '14',
       '18', '1', '6', '5', '9',
       '3', '7', '15', '16', '20',
       '19', '21', '23'
     ]; // all in order
-    var hidden_full = [['22','Region In Transition']];
+    var hiddenFull = [['22','Region In Transition']];
     if (this.get('hdfs_model') == null) {
-      var hdfs_arr = ['1', '2', '3', '4', '5', '15', '17'];
-      hdfs_arr.forEach ( function (item) {
-        var index = visible_full.indexOf(item);
-        visible_full.splice(index, 1);
+      var hdfs= ['1', '2', '3', '4', '5', '15', '17'];
+      hdfs.forEach ( function (item) {
+        var index = visibleFull.indexOf(item);
+        visibleFull.splice(index, 1);
       }, this);
     }
     if (this.get('mapreduce_model') == null) {
-      var map_arr = ['6', '7', '8', '9', '10', '16', '18'];
-      map_arr.forEach ( function (item) {
-        var index = visible_full.indexOf(item);
-        visible_full.splice(index, 1);
+      var map = ['6', '7', '8', '9', '10', '16', '18'];
+      map.forEach ( function (item) {
+        var index = visibleFull.indexOf(item);
+        visibleFull.splice(index, 1);
       }, this);
     }
     if (this.get('hbase_model') == null) {
-      var hbase_arr = ['19', '20', '21', '23'];
-      hbase_arr.forEach ( function (item) {
-        var index = visible_full.indexOf(item);
-        visible_full.splice(index, 1);
+      var hbase = ['19', '20', '21', '23'];
+      hbase.forEach ( function (item) {
+        var index = visibleFull.indexOf(item);
+        visibleFull.splice(index, 1);
       }, this);
-      hidden_full = [];
+      hiddenFull = [];
     }
     var obj = this.get('initPrefObject');
-    obj.visible = visible_full;
-    obj.hidden = hidden_full;
+    obj.visible = visibleFull;
+    obj.hidden = hiddenFull;
   },
   
   hdfs_model: null,
@@ -147,8 +147,8 @@ App.MainDashboardView = Em.View.extend({
         if (App.testMode) {
           var visibleWidgets = this.get('visibleWidgets');
           checkedWidgets.forEach(function(item){
-            var new_obj = parent.widgetsMapper(item.id);
-            visibleWidgets.pushObject(new_obj);
+            var newObj = parent.widgetsMapper(item.id);
+            visibleWidgets.pushObject(newObj);
             hiddenWidgets.removeObject(item);
           }, this);
         } else {
@@ -187,39 +187,31 @@ App.MainDashboardView = Em.View.extend({
 
     if (version == 'classic') {
       this.set('isClassicDashboard', true);
-    }else if(version == 'new'){
+    } else if (version == 'new') {
       this.set('isClassicDashboard', false);
-      // clear current visible and hiddenWidgets
-      var visibleWidgets = this.get('visibleWidgets');
-      var size = visibleWidgets.length;
-      for (var i = 1; i <= size; i++) {
-        visibleWidgets.removeAt(0);
-      }
-      var hiddenWidgets = this.get('hiddenWidgets');
-      var size = hiddenWidgets.length;
-      for (var i = 1; i <= size; i++) {
-        hiddenWidgets.removeAt(0);
-      }
+      var visibleWidgets = [];
+      var hiddenWidgets = [];
       // re-construct visibleWidgets and hiddenWidgets
-      for (var j = 0; j <= visible.length -1; j++){
-        var cur_id = visible[j];
-        var widgetClass = this.widgetsMapper(cur_id);
+      for (var j = 0; j <= visible.length -1; j++) {
+        var id = visible[j];
+        var widgetClass = this.widgetsMapper(id);
         //override with new threshold
-        if (threshold[cur_id].length > 0) {
+        if (threshold[id].length > 0) {
           widgetClass.reopen({
-            thresh1: threshold[cur_id][0],
-            thresh2: threshold[cur_id][1]
+            thresh1: threshold[id][0],
+            thresh2: threshold[id][1]
           });
         }
         visibleWidgets.pushObject(widgetClass);
       }
-      for (var j = 0; j <= hidden.length -1; j++){
-        var cur_id = hidden[j][0];
-        var cur_title = hidden[j][1];
-        hiddenWidgets.pushObject(Em.Object.create({displayName:cur_title , id: cur_id, checked:
false}));
+      for (var j = 0; j <= hidden.length -1; j++) {
+        var id = hidden[j][0];
+        var title = hidden[j][1];
+        hiddenWidgets.pushObject(Em.Object.create({displayName:title , id: id, checked: false}));
       }
+      this.set('visibleWidgets', visibleWidgets);
+      this.set('hiddenWidgets', hiddenWidgets);
     }
-
   },
 
   setOnLoadVisibleWidgets: function () {

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/26359251/ambari-web/app/views/main/dashboard/widget.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widget.js b/ambari-web/app/views/main/dashboard/widget.js
index 4985598..c69e528 100644
--- a/ambari-web/app/views/main/dashboard/widget.js
+++ b/ambari-web/app/views/main/dashboard/widget.js
@@ -58,12 +58,12 @@ App.DashboardWidgetView = Em.View.extend({
 
   deleteWidget: function (event) {
     var parent = this.get('parentView');
-    //update view on dashboard
-    var obj_class = parent.widgetsMapper(this.id);
-    parent.get('visibleWidgets').removeObject(obj_class);
-    parent.get('hiddenWidgets').pushObject(Em.Object.create({displayName: this.title, id:
this.id, checked: false}));
-
-    if (!App.testMode) {
+    if (App.testMode) {
+      //update view on dashboard
+      var objClass = parent.widgetsMapper(this.id);
+      parent.get('visibleWidgets').removeObject(objClass);
+      parent.get('hiddenWidgets').pushObject(Em.Object.create({displayName: this.title, id:
this.id, checked: false}));
+    } else {
       //reconstruct new persist value then post in persist
       parent.getUserPref(parent.get('persistKey'));
       var oldValue = parent.get('currentPrefObject');
@@ -74,15 +74,15 @@ App.DashboardWidgetView = Em.View.extend({
         hidden: oldValue.hidden,
         threshold: oldValue.threshold
       });
-      for(var i = 0; i <= oldValue.visible.length -1; i++){
-        if(oldValue.visible[i] != deletedId){
+      for (var i = 0; i <= oldValue.visible.length - 1; i++) {
+        if (oldValue.visible[i] != deletedId) {
           newValue.visible.push(oldValue.visible[i]);
         }
       }
       newValue.hidden.push([deletedId, this.title]);
       parent.postUserPref(parent.get('persistKey'), newValue);
+      parent.translateToReal(newValue);
     }
-
   },
 
   editWidget: function (event) {
@@ -101,7 +101,7 @@ App.DashboardWidgetView = Em.View.extend({
       observeNewThresholdValue: function () {
         var thresh1 = this.get('thresh1');
         var thresh2 = this.get('thresh2');
-        if(thresh1.trim() != ""){
+        if (thresh1.trim() != "") {
           if (isNaN(thresh1) || thresh1 > max_tmp || thresh1 < 0) {
             this.set('isThresh1Error', true);
             this.set('errorMessage1', 'Invalid! Enter a number between 0 - ' + max_tmp);
@@ -230,7 +230,7 @@ App.DashboardWidgetView = Em.View.extend({
         rv = parseFloat( RegExp.$1 ); // IE version 1-10
     }
     var isFirefox = typeof InstallTrigger !== 'undefined';   // Firefox 1.0+
-    if(isFirefox) {
+    if (isFirefox) {
       return -2;
     }else{
       return rv;


Mime
View raw message