mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
grid: remove panel works
This commit is contained in:
@@ -60,6 +60,10 @@ export class GridCtrl {
|
|||||||
bindItem(element) {
|
bindItem(element) {
|
||||||
this.gridstack.makeWidget(element);
|
this.gridstack.makeWidget(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeItem(element) {
|
||||||
|
this.gridstack.removeWidget(element, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @ngInject **/
|
/** @ngInject **/
|
||||||
@@ -115,6 +119,13 @@ export function dashGridItem($timeout, $rootScope) {
|
|||||||
element.addClass('panel-fullscreen');
|
element.addClass('panel-fullscreen');
|
||||||
}, scope);
|
}, scope);
|
||||||
|
|
||||||
|
scope.$on('$destroy', () => {
|
||||||
|
gridCtrl.removeItem(element);
|
||||||
|
});
|
||||||
|
|
||||||
|
// scope.onItemRemoved({item: item});
|
||||||
|
// ctrl.removeItem(element);
|
||||||
|
|
||||||
|
|
||||||
//var item = element.data('_gridstack_node');
|
//var item = element.data('_gridstack_node');
|
||||||
//console.log('link item', item);
|
//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() {
|
isTimezoneUtc() {
|
||||||
return this.getTimezone() === 'utc';
|
return this.getTimezone() === 'utc';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ export class PanelCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
removePanel() {
|
removePanel() {
|
||||||
this.row.removePanel(this.panel);
|
this.dashboard.removePanel(this.panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
editPanelJson() {
|
editPanelJson() {
|
||||||
|
|||||||
@@ -92,12 +92,6 @@ function panelHeader($compile) {
|
|||||||
elem.click(function(evt) {
|
elem.click(function(evt) {
|
||||||
const targetClass = evt.target.className;
|
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
|
// remove existing scope
|
||||||
if (menuScope) {
|
if (menuScope) {
|
||||||
menuScope.$destroy();
|
menuScope.$destroy();
|
||||||
|
|||||||
Reference in New Issue
Block a user