Torkel Ödegaard 12 лет назад
Родитель
Сommit
1e7ced2ac6

+ 10 - 12
src/app/controllers/graphiteTarget.js

@@ -81,25 +81,23 @@ function (angular, _, config, graphiteFuncs, Parser) {
         }
 
         $scope.segments = _.map(astNode.segments, function(segment) {
-          return {
+          var node = {
             type: segment.type,
             val: segment.value,
-            html: getSegmentHtml(segment)
+            html: segment.value
           };
+          if (segment.value === '*') {
+            node.html = '<i class="icon-asterisk"><i>';
+          }
+          if (segment.type === 'template') {
+            node.val = node.html = '[[' + segment.value + ']]';
+            node.html = "<span style='color: #ECEC09'>" + node.html + "</span>";
+          }
+          return node;
         });
       }
     }
 
-    function getSegmentHtml(segment) {
-      if (segment.value === '*') {
-        return '<i class="icon-asterisk"><i>';
-      }
-      if (segment.type === 'template') {
-        return "<span style='color: #ECEC09'>[[" + segment.value  + "]]</span>";
-      }
-      return segment.value;
-    }
-
     function getSegmentPathUpTo(index) {
       var arr = $scope.segments.slice(0, index);
 

+ 1 - 6
src/app/panels/graphite/module.js

@@ -332,7 +332,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
       var data = [];
 
       if(results.length === 0 ) {
-        throw { message: 'no data in response from graphite' };
+        return [];
       }
 
       var tsOpts = {
@@ -662,10 +662,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
             });
           }
 
-         /* var totalDataPoints = _.reduce(data, function(num, series) { return series.data.length + num; }, 0);
-          console.log('Datapoints[0] count:', data[0].data.length);
-          console.log('Datapoints.Total count:', totalDataPoints);*/
-
           plot = $.plot(elem, data, options);
 
           if (scope.panel.leftYAxisLabel) {
@@ -678,7 +674,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
           } else if (elem.css('margin-left')) {
             elem.css('margin-left', '');
           }
-
         }
 
         function time_format(interval) {

+ 1 - 0
src/test/specs/parser-specs.js

@@ -61,6 +61,7 @@ define([
       expect(rootNode.message).to.be(undefined)
       expect(rootNode.params[0].type).to.be('metric');
       expect(rootNode.params[0].segments[1].type).to.be('template');
+      expect(rootNode.params[0].segments[1].value).to.be('server');
     });
 
     it('invalid metric expression', function() {