mirror of
https://github.com/grafana/grafana.git
synced 2024-11-30 12:44:10 -06:00
c4ce7a40af
* AngularPanels: Move to app/angular folder * Fixing issues
43 lines
1.0 KiB
TypeScript
43 lines
1.0 KiB
TypeScript
import angular from 'angular';
|
|
|
|
const directiveModule = angular.module('grafana.directives');
|
|
const directiveCache: any = {};
|
|
|
|
/** @ngInject */
|
|
function panelEditorTab(dynamicDirectiveSrv: any) {
|
|
return dynamicDirectiveSrv.create({
|
|
scope: {
|
|
ctrl: '=',
|
|
editorTab: '=',
|
|
},
|
|
directive: (scope: any) => {
|
|
const pluginId = scope.ctrl.pluginId;
|
|
const tabName = scope.editorTab.title
|
|
.toLowerCase()
|
|
.replace(' ', '-')
|
|
.replace('&', '')
|
|
.replace(' ', '')
|
|
.replace(' ', '-');
|
|
|
|
if (directiveCache[pluginId]) {
|
|
if (directiveCache[pluginId][tabName]) {
|
|
return directiveCache[pluginId][tabName];
|
|
}
|
|
} else {
|
|
directiveCache[pluginId] = [];
|
|
}
|
|
|
|
const result = {
|
|
fn: () => scope.editorTab.directiveFn(),
|
|
name: `panel-editor-tab-${pluginId}${tabName}`,
|
|
};
|
|
|
|
directiveCache[pluginId][tabName] = result;
|
|
|
|
return result;
|
|
},
|
|
});
|
|
}
|
|
|
|
directiveModule.directive('panelEditorTab', panelEditorTab);
|