Merge pull request #1859 from influxdata/feature/tr-layout-cell-axes

Add Axes to Layout Cells
pull/1887/head
Timothy J. Raymond 2017-08-16 16:45:26 -04:00 committed by GitHub
commit 50a05c7f6e
9 changed files with 339 additions and 146 deletions

View File

@ -19,6 +19,7 @@
1. [#1866](https://github.com/influxdata/chronograf/pull/1866): Fix non-persistence of dashboard graph types 1. [#1866](https://github.com/influxdata/chronograf/pull/1866): Fix non-persistence of dashboard graph types
### Features ### Features
1. [#1859](https://github.com/influxdata/chronograf/pull/1859): Add y-axis controls to the API for layouts
### UI Improvements ### UI Improvements
1. [#1846](https://github.com/influxdata/chronograf/pull/1846): Increase screen real estate of Query Maker in the Cell Editor Overlay 1. [#1846](https://github.com/influxdata/chronograf/pull/1846): Increase screen real estate of Query Maker in the Cell Editor Overlay

View File

@ -98,6 +98,14 @@ func MarshalLayout(l chronograf.Layout) ([]byte, error) {
} }
} }
axes := make(map[string]*Axis, len(c.Axes))
for a, r := range c.Axes {
axes[a] = &Axis{
Bounds: r.Bounds,
Label: r.Label,
}
}
cells[i] = &Cell{ cells[i] = &Cell{
X: c.X, X: c.X,
Y: c.Y, Y: c.Y,
@ -107,6 +115,7 @@ func MarshalLayout(l chronograf.Layout) ([]byte, error) {
Name: c.Name, Name: c.Name,
Queries: queries, Queries: queries,
Type: c.Type, Type: c.Type,
Axes: axes,
} }
} }
return proto.Marshal(&Layout{ return proto.Marshal(&Layout{
@ -148,6 +157,13 @@ func UnmarshalLayout(data []byte, l *chronograf.Layout) error {
} }
} }
} }
axes := make(map[string]chronograf.Axis, len(c.Axes))
for a, r := range c.Axes {
axes[a] = chronograf.Axis{
Bounds: r.Bounds,
Label: r.Label,
}
}
cells[i] = chronograf.Cell{ cells[i] = chronograf.Cell{
X: c.X, X: c.X,
@ -158,6 +174,7 @@ func UnmarshalLayout(data []byte, l *chronograf.Layout) error {
Name: c.Name, Name: c.Name,
Queries: queries, Queries: queries,
Type: c.Type, Type: c.Type,
Axes: axes,
} }
} }
l.Cells = cells l.Cells = cells

View File

