Parcourir la source

feat(example): add basic annotation support for ds

bergquist il y a 9 ans
Parent
commit
1d8222ef6a

+ 1 - 1
examples/datasource-plugin-genericdatasource/plugin.json

@@ -8,7 +8,7 @@
   "staticRoot": ".",
 
   "metrics": true,
-  "annotations": false,
+  "annotations": true,
 
   "info": {
     "description": "generic datsource plugin",

+ 9 - 0
examples/datasource-plugin-genericdatasource/src/datasource.js

@@ -37,6 +37,15 @@ export class GenericDatasource {
     });
   }
 
+  annotationQuery(options) {
+    return this.backendSrv.datasourceRequest({
+      url: this.url + '/annotations',
+      method: 'GET'
+    }).then(result => {
+      return result.data;
+    });
+  }
+
   // Optional
   // Required for templating
   metricFindQuery(options) {

+ 5 - 1
examples/datasource-plugin-genericdatasource/src/module.js

@@ -7,9 +7,13 @@ GenericConfigCtrl.templateUrl = 'partials/config.html';
 class GenericQueryOptionsCtrl {}
 GenericQueryOptionsCtrl.templateUrl = 'partials/query.options.html';
 
+class GenericAnnotationsQueryCtrl {}
+GenericAnnotationsQueryCtrl.templateUrl = 'partials/annotations.editor.html'
+
 export {
   GenericDatasource as Datasource,
   GenericDatasourceQueryCtrl as QueryCtrl,
   GenericConfigCtrl as ConfigCtrl,
-  GenericQueryOptionsCtrl as QueryOptionsCtrl
+  GenericQueryOptionsCtrl as QueryOptionsCtrl,
+  GenericAnnotationsQueryCtrl as AnnotationsQueryCtrl
 };

+ 9 - 0
examples/datasource-plugin-genericdatasource/src/partials/annotations.editor.html

@@ -0,0 +1,9 @@
+
+<h5 class="section-heading">Query</h5>
+<div class="gf-form-group">
+  <div class="gf-form">
+    <input type="text" class="gf-form-input" ng-model='ctrl.annotation.query' placeholder=""></input>
+  </div>
+</div>
+
+