mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(plugins): completed upgrade of all built in panels
This commit is contained in:
parent
1d9ad9be33
commit
b5726a8d5a
@ -11,6 +11,10 @@ function metricsQueryEditor(dynamicDirectiveSrv, datasourceSrv) {
|
|||||||
return datasourceSrv.get(datasource).then(ds => {
|
return datasourceSrv.get(datasource).then(ds => {
|
||||||
scope.datasource = ds;
|
scope.datasource = ds;
|
||||||
|
|
||||||
|
if (!scope.target.refId) {
|
||||||
|
scope.target.refId = 'A';
|
||||||
|
}
|
||||||
|
|
||||||
return System.import(ds.meta.module).then(dsModule => {
|
return System.import(ds.meta.module).then(dsModule => {
|
||||||
return {
|
return {
|
||||||
name: 'metrics-query-editor-' + ds.meta.id,
|
name: 'metrics-query-editor-' + ds.meta.id,
|
||||||
|
@ -10,8 +10,6 @@
|
|||||||
<div ng-if="submenuEnabled" ng-include="'app/partials/submenu.html'">
|
<div ng-if="submenuEnabled" ng-include="'app/partials/submenu.html'">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<asd-test></asd-test>
|
|
||||||
|
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
|
|
||||||
<div class="main-view-container">
|
<div class="main-view-container">
|
||||||
|
@ -11,7 +11,6 @@ function (angular, app, _, kbn, TimeSeries, PanelMeta) {
|
|||||||
|
|
||||||
/** @ngInject */
|
/** @ngInject */
|
||||||
function SingleStatCtrl($scope, panelSrv, panelHelper) {
|
function SingleStatCtrl($scope, panelSrv, panelHelper) {
|
||||||
console.log('controller');
|
|
||||||
|
|
||||||
$scope.panelMeta = new PanelMeta({
|
$scope.panelMeta = new PanelMeta({
|
||||||
panelName: 'Singlestat',
|
panelName: 'Singlestat',
|
||||||
|
@ -20,7 +20,7 @@ export class TablePanelCtrl {
|
|||||||
metricsEditor: true,
|
metricsEditor: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.panelMeta.addEditorTab('Options', 'app/plugins/panels/table/options.html');
|
$scope.panelMeta.addEditorTab('Options', 'app/plugins/panel/table/options.html');
|
||||||
$scope.panelMeta.addEditorTab('Time range', 'app/features/panel/partials/panelTime.html');
|
$scope.panelMeta.addEditorTab('Time range', 'app/features/panel/partials/panelTime.html');
|
||||||
|
|
||||||
var panelDefaults = {
|
var panelDefaults = {
|
||||||
|
@ -118,7 +118,7 @@ export function tablePanelEditor($q, uiSegmentSrv) {
|
|||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
scope: true,
|
scope: true,
|
||||||
templateUrl: 'app/plugins/panels/table/editor.html',
|
templateUrl: 'app/plugins/panel/table/editor.html',
|
||||||
controller: TablePanelEditorCtrl,
|
controller: TablePanelEditorCtrl,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,9 @@ import {TablePanelCtrl} from './controller';
|
|||||||
import {TableRenderer} from './renderer';
|
import {TableRenderer} from './renderer';
|
||||||
import {tablePanelEditor} from './editor';
|
import {tablePanelEditor} from './editor';
|
||||||
|
|
||||||
export function tablePanel() {
|
angular.module('grafana.directives').directive('grafanaPanelTableEditor', tablePanelEditor);
|
||||||
|
|
||||||
|
function tablePanel() {
|
||||||
'use strict';
|
'use strict';
|
||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
@ -102,5 +104,4 @@ export function tablePanel() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
angular.module('grafana.directives').directive('grafanaPanelTable', tablePanel);
|
export {tablePanel as panel};
|
||||||
angular.module('grafana.directives').directive('grafanaPanelTableEditor', tablePanelEditor);
|
|
||||||
|
@ -10,17 +10,7 @@ function (angular, app, _, require, PanelMeta) {
|
|||||||
|
|
||||||
var converter;
|
var converter;
|
||||||
|
|
||||||
var module = angular.module('grafana.panels.text', []);
|
function TextPanelCtrl($scope, templateSrv, $sce, panelSrv) {
|
||||||
app.useModule(module);
|
|
||||||
|
|
||||||
module.directive('grafanaPanelText', function() {
|
|
||||||
return {
|
|
||||||
controller: 'TextPanelCtrl',
|
|
||||||
templateUrl: 'app/plugins/panel/text/module.html',
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
module.controller('TextPanelCtrl', function($scope, templateSrv, $sce, panelSrv) {
|
|
||||||
|
|
||||||
$scope.panelMeta = new PanelMeta({
|
$scope.panelMeta = new PanelMeta({
|
||||||
panelName: 'Text',
|
panelName: 'Text',
|
||||||
@ -107,5 +97,16 @@ function (angular, app, _, require, PanelMeta) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.init();
|
$scope.init();
|
||||||
});
|
}
|
||||||
|
|
||||||
|
function textPanel() {
|
||||||
|
return {
|
||||||
|
controller: TextPanelCtrl,
|
||||||
|
templateUrl: 'app/plugins/panel/text/module.html',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
panel: textPanel,
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
@ -1,8 +1,52 @@
|
|||||||
# Plugin API
|
# Plugin API
|
||||||
|
|
||||||
## Changelog
|
### 3.0 changes to plugin api changes
|
||||||
|
|
||||||
2.5.1
|
There has been big changes to both data source and plugin schema (plugin.json) and how
|
||||||
|
you write the plugin main module.
|
||||||
|
|
||||||
|
#### Datasource plugin
|
||||||
|
|
||||||
|
Now data source plugins AMD/SystemJS module should return:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
return {
|
||||||
|
Datasource: ElasticDatasource,
|
||||||
|
configView: editView.default,
|
||||||
|
annotationsQueryEditor: annotationsQueryEditor,
|
||||||
|
metricsQueryEditor: metricsQueryEditor,
|
||||||
|
metricsQueryOptions: metricsQueryOptions,
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
Where ElasticDatasource is a constructor function to a javascript. The constructor
|
||||||
|
function can take angular services and `instanceSettings` as parameters.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
function ElasticDatasource(instanceSettings, templateSrv) {
|
||||||
|
this.instanceSettings = this.instanceSettings;
|
||||||
|
///...
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
A datasource module can optionally return a configView directive function, metricsQueryEditor directive function, etc.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
function metricsQueryEditor() {
|
||||||
|
return {controller: 'ElasticQueryCtrl', templateUrl: 'app/plugins/datasource/elasticsearch/partials/query.editor.html'};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Panel plugin
|
||||||
|
|
||||||
|
The panel plugin AMD/SystemJS module should return an object with a property named `panel`. This needs to be
|
||||||
|
a directive function.
|
||||||
|
|
||||||
|
### 2.5.1 changes
|
||||||
datasource annotationQuery changed. now single options parameter with:
|
datasource annotationQuery changed. now single options parameter with:
|
||||||
- range
|
- range
|
||||||
- rangeRaw
|
- rangeRaw
|
||||||
|
Loading…
Reference in New Issue
Block a user