Explorar o código

Made the annotation tags support more cross datasource compatible

Torkel Ödegaard %!s(int64=10) %!d(string=hai) anos
pai
achega
96bd66e811

+ 12 - 3
public/app/directives/annotationTooltip.js

@@ -3,7 +3,7 @@ define([
   'jquery',
   'lodash'
 ],
-function (angular, $) {
+function (angular, $, _) {
   'use strict';
 
   angular
@@ -23,8 +23,17 @@ function (angular, $) {
           tooltip += text.replace(/\n/g, '<br>') + '<br>';
         }
 
-        if (event.tags && event.tags.length > 0) {
-          tooltip += '<span class="label label-tag" ng-repeat="tag in event.tags" tag-color-from-name="tag">{{tag}}</span><br/>';
+        var tags = event.tags;
+        if (_.isString(event.tags)) {
+          tags = event.tags.split(',');
+          if (tags.length === 1) {
+            tags = event.tags.split(' ');
+          }
+        }
+
+        if (tags && tags.length) {
+          scope.tags = tags;
+          tooltip += '<span class="label label-tag" ng-repeat="tag in tags" tag-color-from-name="tag">{{tag}}</span><br/>';
         }
 
         tooltip += "</div>";

+ 1 - 8
public/app/plugins/datasource/graphite/datasource.js

@@ -111,19 +111,12 @@ function (angular, _, $, config, kbn, moment) {
             var list = [];
             for (var i = 0; i < results.data.length; i++) {
               var e = results.data[i];
-              var tags = [];
-              if (e.tags) {
-                tags = e.tags.split(',');
-                if (tags.length === 1) {
-                  tags = e.tags.split(' ');
-                }
-              }
 
               list.push({
                 annotation: annotation,
                 time: e.when * 1000,
                 title: e.what,
-                tags: tags,
+                tags: e.tags,
                 text: e.data
               });
             }