Explorar el Código

Merge pull request #1903 from craftytrickster/influx09-annotation-bugfix

Fixed Annotations with InfluxDb9 Datasources
Torkel Ödegaard hace 10 años
padre
commit
593f2e0851

+ 8 - 13
public/app/plugins/datasource/influxdb/influxSeries.js

@@ -5,7 +5,8 @@ function (_) {
   'use strict';
 
   function InfluxSeries(options) {
-    this.seriesList = options.seriesList;
+    this.seriesList = options.seriesList && options.seriesList.results && options.seriesList.results.length > 0
+      ? options.seriesList.results[0].series || [] : [];
     this.alias = options.alias;
     this.annotation = options.annotation;
   }
@@ -17,12 +18,10 @@ function (_) {
     var self = this;
 
     console.log(self.seriesList);
-    if (!self.seriesList || !self.seriesList.results || !self.seriesList.results[0]) {
+    if (self.seriesList.length === 0) {
       return output;
     }
 
-    this.seriesList = self.seriesList.results[0].series;
-
     _.each(self.seriesList, function(series) {
       var datapoints = [];
       for (var i = 0; i < series.values.length; i++) {
@@ -63,19 +62,15 @@ function (_) {
         if (column === self.annotation.textColumn) { textCol = index; return; }
       });
 
-      _.each(series.points, function (point) {
+      _.each(series.values, function (value) {
         var data = {
           annotation: self.annotation,
-          time: point[timeCol],
-          title: point[titleCol],
-          tags: point[tagsCol],
-          text: point[textCol]
+          time: + new Date(value[timeCol]),
+          title: value[titleCol],
+          tags: value[tagsCol],
+          text: value[textCol]
         };
 
-        if (tagsCol) {
-          data.tags = point[tagsCol];
-        }
-
         list.push(data);
       });
     });

+ 2 - 1
public/app/plugins/datasource/influxdb/plugin.json

@@ -13,5 +13,6 @@
     "annotations": "app/plugins/datasource/influxdb/partials/annotations.editor.html"
   },
 
-  "metrics": true
+  "metrics": true,
+  "annotations": true
 }