From 2244224b120525b31109a98f99b59d03ab4de699 Mon Sep 17 00:00:00 2001 From: Dan Cech Date: Mon, 25 Apr 2016 12:44:26 -0400 Subject: [PATCH 01/11] add basic Makefile, remove need for global grunt-cli --- Makefile | 17 +++++++++++++++++ README.md | 4 +--- build.go | 2 +- package.json | 1 + 4 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 00000000000..ccf8246cabf --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +all: deps build + +deps: + go run build.go setup + godep restore + npm install + +build: + go run build.go build + npm run build + +test: + godep go test -v ./pkg/... + npm run test + +run: + ./bin/grafana-server diff --git a/README.md b/README.md index 931055349cf..d538ba78e1e 100644 --- a/README.md +++ b/README.md @@ -103,8 +103,7 @@ npm (v2.5.0) and grunt (v0.4.5). Run the following: ```bash npm install -npm install -g grunt-cli -grunt +npm run build ``` ### Recompile backend on source change @@ -145,4 +144,3 @@ please [sign the CLA](http://docs.grafana.org/project/cla/) Grafana is distributed under Apache 2.0 License. Work in progress Grafana 2.0 (with included Grafana backend) - diff --git a/build.go b/build.go index 93b9e6db087..0965a405e70 100644 --- a/build.go +++ b/build.go @@ -306,7 +306,7 @@ func ChangeWorkingDir(dir string) { } func grunt(params ...string) { - runPrint("./node_modules/grunt-cli/bin/grunt", params...) + runPrint("./node_modules/.bin/grunt", params...) } func setup() { diff --git a/package.json b/package.json index e71a9049dde..e314476f999 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,7 @@ "npm": "2.14.x" }, "scripts": { + "build": "grunt", "test": "grunt test", "coveralls": "grunt karma:coveralls && rm -rf ./coverage" }, From 650bb4c719800c3ec9ac66927f9b963f737f1ec9 Mon Sep 17 00:00:00 2001 From: Dan Cech Date: Mon, 25 Apr 2016 12:53:15 -0400 Subject: [PATCH 02/11] use npm test to run npm tests --- Makefile | 2 +- circle.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index ccf8246cabf..6cccaa7f64b 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ build: test: godep go test -v ./pkg/... - npm run test + npm test run: ./bin/grafana-server diff --git a/circle.yml b/circle.yml index 22dab8ab893..02f9f91e103 100644 --- a/circle.yml +++ b/circle.yml @@ -25,12 +25,12 @@ test: # Go test - godep go test -v ./pkg/... # js tests - - ./node_modules/grunt-cli/bin/grunt test + - npm test - npm run coveralls deployment: master: branch: master owner: grafana - commands: + commands: - ./trigger_grafana_packer.sh ${TRIGGER_GRAFANA_PACKER_CIRCLECI_TOKEN} From 9316bcf30761b263ba9b0d9898499c3091142ef2 Mon Sep 17 00:00:00 2001 From: bergquist Date: Tue, 26 Apr 2016 09:51:31 +0200 Subject: [PATCH 03/11] fix(singlestat): enables autoupdate on change closes #4809 closes #4812 --- public/app/plugins/panel/singlestat/module.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/public/app/plugins/panel/singlestat/module.ts b/public/app/plugins/panel/singlestat/module.ts index 0e28aa8baba..de9a5520f74 100644 --- a/public/app/plugins/panel/singlestat/module.ts +++ b/public/app/plugins/panel/singlestat/module.ts @@ -278,6 +278,14 @@ class SingleStatCtrl extends MetricsPanelCtrl { return body; } + function getValueText() { + var result = panel.prefix ? panel.prefix : ''; + result += data.valueFormated; + result += panel.postfix ? panel.postfix : ''; + + return result; + } + function addGauge() { var plotCanvas = $('
'); var plotCss = { @@ -332,7 +340,7 @@ class SingleStatCtrl extends MetricsPanelCtrl { }, value: { color: panel.colorValue ? getColorForValue(data, data.valueRounded) : null, - formatter: function () { return data.valueFormated; }, + formatter: function() { return getValueText(); }, font: { size: getGaugeFontSize() } }, show: true @@ -419,6 +427,7 @@ class SingleStatCtrl extends MetricsPanelCtrl { function render() { if (!ctrl.data) { return; } + ctrl.setValues(ctrl.data); data = ctrl.data; setElementHeight(); From 79ed99a94062eba08e8381924ba9d4a8355600dc Mon Sep 17 00:00:00 2001 From: bergquist Date: Tue, 26 Apr 2016 10:00:13 +0200 Subject: [PATCH 04/11] fix(singlestat): fixes font size diffs for gauge --- public/app/plugins/panel/singlestat/module.ts | 4 ++-- public/sass/components/_panel_singlestat.scss | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/panel/singlestat/module.ts b/public/app/plugins/panel/singlestat/module.ts index de9a5520f74..8033e73468d 100644 --- a/public/app/plugins/panel/singlestat/module.ts +++ b/public/app/plugins/panel/singlestat/module.ts @@ -341,7 +341,7 @@ class SingleStatCtrl extends MetricsPanelCtrl { value: { color: panel.colorValue ? getColorForValue(data, data.valueRounded) : null, formatter: function() { return getValueText(); }, - font: { size: getGaugeFontSize() } + font: { size: getGaugeFontSize(), family: 'Helvetica Neue", Helvetica, Arial, sans-serif' } }, show: true } @@ -360,7 +360,7 @@ class SingleStatCtrl extends MetricsPanelCtrl { function getGaugeFontSize() { if (panel.valueFontSize) { var num = parseInt(panel.valueFontSize.substring(0, panel.valueFontSize.length - 1)); - return 30 * (num / 100); + return (30 * (num / 100)) + 15; } else { return 30; } diff --git a/public/sass/components/_panel_singlestat.scss b/public/sass/components/_panel_singlestat.scss index 84de79c387e..fac2f716674 100644 --- a/public/sass/components/_panel_singlestat.scss +++ b/public/sass/components/_panel_singlestat.scss @@ -48,4 +48,8 @@ } } +#flotGagueValue0 { + font-weight: bold; //please dont hurt me for this! +} + From baac7809c5d1c10a9f8efa2b470139b678a95395 Mon Sep 17 00:00:00 2001 From: bergquist Date: Tue, 26 Apr 2016 10:04:39 +0200 Subject: [PATCH 05/11] docs(changelog): add notes about fixes for singlestat --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d4ee020dce..a61e0d66c65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ * **Graph**: Fixed issue with unneeded scrollbar in legend for Firefox, fixes [#4760](https://github.com/grafana/grafana/issues/4760) * **Table panel**: Fixed issue table panel formating string array properties, fixes [#4791](https://github.com/grafana/grafana/issues/4791) * **grafana-cli**: Improve error message when failing to install plugins due to corrupt response, fixes [#4651](https://github.com/grafana/grafana/issues/4651) +* **Singlestat**: Fixes prefix an postfix for gauges, fixes [#4812](https://github.com/grafana/grafana/issues/4812) +* **Singlestat**: Fixes auto-refresh on change for some options, fixes [#4809](https://github.com/grafana/grafana/issues/4809) # 3.0.0-beta5 (2016-04-15) From 0762c38d3552df499659ae36ac496e8f2b2d878f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 26 Apr 2016 10:59:57 +0200 Subject: [PATCH 06/11] fix(ds_edit): dont show warning when data source does not support testing, fixes #4811 --- public/app/features/plugins/ds_edit_ctrl.ts | 8 ++++---- public/app/features/plugins/partials/ds_edit.html | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/app/features/plugins/ds_edit_ctrl.ts b/public/app/features/plugins/ds_edit_ctrl.ts index e7e8014ed10..a3e78c33a15 100644 --- a/public/app/features/plugins/ds_edit_ctrl.ts +++ b/public/app/features/plugins/ds_edit_ctrl.ts @@ -98,9 +98,7 @@ export class DataSourceEditCtrl { this.datasourceSrv.get(this.current.name).then(datasource => { if (!datasource.testDatasource) { - this.testing.message = 'Data source does not support test connection feature.'; - this.testing.status = 'warning'; - this.testing.title = 'Unknown'; + delete this.testing; return; } @@ -118,7 +116,9 @@ export class DataSourceEditCtrl { } }); }).finally(() => { - this.testing.done = true; + if (this.testing) { + this.testing.done = true; + } }); } diff --git a/public/app/features/plugins/partials/ds_edit.html b/public/app/features/plugins/partials/ds_edit.html index 6ad0c40fa68..4756428bead 100644 --- a/public/app/features/plugins/partials/ds_edit.html +++ b/public/app/features/plugins/partials/ds_edit.html @@ -53,7 +53,7 @@ -
+
Testing....
{{ctrl.testing.title}}
From 34cb17546dc94f16a4afbfaf1b05ffb27e520d81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 26 Apr 2016 12:39:24 +0200 Subject: [PATCH 07/11] fix(): minor fix for event emitter --- public/app/core/utils/emitter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/core/utils/emitter.ts b/public/app/core/utils/emitter.ts index 5f3f61cca2e..4cdc19e7b20 100644 --- a/public/app/core/utils/emitter.ts +++ b/public/app/core/utils/emitter.ts @@ -23,7 +23,7 @@ export class Emitter { this.emitter.on(name, handler); if (scope) { - scope.$on('$destroy', function() { + scope.$on('$destroy', () => { this.emitter.off(name, handler); }); } From bce5c447b34579107ec2913ccad0e4f8a598f54b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 26 Apr 2016 12:52:44 +0200 Subject: [PATCH 08/11] fix(apps): app dashboards can now be updated, fixes #4817 --- pkg/api/dtos/plugins.go | 2 +- pkg/api/plugins.go | 11 ++++++----- pkg/plugins/dashboard_importer.go | 12 +++++++----- .../features/plugins/import_list/import_list.html | 8 ++++---- .../app/features/plugins/import_list/import_list.ts | 4 ++-- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/pkg/api/dtos/plugins.go b/pkg/api/dtos/plugins.go index fbdf8d4e0ea..7d46cc9d348 100644 --- a/pkg/api/dtos/plugins.go +++ b/pkg/api/dtos/plugins.go @@ -48,6 +48,6 @@ func (slice PluginList) Swap(i, j int) { type ImportDashboardCommand struct { PluginId string `json:"pluginId"` Path string `json:"path"` - Reinstall bool `json:"reinstall"` + Overwrite bool `json:"overwrite"` Inputs []plugins.ImportDashboardInput `json:"inputs"` } diff --git a/pkg/api/plugins.go b/pkg/api/plugins.go index 6446f7fee33..ad81d438978 100644 --- a/pkg/api/plugins.go +++ b/pkg/api/plugins.go @@ -156,11 +156,12 @@ func GetPluginReadme(c *middleware.Context) Response { func ImportDashboard(c *middleware.Context, apiCmd dtos.ImportDashboardCommand) Response { cmd := plugins.ImportDashboardCommand{ - OrgId: c.OrgId, - UserId: c.UserId, - PluginId: apiCmd.PluginId, - Path: apiCmd.Path, - Inputs: apiCmd.Inputs, + OrgId: c.OrgId, + UserId: c.UserId, + PluginId: apiCmd.PluginId, + Path: apiCmd.Path, + Inputs: apiCmd.Inputs, + Overwrite: apiCmd.Overwrite, } if err := bus.Dispatch(&cmd); err != nil { diff --git a/pkg/plugins/dashboard_importer.go b/pkg/plugins/dashboard_importer.go index 834bfabd048..4d2757b9a0e 100644 --- a/pkg/plugins/dashboard_importer.go +++ b/pkg/plugins/dashboard_importer.go @@ -11,12 +11,13 @@ import ( ) type ImportDashboardCommand struct { - Path string `json:"string"` - Inputs []ImportDashboardInput `json:"inputs"` + Path string + Inputs []ImportDashboardInput + Overwrite bool - OrgId int64 `json:"-"` - UserId int64 `json:"-"` - PluginId string `json:"-"` + OrgId int64 + UserId int64 + PluginId string Result *PluginDashboardInfoDTO } @@ -67,6 +68,7 @@ func ImportDashboard(cmd *ImportDashboardCommand) error { Dashboard: generatedDash, OrgId: cmd.OrgId, UserId: cmd.UserId, + Overwrite: cmd.Overwrite, } if err := bus.Dispatch(&saveCmd); err != nil { diff --git a/public/app/features/plugins/import_list/import_list.html b/public/app/features/plugins/import_list/import_list.html index acb6654d520..86534f1adc7 100644 --- a/public/app/features/plugins/import_list/import_list.html +++ b/public/app/features/plugins/import_list/import_list.html @@ -15,16 +15,16 @@ v{{dash.revision}} - - - Imported v{{dash.installedRevision}} + +  (Imported v{{dash.installedRevision}}) +