ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xiw...@apache.org
Subject ambari git commit: AMBARI-10583. Integrate widget reordering with the backend API.(xiwang)
Date Mon, 20 Apr 2015 21:08:35 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 6d3570c05 -> 2505191dd


AMBARI-10583. Integrate widget reordering with the backend API.(xiwang)


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

Branch: refs/heads/trunk
Commit: 2505191ddaafc058925e8a4d7374f5ffabdcfc74
Parents: 6d3570c
Author: Xi Wang <xiwang@apache.org>
Authored: Mon Apr 20 13:53:37 2015 -0700
Committer: Xi Wang <xiwang@apache.org>
Committed: Mon Apr 20 13:58:32 2015 -0700

----------------------------------------------------------------------
 .../controllers/main/service/info/summary.js    | 33 ++++++++++++--------
 ambari-web/app/mappers/server_data_mapper.js    |  3 +-
 ambari-web/app/utils/ajax/ajax.js               | 11 -------
 .../app/views/main/service/info/summary.js      |  4 +--
 4 files changed, 23 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2505191d/ambari-web/app/controllers/main/service/info/summary.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/summary.js b/ambari-web/app/controllers/main/service/info/summary.js
index 9acf5ee..a5c5812 100644
--- a/ambari-web/app/controllers/main/service/info/summary.js
+++ b/ambari-web/app/controllers/main/service/info/summary.js
@@ -645,25 +645,32 @@ App.MainServiceInfoSummaryController = Em.Controller.extend({
   },
 
   /**
-   * save layout
+   * save layout after re-order widgets
    * return {$.ajax}
    */
-  saveLayout: function (widgets, layout) {
+  saveReorderedLayout: function (widgets) {
+    var activeLayout = this.get('activeWidgetLayout');
     var data = {
-      "layout_name": layout.get('layoutName'),
-      "section_name": layout.get('sectionName'),
-      "scope": layout.get('scope'),
-      "widgetLayoutInfo": widgets.map(function (widget) {
-        return {
-          "widget_name": widget.get('widgetName'),
-          "id": widget.get('widgetId')
-        }
-      })
+      "WidgetLayoutInfo": {
+        "display_name": activeLayout.get("displayName"),
+        "id": activeLayout.get("id"),
+        "layout_name": activeLayout.get("layoutName"),
+        "scope": activeLayout.get("scope"),
+        "section_name": activeLayout.get("sectionName"),
+        "widgets": widgets.map(function (widget) {
+          return {
+            "id": widget.get('id')
+          }
+        })
+      }
     };
     return App.ajax.send({
-      name: 'widgets.layout.save',
+      name: 'widget.layout.edit',
       sender: this,
-      data: data
+      data: {
+        layoutId: activeLayout.get("id"),
+        data: data
+      }
     });
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/2505191d/ambari-web/app/mappers/server_data_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/server_data_mapper.js b/ambari-web/app/mappers/server_data_mapper.js
index 45ee5c9..239ba0f 100644
--- a/ambari-web/app/mappers/server_data_mapper.js
+++ b/ambari-web/app/mappers/server_data_mapper.js
@@ -97,7 +97,8 @@ App.QuickDataMapper = App.ServerDataMapper.extend({
               result[i].push(this.parseIt(_data[index], config[i]));
             }
           }
-          if(_type == 'array'){
+          // As for 'widgets', just show the original order
+          if(_type == 'array' && i != 'widgets'){
             result[i] = result[i].sort();
           }
         }

http://git-wip-us.apache.org/repos/asf/ambari/blob/2505191d/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index ff3253b..5225711 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -2447,17 +2447,6 @@ var urls = {
     mock: '/data/widget_layouts/HBASE/layouts.json'
   },
 
-  'widgets.layout.save': {
-    real: '/clusters/{clusterName}/widget_layouts/{layout_name}',
-    mock: '',
-    format: function (data) {
-      return {
-        type: 'PUT',
-        data: JSON.stringify(data.data)
-      }
-    }
-  },
-
   'widget.action.delete': {
     real: '/clusters/{clusterName}/widgets/{id}',
     mock: '',

http://git-wip-us.apache.org/repos/asf/ambari/blob/2505191d/ambari-web/app/views/main/service/info/summary.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/info/summary.js b/ambari-web/app/views/main/service/info/summary.js
index 41bfd31..60734f1 100644
--- a/ambari-web/app/views/main/service/info/summary.js
+++ b/ambari-web/app/views/main/service/info/summary.js
@@ -598,9 +598,7 @@ App.MainServiceInfoSummaryView = Em.View.extend(App.UserPref, {
           var widgets = misc.sortByOrder($("#widget_layout .widget").map(function () {
             return this.id;
           }), self.get('controller.widgets'));
-          //TODO bind to actual layout instance
-          var layout = self.get('controller.widgetLayouts').objectAt(0);
-          self.get('controller').saveLayout(widgets, layout);
+          self.get('controller').saveReorderedLayout(widgets);
         },
         activate: function (event, ui) {
           self.set('isMoving', true);


Mime
View raw message