@ -217,16 +217,17 @@ func (m *Layout) GetCells() []*Cell {
} }
type Cell struct { type Cell struct {
X int32 `protobuf:"varint,1,opt,name=x,proto3" json:"x,omitempty"` X int32 `protobuf:"varint,1,opt,name=x,proto3" json:"x,omitempty"`
Y int32 `protobuf:"varint,2,opt,name=y,proto3" json:"y,omitempty"` Y int32 `protobuf:"varint,2,opt,name=y,proto3" json:"y,omitempty"`
W int32 `protobuf:"varint,3,opt,name=w,proto3" json:"w,omitempty"` W int32 `protobuf:"varint,3,opt,name=w,proto3" json:"w,omitempty"`
H int32 `protobuf:"varint,4,opt,name=h,proto3" json:"h,omitempty"` H int32 `protobuf:"varint,4,opt,name=h,proto3" json:"h,omitempty"`
Queries []*Query `protobuf:"bytes,5,rep,name=queries" json:"queries,omitempty"` Queries []*Query `protobuf:"bytes,5,rep,name=queries" json:"queries,omitempty"`
I string `protobuf:"bytes,6,opt,name=i,proto3" json:"i,omitempty"` I string `protobuf:"bytes,6,opt,name=i,proto3" json:"i,omitempty"`
Name string `protobuf:"bytes,7,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,7,opt,name=name,proto3" json:"name,omitempty"`
Yranges []int64 `protobuf:"varint,8,rep,name=yranges" json:"yranges,omitempty"` Yranges []int64 `protobuf:"varint,8,rep,name=yranges" json:"yranges,omitempty"`
Ylabels []string `protobuf:"bytes,9,rep,name=ylabels" json:"ylabels,omitempty"` Ylabels []string `protobuf:"bytes,9,rep,name=ylabels" json:"ylabels,omitempty"`
Type string `protobuf:"bytes,10,opt,name=type,proto3" json:"type,omitempty"` Type string `protobuf:"bytes,10,opt,name=type,proto3" json:"type,omitempty"`
Axes map[string]*Axis `protobuf:"bytes,11,rep,name=axes" json:"axes,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value"`
} }
func (m *Cell) Reset() { *m = Cell{} } func (m *Cell) Reset() { *m = Cell{} }
@ -241,6 +242,13 @@ func (m *Cell) GetQueries() []*Query {
return nil return nil
} }
func (m *Cell) GetAxes() map[string]*Axis {
if m != nil {
return m.Axes
}
return nil
}
type Query struct { type Query struct {
Command string `protobuf:"bytes,1,opt,name=Command,proto3" json:"Command,omitempty"` Command string `protobuf:"bytes,1,opt,name=Command,proto3" json:"Command,omitempty"`
DB string `protobuf:"bytes,2,opt,name=DB,proto3" json:"DB,omitempty"` DB string `protobuf:"bytes,2,opt,name=DB,proto3" json:"DB,omitempty"`
@ -315,66 +323,67 @@ func init() {
func init() { proto.RegisterFile("internal.proto", fileDescriptorInternal) } func init() { proto.RegisterFile("internal.proto", fileDescriptorInternal) }
var fileDescriptorInternal = []byte{ var fileDescriptorInternal = []byte{
// 974 bytes of a gzipped FileDescriptorProto // 985 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xbc, 0x56, 0xdf, 0x6e, 0xe3, 0xc4, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xbc, 0x56, 0xcd, 0x6e, 0x23, 0x45,
0x17, 0xd6, 0xc4, 0x76, 0x12, 0x9f, 0x76, 0xfb, 0xfb, 0x69, 0xb4, 0x62, 0xcd, 0x72, 0x13, 0x2c, 0x10, 0x56, 0xcf, 0x8f, 0xed, 0x29, 0x67, 0x03, 0x6a, 0xad, 0xd8, 0x61, 0xb9, 0x98, 0x11, 0x48,
0x90, 0x02, 0x12, 0x05, 0xed, 0x0a, 0x09, 0x71, 0x97, 0x36, 0x68, 0x55, 0xda, 0x5d, 0xca, 0xa4, 0x06, 0x41, 0x40, 0xbb, 0x42, 0x42, 0xdc, 0x9c, 0x18, 0xad, 0x42, 0xb2, 0x4b, 0x68, 0x27, 0x81,
0x2d, 0xdc, 0xa0, 0xd5, 0xc4, 0x39, 0x4d, 0xac, 0x75, 0x62, 0x33, 0xb6, 0x9b, 0xf8, 0x2d, 0x78, 0x0b, 0x5a, 0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c4, 0x90, 0x6b, 0x00, 0xff, 0x10, 0x7c, 0x41, 0xe4, 0x69, 0x86, 0x77, 0xe6, 0xa2, 0xc3, 0xc2,
0xda, 0x00, 0xcd, 0x9d, 0x6e, 0xd1, 0x8c, 0x23, 0x47, 0x18, 0x10, 0xfe, 0x00, 0xfe, 0x24, 0x41, 0x64, 0xa3, 0xc7, 0xf6, 0x1a, 0x55, 0xb9, 0xc8, 0x73, 0x54, 0x56, 0x4a, 0x06, 0xe8, 0xda, 0xd9,
0x55, 0x88, 0x32, 0x79, 0x7d, 0x88, 0x71, 0x70, 0xbf, 0x9e, 0x7d, 0xf3, 0xa2, 0xee, 0x04, 0x5a, 0x1a, 0x8d, 0x0b, 0xba, 0xc2, 0x80, 0xe8, 0x47, 0x08, 0x26, 0x29, 0xaa, 0x52, 0x54, 0xe9, 0xcb,
0xb7, 0xfe, 0x75, 0xfe, 0xe1, 0xdf, 0x73, 0x99, 0xc9, 0xb3, 0xa9, 0x2e, 0xac, 0x23, 0x2c, 0x0a, 0xde, 0xc9, 0xc1, 0xfb, 0x66, 0xf6, 0xed, 0xb3, 0x46, 0x80, 0x74, 0xde, 0xca, 0xc6, 0xfd, 0x97,
0x3f, 0x06, 0x97, 0xfa, 0xa4, 0xc3, 0xec, 0xbe, 0xa9, 0xc7, 0xe6, 0x7d, 0xfd, 0xaf, 0xf2, 0xf4, 0x6c, 0x4e, 0x64, 0x2e, 0x8f, 0xa7, 0x7a, 0x9f, 0x5c, 0x61, 0x51, 0xf4, 0x31, 0x78, 0x24, 0xcf,
0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x79, 0x79, 0x87, 0x37, 0xbd, 0x08, 0x00, 0x00, 0x4e, 0x65, 0xef, 0x55, 0xd2, 0x9e, 0xf7, 0xf4, 0x5f, 0xa4, 0xc7, 0xff, 0x04, 0x00, 0x00, 0xff,
0xff, 0x5a, 0xf0, 0x92, 0xd4, 0x34, 0x09, 0x00, 0x00,
} }

View File

@ -93,6 +93,7 @@ message Cell {
repeated int64 yranges = 8; // Limits of the y-axes repeated int64 yranges = 8; // Limits of the y-axes
repeated string ylabels = 9; // Labels of the y-axes repeated string ylabels = 9; // Labels of the y-axes
string type = 10; // Cell visualization type string type = 10; // Cell visualization type
map<string, Axis> axes = 11; // Axes represent the graphical viewport for a cell's visualizations
} }
message Query { message Query {

View File

@ -108,6 +108,12 @@ func TestMarshalLayout(t *testing.T) {
I: "anotherid", I: "anotherid",
Type: "line", Type: "line",
Name: "cell1", Name: "cell1",
Axes: map[string]chronograf.Axis{
"y": chronograf.Axis{
Bounds: []string{"0", "100"},
Label: "foo",
},
},
Queries: []chronograf.Query{ Queries: []chronograf.Query{
{ {
Range: &chronograf.Range{ Range: &chronograf.Range{
@ -133,8 +139,8 @@ func TestMarshalLayout(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} else if err := internal.UnmarshalLayout(buf, &vv); err != nil { } else if err := internal.UnmarshalLayout(buf, &vv); err != nil {
t.Fatal(err) t.Fatal(err)
} else if !reflect.DeepEqual(layout, vv) { } else if !cmp.Equal(layout, vv) {
t.Fatalf("source protobuf copy error: got %#v, expected %#v", vv, layout) t.Fatal("source protobuf copy error: diff:\n", cmp.Diff(layout, vv))
} }
} }

View File

@ -675,14 +675,15 @@ type DashboardsStore interface {
// Cell is a rectangle and multiple time series queries to visualize. // Cell is a rectangle and multiple time series queries to visualize.
type Cell struct { type Cell struct {
X int32 `json:"x"` X int32 `json:"x"`
Y int32 `json:"y"` Y int32 `json:"y"`
W int32 `json:"w"` W int32 `json:"w"`
H int32 `json:"h"` H int32 `json:"h"`
I string `json:"i"` I string `json:"i"`
Name string `json:"name"` Name string `json:"name"`
Queries []Query `json:"queries"` Queries []Query `json:"queries"`
Type string `json:"type"` Axes map[string]Axis `json:"axes"`
Type string `json:"type"`
} }
// Layout is a collection of Cells for visualization // Layout is a collection of Cells for visualization

37
mocks/layouts.go Normal file
View File

@ -0,0 +1,37 @@
package mocks
import (
"context"
"github.com/influxdata/chronograf"
)
var _ chronograf.LayoutStore = &LayoutStore{}
type LayoutStore struct {
AddF func(ctx context.Context, layout chronograf.Layout) (chronograf.Layout, error)
AllF func(ctx context.Context) ([]chronograf.Layout, error)
DeleteF func(ctx context.Context, layout chronograf.Layout) error
GetF func(ctx context.Context, id string) (chronograf.Layout, error)
UpdateF func(ctx context.Context, layout chronograf.Layout) error
}
func (s *LayoutStore) Add(ctx context.Context, layout chronograf.Layout) (chronograf.Layout, error) {
return s.AddF(ctx, layout)
}
func (s *LayoutStore) All(ctx context.Context) ([]chronograf.Layout, error) {
return s.AllF(ctx)
}
func (s *LayoutStore) Delete(ctx context.Context, layout chronograf.Layout) error {
return s.DeleteF(ctx, layout)
}
func (s *LayoutStore) Get(ctx context.Context, id string) (chronograf.Layout, error) {
return s.GetF(ctx, id)
}
func (s *LayoutStore) Update(ctx context.Context, layout chronograf.Layout) error {
return s.UpdateF(ctx, layout)
}

View File

@ -23,6 +23,23 @@ func newLayoutResponse(layout chronograf.Layout) layoutResponse {
httpAPILayouts := "/chronograf/v1/layouts" httpAPILayouts := "/chronograf/v1/layouts"
href := fmt.Sprintf("%s/%s", httpAPILayouts, layout.ID) href := fmt.Sprintf("%s/%s", httpAPILayouts, layout.ID)
rel := "self" rel := "self"
for idx, cell := range layout.Cells {
axes := []string{"x", "y", "y2"}
if cell.Axes == nil {
layout.Cells[idx].Axes = make(map[string]chronograf.Axis, len(axes))
}
for _, axis := range axes {
if _, found := cell.Axes[axis]; !found {
layout.Cells[idx].Axes[axis] = chronograf.Axis{
Bounds: []string{},
}
}
}
}
return layoutResponse{ return layoutResponse{
Layout: layout, Layout: layout,
Link: link{ Link: link{

View File

@ -1,79 +1,183 @@
package server_test package server_test
/* import (
func TestNewLayout(t *testing.T) { "context"
t.Parallel() "encoding/json"
var tests = []struct { "net/http/httptest"
Desc string "net/url"
AddError error "strings"
ExistingLayouts map[string]chronograf.Layout "testing"
NewLayout *models.Layout
ExpectedID int "github.com/google/go-cmp/cmp"
ExpectedHref string "github.com/influxdata/chronograf"
ExpectedStatus int "github.com/influxdata/chronograf/mocks"
"github.com/influxdata/chronograf/server"
)
func Test_Layouts(t *testing.T) {
layoutTests := []struct {
name string
expected chronograf.Layout
allLayouts []chronograf.Layout
focusedApp string // should filter all layouts to this app only
shouldErr bool
}{ }{
{ {
Desc: "Test that an error in datastore returns 500 status", "empty layout",
AddError: errors.New("error"), chronograf.Layout{},
NewLayout: &models.Layout{ []chronograf.Layout{},
Measurement: new(string), "",
App: new(string), false,
Cells: []*models.Cell{
&models.Cell{
X: new(int32),
Y: new(int32),
W: new(int32),
H: new(int32),
},
},
},
ExpectedStatus: http.StatusInternalServerError,
}, },
{ {
Desc: "Test that creating a layout returns 201 status", "several layouts",
ExistingLayouts: map[string]chronograf.Layout{}, chronograf.Layout{
NewLayout: &models.Layout{ ID: "d20a21c8-69f1-4780-90fe-e69f5e4d138c",
Measurement: new(string), Application: "influxdb",
App: new(string), Measurement: "influxdb",
Cells: []*models.Cell{ },
&models.Cell{ []chronograf.Layout{
X: new(int32), chronograf.Layout{
Y: new(int32), ID: "d20a21c8-69f1-4780-90fe-e69f5e4d138c",
W: new(int32), Application: "influxdb",
H: new(int32), Measurement: "influxdb",
},
},
"",
false,
},
{
"filtered app",
chronograf.Layout{
ID: "d20a21c8-69f1-4780-90fe-e69f5e4d138c",
Application: "influxdb",
Measurement: "influxdb",
},
[]chronograf.Layout{
chronograf.Layout{
ID: "d20a21c8-69f1-4780-90fe-e69f5e4d138c",
Application: "influxdb",
Measurement: "influxdb",
},
chronograf.Layout{
ID: "b020101b-ea6b-4c8c-9f0e-db0ba501f4ef",
Application: "chronograf",
Measurement: "chronograf",
},
},
"influxdb",
false,
},
{
"axis zero values",
chronograf.Layout{
ID: "d20a21c8-69f1-4780-90fe-e69f5e4d138c",
Application: "influxdb",
Measurement: "influxdb",
Cells: []chronograf.Cell{
{
X: 0,
Y: 0,
W: 4,
H: 4,
I: "3b0e646b-2ca3-4df2-95a5-fd80915459dd",
Name: "A Graph",
Axes: map[string]chronograf.Axis{
"x": chronograf.Axis{
Bounds: []string{},
},
"y": chronograf.Axis{
Bounds: []string{},
},
"y2": chronograf.Axis{
Bounds: []string{},
},
},
}, },
}, },
}, },
ExpectedID: 0, []chronograf.Layout{
ExpectedHref: "/chronograf/v1/layouts/0", chronograf.Layout{
ExpectedStatus: http.StatusCreated, ID: "d20a21c8-69f1-4780-90fe-e69f5e4d138c",
Application: "influxdb",
Measurement: "influxdb",
Cells: []chronograf.Cell{
{
X: 0,
Y: 0,
W: 4,
H: 4,
I: "3b0e646b-2ca3-4df2-95a5-fd80915459dd",
Name: "A Graph",
},
},
},
},
"",
false,
}, },
} }
for _, test := range tests { for _, test := range layoutTests {
// The mocked backing store will be used to test := test
// check stored values. t.Run(test.name, func(t *testing.T) {
store := server.Store{ t.Parallel()
LayoutStore: &mock.LayoutStore{
AddError: test.AddError,
Layouts: test.ExistingLayouts,
},
}
// Send the test layout to the mocked store. // setup mock chronograf.Service and mock logger
params := op.PostLayoutsParams{ lg := &mocks.TestLogger{}
Layout: test.NewLayout, svc := server.Service{
} LayoutStore: &mocks.LayoutStore{
resp := store.NewLayout(context.Background(), params) AllF: func(ctx context.Context) ([]chronograf.Layout, error) {
w := httptest.NewRecorder() if len(test.allLayouts) == 0 {
resp.WriteResponse(w, runtime.JSONProducer()) return []chronograf.Layout{
if w.Code != test.ExpectedStatus { test.expected,
t.Fatalf("Expected status %d; actual %d", test.ExpectedStatus, w.Code) }, nil
} } else {
loc := w.Header().Get("Location") return test.allLayouts, nil
if loc != test.ExpectedHref { }
t.Fatalf("Expected status %s; actual %s", test.ExpectedHref, loc) },
} },
Logger: lg,
}
// setup mock request and response
rr := httptest.NewRecorder()
reqURL := url.URL{
Path: "/chronograf/v1/layouts",
}
params := reqURL.Query()
// add query params required by test
if test.focusedApp != "" {
params.Add("app", test.focusedApp)
}
// re-inject query params
reqURL.RawQuery = params.Encode()
req := httptest.NewRequest("GET", reqURL.RequestURI(), strings.NewReader(""))
// invoke handler for layouts endpoint
svc.Layouts(rr, req)
// create a throwaway frame to unwrap Layouts
respFrame := struct {
Layouts []struct {
chronograf.Layout
Link interface{} `json:"-"`
} `json:"layouts"`
}{}
// decode resp into respFrame
resp := rr.Result()
if err := json.NewDecoder(resp.Body).Decode(&respFrame); err != nil {
t.Fatalf("%q - Error unmarshaling JSON: err: %s", test.name, err.Error())
}
// compare actual and expected
if !cmp.Equal(test.expected, respFrame.Layouts[0].Layout) {
t.Fatalf("%q - Expected layouts to be equal: diff:\n\t%s", test.name, cmp.Diff(test.expected, respFrame.Layouts[0].Layout))
}
})
} }
} }
*/