mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge branch 'master' into valuepanel
This commit is contained in:
84
'
84
'
@@ -1,84 +0,0 @@
|
|||||||
/* global _ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Complex scripted dashboard
|
|
||||||
* This script generates a dashboard object that Grafana can load. It also takes a number of user
|
|
||||||
* supplied URL parameters (int ARGS variable)
|
|
||||||
*
|
|
||||||
* Return a dashboard object, or a function
|
|
||||||
*
|
|
||||||
* For async scripts, return a function, this function must take a single callback function as argument,
|
|
||||||
* call this callback function with the dashboard object (look at scripted_async.js for an example)
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
// accessable variables in this scope
|
|
||||||
var window, document, ARGS, $, jQuery, moment, kbn, services, _;
|
|
||||||
|
|
||||||
// default datasource
|
|
||||||
var datasource = services.datasourceSrv.default;
|
|
||||||
// get datasource used for saving dashboards
|
|
||||||
var dashboardDB = services.datasourceSrv.getGrafanaDB();
|
|
||||||
|
|
||||||
var targets = [];
|
|
||||||
|
|
||||||
function getTargets(path) {
|
|
||||||
return datasource.metricFindQuery(path + '.*').then(function(result) {
|
|
||||||
if (!result) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (targets.length === 10) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var promises = _.map(result, function(metric) {
|
|
||||||
if (metric.expandable) {
|
|
||||||
return getTargets(path + "." + metric.text);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
targets.push(path + '.' + metric.text);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
|
|
||||||
return services.$q.when(promises);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function createDashboard(target, index) {
|
|
||||||
// Intialize a skeleton with nothing but a rows array and service object
|
|
||||||
var dashboard = { rows : [] };
|
|
||||||
dashboard.title = 'Scripted dash ' + index;
|
|
||||||
dashboard.time = {
|
|
||||||
from: "now-6h",
|
|
||||||
to: "now"
|
|
||||||
};
|
|
||||||
|
|
||||||
dashboard.rows.push({
|
|
||||||
title: 'Chart',
|
|
||||||
height: '300px',
|
|
||||||
panels: [
|
|
||||||
{
|
|
||||||
title: 'Events',
|
|
||||||
type: 'graph',
|
|
||||||
span: 12,
|
|
||||||
targets: [ {target: target} ]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return function(callback) {
|
|
||||||
|
|
||||||
getTargets('apps').then(function(results) {
|
|
||||||
console.log('targets: ', targets);
|
|
||||||
_.each(targets, function(target, index) {
|
|
||||||
var dashboard = createDashboard(target);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
@@ -13,6 +13,9 @@
|
|||||||
- [Issue #952](https://github.com/grafana/grafana/issues/952). Help: Shortcut "?" to open help modal with list of all shortcuts
|
- [Issue #952](https://github.com/grafana/grafana/issues/952). Help: Shortcut "?" to open help modal with list of all shortcuts
|
||||||
- [Issue #991](https://github.com/grafana/grafana/issues/991). ScriptedDashboard: datasource services are now available in scripted dashboards, you can query datasource for metric keys, generate dashboards, and even save them in a scripted dashboard (see scripted_gen_and_save.js for example)
|
- [Issue #991](https://github.com/grafana/grafana/issues/991). ScriptedDashboard: datasource services are now available in scripted dashboards, you can query datasource for metric keys, generate dashboards, and even save them in a scripted dashboard (see scripted_gen_and_save.js for example)
|
||||||
|
|
||||||
|
**Changes**
|
||||||
|
- [Issue #1007](https://github.com/grafana/grafana/issues/1007). Graph: Series hide/show toggle changed to be default exclusive, so clicking on a series name will show only that series. (SHIFT or meta)+click will toggle hide/show.
|
||||||
|
|
||||||
**OpenTSDB**
|
**OpenTSDB**
|
||||||
- [Issue #930](https://github.com/grafana/grafana/issues/930). OpenTSDB: Adding counter max and counter reset value to open tsdb query editor, thx @rsimiciuc
|
- [Issue #930](https://github.com/grafana/grafana/issues/930). OpenTSDB: Adding counter max and counter reset value to open tsdb query editor, thx @rsimiciuc
|
||||||
|
|
||||||
|
|||||||
@@ -275,6 +275,10 @@ function (angular, _, config, gfunc, Parser) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.moveMetricQuery = function(fromIndex, toIndex) {
|
||||||
|
_.move($scope.panel.targets, fromIndex, toIndex);
|
||||||
|
};
|
||||||
|
|
||||||
$scope.duplicate = function() {
|
$scope.duplicate = function() {
|
||||||
var clone = angular.copy($scope.target);
|
var clone = angular.copy($scope.target);
|
||||||
$scope.panel.targets.push(clone);
|
$scope.panel.targets.push(clone);
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
define([
|
define([
|
||||||
'angular'
|
'angular',
|
||||||
|
'lodash'
|
||||||
],
|
],
|
||||||
function (angular) {
|
function (angular, _) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var module = angular.module('grafana.controllers');
|
var module = angular.module('grafana.controllers');
|
||||||
@@ -96,6 +97,10 @@ function (angular) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.moveMetricQuery = function(fromIndex, toIndex) {
|
||||||
|
_.move($scope.panel.targets, fromIndex, toIndex);
|
||||||
|
};
|
||||||
|
|
||||||
$scope.duplicate = function() {
|
$scope.duplicate = function() {
|
||||||
var clone = angular.copy($scope.target);
|
var clone = angular.copy($scope.target);
|
||||||
$scope.panel.targets.push(clone);
|
$scope.panel.targets.push(clone);
|
||||||
|
|||||||
@@ -275,14 +275,14 @@ function (angular, app, $, _, kbn, moment, TimeSeries) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.toggleSeries = function(serie, event) {
|
$scope.toggleSeries = function(serie, event) {
|
||||||
if ($scope.hiddenSeries[serie.alias]) {
|
|
||||||
delete $scope.hiddenSeries[serie.alias];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$scope.hiddenSeries[serie.alias] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
||||||
|
if ($scope.hiddenSeries[serie.alias]) {
|
||||||
|
delete $scope.hiddenSeries[serie.alias];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$scope.hiddenSeries[serie.alias] = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
$scope.toggleSeriesExclusiveMode(serie);
|
$scope.toggleSeriesExclusiveMode(serie);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,19 @@
|
|||||||
ng-click="duplicate()">
|
ng-click="duplicate()">
|
||||||
Duplicate
|
Duplicate
|
||||||
</a>
|
</a>
|
||||||
|
</li>
|
||||||
|
<li role="menuitem">
|
||||||
|
<a tabindex="1"
|
||||||
|
ng-click="moveMetricQuery($index, $index-1)">
|
||||||
|
Move up
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li role="menuitem">
|
||||||
|
<a tabindex="1"
|
||||||
|
ng-click="moveMetricQuery($index, $index+1)">
|
||||||
|
Move down
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
|||||||
@@ -15,26 +15,26 @@
|
|||||||
tabindex="1">
|
tabindex="1">
|
||||||
<i class="icon icon-cog"></i>
|
<i class="icon icon-cog"></i>
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu pull-right" role="menu">
|
<ul class="dropdown-menu pull-right" role="menu">
|
||||||
<li role="menuitem">
|
<li role="menuitem"><a tabindex="1" ng-click="duplicate()">Duplicate</a></li>
|
||||||
<a tabindex="1" ng-click="duplicate()">Duplicate</a>
|
<li role="menuitem"><a tabindex="1" ng-click="showQuery()" ng-hide="target.rawQuery">Raw query mode</a></li>
|
||||||
<a tabindex="2" ng-click="showQuery()" ng-hide="target.rawQuery">Raw query mode</a>
|
<li role="menuitem"><a tabindex="1" ng-click="hideQuery()" ng-show="target.rawQuery">Query editor mode</a></li>
|
||||||
<a tabindex="2" ng-click="hideQuery()" ng-show="target.rawQuery">Query editor mode</a>
|
<li role="menuitem"><a tabindex="1" ng-click="moveMetricQuery($index, $index-1)">Move up </a></li>
|
||||||
</li>
|
<li role="menuitem"><a tabindex="1" ng-click="moveMetricQuery($index, $index+1)">Move down</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a class="pointer" tabindex="1" ng-click="removeDataQuery(target)">
|
<a class="pointer" tabindex="1" ng-click="removeDataQuery(target)">
|
||||||
<i class="icon icon-remove"></i>
|
<i class="icon icon-remove"></i>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<ul class="grafana-segment-list">
|
<ul class="grafana-segment-list">
|
||||||
<li>
|
<li>
|
||||||
<a class="grafana-target-segment" ng-click="target.hide = !target.hide; get_data();" role="menuitem">
|
<a class="grafana-target-segment" ng-click="target.hide = !target.hide; get_data();" role="menuitem">
|
||||||
<i class="icon-eye-open"></i>
|
<i class="icon-eye-open"></i>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|||||||
@@ -32,26 +32,27 @@ function (angular, _, $) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.update(this.getQueryStringState(), true);
|
this.update(this.getQueryStringState(), true);
|
||||||
|
this.expandRowForPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DashboardViewState.prototype.expandRowForPanel = function() {
|
||||||
|
if (!this.state.panelId) { return; }
|
||||||
|
|
||||||
|
var panelInfo = this.$scope.dashboard.getPanelInfoById(this.state.panelId);
|
||||||
|
panelInfo.row.collapse = false;
|
||||||
|
};
|
||||||
|
|
||||||
DashboardViewState.prototype.needsSync = function(urlState) {
|
DashboardViewState.prototype.needsSync = function(urlState) {
|
||||||
return _.isEqual(this.state, urlState) === false;
|
return _.isEqual(this.state, urlState) === false;
|
||||||
};
|
};
|
||||||
|
|
||||||
DashboardViewState.prototype.getQueryStringState = function() {
|
DashboardViewState.prototype.getQueryStringState = function() {
|
||||||
var queryParams = $location.search();
|
var state = $location.search();
|
||||||
var urlState = {
|
state.panelId = parseInt(state.panelId) || null;
|
||||||
panelId: parseInt(queryParams.panelId) || null,
|
state.fullscreen = state.fullscreen ? true : false;
|
||||||
fullscreen: queryParams.fullscreen ? true : false,
|
state.edit = state.edit ? true : false;
|
||||||
edit: queryParams.edit ? true : false,
|
|
||||||
};
|
|
||||||
|
|
||||||
_.each(queryParams, function(value, key) {
|
return state;
|
||||||
if (key.indexOf('var-') !== 0) { return; }
|
|
||||||
urlState[key] = value;
|
|
||||||
});
|
|
||||||
|
|
||||||
return urlState;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DashboardViewState.prototype.serializeToUrl = function() {
|
DashboardViewState.prototype.serializeToUrl = function() {
|
||||||
|
|||||||
@@ -339,8 +339,12 @@ function (_) {
|
|||||||
addFuncDef({
|
addFuncDef({
|
||||||
name: 'summarize',
|
name: 'summarize',
|
||||||
category: categories.Transform,
|
category: categories.Transform,
|
||||||
params: [{ name: "interval", type: "string" }, { name: "func", type: "select", options: ['sum', 'avg', 'min', 'max', 'last'] }],
|
params: [
|
||||||
defaultParams: ['1h', 'sum']
|
{ name: "interval", type: "string" },
|
||||||
|
{ name: "func", type: "select", options: ['sum', 'avg', 'min', 'max', 'last'] },
|
||||||
|
{ name: "alignToFrom", type: "boolean", optional: true, options: ['false', 'true'] },
|
||||||
|
],
|
||||||
|
defaultParams: ['1h', 'sum', 'false']
|
||||||
});
|
});
|
||||||
|
|
||||||
addFuncDef({
|
addFuncDef({
|
||||||
@@ -543,7 +547,7 @@ function (_) {
|
|||||||
var parameters = _.map(this.params, function(value, index) {
|
var parameters = _.map(this.params, function(value, index) {
|
||||||
|
|
||||||
var paramType = this.def.params[index].type;
|
var paramType = this.def.params[index].type;
|
||||||
if (paramType === 'int' || paramType === 'value_or_series') {
|
if (paramType === 'int' || paramType === 'value_or_series' || paramType === 'boolean') {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ define([
|
|||||||
var func = gfunc.createFuncInstance('summarize', { withDefaultParams: true });
|
var func = gfunc.createFuncInstance('summarize', { withDefaultParams: true });
|
||||||
func.updateParam('1h', 0);
|
func.updateParam('1h', 0);
|
||||||
expect(func.params[0]).to.be('1h');
|
expect(func.params[0]).to.be('1h');
|
||||||
expect(func.text).to.be('summarize(1h, sum)');
|
expect(func.text).to.be('summarize(1h, sum, false)');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should parse numbers as float', function() {
|
it('should parse numbers as float', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user