add dashboards interface/structs
parent
9a2e49b4d2
commit
7599369eed
|
@ -223,6 +223,39 @@ type UsersStore interface {
|
||||||
FindByEmail(ctx context.Context, Email string) (*User, error)
|
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.
|
// ExplorationID is a unique ID for an Exploration.
|
||||||
type ExplorationID int
|
type ExplorationID int
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,25 @@ package server
|
||||||
|
|
||||||
import "net/http"
|
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
|
// Dashboards returns all dashboards within the store
|
||||||
func (s *Service) Dashboards(w http.ResponseWriter, r *http.Request) {
|
func (s *Service) Dashboards(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ type getRoutesResponse struct {
|
||||||
Sources string `json:"sources"` // Location of the sources endpoint
|
Sources string `json:"sources"` // Location of the sources endpoint
|
||||||
Users string `json:"users"` // Location of the users endpoint
|
Users string `json:"users"` // Location of the users endpoint
|
||||||
Me string `json:"me"` // Location of the me 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
|
// AllRoutes returns all top level routes within chronograf
|
||||||
|
@ -22,6 +23,7 @@ func AllRoutes(logger chronograf.Logger) http.HandlerFunc {
|
||||||
Users: "/chronograf/v1/users",
|
Users: "/chronograf/v1/users",
|
||||||
Me: "/chronograf/v1/me",
|
Me: "/chronograf/v1/me",
|
||||||
Mappings: "/chronograf/v1/mappings",
|
Mappings: "/chronograf/v1/mappings",
|
||||||
|
Dashboards: "/chronograf/v1/dashboards",
|
||||||
}
|
}
|
||||||
|
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
|
@ -10,6 +10,7 @@ type Service struct {
|
||||||
LayoutStore chronograf.LayoutStore
|
LayoutStore chronograf.LayoutStore
|
||||||
AlertRulesStore chronograf.AlertRulesStore
|
AlertRulesStore chronograf.AlertRulesStore
|
||||||
UsersStore chronograf.UsersStore
|
UsersStore chronograf.UsersStore
|
||||||
|
DashboardsStore chronograf.DashboardsStore
|
||||||
TimeSeries chronograf.TimeSeries
|
TimeSeries chronograf.TimeSeries
|
||||||
Logger chronograf.Logger
|
Logger chronograf.Logger
|
||||||
UseAuth bool
|
UseAuth bool
|
||||||
|
|
Loading…
Reference in New Issue