feat(examples): add datasource plugin example
This commit is contained in:
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user