Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphite 1.0 functions #8987

Merged
merged 5 commits into from Aug 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 11 additions & 8 deletions public/app/plugins/datasource/graphite/add_graphite_func.js
Expand Up @@ -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);

Expand Down Expand Up @@ -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
};
});
}
Expand Down
20 changes: 20 additions & 0 deletions public/app/plugins/datasource/graphite/config_ctrl.ts
@@ -0,0 +1,20 @@
///<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'},
];
}

1 change: 1 addition & 0 deletions public/app/plugins/datasource/graphite/datasource.ts
Expand Up @@ -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';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we additionally check instanceSettings.jsonData?

instanceSettings.jsonData = instanceSettings.jsonData || {};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed unit tests, but maybe better to check this instead. When I'm loading DS with old settings, seems, instanceSettings contains empty jsonData anyway. But not sure how it works in previous grafana versions.

this.cacheTimeout = instanceSettings.cacheTimeout;
this.withCredentials = instanceSettings.withCredentials;
this.render_method = instanceSettings.render_method || 'POST';
Expand Down