Commit 23666c0f by Torkel Ödegaard

grid: remove panel works

parent 83568716
......@@ -60,6 +60,10 @@ export class GridCtrl {
bindItem(element) {
this.gridstack.makeWidget(element);
}
removeItem(element) {
this.gridstack.removeWidget(element, false);
}
}
/** @ngInject **/
......@@ -115,6 +119,13 @@ export function dashGridItem($timeout, $rootScope) {
element.addClass('panel-fullscreen');
}, scope);
scope.$on('$destroy', () => {
gridCtrl.removeItem(element);
});
// scope.onItemRemoved({item: item});
// ctrl.removeItem(element);
//var item = element.data('_gridstack_node');
//console.log('link item', item);
......
......@@ -302,6 +302,34 @@ export class DashboardModel {
});
}
removePanel(panel, ask?) {
// confirm deletion
if (ask !== false) {
var text2, confirmText;
if (panel.alert) {
text2 = "Panel includes an alert rule, removing panel will also remove alert rule";
confirmText = "YES";
}
appEvents.emit('confirm-modal', {
title: 'Remove Panel',
text: 'Are you sure you want to remove this panel?',
text2: text2,
icon: 'fa-trash',
confirmText: confirmText,
yesText: 'Remove',
onConfirm: () => {
this.removePanel(panel, false);
}
});
return;
}
var index = _.indexOf(this.panels, panel);
this.panels.splice(index, 1);
this.events.emit('panel-removed', panel);
}
isTimezoneUtc() {
return this.getTimezone() === 'utc';
}
......
......@@ -217,7 +217,7 @@ export class PanelCtrl {
}
removePanel() {
this.row.removePanel(this.panel);
this.dashboard.removePanel(this.panel);
}
editPanelJson() {
......
......@@ -92,12 +92,6 @@ function panelHeader($compile) {
elem.click(function(evt) {
const targetClass = evt.target.className;
console.log(elem.closest('.ui-draggable-dragging'));
// ignore click if we are dragging
if (elem.closest('.ui-draggable-dragging').length > 0) {
return;
}
// remove existing scope
if (menuScope) {
menuScope.$destroy();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment