From 6c70122e55b8359dc2457a904ae0036524947c5c Mon Sep 17 00:00:00 2001 From: Adrien Samson Date: Wed, 22 Oct 2014 10:26:43 +0200 Subject: [PATCH 1/5] Add alignToFrom param to summarize --- src/app/services/graphite/gfunc.js | 10 +++++++--- src/test/specs/gfunc-specs.js | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/app/services/graphite/gfunc.js b/src/app/services/graphite/gfunc.js index 22b79527cbd..81bf9713e79 100644 --- a/src/app/services/graphite/gfunc.js +++ b/src/app/services/graphite/gfunc.js @@ -339,8 +339,12 @@ function (_) { addFuncDef({ name: 'summarize', category: categories.Transform, - params: [{ name: "interval", type: "string" }, { name: "func", type: "select", options: ['sum', 'avg', 'min', 'max', 'last'] }], - defaultParams: ['1h', 'sum'] + params: [ + { 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({ @@ -543,7 +547,7 @@ function (_) { var parameters = _.map(this.params, function(value, index) { 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; } diff --git a/src/test/specs/gfunc-specs.js b/src/test/specs/gfunc-specs.js index e0714d8376f..f0650c16077 100644 --- a/src/test/specs/gfunc-specs.js +++ b/src/test/specs/gfunc-specs.js @@ -79,7 +79,7 @@ define([ var func = gfunc.createFuncInstance('summarize', { withDefaultParams: true }); func.updateParam('1h', 0); 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() { From cdb4b3cc7ddc576bd63f564a8779f589d373f366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 29 Oct 2014 09:51:44 +0100 Subject: [PATCH 2/5] Panel: fix fullscreen/edit view and page refresh when panel is in collapsed/hidden row, Fixes #992 --- src/app/services/dashboard/dashboardViewStateSrv.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/app/services/dashboard/dashboardViewStateSrv.js b/src/app/services/dashboard/dashboardViewStateSrv.js index 2f85da5d27a..1ff95e8d4d3 100644 --- a/src/app/services/dashboard/dashboardViewStateSrv.js +++ b/src/app/services/dashboard/dashboardViewStateSrv.js @@ -32,8 +32,16 @@ function (angular, _, $) { }); 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) { return _.isEqual(this.state, urlState) === false; }; From 74e03092411eb70c5219637c066fdb457455a982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sun, 2 Nov 2014 11:56:51 +0100 Subject: [PATCH 3/5] Fixes #912, URL parameters are lost when switching to fullscreen/edit mode --- .../services/dashboard/dashboardViewStateSrv.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/app/services/dashboard/dashboardViewStateSrv.js b/src/app/services/dashboard/dashboardViewStateSrv.js index 1ff95e8d4d3..6eafcc8dd66 100644 --- a/src/app/services/dashboard/dashboardViewStateSrv.js +++ b/src/app/services/dashboard/dashboardViewStateSrv.js @@ -47,19 +47,12 @@ function (angular, _, $) { }; DashboardViewState.prototype.getQueryStringState = function() { - var queryParams = $location.search(); - var urlState = { - panelId: parseInt(queryParams.panelId) || null, - fullscreen: queryParams.fullscreen ? true : false, - edit: queryParams.edit ? true : false, - }; + var state = $location.search(); + state.panelId = parseInt(state.panelId) || null; + state.fullscreen = state.fullscreen ? true : false; + state.edit = state.edit ? true : false; - _.each(queryParams, function(value, key) { - if (key.indexOf('var-') !== 0) { return; } - urlState[key] = value; - }); - - return urlState; + return state; }; DashboardViewState.prototype.serializeToUrl = function() { From 10ea140358af04c5b018e27a8169898fb418c9a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 3 Nov 2014 08:56:13 +0100 Subject: [PATCH 4/5] MetricEditors: Ability to reorder metric queries in metrics tag, Closes #716, Closes #856 --- ' | 84 ------------------------- CHANGELOG.md | 1 + src/app/controllers/graphiteTarget.js | 4 ++ src/app/controllers/influxTargetCtrl.js | 9 ++- src/app/partials/graphite/editor.html | 13 ++++ src/app/partials/influxdb/editor.html | 38 +++++------ 6 files changed, 44 insertions(+), 105 deletions(-) delete mode 100644 ' diff --git a/' b/' deleted file mode 100644 index 86791d43fde..00000000000 --- a/' +++ /dev/null @@ -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); - }); - }); - -}; - diff --git a/CHANGELOG.md b/CHANGELOG.md index 24772741c14..b29e659c472 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - [Issue #938](https://github.com/grafana/grafana/issues/938). Panel: Plugin panels now reside outside of app/panels directory - [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 #716](https://github.com/grafana/grafana/issues/716). MetricsEditors: Ability to reorder metric queries **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 diff --git a/src/app/controllers/graphiteTarget.js b/src/app/controllers/graphiteTarget.js index 3d6368a7793..3d899ac152f 100644 --- a/src/app/controllers/graphiteTarget.js +++ b/src/app/controllers/graphiteTarget.js @@ -275,6 +275,10 @@ function (angular, _, config, gfunc, Parser) { } }; + $scope.moveMetricQuery = function(fromIndex, toIndex) { + _.move($scope.panel.targets, fromIndex, toIndex); + }; + $scope.duplicate = function() { var clone = angular.copy($scope.target); $scope.panel.targets.push(clone); diff --git a/src/app/controllers/influxTargetCtrl.js b/src/app/controllers/influxTargetCtrl.js index 175bf268098..e2b1a5234d4 100644 --- a/src/app/controllers/influxTargetCtrl.js +++ b/src/app/controllers/influxTargetCtrl.js @@ -1,7 +1,8 @@ define([ - 'angular' + 'angular', + 'lodash' ], -function (angular) { +function (angular, _) { 'use strict'; 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() { var clone = angular.copy($scope.target); $scope.panel.targets.push(clone); diff --git a/src/app/partials/graphite/editor.html b/src/app/partials/graphite/editor.html index f54c830d46b..77ef46a7e39 100755 --- a/src/app/partials/graphite/editor.html +++ b/src/app/partials/graphite/editor.html @@ -30,6 +30,19 @@ ng-click="duplicate()"> Duplicate + +
  • + + Move up + +
  • +
  • + + Move down + +
  • diff --git a/src/app/partials/influxdb/editor.html b/src/app/partials/influxdb/editor.html index fdc14166b7e..7fe41c1d268 100644 --- a/src/app/partials/influxdb/editor.html +++ b/src/app/partials/influxdb/editor.html @@ -15,26 +15,26 @@ tabindex="1"> - -
  • -
  • - - - -
  • - + + +
  • + + + +
  • + -
      -
    • - - - + From ecdcd1061245559f62ad1e347c9f1f943619216c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 3 Nov 2014 10:21:12 +0100 Subject: [PATCH 5/5] 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. Closes #1007 --- CHANGELOG.md | 4 +++- src/app/panels/graph/module.js | 14 +++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b29e659c472..e316f74ba8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,9 @@ - [Issue #938](https://github.com/grafana/grafana/issues/938). Panel: Plugin panels now reside outside of app/panels directory - [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 #716](https://github.com/grafana/grafana/issues/716). MetricsEditors: Ability to reorder metric queries + +**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** - [Issue #930](https://github.com/grafana/grafana/issues/930). OpenTSDB: Adding counter max and counter reset value to open tsdb query editor, thx @rsimiciuc diff --git a/src/app/panels/graph/module.js b/src/app/panels/graph/module.js index 87098a2d4d7..c24b61dffce 100644 --- a/src/app/panels/graph/module.js +++ b/src/app/panels/graph/module.js @@ -276,14 +276,14 @@ function (angular, app, $, _, kbn, moment, TimeSeries) { }; $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 ($scope.hiddenSeries[serie.alias]) { + delete $scope.hiddenSeries[serie.alias]; + } + else { + $scope.hiddenSeries[serie.alias] = true; + } + } else { $scope.toggleSeriesExclusiveMode(serie); }