|
|
@@ -8,48 +8,21 @@ function ($, RQ, _, config) {
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
- function build_graphite_options(options, raw) {
|
|
|
- raw = raw || false;
|
|
|
+ function build_graphite_options(options) {
|
|
|
var clean_options = [];
|
|
|
- //var internal_options = ['_t'];
|
|
|
var graphite_options = ['target', 'targets', 'from', 'until', 'rawData', 'format', 'maxDataPoints'];
|
|
|
- var graphite_png_options = ['areaMode', 'width', 'height', 'template', 'margin', 'bgcolor',
|
|
|
- 'fgcolor', 'fontName', 'fontSize', 'fontBold', 'fontItalic',
|
|
|
- 'yMin', 'yMax', 'colorList', 'title', 'vtitle', 'lineMode',
|
|
|
- 'lineWith', 'hideLegend', 'hideAxes', 'hideGrid', 'minXstep',
|
|
|
- 'majorGridlineColor', 'minorGridLineColor', 'minorY',
|
|
|
- 'thickness', 'min', 'max', 'tz'];
|
|
|
|
|
|
- if(raw) {
|
|
|
- options['format'] = 'json';
|
|
|
- } else {
|
|
|
- // use random parameter to force image refresh
|
|
|
- options["_t"] = options["_t"] || Math.random();
|
|
|
- }
|
|
|
+ options['format'] = 'json';
|
|
|
|
|
|
$.each(options, function (key, value) {
|
|
|
- if(raw) {
|
|
|
- if ($.inArray(key, graphite_options) === -1) {
|
|
|
- return;
|
|
|
- }
|
|
|
- } else {
|
|
|
- if ($.inArray(key, graphite_options) === -1 && $.inArray(key, graphite_png_options) === -1) {
|
|
|
- return;
|
|
|
- }
|
|
|
+ if ($.inArray(key, graphite_options) === -1) {
|
|
|
+ return;
|
|
|
}
|
|
|
+
|
|
|
if (key === "targets") {
|
|
|
$.each(value, function (index, value) {
|
|
|
- if (raw) {
|
|
|
- // it's normally pointless to use alias() in raw mode, because we apply an alias (name) ourself
|
|
|
- // in the client rendering step. we just need graphite to return the target.
|
|
|
- // but graphite sometimes alters the name of the target in the returned data
|
|
|
- // (https://github.com/graphite-project/graphite-web/issues/248)
|
|
|
- // so we need a good string identifier and set it using alias() (which graphite will honor)
|
|
|
- // so that we recognize the returned output. simplest is just to include the target spec again
|
|
|
- // though this duplicates a lot of info in the url.
|
|
|
+ if (!value.hide) {
|
|
|
clean_options.push("target=" + encodeURIComponent(value.target));
|
|
|
- } else {
|
|
|
- clean_options.push("target=alias(color(" +encodeURIComponent(value.target + ",'" + value.color) +"'),'" + value.name +"')");
|
|
|
}
|
|
|
});
|
|
|
} else if (value !== null) {
|
|
|
@@ -69,7 +42,7 @@ function ($, RQ, _, config) {
|
|
|
maxDataPoints: options.maxDataPoints
|
|
|
};
|
|
|
|
|
|
- var graphiteParameters = build_graphite_options(graphOptions, true);
|
|
|
+ var graphiteParameters = build_graphite_options(graphOptions);
|
|
|
getGraphiteData(graphiteParameters)
|
|
|
.done(function(data) {
|
|
|
requestion(data);
|