From c555bbce3d531f50942e872ba959a248c6f2e4c7 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Lespiau Date: Sun, 1 May 2016 01:32:36 +0200 Subject: [PATCH 01/36] Add optional tooltip ordering --- .../app/plugins/panel/graph/graph_tooltip.js | 18 +++++++++++++++--- public/app/plugins/panel/graph/module.ts | 1 + .../app/plugins/panel/graph/tab_display.html | 12 +++++++++--- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/public/app/plugins/panel/graph/graph_tooltip.js b/public/app/plugins/panel/graph/graph_tooltip.js index 9ab6369a6b2..0c2136f7d9d 100644 --- a/public/app/plugins/panel/graph/graph_tooltip.js +++ b/public/app/plugins/panel/graph/graph_tooltip.js @@ -81,9 +81,9 @@ function ($) { // Stacked series can increase its length on each new stacked serie if null points found, // to speed the index search we begin always on the last found hoverIndex. var newhoverIndex = this.findHoverIndexFromDataPoints(pos.x, series, hoverIndex); - results.push({ value: value, hoverIndex: newhoverIndex }); + results.push({ value: value, hoverIndex: newhoverIndex, color: series.color, label: series.label }); } else { - results.push({ value: value, hoverIndex: hoverIndex }); + results.push({ value: value, hoverIndex: hoverIndex, color: series.color, label: series.label }); } } @@ -133,6 +133,18 @@ function ($) { absoluteTime = dashboard.formatDate(seriesHoverInfo.time, tooltipFormat); + // Dynamically reorder the hovercard for the current time point if the + // option is enabled. + if (panel.tooltip.ordering === 'decreasing') { + seriesHoverInfo.sort(function(a, b) { + return parseFloat(b.value) - parseFloat(a.value); + }); + } else if (panel.tooltip.ordering === 'increasing') { + seriesHoverInfo.sort(function(a, b) { + return parseFloat(a.value) - parseFloat(b.value); + }); + } + for (i = 0; i < seriesHoverInfo.length; i++) { hoverInfo = seriesHoverInfo[i]; @@ -150,7 +162,7 @@ function ($) { value = series.formatValue(hoverInfo.value); seriesHtml += '
'; - seriesHtml += ' ' + series.label + ':
'; + seriesHtml += ' ' + hoverInfo.label + ':
'; seriesHtml += '
' + value + '
'; plot.highlight(i, hoverInfo.hoverIndex); } diff --git a/public/app/plugins/panel/graph/module.ts b/public/app/plugins/panel/graph/module.ts index a11c537b178..2b2e75b5a33 100644 --- a/public/app/plugins/panel/graph/module.ts +++ b/public/app/plugins/panel/graph/module.ts @@ -92,6 +92,7 @@ class GraphCtrl extends MetricsPanelCtrl { tooltip : { value_type: 'cumulative', shared: true, + ordering: 'alphabetical', msResolution: false, }, // time overrides diff --git a/public/app/plugins/panel/graph/tab_display.html b/public/app/plugins/panel/graph/tab_display.html index 067651540e2..a33ae0bc67f 100644 --- a/public/app/plugins/panel/graph/tab_display.html +++ b/public/app/plugins/panel/graph/tab_display.html @@ -42,23 +42,29 @@
Misc options
- +
- +
- +
+
+ +
+ +
+
From de5a39f320555e5fce2bf190b06c5725059a06ab Mon Sep 17 00:00:00 2001 From: bergquist Date: Mon, 2 May 2016 13:17:57 +0200 Subject: [PATCH 02/36] Revert "Revert "Merge branch 'utkarshcmu-rangeMaps'"" This reverts commit 58b91befdedfd5115f07710bc47ed4524bc0cb56. --- .../app/plugins/panel/singlestat/editor.html | 32 --------- .../plugins/panel/singlestat/mappings.html | 58 +++++++++++++++++ public/app/plugins/panel/singlestat/module.ts | 65 +++++++++++++++---- .../singlestat/specs/singlestat-specs.ts | 25 +++++++ 4 files changed, 136 insertions(+), 44 deletions(-) create mode 100644 public/app/plugins/panel/singlestat/mappings.html diff --git a/public/app/plugins/panel/singlestat/editor.html b/public/app/plugins/panel/singlestat/editor.html index fc3c9f69542..0504277a5e1 100644 --- a/public/app/plugins/panel/singlestat/editor.html +++ b/public/app/plugins/panel/singlestat/editor.html @@ -204,35 +204,3 @@
- -
-
-
-
    -
  • - Value to text mapping -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • - -
  • - - - -
  • - -
-
-
-
-
diff --git a/public/app/plugins/panel/singlestat/mappings.html b/public/app/plugins/panel/singlestat/mappings.html new file mode 100644 index 00000000000..a1105a159dd --- /dev/null +++ b/public/app/plugins/panel/singlestat/mappings.html @@ -0,0 +1,58 @@ +
+
+
+ + Type + +
+ +
+
+
+
+
+
Set valuea mappings
+
+
+ + + + + + + + +
+ +
+ +
+
+
+
+
Set range mappings
+
+
+ + + + From + + To + + Text + +
+ +
+ +
+
+
diff --git a/public/app/plugins/panel/singlestat/module.ts b/public/app/plugins/panel/singlestat/module.ts index 3c0b9e5342a..e2e529d00c7 100644 --- a/public/app/plugins/panel/singlestat/module.ts +++ b/public/app/plugins/panel/singlestat/module.ts @@ -35,6 +35,14 @@ class SingleStatCtrl extends MetricsPanelCtrl { valueMaps: [ { value: 'null', op: '=', text: 'N/A' } ], + mappingTypes: [ + {name: 'value to text', value: 1}, + {name: 'range to text', value: 2}, + ], + rangeMaps: [ + { from: 'null', to: 'null', text: 'N/A' } + ], + mappingType: 1, nullPointMode: 'connected', valueName: 'avg', prefixFontSize: '50%', @@ -73,6 +81,7 @@ class SingleStatCtrl extends MetricsPanelCtrl { onInitEditMode() { this.fontSizes = ['20%', '30%','50%','70%','80%','100%', '110%', '120%', '150%', '170%', '200%']; this.addEditorTab('Options', 'public/app/plugins/panel/singlestat/editor.html', 2); + this.addEditorTab('Value Mappings', 'public/app/plugins/panel/singlestat/mappings.html', 3); this.unitFormats = kbn.getUnitFormats(); } @@ -197,23 +206,45 @@ class SingleStatCtrl extends MetricsPanelCtrl { } } - // check value to text mappings - for (var i = 0; i < this.panel.valueMaps.length; i++) { - var map = this.panel.valueMaps[i]; - // special null case - if (map.value === 'null') { - if (data.value === null || data.value === void 0) { + // check value to text mappings if its enabled + if (this.panel.mappingType === 1) { + for (var i = 0; i < this.panel.valueMaps.length; i++) { + var map = this.panel.valueMaps[i]; + // special null case + if (map.value === 'null') { + if (data.value === null || data.value === void 0) { + data.valueFormated = map.text; + return; + } + continue; + } + + // value/number to text mapping + var value = parseFloat(map.value); + if (value === data.valueRounded) { data.valueFormated = map.text; return; } - continue; } + } else if (this.panel.mappingType === 2) { + for (var i = 0; i < this.panel.rangeMaps.length; i++) { + var map = this.panel.rangeMaps[i]; + // special null case + if (map.from === 'null' && map.to === 'null') { + if (data.value === null || data.value === void 0) { + data.valueFormated = map.text; + return; + } + continue; + } - // value/number to text mapping - var value = parseFloat(map.value); - if (value === data.valueRounded) { - data.valueFormated = map.text; - return; + // value/number to range mapping + var from = parseFloat(map.from); + var to = parseFloat(map.to); + if (to >= data.valueRounded && from <= data.valueRounded) { + data.valueFormated = map.text; + return; + } } } @@ -232,6 +263,16 @@ class SingleStatCtrl extends MetricsPanelCtrl { this.panel.valueMaps.push({value: '', op: '=', text: '' }); } + removeRangeMap(rangeMap) { + var index = _.indexOf(this.panel.rangeMaps, rangeMap); + this.panel.rangeMaps.splice(index, 1); + this.render(); + }; + + addRangeMap() { + this.panel.rangeMaps.push({from: '', to: '', text: ''}); + } + link(scope, elem, attrs, ctrl) { var $location = this.$location; var linkSrv = this.linkSrv; diff --git a/public/app/plugins/panel/singlestat/specs/singlestat-specs.ts b/public/app/plugins/panel/singlestat/specs/singlestat-specs.ts index dc85454b64a..3d6c565443b 100644 --- a/public/app/plugins/panel/singlestat/specs/singlestat-specs.ts +++ b/public/app/plugins/panel/singlestat/specs/singlestat-specs.ts @@ -84,4 +84,29 @@ describe('SingleStatCtrl', function() { expect(ctx.data.valueFormated).to.be('OK'); }); }); + + singleStatScenario('When range to text mapping is specifiedfor first range', function(ctx) { + ctx.setup(function() { + ctx.datapoints = [[41,50]]; + ctx.ctrl.panel.mappingType = 2; + ctx.ctrl.panel.rangeMaps = [{from: '10', to: '50', text: 'OK'},{from: '51', to: '100', text: 'NOT OK'}]; + }); + + it('Should replace value with text OK', function() { + expect(ctx.data.valueFormated).to.be('OK'); + }); + }); + + singleStatScenario('When range to text mapping is specified for other ranges', function(ctx) { + ctx.setup(function() { + ctx.datapoints = [[65,75]]; + ctx.ctrl.panel.mappingType = 2; + ctx.ctrl.panel.rangeMaps = [{from: '10', to: '50', text: 'OK'},{from: '51', to: '100', text: 'NOT OK'}]; + }); + + it('Should replace value with text NOT OK', function() { + expect(ctx.data.valueFormated).to.be('NOT OK'); + }); + }); + }); From 02ae1f79f7ede9d90416029aeb31cd88bee13ffc Mon Sep 17 00:00:00 2001 From: bergquist Date: Tue, 3 May 2016 10:42:01 +0200 Subject: [PATCH 03/36] docs(changelog): add node about range to text mappings in singlestat --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a67f45e69ec..3f9a7a7b299 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 3.1.0 + +### Enhancements +* **Singlestat**: Add support for range to text mappings, closes [#1319](https://github.com/grafana/grafana/issues/1319) + # 3.0.0-beta7 (2016-05-02) ### Bug fixes From 5ee1b6ca972278fd591809043f2da7e039900676 Mon Sep 17 00:00:00 2001 From: bergquist Date: Tue, 10 May 2016 12:54:25 +0200 Subject: [PATCH 04/36] docs(changelog): add note about merged PR --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52708480ac1..0aa8bc79b94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Enhancements * **Singlestat**: Add support for range to text mappings, closes [#1319](https://github.com/grafana/grafana/issues/1319) +* **Graph**: Adds sort order options for graph tooltip, closes [#1189](https://github.com/grafana/grafana/issues/1189) # 3.0.0 stable (unreleased) From 2f6b00b6f74379eeffd0d87656f1d3d65564c944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denny=20Sch=C3=A4fer?= Date: Thu, 12 May 2016 10:41:36 +0200 Subject: [PATCH 05/36] Add What's New in Grafana 3.0 link into the readme (#5001) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 18a497092f2..6dbfc5388c2 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ Graphite, Elasticsearch, OpenTSDB, Prometheus and InfluxDB. - [What's New in Grafana 2.0](http://docs.grafana.org/guides/whats-new-in-v2/) - [What's New in Grafana 2.1](http://docs.grafana.org/guides/whats-new-in-v2-1/) - [What's New in Grafana 2.5](http://docs.grafana.org/guides/whats-new-in-v2-5/) +- [What's New in Grafana 3.0](http://docs.grafana.org/guides/whats-new-in-v3/) ## Features ### Graphite Target Editor From 9f9f4e7fef934365dc05a2135e143f46ec7e116d Mon Sep 17 00:00:00 2001 From: Dan Cech Date: Thu, 12 May 2016 04:43:31 -0400 Subject: [PATCH 06/36] use new plugin-specific repo route when installing or updating a single plugin (#4992) --- .../grafana-cli/commands/upgrade_command.go | 15 ++++++------- pkg/cmd/grafana-cli/services/services.go | 22 +++++++++++++------ 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/pkg/cmd/grafana-cli/commands/upgrade_command.go b/pkg/cmd/grafana-cli/commands/upgrade_command.go index b9ca834be6d..e788b3bdfaa 100644 --- a/pkg/cmd/grafana-cli/commands/upgrade_command.go +++ b/pkg/cmd/grafana-cli/commands/upgrade_command.go @@ -1,6 +1,8 @@ package commands import ( + "github.com/fatih/color" + "github.com/grafana/grafana/pkg/cmd/grafana-cli/log" s "github.com/grafana/grafana/pkg/cmd/grafana-cli/services" ) @@ -14,20 +16,17 @@ func upgradeCommand(c CommandLine) error { return err } - remotePlugins, err2 := s.ListAllPlugins(c.GlobalString("repo")) + v, err2 := s.GetPlugin(localPlugin.Id, c.GlobalString("repo")) if err2 != nil { return err2 } - for _, v := range remotePlugins.Plugins { - if localPlugin.Id == v.Id { - if ShouldUpgrade(localPlugin.Info.Version, v) { - s.RemoveInstalledPlugin(pluginsDir, pluginName) - return InstallPlugin(localPlugin.Id, "", c) - } - } + if ShouldUpgrade(localPlugin.Info.Version, v) { + s.RemoveInstalledPlugin(pluginsDir, pluginName) + return InstallPlugin(localPlugin.Id, "", c) } + log.Infof("%s %s is up to date \n", color.GreenString("✔"), localPlugin.Id) return nil } diff --git a/pkg/cmd/grafana-cli/services/services.go b/pkg/cmd/grafana-cli/services/services.go index f0ad460842d..2332511ed89 100644 --- a/pkg/cmd/grafana-cli/services/services.go +++ b/pkg/cmd/grafana-cli/services/services.go @@ -44,7 +44,7 @@ func ReadPlugin(pluginDir, pluginName string) (m.InstalledPlugin, error) { } if res.Id == "" { - return m.InstalledPlugin{}, errors.New("could not read find plugin " + pluginName) + return m.InstalledPlugin{}, errors.New("could not find plugin " + pluginName + " in " + pluginDir) } return res, nil @@ -69,13 +69,21 @@ func RemoveInstalledPlugin(pluginPath, id string) error { } func GetPlugin(pluginId, repoUrl string) (m.Plugin, error) { - resp, _ := ListAllPlugins(repoUrl) + fullUrl := repoUrl + "/repo/" + pluginId - for _, i := range resp.Plugins { - if i.Id == pluginId { - return i, nil - } + res, err := goreq.Request{Uri: fullUrl, MaxRedirects: 3}.Do() + if err != nil { + return m.Plugin{}, err + } + if res.StatusCode != 200 { + return m.Plugin{}, fmt.Errorf("Could not access %s statuscode %v", fullUrl, res.StatusCode) } - return m.Plugin{}, errors.New("could not find plugin named \"" + pluginId + "\"") + var resp m.Plugin + err = res.Body.FromJsonTo(&resp) + if err != nil { + return m.Plugin{}, errors.New("Could not load plugin data") + } + + return resp, nil } From c6744925c469f43ba658c5c351c3a6c21bd1c0c6 Mon Sep 17 00:00:00 2001 From: Anton Chevychalov Date: Thu, 12 May 2016 15:11:10 +0300 Subject: [PATCH 07/36] Add new parameter to config: default_theme. --- conf/defaults.ini | 3 +++ conf/sample.ini | 3 +++ pkg/services/sqlstore/preferences.go | 4 +++- pkg/setting/setting.go | 2 ++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/conf/defaults.ini b/conf/defaults.ini index f78287619a3..0a4b61fbe78 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -172,6 +172,9 @@ verify_email_enabled = false # Background text for the user field on the login page login_hint = email or username +# Default UI theme ("dark" or "light") +default_theme = dark + #################################### Anonymous Auth ########################## [auth.anonymous] # enable anonymous access diff --git a/conf/sample.ini b/conf/sample.ini index 6a26589d40d..7f358b07199 100644 --- a/conf/sample.ini +++ b/conf/sample.ini @@ -155,6 +155,9 @@ check_for_updates = true # Background text for the user field on the login page ;login_hint = email or username +# Default UI theme ("dark" or "light") +;default_theme = dark + #################################### Anonymous Auth ########################## [auth.anonymous] # enable anonymous access diff --git a/pkg/services/sqlstore/preferences.go b/pkg/services/sqlstore/preferences.go index d120c485ed3..65609a9c57c 100644 --- a/pkg/services/sqlstore/preferences.go +++ b/pkg/services/sqlstore/preferences.go @@ -5,6 +5,8 @@ import ( "github.com/grafana/grafana/pkg/bus" m "github.com/grafana/grafana/pkg/models" + + "github.com/grafana/grafana/pkg/setting" ) func init() { @@ -26,7 +28,7 @@ func GetPreferencesWithDefaults(query *m.GetPreferencesWithDefaultsQuery) error } res := &m.Preferences{ - Theme: "dark", + Theme: setting.DefaultTheme, Timezone: "browser", HomeDashboardId: 0, } diff --git a/pkg/setting/setting.go b/pkg/setting/setting.go index 2d1bad945eb..b883a8d995d 100644 --- a/pkg/setting/setting.go +++ b/pkg/setting/setting.go @@ -88,6 +88,7 @@ var ( AutoAssignOrgRole string VerifyEmailEnabled bool LoginHint string + DefaultTheme string // Http auth AdminUser string @@ -454,6 +455,7 @@ func NewConfigContext(args *CommandLineArgs) error { AutoAssignOrgRole = users.Key("auto_assign_org_role").In("Editor", []string{"Editor", "Admin", "Read Only Editor", "Viewer"}) VerifyEmailEnabled = users.Key("verify_email_enabled").MustBool(false) LoginHint = users.Key("login_hint").String() + DefaultTheme = users.Key("default_theme").String() // anonymous access AnonymousEnabled = Cfg.Section("auth.anonymous").Key("enabled").MustBool(false) From 3feb6492e6d03de265e9c5c61b5e3d0eb0126aae Mon Sep 17 00:00:00 2001 From: Prajwal Rao Date: Thu, 12 May 2016 12:49:58 -0700 Subject: [PATCH 08/36] fixed datasources icon (#5015) --- public/app/features/panel/metrics_ds_selector.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/features/panel/metrics_ds_selector.ts b/public/app/features/panel/metrics_ds_selector.ts index b281c43048b..c0e1b776062 100644 --- a/public/app/features/panel/metrics_ds_selector.ts +++ b/public/app/features/panel/metrics_ds_selector.ts @@ -10,7 +10,7 @@ var template = `
-
+