wip: moving option tabs into viz tab

pull/13578/head
Torkel Ödegaard 7 years ago
parent c82bf7f67f
commit 3ceab9484d
  1. 22
      public/app/features/panel/panel_ctrl.ts
  2. 11
      public/app/features/panel/panel_editor_tab.ts
  3. 6
      public/app/features/panel/viz_tab.ts

@ -22,6 +22,7 @@ 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;
@ -96,9 +97,10 @@ export class PanelCtrl {
initEditMode() { initEditMode() {
this.editorTabs = []; this.editorTabs = [];
this.addEditorTab('Queries', metricsTabDirective, 0, 'fa fa-database'); this.optionTabs = [];
this.addEditorTab('Visualization', vizTabDirective, 1, 'fa fa-line-chart'); this.addCommonTab('Queries', metricsTabDirective, 0, 'fa fa-database');
this.addEditorTab('General', 'public/app/partials/panelgeneral.html'); this.addCommonTab('Visualization', vizTabDirective, 1, 'fa fa-line-chart');
this.addCommonTab('General', 'public/app/partials/panelgeneral.html');
this.editModeInitiated = true; this.editModeInitiated = true;
this.events.emit('init-edit-mode', null); this.events.emit('init-edit-mode', null);
@ -120,7 +122,7 @@ export class PanelCtrl {
route.updateParams(); route.updateParams();
} }
addEditorTab(title, directiveFn, index?, icon?) { addCommonTab(title, directiveFn, index?, icon?) {
const editorTab = { title, directiveFn, icon }; const editorTab = { title, directiveFn, icon };
if (_.isString(directiveFn)) { if (_.isString(directiveFn)) {
@ -136,6 +138,18 @@ 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({

@ -13,11 +13,12 @@ function panelEditorTab(dynamicDirectiveSrv) {
}, },
directive: scope => { directive: scope => {
const pluginId = scope.ctrl.pluginId; const pluginId = scope.ctrl.pluginId;
const tabIndex = scope.index; const tabName = scope.editorTab.title.toLowerCase();
console.log('panelEditorTab', pluginId, tabName);
if (directiveCache[pluginId]) { if (directiveCache[pluginId]) {
if (directiveCache[pluginId][tabIndex]) { if (directiveCache[pluginId][tabName]) {
return directiveCache[pluginId][tabIndex]; return directiveCache[pluginId][tabName];
} }
} else { } else {
directiveCache[pluginId] = []; directiveCache[pluginId] = [];
@ -25,10 +26,10 @@ function panelEditorTab(dynamicDirectiveSrv) {
const result = { const result = {
fn: () => scope.editorTab.directiveFn(), fn: () => scope.editorTab.directiveFn(),
name: `panel-editor-tab-${pluginId}${tabIndex}`, name: `panel-editor-tab-${pluginId}${tabName}`,
}; };
directiveCache[pluginId][tabIndex] = result; directiveCache[pluginId][tabName] = result;
return result; return result;
}, },

@ -27,7 +27,10 @@ const template = `
<viz-type-picker currentType="ctrl.panelCtrl.panel.type" onTypeChanged="ctrl.onTypeChanged"></viz-type-picker> <viz-type-picker currentType="ctrl.panelCtrl.panel.type" onTypeChanged="ctrl.onTypeChanged"></viz-type-picker>
</div> </div>
<div class="viz-editor-col2"> <div class="viz-editor-col2">
<h5 class="page-heading">Options</h5> <div ng-repeat="tab in ctrl.panelCtrl.optionTabs" >
<h5 class="page-heading">{{tab.title}}</h5>
<panel-editor-tab editor-tab="tab" ctrl="ctrl.panelCtrl" index="$index"></panel-editor-tab>
</div>
</div> </div>
</div> </div>
`; `;
@ -37,7 +40,6 @@ export function vizTabDirective() {
'use strict'; 'use strict';
return { return {
restrict: 'E', restrict: 'E',
scope: true,
template: template, template: template,
controller: VizTabCtrl, controller: VizTabCtrl,
}; };

Loading…
Cancel
Save