Commit 4fe79edd by Alexander Zobnin Committed by Torkel Ödegaard

Graphite 1.0 functions (#8987)

* graphite-ds: add graphite version to config editor

* graphite-ds: modify add-graphite-function to show only version-related functions

* graphite-ds: refactor, move func filtering to gfunc.js

* graphite-ds: add new functions for graphite 1.0.x

* graphite-ds: fix unit tests (add jsonData)
parent 35522c47
......@@ -20,9 +20,10 @@ function (angular, _, $, gfunc) {
return {
link: function($scope, elem) {
var categories = gfunc.getCategories();
var allFunctions = getAllFunctionNames(categories);
var ctrl = $scope.ctrl;
var graphiteVersion = ctrl.datasource.graphiteVersion;
var categories = gfunc.getCategories(graphiteVersion);
var allFunctions = getAllFunctionNames(categories);
$scope.functionMenu = createFunctionDropDownMenu(categories);
......@@ -94,14 +95,16 @@ function (angular, _, $, gfunc) {
function createFunctionDropDownMenu(categories) {
return _.map(categories, function(list, category) {
var submenu = _.map(list, function(value) {
return {
text: value.name,
click: "ctrl.addFunction('" + value.name + "')",
};
});
return {
text: category,
submenu: _.map(list, function(value) {
return {
text: value.name,
click: "ctrl.addFunction('" + value.name + "')",
};
})
submenu: submenu
};
});
}
......
///<reference path="../../../headers/common.d.ts" />
import angular from 'angular';
import _ from 'lodash';
export class GraphiteConfigCtrl {
static templateUrl = 'public/app/plugins/datasource/graphite/partials/config.html';
current: any;
/** @ngInject */
constructor($scope) {
this.current.jsonData.graphiteVersion = this.current.jsonData.graphiteVersion || '0.9';
}
graphiteVersions = [
{name: '0.9.x', value: '0.9'},
{name: '1.0.x', value: '1.0'},
];
}
......@@ -11,6 +11,7 @@ export function GraphiteDatasource(instanceSettings, $q, backendSrv, templateSrv
this.basicAuth = instanceSettings.basicAuth;
this.url = instanceSettings.url;
this.name = instanceSettings.name;
this.graphiteVersion = instanceSettings.jsonData.graphiteVersion || '0.9';
this.cacheTimeout = instanceSettings.cacheTimeout;
this.withCredentials = instanceSettings.withCredentials;
this.render_method = instanceSettings.render_method || 'POST';
......
import {GraphiteDatasource} from './datasource';
import {GraphiteQueryCtrl} from './query_ctrl';
class GraphiteConfigCtrl {
static templateUrl = 'partials/config.html';
}
import {GraphiteConfigCtrl} from './config_ctrl';
class GraphiteQueryOptionsCtrl {
static templateUrl = 'partials/query.options.html';
......
......@@ -3,3 +3,11 @@
suggest-url="http://localhost:8080">
</datasource-http-settings>
<h3 class="page-heading">Graphite details</h3>
<div class="gf-form-group">
<div class="gf-form">
<span class="gf-form-label width-8">Version</span>
<select class="gf-form-input gf-size-auto" ng-model="ctrl.current.jsonData.graphiteVersion" ng-options="f.value as f.name for f in ctrl.graphiteVersions"></select>
</div>
</div>
......@@ -5,7 +5,7 @@ import {GraphiteDatasource} from "../datasource";
describe('graphiteDatasource', function() {
var ctx = new helpers.ServiceTestContext();
var instanceSettings: any = {url: [''], name: 'graphiteProd'};
var instanceSettings: any = {url: [''], name: 'graphiteProd', jsonData: {}};
beforeEach(angularMocks.module('grafana.core'));
beforeEach(angularMocks.module('grafana.services'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment