|
@@ -3,7 +3,9 @@ import _ from 'lodash';
|
|
|
|
|
|
|
|
import config from 'app/core/config';
|
|
import config from 'app/core/config';
|
|
|
import coreModule from 'app/core/core_module';
|
|
import coreModule from 'app/core/core_module';
|
|
|
-import { importPluginModule } from './plugin_loader';
|
|
|
|
|
|
|
+
|
|
|
|
|
+import { AngularPanelPlugin, DataSourceApi } from '@grafana/ui/src/types';
|
|
|
|
|
+import { importPanelPlugin, importDataSourcePlugin, importAppPlugin } from './plugin_loader';
|
|
|
|
|
|
|
|
/** @ngInject */
|
|
/** @ngInject */
|
|
|
function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $templateCache, $timeout) {
|
|
function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $templateCache, $timeout) {
|
|
@@ -67,14 +69,9 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const panelInfo = config.panels[scope.panel.type];
|
|
const panelInfo = config.panels[scope.panel.type];
|
|
|
- let panelCtrlPromise = Promise.resolve(null);
|
|
|
|
|
- if (panelInfo) {
|
|
|
|
|
- panelCtrlPromise = importPluginModule(panelInfo.module).then(panelModule => {
|
|
|
|
|
- return panelModule.PanelCtrl;
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return panelCtrlPromise.then((PanelCtrl: any) => {
|
|
|
|
|
|
|
+ return importPanelPlugin(panelInfo.module).then(panelPlugin => {
|
|
|
|
|
+ const angularPanelPlugin = panelPlugin as AngularPanelPlugin;
|
|
|
|
|
+ const PanelCtrl = angularPanelPlugin.components.PanelCtrl;
|
|
|
componentInfo.Component = PanelCtrl;
|
|
componentInfo.Component = PanelCtrl;
|
|
|
|
|
|
|
|
if (!PanelCtrl || PanelCtrl.registered) {
|
|
if (!PanelCtrl || PanelCtrl.registered) {
|
|
@@ -101,11 +98,12 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function getModule(scope, attrs) {
|
|
|
|
|
|
|
+ function getModule(scope: any, attrs: any) {
|
|
|
switch (attrs.type) {
|
|
switch (attrs.type) {
|
|
|
// QueryCtrl
|
|
// QueryCtrl
|
|
|
case 'query-ctrl': {
|
|
case 'query-ctrl': {
|
|
|
- const ds = scope.ctrl.datasource;
|
|
|
|
|
|
|
+ const ds: DataSourceApi = scope.ctrl.datasource as DataSourceApi;
|
|
|
|
|
+
|
|
|
return $q.when({
|
|
return $q.when({
|
|
|
baseUrl: ds.meta.baseUrl,
|
|
baseUrl: ds.meta.baseUrl,
|
|
|
name: 'query-ctrl-' + ds.meta.id,
|
|
name: 'query-ctrl-' + ds.meta.id,
|
|
@@ -115,12 +113,12 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
|
|
|
'panel-ctrl': 'ctrl',
|
|
'panel-ctrl': 'ctrl',
|
|
|
datasource: 'ctrl.datasource',
|
|
datasource: 'ctrl.datasource',
|
|
|
},
|
|
},
|
|
|
- Component: ds.pluginExports.QueryCtrl,
|
|
|
|
|
|
|
+ Component: ds.components.QueryCtrl,
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
// Annotations
|
|
// Annotations
|
|
|
case 'annotations-query-ctrl': {
|
|
case 'annotations-query-ctrl': {
|
|
|
- return importPluginModule(scope.ctrl.currentDatasource.meta.module).then(dsModule => {
|
|
|
|
|
|
|
+ return importDataSourcePlugin(scope.ctrl.currentDatasource.meta.module).then(dsPlugin => {
|
|
|
return {
|
|
return {
|
|
|
baseUrl: scope.ctrl.currentDatasource.meta.baseUrl,
|
|
baseUrl: scope.ctrl.currentDatasource.meta.baseUrl,
|
|
|
name: 'annotations-query-ctrl-' + scope.ctrl.currentDatasource.meta.id,
|
|
name: 'annotations-query-ctrl-' + scope.ctrl.currentDatasource.meta.id,
|
|
@@ -129,60 +127,54 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
|
|
|
annotation: 'ctrl.currentAnnotation',
|
|
annotation: 'ctrl.currentAnnotation',
|
|
|
datasource: 'ctrl.currentDatasource',
|
|
datasource: 'ctrl.currentDatasource',
|
|
|
},
|
|
},
|
|
|
- Component: dsModule.AnnotationsQueryCtrl,
|
|
|
|
|
|
|
+ Component: dsPlugin.components.AnnotationsQueryCtrl,
|
|
|
};
|
|
};
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
// Datasource ConfigCtrl
|
|
// Datasource ConfigCtrl
|
|
|
case 'datasource-config-ctrl': {
|
|
case 'datasource-config-ctrl': {
|
|
|
const dsMeta = scope.ctrl.datasourceMeta;
|
|
const dsMeta = scope.ctrl.datasourceMeta;
|
|
|
- return importPluginModule(dsMeta.module).then(
|
|
|
|
|
- (dsModule): any => {
|
|
|
|
|
- if (!dsModule.ConfigCtrl) {
|
|
|
|
|
- return { notFound: true };
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- scope.$watch(
|
|
|
|
|
- 'ctrl.current',
|
|
|
|
|
- () => {
|
|
|
|
|
- scope.onModelChanged(scope.ctrl.current);
|
|
|
|
|
- },
|
|
|
|
|
- true
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ return importDataSourcePlugin(dsMeta.module).then(dsPlugin => {
|
|
|
|
|
+ scope.$watch(
|
|
|
|
|
+ 'ctrl.current',
|
|
|
|
|
+ () => {
|
|
|
|
|
+ scope.onModelChanged(scope.ctrl.current);
|
|
|
|
|
+ },
|
|
|
|
|
+ true
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
- return {
|
|
|
|
|
- baseUrl: dsMeta.baseUrl,
|
|
|
|
|
- name: 'ds-config-' + dsMeta.id,
|
|
|
|
|
- bindings: { meta: '=', current: '=' },
|
|
|
|
|
- attrs: { meta: 'ctrl.datasourceMeta', current: 'ctrl.current' },
|
|
|
|
|
- Component: dsModule.ConfigCtrl,
|
|
|
|
|
- };
|
|
|
|
|
- }
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ return {
|
|
|
|
|
+ baseUrl: dsMeta.baseUrl,
|
|
|
|
|
+ name: 'ds-config-' + dsMeta.id,
|
|
|
|
|
+ bindings: { meta: '=', current: '=' },
|
|
|
|
|
+ attrs: { meta: 'ctrl.datasourceMeta', current: 'ctrl.current' },
|
|
|
|
|
+ Component: dsPlugin.components.ConfigCtrl,
|
|
|
|
|
+ };
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
// AppConfigCtrl
|
|
// AppConfigCtrl
|
|
|
case 'app-config-ctrl': {
|
|
case 'app-config-ctrl': {
|
|
|
const model = scope.ctrl.model;
|
|
const model = scope.ctrl.model;
|
|
|
- return importPluginModule(model.module).then(appModule => {
|
|
|
|
|
|
|
+ return importAppPlugin(model.module).then(appPlugin => {
|
|
|
return {
|
|
return {
|
|
|
baseUrl: model.baseUrl,
|
|
baseUrl: model.baseUrl,
|
|
|
name: 'app-config-' + model.id,
|
|
name: 'app-config-' + model.id,
|
|
|
bindings: { appModel: '=', appEditCtrl: '=' },
|
|
bindings: { appModel: '=', appEditCtrl: '=' },
|
|
|
attrs: { 'app-model': 'ctrl.model', 'app-edit-ctrl': 'ctrl' },
|
|
attrs: { 'app-model': 'ctrl.model', 'app-edit-ctrl': 'ctrl' },
|
|
|
- Component: appModule.ConfigCtrl,
|
|
|
|
|
|
|
+ Component: appPlugin.components.ConfigCtrl,
|
|
|
};
|
|
};
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
// App Page
|
|
// App Page
|
|
|
case 'app-page': {
|
|
case 'app-page': {
|
|
|
const appModel = scope.ctrl.appModel;
|
|
const appModel = scope.ctrl.appModel;
|
|
|
- return importPluginModule(appModel.module).then(appModule => {
|
|
|
|
|
|
|
+ return importAppPlugin(appModel.module).then(appPlugin => {
|
|
|
return {
|
|
return {
|
|
|
baseUrl: appModel.baseUrl,
|
|
baseUrl: appModel.baseUrl,
|
|
|
name: 'app-page-' + appModel.id + '-' + scope.ctrl.page.slug,
|
|
name: 'app-page-' + appModel.id + '-' + scope.ctrl.page.slug,
|
|
|
bindings: { appModel: '=' },
|
|
bindings: { appModel: '=' },
|
|
|
attrs: { 'app-model': 'ctrl.appModel' },
|
|
attrs: { 'app-model': 'ctrl.appModel' },
|
|
|
- Component: appModule[scope.ctrl.page.component],
|
|
|
|
|
|
|
+ Component: appPlugin.pages[scope.ctrl.page.component],
|
|
|
};
|
|
};
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|