Commit Graph

31 Commits

Author SHA1 Message Date
Torkel Ödegaard
9605ab4475 Merge branch 'master' into develop 2017-10-26 15:59:50 +02:00
Torkel Ödegaard
74fcb2494a prometheus: fixed unsaved changes warning when changing time range due to step option on query model was changed in datasource.query code, fixes #9675 2017-10-26 11:46:33 +02:00
Daniel Lee
4c5bf76829 dashgrid: fix or skip tests for repeat rows 2017-10-12 12:01:13 +02:00
Torkel Ödegaard
546d489dd3 dashboard_history: restored unsaved changes modal to simple cancel, discard, save 2017-06-06 14:27:30 +02:00
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
a9c0f66cda fix(influxdb): Fix for Ad-Hoc Filters variable & changing dashboards, fixes #6821 2016-12-05 11:04:05 +01:00
Torkel Ödegaard
d9cf6a958b fix(unsaved changes): You now navigate to the intended page after saving in the unsaved changes dialog fixes #6675 2016-11-24 11:06:09 +01:00
Torkel Ödegaard
18056e53cc ux(dashboard): Fixing broken unit test made by changes for dash edit mode, #6442 2016-11-01 14:35:35 +01:00
Torkel Ödegaard
ca1f06f18f hunting memory leaks 2016-10-30 17:11:19 +01:00
Torkel Ödegaard
4d420a0c33 refactor(): dashboard row model and hunting down memory leak 2016-10-30 15:14:18 +01:00
Torkel Ödegaard
0fa0066cd9 tech(lodash): began migration work 2016-09-13 22:10:44 +02:00
Torkel Ödegaard
9868edb138 ux(): changed tooltip style 2016-04-12 13:00:33 -04:00
Torkel Ödegaard
fcd75422d5 ux(): update all confirm modals to new design 2016-03-04 20:57:10 +01:00
Torkel Ödegaard
e737dab5ca removed /app route, confusing when some assets use public/app/.. route and some use just app/... all public static assets should no use public route, app route is no more 2016-02-01 18:19:02 +01:00
Joakim Lahtinen
9c0141e84e Fixed some broken HTML.
Simplified some control flow.
2015-11-24 07:29:52 +01:00
Torkel Ödegaard
a82aa8203b Merge branch 'master' into invite 2015-07-18 10:14:45 +02:00
Torkel Ödegaard
0a59d6ab2f fix(repeat panel): fix for unwanted unsaved changes warnings when using repeat panel, #2364 2015-07-18 10:14:21 +02:00
Torkel Ödegaard
57c78bc603 feat(invite): began work on invite users dialog, #2353 2015-07-16 10:44:55 +02:00
Torkel Ödegaard
2c3aad785d Fix in unsaved changes service 2015-05-06 07:59:47 +02:00
Torkel Ödegaard
53cb0feda9 Various fixes, restored search auto focus 2015-04-28 17:28:34 +02:00
Torkel Ödegaard
14e8c15a3a Lots of new unit tests for unsaved changes service 2015-04-28 16:42:40 +02:00
Torkel Ödegaard
aaea80e053 A lot of refactoring opf unsaved changes service so it can be unit tested better 2015-04-28 13:45:59 +02:00
Torkel Ödegaard
f6a61c1ec5 Changes to unsaved changes service to ignore repeated panels and rows, #1888 2015-04-28 12:02:39 +02:00
Torkel Ödegaard
ca7aa294e0 Began wriing unit test for new panel repeat features, #1888 2015-04-27 17:20:32 +02:00
Torkel Ödegaard
29a7490af2 Small fix for unsaved changes when using save as feature 2015-04-27 10:29:04 +02:00
Torkel Ödegaard
a446286869 Fixed issue with unsaved changes srv being triggerd by starring / unstarring a dashboard, Fixes #1795 2015-04-16 17:21:03 +02:00
Torkel Ödegaard
538ec7c0a0 Unsaved changes: Do not show for snapshots, scripted and file based dashboards, Fixes #1707 2015-04-06 11:22:35 +02:00
Torkel Ödegaard
1e1a6df480 Playlist: fixed issue where dashboard title was not visible when playing playlist 2015-04-02 15:37:03 +02:00
Torkel Ödegaard
b291b18a87 Unsaved changes improvements: ignore row collapse state, ignore graph legend sort order, Closes #1702 2015-04-02 09:44:16 +02:00
Torkel Ödegaard
3b737999d6 Unsaved changes: Do not show for users with role , Fixes #1703 2015-04-02 08:08:22 +02:00
Torkel Ödegaard
fde11be279 Renamed src directory to public 2015-03-29 12:57:28 +02:00