Adding snapshot storage and route, #1623

This commit is contained in:
Torkel Ödegaard
2015-03-21 10:56:26 -04:00
parent 964f0861d6
commit f48f5428e5
7 changed files with 77 additions and 22 deletions
+8 -2
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}