Commit Graph

661 Commits

Author SHA1 Message Date
Ben Tranter
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
Torkel Ödegaard
c3bad4701a fix: annotations fix for snapshots, fixes #7659 2017-04-25 14:27:41 +02:00
Torkel Ödegaard
c78c460f79 mysql: worked on mysql data soruce 2017-04-20 17:10:23 +02:00
Torkel Ödegaard
f1276774a0 typescript: updated tslint and fixed new warnings 2017-04-20 11:16:37 +02:00
Torkel Ödegaard
809467955a Merge branch 'master' into create-annotations 2017-04-18 17:07:44 +02:00
Torkel Ödegaard
db36639ffc fix: #8111 2017-04-18 16:58:34 +02:00
Torkel Ödegaard
ff426ae9a3 more work on annotations 2017-04-14 12:23:32 +02:00
Torkel Ödegaard
dbe5480edc create annotations work 2017-04-14 11:41:02 +02:00
Torkel Ödegaard
2fce88ee62 ux: popover forms 2017-04-14 10:18:49 +02:00
Torkel Ödegaard
2f61fc6afe ux: made progress on popover forms 2017-04-13 18:39:49 +02:00
Alexander Zobnin
2142323da9 graph(create annotation): refactor, AddAnnotationModalCtrl 2017-04-12 21:07:39 +03:00
Alexander Zobnin
17d3970673 graph(create annotation): push one annotation with time from and time to 2017-04-12 21:04:18 +03:00
Alexander Zobnin
ef99ff0ad7 graph(create annotation): use single description for range 2017-04-12 20:37:33 +03:00
Torkel Ödegaard
de21be30d2 ux: working on how to show form in popover 2017-04-12 17:28:32 +02:00
Torkel Ödegaard
0156a94a49 annotations: you can now read annoations via manually created annoation query 2017-04-12 15:46:41 +02:00
Torkel Ödegaard
752b42798a annotations: added new options hide toggle, and show option 2017-04-12 15:01:17 +02:00
Alexander Zobnin
f42202e665 Merge branch 'master' into graph-annotations 2017-04-11 10:27:37 +03:00
Alexander Zobnin
362860f687 graph(add annotation): able to select region (start and stop time) #1286 2017-04-10 12:45:08 +03:00
Simen Bekkhus
21ae987bcd If earlier dashboard refresh was supressed, force a new one on page becoming visible (#8076) 2017-04-10 09:43:35 +02:00
Alexander Zobnin
32d34aed7a graph: initial Add Annotation flow #1286 2017-04-08 19:44:40 +03:00
Torkel Ödegaard
4d4e165be7 links: updated links from grafana.net to grafana.com 2017-03-20 10:20:32 +01:00
Daniel Lee
77921c4dcd renderpng: fixes invalid image link (#7797)
Closes #7770
2017-03-13 09:31:59 +01:00
Denis Doria
0264fcc66c Remove unsaved dialog when removing a dashboard #7591 (#7733) 2017-03-06 07:49:28 +01:00
Torkel Ödegaard
e73b306e0c fix(templating): fixed duplicate dashboard refresh when changing template variable, #7654 2017-02-24 08:16:37 +01:00
bergquist
d88286ab81 orgs: set orgId as query param on load
ref #1613
2017-02-23 11:03:39 +01:00
bergquist
fdb06c7c10 sharing: set orgId as query parameter when sharing a dashboard
to make sure an user opens the dashboard in the correct org, orgId will
always be added when sharing a dashboard. if the users current orgId
doesnt match the query parameter grafana will change it and redirect the
user.

closes #1613
2017-02-22 13:56:06 +01:00
Torkel Ödegaard
ac0d09c419 fix(): fixed issue with syncing refresh interval to url 2017-02-17 14:07:15 +01:00
Ryuichi Sakai
0c9f664ea0 Make timeout for snapshot creation configurable 2017-02-14 10:10:51 +01:00
Torkel Ödegaard
5fc5971145 refactor(): refactoring PR #7124 2017-01-31 08:27:48 +01:00
Torkel Ödegaard
1a9aaa4138 feat(server side png rendering): added timezone parameter for server side rendering, refactoring PR #7264 2017-01-31 07:48:10 +01:00
Torkel Ödegaard
830491fa66 Merge branch 'time-offset-to-image' of https://github.com/ryu1-sakai/grafana into ryu1-sakai-time-offset-to-image 2017-01-31 06:28:54 +01:00
Torkel Ödegaard
710d07d7a5 Merge branch 'mtanda-clipboard_js' 2017-01-16 21:08:47 +01:00
Torkel Ödegaard
09cec8535e Merge branch 'clipboard_js' of https://github.com/mtanda/grafana into mtanda-clipboard_js 2017-01-16 20:57:16 +01:00
Mitsuhiro Tanda
d683b0379b fix monkey patch for clipboard.js 2017-01-17 01:12:37 +09:00
Ryuichi Sakai
1bc55a2d38 Enable image rendering to use browser time offset 2017-01-15 22:01:28 +09:00
Torkel Ödegaard
49fe74228b fix(browser history): fixes and enhancements to browser history, it now works properly again AND it can restore previous time ranges in dashboards, closes #7259 2017-01-13 17:37:53 +01:00
Torkel Ödegaard
deff24d2c1 Merge branch 'clipboard_js' of https://github.com/mtanda/grafana into mtanda-clipboard_js 2017-01-13 14:57:23 +01:00
Mitsuhiro Tanda
1672ca4edb call clipboard destroy() 2017-01-13 02:58:44 +09:00
Mitsuhiro Tanda
3df119002d patch for clipboard.js work 2017-01-13 02:19:02 +09:00
Mitsuhiro Tanda
4b567e35d5 suppress refresh when user is inactive (#7219) 2017-01-11 19:46:34 +01:00
Mitsuhiro Tanda
1571072c18 use clipboard.js 2017-01-12 02:37:29 +09:00
Torkel Ödegaard
45d2e70ba7 feat(dashboard): sorting dashboard model kekeys, refactoring PR #7139 2017-01-06 10:09:11 +01:00
Dan Cech
df1e90c723 export sorted dashboard json 2017-01-04 18:13:33 -05:00
Torkel Ödegaard
9dc42648cf fix(templating): fixed issue with experimental feature template variable value groups tags, fixes #6752 2017-01-02 13:32:20 +01:00
Torkel Ödegaard
a361d1f488 feat(panel): refinements for panel help text, made the inspector the home for the model version 2016-12-16 16:09:02 +01:00
Torkel Ödegaard
62f3b16671 feat(panel): working on panel help text and unifying panel links, panel errors, and panel help into a single panel feature, #4079 , #6847 2016-12-16 13:06:04 +01:00
Torkel Ödegaard
b9043c915e feat(panel): working on panel help text, #4079 , #6847 2016-12-16 11:48:32 +01:00
Torkel Ödegaard
ca7bc25c83 feat(panel): working on panel help text, #4079 , #6847 2016-12-16 10:34:00 +01:00
Torkel Ödegaard
7425c63528 fix(dashboard): fixed unit test 2016-12-14 14:42:25 +01:00
Torkel Ödegaard
e72a60bbf5 feat(graph): shared graph tooltip is not a select option with 3 options, normal, shared crosshair & shared tooltip, CTRL+O or CMD+O cycles option, closes #6894 2016-12-14 14:33:33 +01:00