Dashboard: When saving a dashboard and another user has made changes inbetween, the user is promted with a warning if he really wants to overwrite the other's changes, Closes #718

This commit is contained in:
Torkel Ödegaard
2015-03-02 22:24:01 +01:00
parent 56c83cefe9
commit 04d25dc58a
14 changed files with 324 additions and 22 deletions

View File

@@ -11,6 +11,7 @@ import (
var (
ErrDashboardNotFound = errors.New("Account not found")
ErrDashboardWithSameNameExists = errors.New("A dashboard with the same name already exists")
ErrDashboardVersionMismatch = errors.New("The dashboard has been changed by someone else")
)
type Dashboard struct {
@@ -58,6 +59,10 @@ func (cmd *SaveDashboardCommand) GetDashboardModel() *Dashboard {
if dash.Data["id"] != nil {
dash.Id = int64(dash.Data["id"].(float64))
if dash.Data["version"] != nil {
dash.Version = int(dash.Data["version"].(float64))
}
}
return dash
@@ -79,7 +84,8 @@ func (dash *Dashboard) UpdateSlug() {
//
type SaveDashboardCommand struct {
Dashboard map[string]interface{} `json:"dashboard"`
Dashboard map[string]interface{} `json:"dashboard" binding:"Required"`
Overwrite bool `json:"overwrite"`
OrgId int64 `json:"-"`
Result *Dashboard