|
@@ -449,7 +449,7 @@ App.MainServiceInfoSummaryController = Em.Controller.extend({
|
|
|
description: widget.Widgets.description,
|
|
|
widgetType: widgetType,
|
|
|
iconPath: "/img/widget-" + widgetType.toLowerCase() + ".png",
|
|
|
- serviceName: widget.Widgets.metrics.mapProperty('service_name').uniq().join('-'),
|
|
|
+ serviceName: JSON.parse(widget.Widgets.metrics).mapProperty('service_name').uniq().join('-'),
|
|
|
added: addedWidgetsNames.contains(widgetName),
|
|
|
isShared: true
|
|
|
});
|
|
@@ -498,7 +498,7 @@ App.MainServiceInfoSummaryController = Em.Controller.extend({
|
|
|
description: widget.Widgets.description,
|
|
|
widgetType: widgetType,
|
|
|
iconPath: "/img/widget-" + widgetType.toLowerCase() + ".png",
|
|
|
- serviceName: widget.Widgets.metrics.mapProperty('service_name').uniq().join('-'),
|
|
|
+ serviceName: JSON.parse(widget.Widgets.metrics).mapProperty('service_name').uniq().join('-'),
|
|
|
added: addedWidgetsNames.contains(widgetName),
|
|
|
isShared: false
|
|
|
});
|
|
@@ -512,22 +512,81 @@ App.MainServiceInfoSummaryController = Em.Controller.extend({
|
|
|
* add widgets, on click handler for "Add"
|
|
|
*/
|
|
|
addWidget: function (event) {
|
|
|
- var widget = event.context;
|
|
|
- var widgetName = widget.widgetName;
|
|
|
- widget.set('added', !widget.added);
|
|
|
- // add current widget to current layout
|
|
|
+ var widgetToAdd = event.context;
|
|
|
+ var activeLayout = this.get('activeWidgetLayout');
|
|
|
+ var widgetIds = activeLayout.get('widgets').map(function(widget) {
|
|
|
+ return {
|
|
|
+ "id": widget.get("id")
|
|
|
+ }
|
|
|
+ });
|
|
|
+ widgetIds.pushObject({
|
|
|
+ "id": widgetToAdd.id
|
|
|
+ })
|
|
|
+ var data = {
|
|
|
+ "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": widgetIds
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
+ widgetToAdd.set('added', !widgetToAdd.added);
|
|
|
+ return App.ajax.send({
|
|
|
+ name: 'widget.layout.edit',
|
|
|
+ sender: this,
|
|
|
+ data: {
|
|
|
+ layoutId: activeLayout.get("id"),
|
|
|
+ data: data
|
|
|
+ },
|
|
|
+ success: 'updateActiveLayout'
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
- * delete widgets, on click handler for "Added"
|
|
|
+ * hide widgets, on click handler for "Added"
|
|
|
*/
|
|
|
hideWidget: function (event) {
|
|
|
- var widget = event.context;
|
|
|
- var widgetName = widget.widgetName;
|
|
|
- widget.set('added', !widget.added);
|
|
|
- // hide current widget from current layout
|
|
|
+ var widgetToHide = event.context;
|
|
|
+ var activeLayout = this.get('activeWidgetLayout');
|
|
|
+ var widgetIds = activeLayout.get('widgets').map(function(widget) {
|
|
|
+ return {
|
|
|
+ "id": widget.get("id")
|
|
|
+ }
|
|
|
+ });
|
|
|
+ var data = {
|
|
|
+ "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": widgetIds.filter(function(widget) {
|
|
|
+ return widget.id != widgetToHide.id;
|
|
|
+ })
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
+ widgetToHide.set('added', !widgetToHide.added);
|
|
|
+ return App.ajax.send({
|
|
|
+ name: 'widget.layout.edit',
|
|
|
+ sender: this,
|
|
|
+ data: {
|
|
|
+ layoutId: activeLayout.get("id"),
|
|
|
+ data: data
|
|
|
+ },
|
|
|
+ success: 'updateActiveLayout'
|
|
|
+ });
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * update current active widget layout
|
|
|
+ */
|
|
|
+ updateActiveLayout: function () {
|
|
|
+ this.loadActiveWidgetLayout();
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -567,6 +626,7 @@ App.MainServiceInfoSummaryController = Em.Controller.extend({
|
|
|
unshareWidget: function (event) {
|
|
|
var widget = event.context;
|
|
|
var widgetName = widget.widgetName;
|
|
|
+ //todo unshare current widget
|
|
|
|
|
|
},
|
|
|
|
|
@@ -576,6 +636,7 @@ App.MainServiceInfoSummaryController = Em.Controller.extend({
|
|
|
shareWidget: function (event) {
|
|
|
var widget = event.context;
|
|
|
var widgetName = widget.widgetName;
|
|
|
+ // todo share current widget
|
|
|
|
|
|
},
|
|
|
|