2022-05-25 03:41:51 -05:00
|
|
|
package dashver
|
|
|
|
|
|
|
|
import (
|
2022-05-31 04:56:05 -05:00
|
|
|
"errors"
|
2022-05-25 03:41:51 -05:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/grafana/grafana/pkg/components/simplejson"
|
|
|
|
)
|
|
|
|
|
2022-05-31 04:56:05 -05:00
|
|
|
var (
|
|
|
|
ErrDashboardVersionNotFound = errors.New("dashboard version not found")
|
2022-06-02 08:59:05 -05:00
|
|
|
ErrNoVersionsForDashboardID = errors.New("no dashboard versions found for the given DashboardId")
|
2022-05-31 04:56:05 -05:00
|
|
|
)
|
|
|
|
|
2022-05-25 03:41:51 -05:00
|
|
|
type DashboardVersion struct {
|
2022-08-25 16:04:16 -05:00
|
|
|
ID int64 `json:"id" xorm:"pk autoincr 'id'" db:"id"`
|
|
|
|
DashboardID int64 `json:"dashboardId" xorm:"dashboard_id" db:"dashboard_id"`
|
|
|
|
ParentVersion int `json:"parentVersion" db:"parent_version"`
|
|
|
|
RestoredFrom int `json:"restoredFrom" db:"restored_from"`
|
|
|
|
Version int `json:"version" db:"version"`
|
2022-05-25 03:41:51 -05:00
|
|
|
|
2022-08-25 16:04:16 -05:00
|
|
|
Created time.Time `json:"created" db:"created"`
|
|
|
|
CreatedBy int64 `json:"createdBy" db:"created_by"`
|
2022-05-25 03:41:51 -05:00
|
|
|
|
2022-08-25 16:04:16 -05:00
|
|
|
Message string `json:"message" db:"message"`
|
|
|
|
Data *simplejson.Json `json:"data" db:"data"`
|
2022-05-25 03:41:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
type GetDashboardVersionQuery struct {
|
|
|
|
DashboardID int64
|
|
|
|
OrgID int64
|
|
|
|
Version int
|
|
|
|
}
|
2022-05-31 04:56:05 -05:00
|
|
|
|
|
|
|
type DeleteExpiredVersionsCommand struct {
|
|
|
|
DeletedRows int64
|
|
|
|
}
|
2022-06-02 08:59:05 -05:00
|
|
|
|
|
|
|
type ListDashboardVersionsQuery struct {
|
|
|
|
DashboardID int64
|
|
|
|
DashboardUID string
|
|
|
|
OrgID int64
|
|
|
|
Limit int
|
|
|
|
Start int
|
|
|
|
}
|
|
|
|
|
|
|
|
type DashboardVersionDTO struct {
|
2022-08-25 16:04:16 -05:00
|
|
|
ID int64 `json:"id" xorm:"id" db:"id"`
|
|
|
|
DashboardID int64 `json:"dashboardId" xorm:"dashboard_id" db:"dashboard_id"`
|
|
|
|
DashboardUID string `json:"dashboardUid" xorm:"dashboard_uid" db:"dashboard_uid"`
|
|
|
|
ParentVersion int `json:"parentVersion" db:"parent_version"`
|
|
|
|
RestoredFrom int `json:"restoredFrom" db:"restored_from"`
|
|
|
|
Version int `json:"version" db:"version"`
|
|
|
|
Created time.Time `json:"created" db:"created"`
|
|
|
|
// Since we get created by with left join user table, this can be null technically,
|
|
|
|
// but in reality it will always be set, when database is not corrupted.
|
|
|
|
CreatedBy *string `json:"createdBy" db:"created_by_login"`
|
|
|
|
Message string `json:"message" db:"message"`
|
2022-06-02 08:59:05 -05:00
|
|
|
}
|
2022-06-08 05:22:55 -05:00
|
|
|
|
|
|
|
// DashboardVersionMeta extends the dashboard version model with the names
|
|
|
|
// associated with the UserIds, overriding the field with the same name from
|
|
|
|
// the DashboardVersion model.
|
|
|
|
type DashboardVersionMeta struct {
|
|
|
|
ID int64 `json:"id"`
|
|
|
|
DashboardID int64 `json:"dashboardId"`
|
|
|
|
DashboardUID string `json:"uid"`
|
|
|
|
ParentVersion int `json:"parentVersion"`
|
|
|
|
RestoredFrom int `json:"restoredFrom"`
|
|
|
|
Version int `json:"version"`
|
|
|
|
Created time.Time `json:"created"`
|
|
|
|
Message string `json:"message"`
|
|
|
|
Data *simplejson.Json `json:"data"`
|
|
|
|
CreatedBy string `json:"createdBy"`
|
|
|
|
}
|