Commit Graph

57 Commits

Author SHA1 Message Date
Arve Knudsen
a5d9196a53
Chore/fix lint issues (#27704)
* Chore: Fix linting issues

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-09-22 16:22:19 +02:00
Kirchen99
5da3276db1
Dashboard: Use same min refresh interval fallback in the API as in provisioning (#25926)
* Dashboard: Solve the discrepancy between provisioning and the API, Handle min refresh interval when creating/updating dashboard via API

* Docs: Add refresh field in the example dashboard http api docs

* Update create dashboard API docs

Add refresh field in the create dashboard example response

* Fix create dashboard API docs

* Fix create dashboard API docs

* Update docs/sources/http_api/dashboard.md

Co-authored-by: Sofia Papagiannaki <papagian@users.noreply.github.com>
Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
2020-08-17 12:00:10 -07:00
Arve Knudsen
16c185c3b9
Chore: Drop xerrors dependency (#26718)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-07-31 09:45:20 +02:00
gastonqiu
f427f90a45
Chore: Aggregate save dashboard error (#26443)
* Chore: Aggregate save dashboard error
* Use errors package for error detection

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
Co-authored-by: Sofia Papagiannaki <papagian@users.noreply.github.com>
2020-07-21 11:12:01 +02:00
Arve Knudsen
41d432b5ae
Chore: Enable whitespace linter (#25903)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-07-06 20:17:28 +02:00
Arve Knudsen
5070f7a75b
Chore: Start harmonizing linting with plugin SDK (#25854)
* Chore: Harmonize linting with plugin SDK

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Chore: Fix linting issues

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-06-29 14:08:32 +02:00
Marcus Efraimsson
b22649bf8d
Dashboard: Handle min refresh interval when importing dashboard (#23959)
If refresh interval is lower than minimum refresh interval
when importing dashboard, use the minimum refresh interval
instead of returning error.

Fixes #23099
2020-04-27 21:17:28 +02:00
Carl Bergquist
5fc255bd89
Linting fixes for provisoning (#23600) 2020-04-16 05:46:20 +02:00
lfroment
72628c8ea0
Dashboard: Adds support for a global minimum dashboard refresh interval (#19416)
This feature would provide a way for administrators to limit the minimum 
dashboard refresh interval globally.
Filters out the refresh intervals available in the time picker that are lower 
than the set minimum refresh interval in the configuration .ini file
Adds the minimum refresh interval as available in the time picker.
If the user tries to enter a refresh interval that is lower than the minimum 
in the URL, defaults to the minimum interval.
When trying to update the JSON via the API, rejects the update if the 
dashboard's refresh interval is lower than the minimum.
When trying to update a dashboard via provisioning having a lower 
refresh interval than the minimum, defaults to the minimum interval 
and logs a warning. 

Fixes #3356

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2020-02-28 14:32:01 +01:00
Jon Gyllenswärd
b489c75aaf
Provisioning: fix for cannot save provisioned dashboard (#20218)
Provisioning of dashboards now always overwrite existing ones and does not look at the configuration `allowUiUpdates` anymore
2019-11-07 10:49:24 +01:00
Jon Gyllenswärd
a45ce36566
Allow saving of provisioned dashboards (#19820)
Allows saving of provisioned dashboards if the config value allowUiUpdates is set to true

Fixes #11778
2019-10-31 14:27:31 +01:00
zhulongcheng
2fff8f77dc move log package to /infra (#17023)
ref #14679

Signed-off-by: zhulongcheng <zhulongcheng.me@gmail.com>
2019-05-13 08:45:54 +02:00
Andrej Ocenas
eb82a75668
Provisioning: Show file path of provisioning file in save/delete dialogs (#16706)
* Add file path to metadata and show it in dialogs

* Make path relative to config directory

* Fix tests

* Add test for the relative path

* Refactor to use path relative to provisioner path

* Change return types

* Rename attribute

* Small fixes from review
2019-04-30 13:32:18 +02:00
Andrej Ocenas
c429934a66
Chore: Use x/xerrors instead of pkg/errors (#16668)
* Use xerrors instead of pkg/errors

* Add Wrap util func

* Move Wrap to errutil package
2019-04-23 11:50:31 +02:00
Torkel Ödegaard
8b0dd4244b
Search: Fixes search limits and adds a page parameter (#16458)
* Search: Fixes search limits and adds a page parameter

This adds a page parameter to search api without adding
any major breaking change.

It does at an api validation error when trying to use
a limit beyond 5000. This is a breaking change. We could
remove this and have it only in the docs and describe that this
is a limit that grafana will apply silently.

Fixes #16049

* Fix: Corrected wrong array slice change

* Docs: minor docs fix

* Search: fixed folder tests

* Fixed: Moved limit to correct inner query

* Search: moving limit check and page check

* Search: limit in handler is no longer needed
2019-04-17 13:07:50 +02:00
Andrej Ocenas
2d7fc55df7
Provisioning: Do not allow deletion of provisioned dashboards (#16211)
* Unprovision dashboard in case of DisableDeletion = true

* Rename command struct

* Handle removed provision files

* Allow html in confirm-modal

* Do not show confirm button without onConfirm

* Show dialog on deleting provisioned dashboard

* Changed DeleteDashboard to DeleteProvisionedDashboard

* Remove unreachable return

* Add provisioned checks to API

* Remove filter func

* Fix and add tests for deleting dashboards

* Change delete confirm text

* Added and used pkg/errors for error wrapping
2019-04-10 13:29:10 +02:00
Leonard Gram
a615b78f8a permissions: removes global access to bus from MakeUserAdmin. 2019-03-19 14:01:20 +01:00
Leonard Gram
9f8e43916d permissions: refactor. 2019-03-19 14:01:19 +01:00
Leonard Gram
0b209de5d1 dashboard: only admin permission added to dashboard in folder. 2019-03-19 13:57:30 +01:00
Leonard Gram
da3dcd1918 folder: uses service to make user admin of created folder. 2019-03-19 13:57:21 +01:00
Leonard Gram
c8c004095c permissions: broken out func for making creator admin. 2019-03-19 13:57:21 +01:00
Leonard Gram
e174f7c20b folders: admin for created folders 2019-03-19 13:57:20 +01:00
Leonard Gram
e294252e92 dashboards: user automatically becomes admin for created dashboards 2019-03-19 13:57:20 +01:00
Mario Trangoni
b7628f2060 pkg/util/{filepath.go,shortid_generator.go}: Fix golint issues
See,
$ gometalinter --vendor --deadline 10m --disable-all --enable=golint  ./...
filepath.go:12:5⚠️ error var WalkSkipDir should have name of the form ErrFoo (golint)
shortid_generator.go:11:5⚠️ var validUidPattern should be validUIDPattern (golint)
shortid_generator.go:19:6⚠️ func IsValidShortUid should be IsValidShortUID (golint)
shortid_generator.go:24:6⚠️ func GenerateShortUid should be GenerateShortUID (golint)
2019-01-28 22:37:44 +01:00
Mario Trangoni
bf90ff87cf pkg/services/dashboards/dashboard_service.go: simplify return
See,
$ gometalinter --vendor --deadline 10m --disable-all --enable=megacheck  ./...
pkg/services/dashboards/dashboard_service.go:167:2⚠️ 'if err != nil { return err }; return nil' can be simplified to 'return err' (S1013) (megacheck)
2019-01-26 14:23:10 +01:00
Torkel Ödegaard
3e873a2500
Merge pull request #14710 from grafana/fixed-gometalinter
Fixed new gotmetalinter warning
2019-01-03 07:23:45 +01:00
Torkel Ödegaard
80e441f48b Fixed new gotmetalinter warning 2019-01-02 19:17:35 +01:00
bergquist
9895b1e6d0 adds orgId to user dto for provisioned dashboards 2018-12-28 10:49:00 +01:00
Marcus Efraimsson
36aec52c08
return actual error if failing to update alert data 2018-11-22 11:19:08 +01:00
Marcus Efraimsson
9e0da02b6a
refactor dashboard alert extractor 2018-11-05 14:25:19 +01:00
Torkel Ödegaard
ec4698fb96 alerting: propagate alert validation issues to the user instead of just 'invalid alert data' message 2018-10-12 23:03:54 -07:00
Marcus Efraimsson
d7688241c6
Merge branch 'master' into readonly_dashboards 2018-04-17 16:27:51 +02:00
Marcus Efraimsson
ff4e38c1d8
provisioned dashboard validation should be made when importing a dashboard
Had to add the validate before save command before validating provisioned dashboard
so that the import would get a proper dashboard id
2018-04-13 17:54:41 +02:00
Marcus Efraimsson
79d8937ce5
provisioned dashboard validation should not be made from provisioning service
Provisioned dashboard validation should not be made when creating/updating a folder or
when provisioning service are trying to provision/create/update dashboard
2018-04-13 17:45:32 +02:00
Marcus Efraimsson
b4863002c9
permission: fix user with org viewer save/move permissions
User with org viewer role should not be able to save/move dashboards
in/to general folder.
2018-04-11 00:23:50 +02:00
bergquist
949484b949 provisioning: simplify db query
the GetProvisionedDashboardQuery wasent used for anything
else than check if a dashboard is provisioned or not. So
we simplified this query to make it more maintainable.
2018-04-10 12:30:37 +02:00
bergquist
77e7887e5e provisioning: check provisiong before saveCmd 2018-04-10 09:35:54 +02:00
bergquist
627df67992 dashboards: reject updates of provisioned dashboards 2018-03-27 15:12:47 +02:00
Julian Kornberger
0a415c50d0 Make golint happier 2018-03-22 22:38:44 +01:00
Marcus Efraimsson
87284d284e dashboard: fix import dashboard with alert rule
Importing a dashboard with alert rule(s) should be possible without receiving invalid
alert data error. This fix reverts the import logic to how it worked before Grafana v5.0,
that is import will allow dashboard with alert rule(s) but no alerts will be created.
After an import the user will need to update the dashboard for the alerts to be created.
Fixes #11227
2018-03-14 14:24:56 +01:00
Marcus Efraimsson
8a8f3bd5bb folders: fix typo 2018-02-21 11:28:11 +01:00
Marcus Efraimsson
3c6bc263dc Merge branch 'master' into 10630_folder_api 2018-02-21 11:25:56 +01:00
Marcus Efraimsson
78283b9c77 folders: extend folder service tests 2018-02-21 11:25:21 +01:00
Marcus Efraimsson
a167e19b37 folders: folder api tests 2018-02-21 11:24:54 +01:00
Marcus Efraimsson
02278f90a7 dashboards: make fake dashboard guardian available to other packages 2018-02-20 18:08:19 +01:00
Marcus Efraimsson
268fb4dc6c folders: new folder service for managing folders 2018-02-20 13:56:22 +01:00
Torkel Ödegaard
21d48df095 fix: plugin dashboard did not get plugin id after import 2018-02-20 11:30:18 +01:00
Marcus Efraimsson
53cd39fde5 Shouldn't be able to overwrite a dashboard if you don't have permissions (#10900)
* dashboards: new command for validating dashboard before update

Removes validation logic from saveDashboard and later on use the new command for validating
dashboard before saving a dashboard. This due to the fact that we need to validate permissions
for overwriting other dashboards by uid and title.

* dashboards: use the new command for validating dashboard before saving

Had to refactor dashboard provisioning a bit to be able to sidetrack the permission validation
in a somewhat reasonable way.
Adds some initial tests of the dashboard repository, but needs to be extended later. At least
now you can mock the dashboard guardian

* dashboards: removes validation logic in the save dashboard api layer

Use the dashboard repository solely for create/update dashboards and let it do all
the validation. One exception regarding quota validation which still is in api layer
since that logic is in a macaron middleware.
Need to move out-commented api tests later.

* dashboards: fix database tests for validate and saving dashboards

* dashboards: rename dashboard repository to dashboard service

Split the old dashboard repository interface in two new interfaces, IDashboardService and
IDashboardProvisioningService. Makes it more explicit when using it from the provisioning package
and there's no possibility of calling an incorrect method for saving a dashboard.

* database: make the InitTestDB function available to use from other packages

* dashboards: rename ValidateDashboardForUpdateCommand and some refactoring

* dashboards: integration tests of dashboard service

* dashboard: fix sqlstore test due to folder exist validation

* dashboards: move dashboard service integration tests to sqlstore package

Had to move it to the sqlstore package due to concurrency problems when running
against mysql and postgres. Using InitTestDB from two packages added conflicts
when clearing and running migrations on the test database

* dashboards: refactor how to find id to be used for save permission check

* dashboards: remove duplicated dashboard tests

* dashboards: cleanup dashboard service integration tests

* dashboards: handle save dashboard errors and return correct http status

* fix: remove log statement

* dashboards: import dashboard should use dashboard service

Had to move alerting commands to models package due to problems with import cycles of packages.

* dashboards: cleanup dashboard api tests and add some tests for post dashboard

* dashboards: rename dashboard service interfaces

* dashboards: rename dashboard guardian interface
2018-02-19 11:12:56 +01:00
bergquist
8954559cbd dashboard: whitelist allowed chars for uid 2018-02-15 09:56:13 +01:00
Leonard Gram
e0abd862e0 provisioning: fixed bug in saving dashboards. 2018-02-08 16:36:53 +01:00