From 37907e4110e48b115dcd7d3113dda62f358582d5 Mon Sep 17 00:00:00 2001 From: Mark McKinstry Date: Mon, 2 May 2016 12:31:39 -0400 Subject: [PATCH 01/19] fix broken link for kairosdb image --- docs/sources/datasources/kairosdb.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sources/datasources/kairosdb.md b/docs/sources/datasources/kairosdb.md index fc9b5682515..4430b427250 100644 --- a/docs/sources/datasources/kairosdb.md +++ b/docs/sources/datasources/kairosdb.md @@ -30,7 +30,7 @@ Access | Proxy = access via Grafana backend, Direct = access directory from brow ## Query editor Open a graph in edit mode by click the title. -![](/img/v2/kairos_query_editor.png) +![](/img/v2/kairos_query_editor.jpg) For details on KairosDB metric queries checkout the official. - [Query Metrics - KairosDB 0.9.4 documentation](http://kairosdb.github.io/kairosdocs/restapi/QueryMetrics.html). From d2fd829a58db016dfb4eca0e3f02a8be4a67052c Mon Sep 17 00:00:00 2001 From: Matt Toback Date: Tue, 3 May 2016 12:42:37 -0400 Subject: [PATCH 02/19] Update module.html --- public/app/plugins/panel/pluginlist/module.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/plugins/panel/pluginlist/module.html b/public/app/plugins/panel/pluginlist/module.html index 8e74f173a07..7d31d096e4c 100644 --- a/public/app/plugins/panel/pluginlist/module.html +++ b/public/app/plugins/panel/pluginlist/module.html @@ -23,7 +23,7 @@ From f4a013946f1a17217fea6a895ed31af8c71ee987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 3 May 2016 19:00:42 +0200 Subject: [PATCH 03/19] feat(pluginlist): link in plugin list now goes to app/plugin default nav unless enabled --- pkg/api/dtos/plugins.go | 1 + pkg/api/plugins.go | 6 ++++++ pkg/plugins/app_plugin.go | 2 -- public/app/plugins/panel/pluginlist/module.html | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/api/dtos/plugins.go b/pkg/api/dtos/plugins.go index 7d46cc9d348..fccb7c36849 100644 --- a/pkg/api/dtos/plugins.go +++ b/pkg/api/dtos/plugins.go @@ -29,6 +29,7 @@ type PluginListItem struct { Info *plugins.PluginInfo `json:"info"` LatestVersion string `json:"latestVersion"` HasUpdate bool `json:"hasUpdate"` + DefaultNavUrl string `json:"defaultNavUrl"` } type PluginList []PluginListItem diff --git a/pkg/api/plugins.go b/pkg/api/plugins.go index ad81d438978..7d6d5906913 100644 --- a/pkg/api/plugins.go +++ b/pkg/api/plugins.go @@ -8,6 +8,7 @@ import ( "github.com/grafana/grafana/pkg/middleware" m "github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/plugins" + "github.com/grafana/grafana/pkg/setting" ) func GetPluginList(c *middleware.Context) Response { @@ -46,6 +47,7 @@ func GetPluginList(c *middleware.Context) Response { Info: &pluginDef.Info, LatestVersion: pluginDef.GrafanaNetVersion, HasUpdate: pluginDef.GrafanaNetHasUpdate, + DefaultNavUrl: pluginDef.DefaultNavUrl, } if pluginSetting, exists := pluginSettingsMap[pluginDef.Id]; exists { @@ -53,6 +55,10 @@ func GetPluginList(c *middleware.Context) Response { listItem.Pinned = pluginSetting.Pinned } + if listItem.DefaultNavUrl == "" || !listItem.Enabled { + listItem.DefaultNavUrl = setting.AppSubUrl + "/plugins/" + listItem.Id + "/edit" + } + // filter out disabled if enabledFilter == "1" && !listItem.Enabled { continue diff --git a/pkg/plugins/app_plugin.go b/pkg/plugins/app_plugin.go index f565b0e2b22..cc588bf1d55 100644 --- a/pkg/plugins/app_plugin.go +++ b/pkg/plugins/app_plugin.go @@ -76,8 +76,6 @@ func (app *AppPlugin) initApp() { } } - app.DefaultNavUrl = setting.AppSubUrl + "/plugins/" + app.Id + "/edit" - // slugify pages for _, include := range app.Includes { if include.Slug == "" { diff --git a/public/app/plugins/panel/pluginlist/module.html b/public/app/plugins/panel/pluginlist/module.html index 8e74f173a07..82e0110676f 100644 --- a/public/app/plugins/panel/pluginlist/module.html +++ b/public/app/plugins/panel/pluginlist/module.html @@ -4,7 +4,7 @@ {{category.header}}
- + {{plugin.name}} From a34a784b43dcd453f43eccd96749fc18395a6a50 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Lespiau Date: Mon, 2 May 2016 20:36:06 +0200 Subject: [PATCH 04/19] Add more documentation on how to contribute Add more documentation on how to fork the project, and how to build on changes using grunt --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index d538ba78e1e..b92a9d5236f 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,18 @@ the latest master builds [here](http://grafana.org/download/builds) go get github.com/grafana/grafana ``` +Since imports of dependencies use the absolute path github.com/grafana/grafana within the $GOPATH, +you will need to put your version of the code in $GOPATH/src/github.com/grafana/grafana to be able +to develop and build grafana on a cloned repository. To do so, you can clone your forked repository +directly to $GOPATH/src/github.com/grafana or you can create a symbolic link from your version +of the code to $GOPATH/src/github.com/grafana/grafana. The last options makes it possible to change +easily the grafana repository you want to build. +```bash +go get github.com/*your_account*/grafana +mkdir $GOPATH/src/github.com/grafana +ln -s github.com/*your_account*/grafana $GOPATH/src/github.com/grafana/grafana +``` + ### Building the backend Replace X.Y.Z by actual version number. ```bash @@ -106,6 +118,13 @@ npm install npm run build ``` +To build the frontend assets only on changes: + +```bash +sudo npm install -g grunt-cli # to do only once to install grunt command line interface +grunt watch +``` + ### Recompile backend on source change To rebuild on source change (requires that you executed godep restore) ```bash From ca1182e783077397ebd4ac44ad586ab47a7f5f6a Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Lespiau Date: Mon, 2 May 2016 20:42:25 +0200 Subject: [PATCH 05/19] Stress the required version of node JS --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b92a9d5236f..65cb830a522 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ the latest master builds [here](http://grafana.org/download/builds) ### Dependencies - Go 1.5 -- NodeJS +- NodeJS v0.12.0 - [Godep](https://github.com/tools/godep) ### Get Code @@ -110,7 +110,7 @@ go run build.go build ### Building frontend assets -To build less to css for the frontend you will need a recent version of of node (v0.12.0), +To build less to css for the frontend you will need a recent version of of **node (v0.12.0)**, npm (v2.5.0) and grunt (v0.4.5). Run the following: ```bash From 543d247af851c38eec7c7ba2f8e2824baa06be63 Mon Sep 17 00:00:00 2001 From: Matt Toback Date: Tue, 3 May 2016 15:02:57 -0400 Subject: [PATCH 06/19] Wrapped the form in a form tag and added a submit, the ng-click shoudl work the same, but now enter works. @torkelo, pls review (#4898) --- public/app/features/org/partials/newOrg.html | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/public/app/features/org/partials/newOrg.html b/public/app/features/org/partials/newOrg.html index 88c348db78f..1c0a19ddec0 100644 --- a/public/app/features/org/partials/newOrg.html +++ b/public/app/features/org/partials/newOrg.html @@ -8,14 +8,16 @@

Each organization contains their own dashboards, data sources and configuration, and cannot be shared between orgs. While users may belong to more than one, mutiple organization are most frequently used in multi-tenant deployments.

-
-
- Org. name - +
+
+
+ Org. name + +
+
+
+ +
-
-
- -
-
+
From 2f7af968bfdcfee85c63f343a32892fc80da78be Mon Sep 17 00:00:00 2001 From: Idan Zalzberg Date: Wed, 4 May 2016 10:04:00 +0700 Subject: [PATCH 07/19] Bring back threshold line mode Threshold line mode was somehow discarded from the HTML in the ui redesign, this brings it back --- public/app/plugins/panel/graph/tab_axes.html | 1 + 1 file changed, 1 insertion(+) diff --git a/public/app/plugins/panel/graph/tab_axes.html b/public/app/plugins/panel/graph/tab_axes.html index 81ab3deeb31..0521af093dd 100644 --- a/public/app/plugins/panel/graph/tab_axes.html +++ b/public/app/plugins/panel/graph/tab_axes.html @@ -68,5 +68,6 @@
+ From 303cd8a5af28b60b6e15fbe18ac3d87516d8746a Mon Sep 17 00:00:00 2001 From: fg2it Date: Wed, 4 May 2016 09:07:45 +0200 Subject: [PATCH 08/19] [RenderToPng fix] (#4901) * removing useless code * fix various minor typo * don't silence phantomjs timeout and allow more time * fix gofmt --- README.md | 1 - build.go | 2 +- conf/defaults.ini | 2 +- conf/sample.ini | 2 +- pkg/api/render.go | 2 +- pkg/components/renderer/renderer.go | 2 ++ tasks/options/phantomjs.js | 2 -- 7 files changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d538ba78e1e..3c2d9af7590 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,6 @@ go get github.com/grafana/grafana ``` ### Building the backend -Replace X.Y.Z by actual version number. ```bash cd $GOPATH/src/github.com/grafana/grafana go run build.go setup (only needed once to install godep) diff --git a/build.go b/build.go index 0965a405e70..e1fc3599aa8 100644 --- a/build.go +++ b/build.go @@ -136,7 +136,7 @@ func readVersionFromPackageJson() { // add timestamp to iteration linuxPackageIteration = fmt.Sprintf("%s%v", linuxPackageIteration, time.Now().Unix()) } - log.Println(fmt.Sprintf("teration %v", linuxPackageIteration)) + log.Println(fmt.Sprintf("Iteration %v", linuxPackageIteration)) } } diff --git a/conf/defaults.ini b/conf/defaults.ini index 6f63891d1ee..ccbb8004fd5 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -248,7 +248,7 @@ mode = console, file # Buffer length of channel, keep it as it is if you don't know what it is. buffer_len = 10000 -# Either "Trace", "Debug", "Info", "Warn", "Error", "Critical", default is "Trace" +# Either "Trace", "Debug", "Info", "Warn", "Error", "Critical", default is "Info" level = Info # For "console" mode only diff --git a/conf/sample.ini b/conf/sample.ini index 4ab923c1376..91e6a23981f 100644 --- a/conf/sample.ini +++ b/conf/sample.ini @@ -230,7 +230,7 @@ check_for_updates = true # Buffer length of channel, keep it as it is if you don't know what it is. ;buffer_len = 10000 -# Either "Trace", "Debug", "Info", "Warn", "Error", "Critical", default is "Trace" +# Either "Trace", "Debug", "Info", "Warn", "Error", "Critical", default is "Info" ;level = Info # For "console" mode only diff --git a/pkg/api/render.go b/pkg/api/render.go index 9ed0c5ee6d7..65c1499d0c5 100644 --- a/pkg/api/render.go +++ b/pkg/api/render.go @@ -31,7 +31,7 @@ func RenderToPng(c *middleware.Context) { Width: queryReader.Get("width", "800"), Height: queryReader.Get("height", "400"), SessionId: c.Session.ID(), - Timeout: queryReader.Get("timeout", "15"), + Timeout: queryReader.Get("timeout", "30"), } renderOpts.Url = setting.ToAbsUrl(renderOpts.Url) diff --git a/pkg/components/renderer/renderer.go b/pkg/components/renderer/renderer.go index f81da43c295..d6091a3cb19 100644 --- a/pkg/components/renderer/renderer.go +++ b/pkg/components/renderer/renderer.go @@ -1,6 +1,7 @@ package renderer import ( + "fmt" "io" "os" "os/exec" @@ -72,6 +73,7 @@ func RenderToPng(params *RenderOpts) (string, error) { if err := cmd.Process.Kill(); err != nil { log.Error(4, "failed to kill: %v", err) } + return "", fmt.Errorf("PhantomRenderer::renderToPng timeout (>%vs)", timeout) case <-done: } diff --git a/tasks/options/phantomjs.js b/tasks/options/phantomjs.js index ae777a1cf74..4339f9880b6 100644 --- a/tasks/options/phantomjs.js +++ b/tasks/options/phantomjs.js @@ -15,8 +15,6 @@ module.exports = function(config,grunt) { src = confDir+src; } - var exec = require('child_process').execFileSync; - try { grunt.config('copy.phantom_bin', { src: src, From 3d366c2a4c0a92175c9ed93617cd75613fbb7f50 Mon Sep 17 00:00:00 2001 From: bergquist Date: Wed, 4 May 2016 10:42:12 +0200 Subject: [PATCH 09/19] feat(graphs): align forms for line mode checkbox --- CHANGELOG.md | 1 + public/app/plugins/panel/graph/tab_axes.html | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a67f45e69ec..b892322b889 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * **Remove query**: Fixed issue with removing query for data sources without collapsable query editors, fixes [#4856](https://github.com/grafana/grafana/issues/4856) * **Graphite PNG*: Fixed issue graphite png rendering option, fixes [#4864](https://github.com/grafana/grafana/issues/4864) * **InfluxDB**: Fixed issue missing plus group by iconn, fixes [#4862](https://github.com/grafana/grafana/issues/4862) +* **Graph**: Fixes missing line mode for thresholds, fixes [#4902](https://github.com/grafana/grafana/pull/4902) ### Enhancements * **InfluxDB**: Added new functions moving_average and difference to query editor, closes [#4698](https://github.com/grafana/grafana/issues/4698) diff --git a/public/app/plugins/panel/graph/tab_axes.html b/public/app/plugins/panel/graph/tab_axes.html index 0521af093dd..eeaf27aff78 100644 --- a/public/app/plugins/panel/graph/tab_axes.html +++ b/public/app/plugins/panel/graph/tab_axes.html @@ -46,7 +46,7 @@
Thresholds
- +
@@ -58,7 +58,7 @@
- +
@@ -68,6 +68,7 @@
- + + From e0ef6dd8d47ee9f7fa38b0860018dc67fd1d8d01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denny=20Sch=C3=A4fer?= Date: Wed, 4 May 2016 10:47:17 +0200 Subject: [PATCH 10/19] Fix changelog formatting for 3.0.0-beta7 (#4905) --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b892322b889..78502480fa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ * **Dashboard title**: Fixed max dashboard title width (media query) for large screens, fixes [#4859](https://github.com/grafana/grafana/issues/4859) * **Annotations**: Fixed issue with entering annotation edit view, fixes [#4857](https://github.com/grafana/grafana/issues/4857) * **Remove query**: Fixed issue with removing query for data sources without collapsable query editors, fixes [#4856](https://github.com/grafana/grafana/issues/4856) -* **Graphite PNG*: Fixed issue graphite png rendering option, fixes [#4864](https://github.com/grafana/grafana/issues/4864) +* **Graphite PNG**: Fixed issue graphite png rendering option, fixes [#4864](https://github.com/grafana/grafana/issues/4864) * **InfluxDB**: Fixed issue missing plus group by iconn, fixes [#4862](https://github.com/grafana/grafana/issues/4862) * **Graph**: Fixes missing line mode for thresholds, fixes [#4902](https://github.com/grafana/grafana/pull/4902) From 0764a4313beed59c777ab4ac53d9614215890c40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20H=C3=A4ger?= Date: Wed, 4 May 2016 10:47:35 +0200 Subject: [PATCH 11/19] AWS Elasticsearch Service Dimensions (#4903) --- pkg/api/cloudwatch/metrics.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/api/cloudwatch/metrics.go b/pkg/api/cloudwatch/metrics.go index 5ecdaabf516..7717ca27099 100644 --- a/pkg/api/cloudwatch/metrics.go +++ b/pkg/api/cloudwatch/metrics.go @@ -86,7 +86,7 @@ func init() { "AWS/EC2": {"AutoScalingGroupName", "ImageId", "InstanceId", "InstanceType"}, "AWS/ELB": {"LoadBalancerName", "AvailabilityZone"}, "AWS/ElasticMapReduce": {"ClusterId", "JobFlowId", "JobId"}, - "AWS/ES": {}, + "AWS/ES": {"ClientId", "DomainName"}, "AWS/Events": {"RuleName"}, "AWS/Kinesis": {"StreamName", "ShardID"}, "AWS/Lambda": {"FunctionName"}, From bca8d6d07b1beb57e1c8bf51bcc004167025d792 Mon Sep 17 00:00:00 2001 From: Idan Zalzberg Date: Wed, 4 May 2016 15:48:01 +0700 Subject: [PATCH 12/19] singlestat/module.ts onDataError was calling onDataReceived incorrectly (#4897) onDataError was calling onDataReceived with {data : []} which breaks at the first line since object has no map function. The correct form is probably just [] --- public/app/plugins/panel/singlestat/module.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/plugins/panel/singlestat/module.ts b/public/app/plugins/panel/singlestat/module.ts index 3c0b9e5342a..f76a41bfa86 100644 --- a/public/app/plugins/panel/singlestat/module.ts +++ b/public/app/plugins/panel/singlestat/module.ts @@ -82,7 +82,7 @@ class SingleStatCtrl extends MetricsPanelCtrl { } onDataError(err) { - this.onDataReceived({data: []}); + this.onDataReceived([]); } onDataReceived(dataList) { From bd155343603a8832a632f4197b7aee028f290ddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 4 May 2016 11:46:06 +0200 Subject: [PATCH 13/19] fix(singlestat gauge): better font size handling for gauge, now value font size is used as scaling factor, fixes #4876 --- public/app/app.ts | 2 ++ public/app/plugins/panel/singlestat/module.ts | 13 ++----------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/public/app/app.ts b/public/app/app.ts index b30b75a0ca3..3434814d3b6 100644 --- a/public/app/app.ts +++ b/public/app/app.ts @@ -42,6 +42,8 @@ export class GrafanaApp { app.constant('grafanaVersion', "@grafanaVersion@"); app.config(($locationProvider, $controllerProvider, $compileProvider, $filterProvider, $provide) => { + //$compileProvider.debugInfoEnabled(false); + this.registerFunctions.controller = $controllerProvider.register; this.registerFunctions.directive = $compileProvider.directive; this.registerFunctions.factory = $provide.factory; diff --git a/public/app/plugins/panel/singlestat/module.ts b/public/app/plugins/panel/singlestat/module.ts index f76a41bfa86..de18d7b8d2e 100644 --- a/public/app/plugins/panel/singlestat/module.ts +++ b/public/app/plugins/panel/singlestat/module.ts @@ -324,9 +324,9 @@ class SingleStatCtrl extends MetricsPanelCtrl { ? 'rgb(230,230,230)' : 'rgb(38,38,38)'; - + var fontScale = parseInt(panel.valueFontSize) / 100; var dimension = Math.min(width, height); - var fontSize = Math.min(dimension/4, 100); + var fontSize = Math.min(dimension/5, 100) * fontScale; var gaugeWidth = Math.min(dimension/6, 60); var thresholdMarkersWidth = gaugeWidth/5; @@ -374,15 +374,6 @@ class SingleStatCtrl extends MetricsPanelCtrl { $.plot(plotCanvas, [plotSeries], options); } - function getGaugeFontSize() { - if (panel.valueFontSize) { - var num = parseInt(panel.valueFontSize.substring(0, panel.valueFontSize.length - 1)); - return (30 * (num / 100)) + 15; - } else { - return 30; - } - } - function addSparkline() { var width = elem.width() + 20; if (width < 30) { From c86cdb180543b37e2bc5f4bfd909d4c6ecef502b Mon Sep 17 00:00:00 2001 From: Mathieu Payeur Levallois Date: Wed, 4 May 2016 07:47:05 -0400 Subject: [PATCH 14/19] opentsdb: apply templating on filters (#4594) --- public/app/plugins/datasource/opentsdb/datasource.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/datasource/opentsdb/datasource.js b/public/app/plugins/datasource/opentsdb/datasource.js index 32139832628..16f96ae060e 100644 --- a/public/app/plugins/datasource/opentsdb/datasource.js +++ b/public/app/plugins/datasource/opentsdb/datasource.js @@ -376,11 +376,16 @@ function (angular, _, dateMath) { if (target.filters && target.filters.length > 0) { query.filters = angular.copy(target.filters); + if(query.filters){ + for(var filter_key in query.filters){ + query.filters[filter_key].filter = templateSrv.replace(query.filters[filter_key].filter, options.scopedVars, 'pipe'); + } + } } else { query.tags = angular.copy(target.tags); if(query.tags){ - for(var key in query.tags){ - query.tags[key] = templateSrv.replace(query.tags[key], options.scopedVars, 'pipe'); + for(var tag_key in query.tags){ + query.tags[tag_key] = templateSrv.replace(query.tags[tag_key], options.scopedVars, 'pipe'); } } } From 70f717702525b8b6a47ab1a7b4f9454e15c03dd5 Mon Sep 17 00:00:00 2001 From: Utkarsh Bhatnagar Date: Thu, 5 May 2016 00:57:21 -0700 Subject: [PATCH 15/19] Fixed deleting row bug (#4919) --- public/app/features/dashboard/partials/settings.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/features/dashboard/partials/settings.html b/public/app/features/dashboard/partials/settings.html index 8d071d90495..6290ffeacba 100644 --- a/public/app/features/dashboard/partials/settings.html +++ b/public/app/features/dashboard/partials/settings.html @@ -86,7 +86,7 @@ - From c7e7a0cd16a9e5e8794b3359f4c50887314b4317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 5 May 2016 10:29:14 +0200 Subject: [PATCH 16/19] fix(singlestat): rerender singlestat and reevaluate thresholds on render, fixes #4920 --- public/app/plugins/panel/singlestat/module.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/public/app/plugins/panel/singlestat/module.ts b/public/app/plugins/panel/singlestat/module.ts index de18d7b8d2e..9fa3e8e39c6 100644 --- a/public/app/plugins/panel/singlestat/module.ts +++ b/public/app/plugins/panel/singlestat/module.ts @@ -91,11 +91,6 @@ class SingleStatCtrl extends MetricsPanelCtrl { var data: any = {}; this.setValues(data); - data.thresholds = this.panel.thresholds.split(',').map(function(strVale) { - return Number(strVale.trim()); - }); - - data.colorMap = this.panel.colors; this.data = data; this.render(); } @@ -435,8 +430,14 @@ class SingleStatCtrl extends MetricsPanelCtrl { function render() { if (!ctrl.data) { return; } - ctrl.setValues(ctrl.data); data = ctrl.data; + + // get thresholds + data.thresholds = panel.thresholds.split(',').map(function(strVale) { + return Number(strVale.trim()); + }); + data.colorMap = panel.colors; + setElementHeight(); var body = panel.gauge.show ? '' : getBigValueHtml(); From 04ef25b6ff4d631bab5d9eb7aa7617356d322419 Mon Sep 17 00:00:00 2001 From: Peggy Li Date: Fri, 6 May 2016 22:58:01 -0700 Subject: [PATCH 17/19] Set custom type for templating variables (#4941) --- public/dashboards/scripted_templated.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/public/dashboards/scripted_templated.js b/public/dashboards/scripted_templated.js index a0d3e081293..33830336a9f 100644 --- a/public/dashboards/scripted_templated.js +++ b/public/dashboards/scripted_templated.js @@ -47,6 +47,7 @@ dashboard.templating = { refresh: true, options: [], current: null, + type: 'custom' }, { name: 'test2', @@ -54,6 +55,7 @@ dashboard.templating = { refresh: true, options: [], current: null, + type: 'custom' } ] }; From c6c07599c73ef1c5ca4e722f078b82e85ffc3c54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 9 May 2016 09:21:33 +0200 Subject: [PATCH 18/19] conf(): updated comments in config file, fixes #4933 --- conf/defaults.ini | 2 +- conf/sample.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/defaults.ini b/conf/defaults.ini index ccbb8004fd5..f78287619a3 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -241,7 +241,7 @@ templates_pattern = emails/*.html #################################### Logging ########################## [log] -# Either "console", "file", default is "console" +# Either "console", "file", "syslog". Default is console and file # Use comma to separate multiple modes, e.g. "console, file" mode = console, file diff --git a/conf/sample.ini b/conf/sample.ini index 91e6a23981f..6a26589d40d 100644 --- a/conf/sample.ini +++ b/conf/sample.ini @@ -223,7 +223,7 @@ check_for_updates = true #################################### Logging ########################## [log] -# Either "console", "file", default is "console" +# Either "console", "file", "syslog". Default is console and file # Use comma to separate multiple modes, e.g. "console, file" ;mode = console, file From 040dd91d2e7ae691d839b88ed3dacf5a62834d64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 9 May 2016 10:17:30 +0200 Subject: [PATCH 19/19] fix(templating): fixed issue with current data source variable value, fixes #4934 --- CHANGELOG.md | 4 ++++ .../app/features/templating/templateValuesSrv.js | 5 ++--- public/test/specs/templateValuesSrv-specs.js | 14 ++++++++++++-- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78502480fa3..930a91af1da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 3.0.0 stable (unreleased) + +* **Templating**: Fixed issue with new data source variable not persisting current selected value, fixes [#4934](https://github.com/grafana/grafana/issues/4934) + # 3.0.0-beta7 (2016-05-02) ### Bug fixes diff --git a/public/app/features/templating/templateValuesSrv.js b/public/app/features/templating/templateValuesSrv.js index dc878c19c08..472c24aef61 100644 --- a/public/app/features/templating/templateValuesSrv.js +++ b/public/app/features/templating/templateValuesSrv.js @@ -213,8 +213,7 @@ function (angular, _, kbn) { this.updateOptions = function(variable) { if (variable.type !== 'query') { self._updateNonQueryVariable(variable); - self.setVariableValue(variable, variable.options[0]); - return $q.when([]); + return self.validateVariableSelectionState(variable); } return datasourceSrv.get(variable.datasource) @@ -251,7 +250,7 @@ function (angular, _, kbn) { if (_.isArray(variable.current.value)) { self.selectOptionsForCurrentValue(variable); } else { - var currentOption = _.findWhere(variable.options, { text: variable.current.text }); + var currentOption = _.findWhere(variable.options, {text: variable.current.text}); if (currentOption) { return self.setVariableValue(variable, currentOption, true); } else { diff --git a/public/test/specs/templateValuesSrv-specs.js b/public/test/specs/templateValuesSrv-specs.js index 3f4cd96c444..2edcd03da9a 100644 --- a/public/test/specs/templateValuesSrv-specs.js +++ b/public/test/specs/templateValuesSrv-specs.js @@ -166,7 +166,7 @@ define([ describeUpdateVariable('update custom variable', function(scenario) { scenario.setup(function() { - scenario.variable = { type: 'custom', query: 'hej, hop, asd', name: 'test'}; + scenario.variable = {type: 'custom', query: 'hej, hop, asd', name: 'test'}; }); it('should update options array', function() { @@ -286,7 +286,13 @@ define([ describeUpdateVariable('datasource variable with regex filter', function(scenario) { scenario.setup(function() { - scenario.variable = {type: 'datasource', query: 'graphite', name: 'test', current: {}, regex: '/pee$/' }; + scenario.variable = { + type: 'datasource', + query: 'graphite', + name: 'test', + current: {value: 'backend4_pee', text: 'backend4_pee'}, + regex: '/pee$/' + }; scenario.metricSources = [ {name: 'backend1', meta: {id: 'influx'}}, {name: 'backend2_pee', meta: {id: 'graphite'}}, @@ -300,6 +306,10 @@ define([ expect(scenario.variable.options[0].value).to.be('backend2_pee'); expect(scenario.variable.options[1].value).to.be('backend4_pee'); }); + + it('should keep current value if available', function() { + expect(scenario.variable.current.value).to.be('backend4_pee'); + }); }); });