From 1e7ced2ac6e728c79bceea472c148523a8f27015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 1 Jan 2014 19:42:00 +0100 Subject: [PATCH] fix for template targets --- src/app/controllers/graphiteTarget.js | 22 ++++++++++------------ src/app/panels/graphite/module.js | 7 +------ src/test/specs/parser-specs.js | 1 + 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/app/controllers/graphiteTarget.js b/src/app/controllers/graphiteTarget.js index 9ea62b4aab8..5c68c5d510d 100644 --- a/src/app/controllers/graphiteTarget.js +++ b/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 = ''; + } + if (segment.type === 'template') { + node.val = node.html = '[[' + segment.value + ']]'; + node.html = "" + node.html + ""; + } + return node; }); } } - function getSegmentHtml(segment) { - if (segment.value === '*') { - return ''; - } - if (segment.type === 'template') { - return "[[" + segment.value + "]]"; - } - return segment.value; - } - function getSegmentPathUpTo(index) { var arr = $scope.segments.slice(0, index); diff --git a/src/app/panels/graphite/module.js b/src/app/panels/graphite/module.js index 8a3674b1315..48354c27e54 100644 --- a/src/app/panels/graphite/module.js +++ b/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) { diff --git a/src/test/specs/parser-specs.js b/src/test/specs/parser-specs.js index c218e42bc10..00420c65c68 100644 --- a/src/test/specs/parser-specs.js +++ b/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() {