wip: restoring old angular panel tabs / edit mode

This commit is contained in:
Torkel Ödegaard 2018-10-07 10:39:47 -07:00
parent b7ba73819c
commit 2f84101fe7
4 changed files with 9 additions and 24 deletions

View File

@ -7,6 +7,7 @@ import { PanelCtrl } from 'app/features/panel/panel_ctrl';
import * as rangeUtil from 'app/core/utils/rangeutil'; import * as rangeUtil from 'app/core/utils/rangeutil';
import * as dateMath from 'app/core/utils/datemath'; import * as dateMath from 'app/core/utils/datemath';
import { getExploreUrl } from 'app/core/utils/explore'; import { getExploreUrl } from 'app/core/utils/explore';
import { metricsTabDirective } from './metrics_tab';
class MetricsPanelCtrl extends PanelCtrl { class MetricsPanelCtrl extends PanelCtrl {
scope: any; scope: any;
@ -56,7 +57,8 @@ class MetricsPanelCtrl extends PanelCtrl {
} }
private onInitMetricsPanelEditMode() { private onInitMetricsPanelEditMode() {
// this.addCommonTab('Time range', 'public/app/features/panel/partials/panelTime.html'); this.addEditorTab('Queries', metricsTabDirective, 1, 'fa fa-database');
this.addEditorTab('Time range', 'public/app/features/panel/partials/panelTime.html');
} }
private onMetricsPanelRefresh() { private onMetricsPanelRefresh() {

View File

@ -6,8 +6,6 @@ import { PanelModel } from 'app/features/dashboard/panel_model';
import Remarkable from 'remarkable'; import Remarkable from 'remarkable';
import { GRID_CELL_HEIGHT, GRID_CELL_VMARGIN, LS_PANEL_COPY_KEY } from 'app/core/constants'; import { GRID_CELL_HEIGHT, GRID_CELL_VMARGIN, LS_PANEL_COPY_KEY } from 'app/core/constants';
import store from 'app/core/store'; import store from 'app/core/store';
import { metricsTabDirective } from './metrics_tab';
import { vizTabDirective } from './viz_tab';
const TITLE_HEIGHT = 27; const TITLE_HEIGHT = 27;
const PANEL_BORDER = 2; const PANEL_BORDER = 2;
@ -22,7 +20,6 @@ export class PanelCtrl {
pluginName: string; pluginName: string;
pluginId: string; pluginId: string;
editorTabs: any; editorTabs: any;
optionTabs: any;
$scope: any; $scope: any;
$injector: any; $injector: any;
$location: any; $location: any;
@ -97,15 +94,11 @@ export class PanelCtrl {
initEditMode() { initEditMode() {
this.editorTabs = []; this.editorTabs = [];
this.optionTabs = []; this.addEditorTab('General', 'public/app/partials/panelgeneral.html');
this.addCommonTab('Queries', metricsTabDirective, 0, 'fa fa-database');
this.addCommonTab('Visualization', vizTabDirective, 1, 'fa fa-line-chart');
this.editModeInitiated = true; this.editModeInitiated = true;
this.events.emit('init-edit-mode', null); this.events.emit('init-edit-mode', null);
// this.addEditorTab('General', 'public/app/partials/panelgeneral.html');
const urlTab = (this.$injector.get('$routeParams').tab || '').toLowerCase(); const urlTab = (this.$injector.get('$routeParams').tab || '').toLowerCase();
if (urlTab) { if (urlTab) {
this.editorTabs.forEach((tab, i) => { this.editorTabs.forEach((tab, i) => {
@ -123,7 +116,7 @@ export class PanelCtrl {
route.updateParams(); route.updateParams();
} }
addCommonTab(title, directiveFn, index?, icon?) { addEditorTab(title, directiveFn, index?, icon?) {
const editorTab = { title, directiveFn, icon }; const editorTab = { title, directiveFn, icon };
if (_.isString(directiveFn)) { if (_.isString(directiveFn)) {
@ -139,18 +132,6 @@ export class PanelCtrl {
} }
} }
addEditorTab(title, directiveFn, index?, icon?) {
const editorTab = { title, directiveFn, icon };
if (_.isString(directiveFn)) {
editorTab.directiveFn = () => {
return { templateUrl: directiveFn };
};
}
this.optionTabs.push(editorTab);
}
getMenu() { getMenu() {
const menu = []; const menu = [];
menu.push({ menu.push({

View File

@ -32,11 +32,13 @@ const panelTemplate = `
'panel-height-helper': !ctrl.panel.isEditing}"> 'panel-height-helper': !ctrl.panel.isEditing}">
<div class="tabbed-view tabbed-view--new"> <div class="tabbed-view tabbed-view--new">
<div class="tabbed-view-header"> <div class="tabbed-view-header">
<h3 class="tabbed-view-panel-title">
{{ctrl.pluginName}}
</h3>
<ul class="gf-tabs"> <ul class="gf-tabs">
<li class="gf-tabs-item" ng-repeat="tab in ::ctrl.editorTabs"> <li class="gf-tabs-item" ng-repeat="tab in ::ctrl.editorTabs">
<a class="gf-tabs-link" ng-click="ctrl.changeTab($index)" ng-class="{active: ctrl.editorTabIndex === $index}"> <a class="gf-tabs-link" ng-click="ctrl.changeTab($index)" ng-class="{active: ctrl.editorTabIndex === $index}">
<i class="{{::tab.icon}}" ng-show="tab.icon"></i>
{{::tab.title}} {{::tab.title}}
</a> </a>
</li> </li>

View File

@ -139,7 +139,7 @@ class GraphCtrl extends MetricsPanelCtrl {
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.addCommonTab('Alert', alertTab, 5); this.addEditorTab('Alert', alertTab, 5);
} }
this.subTabIndex = 0; this.subTabIndex = 0;