70 Commits

Author SHA1 Message Date
b6e46c9eb8 History and Version Control for Dashboard Updates
A simple version control system for dashboards. Closes #1504.

Goals

1. To create a new dashboard version every time a dashboard is saved.
2. To allow users to view all versions of a given dashboard.
3. To allow users to rollback to a previous version of a dashboard.
4. To allow users to compare two versions of a dashboard.

Usage

Navigate to a dashboard, and click the settings cog. From there, click
the "Changelog" button to be brought to the Changelog view. In this
view, a table containing each version of a dashboard can be seen. Each
entry in the table represents a dashboard version. A selectable
checkbox, the version number, date created, name of the user who created
that version, and commit message is shown in the table, along with a
button that allows a user to restore to a previous version of that
dashboard. If a user wants to restore to a previous version of their
dashboard, they can do so by clicking the previously mentioned button.
If a user wants to compare two different versions of a dashboard, they
can do so by clicking the checkbox of two different dashboard versions,
then clicking the "Compare versions" button located below the dashboard.
From there, the user is brought to a view showing a summary of the
dashboard differences. Each summarized change contains a link that can
be clicked to take the user a JSON diff highlighting the changes line by
line.

Overview of Changes

Backend Changes

- A `dashboard_version` table was created to store each dashboard
  version, along with a dashboard version model and structs to represent
  the queries and commands necessary for the dashboard version API
  methods.
- API endpoints were created to support working with dashboard
  versions.
- Methods were added to create, update, read, and destroy dashboard
  versions in the database.
  - Logic was added to compute the diff between two versions, and
  display it to the user.
  - The dashboard migration logic was updated to save a "Version
  1" of each existing dashboard in the database.

Frontend Changes

- New views
- Methods to pull JSON and HTML from endpoints

New API Endpoints

Each endpoint requires the authorization header to be sent in
the format,

```
Authorization: Bearer <jwt>
```

where `<jwt>` is a JSON web token obtained from the Grafana
admin panel.

`GET "/api/dashboards/db/:dashboardId/versions?orderBy=<string>&limit=<int>&start=<int>"`

Get all dashboard versions for the given dashboard ID. Accepts
three URL parameters:

- `orderBy` String to order the results by. Possible values
  are `version`, `created`, `created_by`, `message`. Default
  is `versions`. Ordering is always in descending order.
- `limit` Maximum number of results to return
- `start` Position in results to start from

`GET "/api/dashboards/db/:dashboardId/versions/:id"`

Get an individual dashboard version by ID, for the given
dashboard ID.

`POST "/api/dashboards/db/:dashboardId/restore"`

Restore to the given dashboard version. Post body is of
content-type `application/json`, and must contain.

```json
{
  "dashboardId": <int>,
  "version": <int>
}
```

`GET "/api/dashboards/db/:dashboardId/compare/:versionA...:versionB"`

