This is an automated email from the ASF dual-hosted git repository.

ababiichuk pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 3fbc357  AMBARI-24082 Reordering of dashboard widgets doesn't work 
after enabling NN federation. (ababiichuk)
3fbc357 is described below

commit 3fbc357f3a972e2e987c56af17e1aac64d91c828
Author: ababiichuk <ababiic...@hortonworks.com>
AuthorDate: Tue Jun 12 18:13:52 2018 +0300

    AMBARI-24082 Reordering of dashboard widgets doesn't work after enabling NN 
federation. (ababiichuk)
---
 ambari-web/app/views/main/dashboard/widgets.js | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/ambari-web/app/views/main/dashboard/widgets.js 
b/ambari-web/app/views/main/dashboard/widgets.js
index 3fcee73..bcc219f 100644
--- a/ambari-web/app/views/main/dashboard/widgets.js
+++ b/ambari-web/app/views/main/dashboard/widgets.js
@@ -255,6 +255,25 @@ App.MainDashboardWidgetsView = Em.View.extend(App.Persist, 
App.LocalStorage, App
         });
       });
     }
+    this.get('widgetGroups').forEach(group => {
+      const groupName = group.get('name');
+      group.get('allWidgets').forEach(widgetsSubGroup => {
+        const subGroupName = widgetsSubGroup.get('subGroupName'),
+          widgets = widgetsSubGroup.get('widgets'),
+          arrayFromSettings = 
newSettings.groups[groupName][subGroupName].visible,
+          isSubGroupForAll = subGroupName === '*',
+          orderedArray = isSubGroupForAll
+            ? arrayFromSettings.map(widget => 
`${widget.id}-${groupName}-${widget.subGroup}-*`)
+            : arrayFromSettings;
+        widgetsSubGroup.set('widgets', widgets.sort((widgetA, widgetB) => {
+          const idA = isSubGroupForAll ? widgetA.get('id') : 
parseInt(widgetA.get('id')),
+            idB = isSubGroupForAll ? widgetB.get('id') : 
parseInt(widgetB.get('id')),
+            indexA = orderedArray.indexOf(idA),
+            indexB = orderedArray.indexOf(idB);
+          return indexA > -1 && indexB > -1 ? indexA - indexB : 0;
+        }));
+      });
+    });
     this.set('userPreferences', newSettings);
     this.setDBProperty(this.get('persistKey'), newSettings);
     this.postUserPref(this.get('persistKey'), newSettings);
@@ -336,8 +355,9 @@ App.MainDashboardWidgetsView = Em.View.extend(App.Persist, 
App.LocalStorage, App
           if (!existingEntry) {
             preferences.groups[widgetGroupName] = currentEntry;
           }
+        } else {
+          preferences[state].push(id);
         }
-        preferences[state].push(id);
       }
       preferences.threshold[id] = widget.threshold;
     });

-- 
To stop receiving notification emails like this one, please contact
ababiic...@apache.org.

Reply via email to