feat(examples): add datasource plugin example

This commit is contained in:
bergquist
2016-03-02 10:43:41 +01:00
parent 5bf2b6c382
commit 3435df8b9c
13 changed files with 365 additions and 0 deletions
@@ -0,0 +1,26 @@
import {QueryCtrl} from 'app/plugins/sdk';
import './css/query-editor.css!'
export class GenericDatasourceQueryCtrl extends QueryCtrl {
constructor($scope, $injector, uiSegmentSrv) {
super($scope, $injector);
this.scope = $scope;
this.uiSegmentSrv = uiSegmentSrv;
this.target.target = this.target.target || 'select metric';
}
getOptions() {
return this.datasource.metricFindQuery(this.target)
.then(this.uiSegmentSrv.transformToSegments(false));
// Options have to be transformed by uiSegmentSrv to be usable by metric-segment-model directive
}
onChangeInternal() {
this.panelCtrl.refresh(); // Asks the panel to refresh data.
}
}
GenericDatasourceQueryCtrl.templateUrl = 'partials/query.editor.html';