Compare two dashboard versions by ID for the given
dashboard ID, returning a JSON delta formatted
representation of the diff. The URL format follows
what GitHub does. For example, visiting
[/api/dashboards/db/18/compare/22...33](http://ec2-54-80-139-44.compute-1.amazonaws.com:3000/api/dashboards/db/18/compare/22...33)
will return the diff between versions 22 and 33 for
the dashboard ID 18.

Dependencies Added

- The Go package [gojsondiff](https://github.com/yudai/gojsondiff)
  was added and vendored.
2017-05-24 19:14:39 -04:00
05772b30d7 feat(ux): completed work on getting started panel, #6466 2016-12-08 10:25:05 +01:00
7f7f080ad8 [5443] Check if title is empty before save a new dashboard 2016-11-29 12:25:20 +02:00
421c1eed82 fix(dashboard): fixes bug when saving dashboards 2016-11-24 11:22:13 +01:00
df2b2e3058 feat(alerting): validate alerts before saving dashboard (#6691)
ref #6576
2016-11-24 09:50:35 +01:00
04f417a423 feat(alerting): enabled by default. configurable elert engine
closes #6210
2016-10-10 13:09:16 +02:00
b0fe69822a Merge branch 'master' into alerting
Conflicts:
	public/app/core/services/alert_srv.ts
	public/app/partials/confirm_modal.html
2016-07-18 18:22:35 +02:00
b2acac3a41 feat(apps): more polish on app dashboard save warning, #5529 2016-07-12 08:41:56 +02:00
d9096110f8 Merge branch 'master' into alerting
Conflicts:
	pkg/api/dashboard.go
	pkg/models/dashboards.go
	pkg/services/sqlstore/dashboard.go
2016-07-11 18:28:07 +02:00
68a8d9bc91 feat(apps): more work on plugin dashboard sync 2016-07-08 13:41:46 +02:00
d44325affd feat(apps): progress on app dashboard imports 2016-07-08 09:35:06 +02:00
2b4a9954b1 feat(alerting): progress on alerting UI and model, refactoring of dashboard parser and tests into extractor component, moved tests from sqlstore to alerting package 2016-06-11 10:13:33 +02:00
f36a44c49a Merge branch 'master' into alerting_definitions
Conflicts:
	conf/defaults.ini
	pkg/api/dashboard.go
2016-06-06 08:43:01 +02:00
35a7a3a52b feat(instrumentation): added some more timers 2016-06-03 17:00:39 +02:00
e2c794ff31 feat(instrumentation): lots of refactoring to support tag based backend, #4696 2016-06-02 21:06:49 +02:00
a8ac37f517 feat(usage_metrics): add timer metrics 2016-06-01 15:04:58 +02:00
1686d86c3b Merge branch 'master' into alerting_definitions 2016-05-30 08:26:08 +02:00
b2a4d8083e feat(alerting): add datasource ref to alert rule 2016-05-25 12:57:49 +02:00
8c2b6b532d fix(preferences): fixes broken default home dashboard
closes #5167
2016-05-25 09:56:45 +02:00
c41c771e9a fix(home dashboard): fixed handling error when default dashboard is not found, fixes #5141 2016-05-24 07:39:58 +02:00
45b2b4bc52 feat(alerting): add feature toggles for alerting functions 2016-05-23 08:00:42 +02:00
7860a2a1b8 feat(alerting): make sure dashboard id exists 2016-04-20 09:55:32 +02:00
91a1a823e2 feat(alerting): add basic tables for alerting definitions 2016-04-13 10:33:45 +02:00
ab1048b7ee feat(preferences): theme and home dashbord settings now work work on profile and org settings page 2016-04-02 13:54:06 -07:00
38a10f8be4 progress 2016-04-01 17:34:30 -07:00
7023dedc05 feat(preferences): refactoring PR #4399 2016-03-20 11:52:19 +01:00
cb42cfc6af Removed unwanted api, moved logic into backend 2016-03-17 02:29:34 -07:00
66621d762e Added getDashboardSlugById api 2016-03-17 01:01:58 -07:00
773a5631c5 Fix typo in function name 2016-02-29 10:52:57 -08:00
00a6efa15e Excluded total calculations from backend 2016-02-01 23:26:11 -08:00
972ac99b7c Added more metadata 2016-01-28 09:53:19 -08:00
58121d89fc Updated http_api docs 2016-01-27 22:02:33 -08:00
6a1192172d Api stores dashboard creator 2016-01-27 21:55:54 -08:00
d8b90721b3 Able to display login Id of the user in Last Updated By 2015-12-18 03:38:49 -08:00
af371249f9 Successfully displayed userdId in UI 2015-12-18 01:52:05 -08:00
e0ffcda32e Added UI , DB settings 2015-12-18 00:20:23 -08:00
5559ad1238 Return correct updated+created timestamps to frontend 2015-11-21 05:03:00 -08:00
09b3433e32 change(dashboards): made home dashboard and json file dashboards editable unless otherwise specified in json file, closes #2567 2015-10-26 18:54:32 +01:00
6488324cf1 enhance quota support.
now includes:
- perOrg (users, dashboards, datasources, api_keys)
- perUser (orgs)
- global (users, orgs, dashboards, datasources, api_keys, sessions)
2015-09-11 23:17:10 +08:00
852f9bd277 refactor quota settings 2015-09-11 01:47:33 +08:00
76e9ebde36 always return after errors. 2015-09-11 01:03:58 +08:00
0688050552 add quota middleware to enforce quotas. issue #321
Conflicts:
	pkg/api/api.go
2015-09-11 01:03:47 +08:00
fb7b475457 Backend: Load dashboards with capital letters in the dashboard url slug (url id), Fixes #2163 2015-06-19 14:42:55 -04:00
c709a28f02 More work on email and notification infra #1456 2015-06-05 08:15:38 +02:00
ff3843bc7f Roles: New user role that replaces the old role behavior, Closes #2088 2015-06-01 17:01:04 +02:00
85c3a0aa14 Panel menu now hides edit actions for users with role Viewer, Closes #1826 2015-06-01 16:36:15 +02:00
448a8b8d1c Major refactorings around searching, moved to seperate package, trying to move stuff out of models package, extend search support searching different types of entities and different types of dashboards, #960 2015-05-13 13:36:24 +02:00
bb7d79e6d2 Refactoring search to support more than just db dashboards 2015-05-13 10:45:53 +02:00
187834b17c Trying to get dashboard loading and dashboard meta flags like canSave, canStar more managable 2015-05-13 09:58:45 +02:00
35cc0a1cc0 Rewriting anb abstracting how dashboards are loaded, unifying db, json files, and script dashboards, #960 2015-05-12 17:39:56 +02:00