Commit dac02d3d by Torkel Ödegaard

React edit mode for angular panels progress

parent ad3e6837
...@@ -4,6 +4,7 @@ import { getAngularLoader, AngularComponent } from 'app/core/services/AngularLoa ...@@ -4,6 +4,7 @@ import { getAngularLoader, AngularComponent } from 'app/core/services/AngularLoa
import { EditorTabBody } from './EditorTabBody'; import { EditorTabBody } from './EditorTabBody';
import { PanelModel } from '../panel_model'; import { PanelModel } from '../panel_model';
import './../../panel/GeneralTabCtrl';
interface Props { interface Props {
panel: PanelModel; panel: PanelModel;
......
...@@ -6,6 +6,7 @@ import { DataSourcePicker } from './DataSourcePicker'; ...@@ -6,6 +6,7 @@ import { DataSourcePicker } from './DataSourcePicker';
import { PanelModel } from '../panel_model'; import { PanelModel } from '../panel_model';
import { DashboardModel } from '../dashboard_model'; import { DashboardModel } from '../dashboard_model';
import './../../panel/metrics_tab';
interface Props { interface Props {
panel: PanelModel; panel: PanelModel;
......
...@@ -45,15 +45,41 @@ export class VisualizationTab extends PureComponent<Props> { ...@@ -45,15 +45,41 @@ export class VisualizationTab extends PureComponent<Props> {
} }
componentDidMount() { componentDidMount() {
this.loadAngularOptions();
}
componentDidUpdate() {
// in some cases we need to do this after mount because angularPanel was not available on mount
this.loadAngularOptions();
}
loadAngularOptions() {
const { angularPanel } = this.props; const { angularPanel } = this.props;
if (!angularPanel || !this.element || this.angularOptions) {
return;
}
if (angularPanel) { if (angularPanel) {
const scope = angularPanel.getScope(); const scope = angularPanel.getScope();
// When full page reloading in edit mode the angular panel has on fully compiled & instantiated yet
if (!scope.$$childHead) {
setTimeout(() => {
this.forceUpdate();
});
return;
}
const panelCtrl = scope.$$childHead.ctrl; const panelCtrl = scope.$$childHead.ctrl;
let template = '';
for (let i = 0; i < panelCtrl.editorTabs.length; i++) {
template += '<panel-editor-tab editor-tab="ctrl.editorTabs[' + i + ']" ctrl="ctrl"></panel-editor-tab>';
}
const loader = getAngularLoader(); const loader = getAngularLoader();
const template = '<panel-editor-tab editor-tab="tab" ctrl="ctrl"></panel-editor-tab>'; const scopeProps = { ctrl: panelCtrl };
const scopeProps = { ctrl: panelCtrl, tab: panelCtrl.editorTabs[2] };
this.angularOptions = loader.load(this.element, scopeProps, template); this.angularOptions = loader.load(this.element, scopeProps, template);
} }
......
...@@ -5,7 +5,6 @@ import config from 'app/core/config'; ...@@ -5,7 +5,6 @@ import config from 'app/core/config';
import { PanelCtrl } from 'app/features/panel/panel_ctrl'; import { PanelCtrl } from 'app/features/panel/panel_ctrl';
import { getExploreUrl } from 'app/core/utils/explore'; import { getExploreUrl } from 'app/core/utils/explore';
import { metricsTabDirective } from './metrics_tab';
import { applyPanelTimeOverrides, getResolution } from 'app/features/dashboard/utils/panel'; import { applyPanelTimeOverrides, getResolution } from 'app/features/dashboard/utils/panel';
class MetricsPanelCtrl extends PanelCtrl { class MetricsPanelCtrl extends PanelCtrl {
...@@ -42,7 +41,6 @@ class MetricsPanelCtrl extends PanelCtrl { ...@@ -42,7 +41,6 @@ class MetricsPanelCtrl extends PanelCtrl {
this.panel.datasource = this.panel.datasource || null; this.panel.datasource = this.panel.datasource || null;
this.events.on('refresh', this.onMetricsPanelRefresh.bind(this)); this.events.on('refresh', this.onMetricsPanelRefresh.bind(this));
this.events.on('init-edit-mode', this.onInitMetricsPanelEditMode.bind(this));
this.events.on('panel-teardown', this.onPanelTearDown.bind(this)); this.events.on('panel-teardown', this.onPanelTearDown.bind(this));
} }
...@@ -53,11 +51,6 @@ class MetricsPanelCtrl extends PanelCtrl { ...@@ -53,11 +51,6 @@ class MetricsPanelCtrl extends PanelCtrl {
} }
} }
private onInitMetricsPanelEditMode() {
this.addEditorTab('Metrics', metricsTabDirective, 1, 'fa fa-database');
this.addEditorTab('Time range', 'public/app/features/panel/partials/panelTime.html');
}
private onMetricsPanelRefresh() { private onMetricsPanelRefresh() {
// ignore fetching data if another panel is in fullscreen // ignore fetching data if another panel is in fullscreen
if (this.otherPanelInFullscreenMode()) { if (this.otherPanelInFullscreenMode()) {
......
...@@ -12,8 +12,6 @@ import { ...@@ -12,8 +12,6 @@ import {
sharePanel as sharePanelUtil, sharePanel as sharePanelUtil,
} from 'app/features/dashboard/utils/panel'; } from 'app/features/dashboard/utils/panel';
import { generalTab } from './GeneralTabCtrl';
import { GRID_CELL_HEIGHT, GRID_CELL_VMARGIN, PANEL_HEADER_HEIGHT, PANEL_BORDER } from 'app/core/constants'; import { GRID_CELL_HEIGHT, GRID_CELL_VMARGIN, PANEL_HEADER_HEIGHT, PANEL_BORDER } from 'app/core/constants';
export class PanelCtrl { export class PanelCtrl {
...@@ -93,7 +91,6 @@ export class PanelCtrl { ...@@ -93,7 +91,6 @@ export class PanelCtrl {
initEditMode() { initEditMode() {
this.editorTabs = []; this.editorTabs = [];
this.addEditorTab('General', generalTab);
this.editModeInitiated = true; this.editModeInitiated = true;
this.events.emit('init-edit-mode', null); this.events.emit('init-edit-mode', null);
......
...@@ -4,8 +4,8 @@ import './thresholds_form'; ...@@ -4,8 +4,8 @@ import './thresholds_form';
import template from './template'; import template from './template';
import _ from 'lodash'; import _ from 'lodash';
import config from 'app/core/config';
import { MetricsPanelCtrl, alertTab } from 'app/plugins/sdk'; import { MetricsPanelCtrl } from 'app/plugins/sdk';
import { DataProcessor } from './data_processor'; import { DataProcessor } from './data_processor';
import { axesEditorComponent } from './axes_editor'; import { axesEditorComponent } from './axes_editor';
...@@ -70,11 +70,11 @@ class GraphCtrl extends MetricsPanelCtrl { ...@@ -70,11 +70,11 @@ class GraphCtrl extends MetricsPanelCtrl {
// length of a dash // length of a dash
dashLength: 10, dashLength: 10,
// length of space between two dashes // length of space between two dashes
spaceLength: 10, paceLength: 10,
// show hide points // show hide points
points: false, points: false,
// point radius in pixels // point radius in pixels
pointradius: 5, pointradius: 2,
// show hide bars // show hide bars
bars: false, bars: false,
// enable/disable stacking // enable/disable stacking
...@@ -137,9 +137,9 @@ class GraphCtrl extends MetricsPanelCtrl { ...@@ -137,9 +137,9 @@ class GraphCtrl extends MetricsPanelCtrl {
this.addEditorTab('Axes', axesEditorComponent, 2); this.addEditorTab('Axes', axesEditorComponent, 2);
this.addEditorTab('Legend', 'public/app/plugins/panel/graph/tab_legend.html', 3); this.addEditorTab('Legend', 'public/app/plugins/panel/graph/tab_legend.html', 3);
if (config.alertingEnabled) { // if (config.alertingEnabled) {
this.addEditorTab('Alert', alertTab, 5); // this.addEditorTab('Alert', alertTab, 5);
} // }
this.subTabIndex = 0; this.subTabIndex = 0;
} }
......
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