|
@@ -1,11 +1,15 @@
|
|
|
import config from 'app/core/config';
|
|
import config from 'app/core/config';
|
|
|
import _ from 'lodash';
|
|
import _ from 'lodash';
|
|
|
import $ from 'jquery';
|
|
import $ from 'jquery';
|
|
|
-import { appEvents, profiler } from 'app/core/core';
|
|
|
|
|
-import { PanelModel } from 'app/features/dashboard/panel_model';
|
|
|
|
|
|
|
+import { profiler } from 'app/core/core';
|
|
|
|
|
+import {
|
|
|
|
|
+ duplicatePanel,
|
|
|
|
|
+ copyPanel as copyPanelUtil,
|
|
|
|
|
+ editPanelJson as editPanelJsonUtil,
|
|
|
|
|
+ sharePanel as sharePanelUtil,
|
|
|
|
|
+} from 'app/features/dashboard/utils/panel';
|
|
|
import Remarkable from 'remarkable';
|
|
import Remarkable from 'remarkable';
|
|
|
-import { GRID_CELL_HEIGHT, GRID_CELL_VMARGIN, LS_PANEL_COPY_KEY } from 'app/core/constants';
|
|
|
|
|
-import store from 'app/core/store';
|
|
|
|
|
|
|
+import { GRID_CELL_HEIGHT, GRID_CELL_VMARGIN } from 'app/core/constants';
|
|
|
|
|
|
|
|
const TITLE_HEIGHT = 27;
|
|
const TITLE_HEIGHT = 27;
|
|
|
const PANEL_BORDER = 2;
|
|
const PANEL_BORDER = 2;
|
|
@@ -241,7 +245,7 @@ export class PanelCtrl {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
duplicate() {
|
|
duplicate() {
|
|
|
- this.dashboard.duplicatePanel(this.panel);
|
|
|
|
|
|
|
+ duplicatePanel(this.dashboard, this.panel);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
removePanel() {
|
|
removePanel() {
|
|
@@ -251,48 +255,15 @@ export class PanelCtrl {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
editPanelJson() {
|
|
editPanelJson() {
|
|
|
- const editScope = this.$scope.$root.$new();
|
|
|
|
|
- editScope.object = this.panel.getSaveModel();
|
|
|
|
|
- editScope.updateHandler = this.replacePanel.bind(this);
|
|
|
|
|
- editScope.enableCopy = true;
|
|
|
|
|
-
|
|
|
|
|
- this.publishAppEvent('show-modal', {
|
|
|
|
|
- src: 'public/app/partials/edit_json.html',
|
|
|
|
|
- scope: editScope,
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ editPanelJsonUtil(this.dashboard, this.panel);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
copyPanel() {
|
|
copyPanel() {
|
|
|
- store.set(LS_PANEL_COPY_KEY, JSON.stringify(this.panel.getSaveModel()));
|
|
|
|
|
- appEvents.emit('alert-success', ['Panel copied. Open Add Panel to paste']);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- replacePanel(newPanel, oldPanel) {
|
|
|
|
|
- const dashboard = this.dashboard;
|
|
|
|
|
- const index = _.findIndex(dashboard.panels, panel => {
|
|
|
|
|
- return panel.id === oldPanel.id;
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- const deletedPanel = dashboard.panels.splice(index, 1);
|
|
|
|
|
- this.dashboard.events.emit('panel-removed', deletedPanel);
|
|
|
|
|
-
|
|
|
|
|
- newPanel = new PanelModel(newPanel);
|
|
|
|
|
- newPanel.id = oldPanel.id;
|
|
|
|
|
-
|
|
|
|
|
- dashboard.panels.splice(index, 0, newPanel);
|
|
|
|
|
- dashboard.sortPanelsByGridPos();
|
|
|
|
|
- dashboard.events.emit('panel-added', newPanel);
|
|
|
|
|
|
|
+ copyPanelUtil(this.panel);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
sharePanel() {
|
|
sharePanel() {
|
|
|
- const shareScope = this.$scope.$new();
|
|
|
|
|
- shareScope.panel = this.panel;
|
|
|
|
|
- shareScope.dashboard = this.dashboard;
|
|
|
|
|
-
|
|
|
|
|
- this.publishAppEvent('show-modal', {
|
|
|
|
|
- src: 'public/app/features/dashboard/partials/shareModal.html',
|
|
|
|
|
- scope: shareScope,
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ sharePanelUtil(this.dashboard, this.panel);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
getInfoMode() {
|
|
getInfoMode() {
|