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 dd04600 AMBARI-23721 Adding and deleting widgets of NameNode section
on dashboard isn't persisted. (ababiichuk)
dd04600 is described below
commit dd046007be89c1c7ad8ccda9e2621ed4fa6bd070
Author: ababiichuk <[email protected]>
AuthorDate: Fri Apr 27 21:20:09 2018 +0300
AMBARI-23721 Adding and deleting widgets of NameNode section on dashboard
isn't persisted. (ababiichuk)
---
ambari-web/app/views/main/dashboard/widgets.js | 44 +++++++++++++++++++++-
.../test/views/main/dashboard/widget_test.js | 22 +++++++----
2 files changed, 57 insertions(+), 9 deletions(-)
diff --git a/ambari-web/app/views/main/dashboard/widgets.js
b/ambari-web/app/views/main/dashboard/widgets.js
index 64412f3..3fcee73 100644
--- a/ambari-web/app/views/main/dashboard/widgets.js
+++ b/ambari-web/app/views/main/dashboard/widgets.js
@@ -209,11 +209,51 @@ App.MainDashboardWidgetsView =
Em.View.extend(App.Persist, App.LocalStorage, App
}
else {
newSettings.threshold = userPreferences.threshold;
- newSettings.groups = userPreferences.groups;
this.get('allWidgets').forEach(widget => {
- let key = widget.get('isVisible') ? 'visible' : 'hidden';
+ const key = widget.get('isVisible') ? 'visible' : 'hidden';
newSettings[key].push(widget.get('id'));
});
+ this.get('widgetGroups').forEach(group => {
+ const groupName = group.get('name');
+ if (!newSettings.groups[groupName]) {
+ newSettings.groups[groupName] = {};
+ }
+ group.get('allWidgets').forEach(widgetsSubGroup => {
+ const subGroupName = widgetsSubGroup.get('subGroupName'),
+ widgets = widgetsSubGroup.get('widgets'),
+ subGroupSettings = {
+ visible: [],
+ hidden: [],
+ threshold: {}
+ };
+ newSettings.groups[groupName][subGroupName] = subGroupSettings;
+ widgets.forEach(widget => {
+ const key = widget.get('isVisible') ? 'visible' : 'hidden',
+ threshold = widget.get('threshold'),
+ widgetId = widget.get('id'),
+ id = parseInt(widgetId);
+ if (subGroupName === '*') {
+ const regExp = new
RegExp(`\\d+\\-${groupName}\\-([\\W\\w]+)\\-\\*`),
+ regExpMatch = widgetId.match(regExp),
+ subGroup = regExpMatch && regExpMatch[1];
+ if (subGroup) {
+ subGroupSettings[key].push({
+ id,
+ subGroup
+ });
+ $.extend(true, subGroupSettings.threshold, {
+ [subGroup]: {
+ [id]: threshold
+ }
+ });
+ }
+ } else {
+ subGroupSettings[key].push(id);
+ subGroupSettings.threshold[id] = threshold;
+ }
+ });
+ });
+ });
}
this.set('userPreferences', newSettings);
this.setDBProperty(this.get('persistKey'), newSettings);
diff --git a/ambari-web/test/views/main/dashboard/widget_test.js
b/ambari-web/test/views/main/dashboard/widget_test.js
index 8a28d19..f63ec00 100644
--- a/ambari-web/test/views/main/dashboard/widget_test.js
+++ b/ambari-web/test/views/main/dashboard/widget_test.js
@@ -136,14 +136,22 @@ describe('App.DashboardWidgetView', function () {
describe('#deleteWidget()', function() {
beforeEach(function() {
- view.get('parentView').set('allWidgets', [Em.Object.create({id: 1,
isVisible: true})]);
- view.set('widget.id', 1);
- view.set('parentView.userPreferences', {
- visible: [1],
- hidden: [],
- threshold: [],
- groups: {}
+ view.get('parentView').setProperties({
+ allWidgets: [
+ Em.Object.create({
+ id: 1,
+ isVisible: true
+ })
+ ],
+ userPreferences: {
+ visible: [1],
+ hidden: [],
+ threshold: [],
+ groups: {}
+ },
+ widgetGroups: []
});
+ view.set('widget.id', 1);
view.deleteWidget();
});
--
To stop receiving notification emails like this one, please contact
[email protected].