grid: remove panel works

pull/9488/head
Torkel Ödegaard 8 years ago
parent 8356871636
commit 23666c0f78
  1. 11
      public/app/features/dashboard/dashgrid/dashgrid.ts
  2. 28
      public/app/features/dashboard/model.ts
  3. 2
      public/app/features/panel/panel_ctrl.ts
  4. 6
      public/app/features/panel/panel_header.ts

@ -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();

Loading…
Cancel
Save