Adding snapshot storage and route, #1623
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/grafana/grafana/pkg/api/dtos"
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/middleware"
|
||||
m "github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
)
|
||||
|
||||
func CreateDashboardSnapshotCommand(c *middleware.Context, cmd m.CreateDashboardSnapshotCommand) {
|
||||
func CreateDashboardSnapshot(c *middleware.Context, cmd m.CreateDashboardSnapshotCommand) {
|
||||
cmd.Key = util.GetRandomString(20)
|
||||
|
||||
if err := bus.Dispatch(&cmd); err != nil {
|
||||
@@ -29,5 +30,10 @@ func GetDashboardSnapshot(c *middleware.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(200, query.Result)
|
||||
dto := dtos.Dashboard{
|
||||
Model: query.Result.Dashboard,
|
||||
Meta: dtos.DashboardMeta{IsSnapshot: true},
|
||||
}
|
||||
|
||||
c.JSON(200, dto)
|
||||
}
|
||||
|
||||
@@ -27,9 +27,10 @@ type CurrentUser struct {
|
||||
}
|
||||
|
||||
type DashboardMeta struct {
|
||||
IsStarred bool `json:"isStarred"`
|
||||
IsHome bool `json:"isHome"`
|
||||
Slug string `json:"slug"`
|
||||
IsStarred bool `json:"isStarred"`
|
||||
IsHome bool `json:"isHome"`
|
||||
IsSnapshot bool `json:"isSnapshot"`
|
||||
Slug string `json:"slug"`
|
||||
}
|
||||
|
||||
type Dashboard struct {
|
||||
|
||||
@@ -3,7 +3,7 @@ package migrations
|
||||
import . "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
|
||||
|
||||
func addDashboardSnapshotMigrations(mg *Migrator) {
|
||||
snapshotV3 := Table{
|
||||
snapshotV4 := Table{
|
||||
Name: "dashboard_snapshot",
|
||||
Columns: []*Column{
|
||||
{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
|
||||
@@ -19,6 +19,6 @@ func addDashboardSnapshotMigrations(mg *Migrator) {
|
||||
},
|
||||
}
|
||||
|
||||
mg.AddMigration("create dashboard_snapshot table v3", NewAddTableMigration(snapshotV3))
|
||||
addTableIndicesMigrations(mg, "v3", snapshotV3)
|
||||
mg.AddMigration("create dashboard_snapshot table v4", NewAddTableMigration(snapshotV4))
|
||||
addTableIndicesMigrations(mg, "v4", snapshotV4)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user