add dashboards interface/structs
parent
c85b0e4e2a
commit
e68f380091
|
@ -223,6 +223,39 @@ type UsersStore interface {
|
|||
FindByEmail(ctx context.Context, Email string) (*User, error)
|
||||
}
|
||||
|
||||
// DashboardID is the dashboard ID
|
||||
type DashboardID int
|
||||
|
||||
// Dashboard represents all visual and query data for a dashboard
|
||||
type Dashboard struct {
|
||||
ID DashboardID `json:"id"`
|
||||
Cells []DashboardCell `json:"cells"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// DashboardCell holds visual and query information for a cell
|
||||
type DashboardCell struct {
|
||||
X int32 `json:"x"`
|
||||
Y int32 `json:"y"`
|
||||
W int32 `json:"w"`
|
||||
H int32 `json:"h"`
|
||||
Name string `json:"name"`
|
||||
Queries []string `json:"queries"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
// DashboardStore is the storage and retrieval of dashboards
|
||||
type DashboardStore interface {
|
||||
// Create a new Dashboard in the DashboardStore
|
||||
Add(context.Context, *Dashboard) (*Dashboard, error)
|
||||
// Delete the Dashboard from the DashboardStore
|
||||
Delete(context.Context, *Dashboard) error
|
||||
// Get retrieves a dashboard if `ID` exists.
|
||||
Get(ctx context.Context, ID DashboardID) (*Dashboard, error)
|
||||
// Update replaces the dashboard information
|
||||
Update(context.Context, *Dashboard) error
|
||||
}
|
||||
|
||||
// ExplorationID is a unique ID for an Exploration.
|
||||
type ExplorationID int
|
||||
|
||||
|
|
|
@ -2,6 +2,25 @@ package server
|
|||
|
||||
import "net/http"
|
||||
|
||||
type dashboardLinks struct {
|
||||
Self string `json:"self"` // Self link mapping to this resource
|
||||
}
|
||||
|
||||
type dashboardResponse struct {
|
||||
*chronograf.Dashboard
|
||||
Links dashboardLinks `json:"links"`
|
||||
}
|
||||
|
||||
func newDashboardResponse(d *chronograf.Dashboard) dashboardResponse {
|
||||
base := "/chronograf/v1/dashboards"
|
||||
return dashboardResponse{
|
||||
Dashboard: d,
|
||||
Links: dashboardLinks{
|
||||
Self: fmt.Sprintf("%s/%d", base, d.ID),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Dashboards returns all dashboards within the store
|
||||
func (s *Service) Dashboards(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
|
|
|
@ -7,21 +7,23 @@ import (
|
|||
)
|
||||
|
||||
type getRoutesResponse struct {
|
||||
Layouts string `json:"layouts"` // Location of the layouts endpoint
|
||||
Mappings string `json:"mappings"` // Location of the application mappings endpoint
|
||||
Sources string `json:"sources"` // Location of the sources endpoint
|
||||
Users string `json:"users"` // Location of the users endpoint
|
||||
Me string `json:"me"` // Location of the me endpoint
|
||||
Layouts string `json:"layouts"` // Location of the layouts endpoint
|
||||
Mappings string `json:"mappings"` // Location of the application mappings endpoint
|
||||
Sources string `json:"sources"` // Location of the sources endpoint
|
||||
Users string `json:"users"` // Location of the users endpoint
|
||||
Me string `json:"me"` // Location of the me endpoint
|
||||
Dashboards string `json:"dashboards"` // Location of the dashboards endpoint
|
||||
}
|
||||
|
||||
// AllRoutes returns all top level routes within chronograf
|
||||
func AllRoutes(logger chronograf.Logger) http.HandlerFunc {
|
||||
routes := getRoutesResponse{
|
||||
Sources: "/chronograf/v1/sources",
|
||||
Layouts: "/chronograf/v1/layouts",
|
||||
Users: "/chronograf/v1/users",
|
||||
Me: "/chronograf/v1/me",
|
||||
Mappings: "/chronograf/v1/mappings",
|
||||
Sources: "/chronograf/v1/sources",
|
||||
Layouts: "/chronograf/v1/layouts",
|
||||
Users: "/chronograf/v1/users",
|
||||
Me: "/chronograf/v1/me",
|
||||
Mappings: "/chronograf/v1/mappings",
|
||||
Dashboards: "/chronograf/v1/dashboards",
|
||||
}
|
||||
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
|
@ -10,6 +10,7 @@ type Service struct {
|
|||
LayoutStore chronograf.LayoutStore
|
||||
AlertRulesStore chronograf.AlertRulesStore
|
||||
UsersStore chronograf.UsersStore
|
||||
DashboardsStore chronograf.DashboardsStore
|
||||
TimeSeries chronograf.TimeSeries
|
||||
Logger chronograf.Logger
|
||||
UseAuth bool
|
||||
|
|
Loading…
Reference in New Issue