pull/691/head
Jade McGough 2016-12-08 19:28:40 -08:00
parent 7599369eed
commit 70e64b6baf
5 changed files with 61 additions and 2 deletions

View File

@ -21,6 +21,7 @@ type Client struct {
LayoutStore *LayoutStore
UsersStore *UsersStore
AlertsStore *AlertsStore
DashboardsStore *DashboardsStore
}
func NewClient() *Client {
@ -34,6 +35,7 @@ func NewClient() *Client {
client: c,
IDs: &uuid.V4{},
}
c.DashboardsStore = &DashboardsStore{client: c}
return c
}

36
bolt/dashboards.go Normal file
View File

@ -0,0 +1,36 @@
package bolt
import (
"context"
"github.com/boltdb/bolt"
"github.com/influxdata/chronograf"
"github.com/influxdata/chronograf/bolt/internal"
)
var _ chronograf.DashboardsStore = &DashboardsStore{}
type DashboardsStore struct {
client *Client
}
func (s *DashboardsStore) All(ctx context.Context) ([]chronograf.Dashboard, error) {
var srcs []chronograf.Dashboard
if err := s.client.db.View(func(tx *bolt.Tx) error {
if err := tx.Bucket(DashboardBucket).ForEach(func(k, v []byte) error {
var src chonograf.Dashboard
if err := internal.UnmarshalDashboard(v, &src); err != nil {
return err
}
srcs = append(srcs, src)
return nil
}); err != nil {
return err
}
return nil
}); err != nil {
return nil, err
}
return srcs, nil
}

View File

@ -188,6 +188,12 @@ func UnmarshalLayout(data []byte, l *chronograf.Layout) error {
return nil
}
func MarshalDashboard(d chronograf.Dashboard) ([]byte, error) {
return proto.Marshal(&Dashboard{
})
}
// ScopedAlert contains the source and the kapacitor id
type ScopedAlert struct {
chronograf.AlertRule

View File

@ -244,8 +244,8 @@ type DashboardCell struct {
Type string `json:"type"`
}
// DashboardStore is the storage and retrieval of dashboards
type DashboardStore interface {
// DashboardsStore is the storage and retrieval of dashboards
type DashboardsStore interface {
// Create a new Dashboard in the DashboardStore
Add(context.Context, *Dashboard) (*Dashboard, error)
// Delete the Dashboard from the DashboardStore

15
server/dashboards_test.go Normal file
View File

@ -0,0 +1,15 @@
package handlers
//
// import (
// "net/http"
// "testing"
// )
//
// func TestDashboards(t *testing.T) {
//
// _, err := http.NewRequest("GET", "/chronograf/v1/dashbords", nil)
// if err != nil {
// t.Fatal(err)
// }
//
// }