Legacy dashboard cells default to type 'line'

Closes #2920, #2919
pull/2966/head
Brandon Farmer 2018-03-12 14:32:09 -07:00
parent a15eb72541
commit 7217d40f64
2 changed files with 90 additions and 2 deletions

View File

@ -404,6 +404,13 @@ func UnmarshalDashboard(data []byte, d *chronograf.Dashboard) error {
legend.Orientation = c.Legend.Orientation
}
// FIXME: this is merely for legacy cells and
// should be removed as soon as possible
cellType := c.Type
if cellType == "" {
cellType = "line"
}
cells[i] = chronograf.DashboardCell{
ID: c.ID,
X: c.X,
@ -412,7 +419,7 @@ func UnmarshalDashboard(data []byte, d *chronograf.Dashboard) error {
H: c.H,
Name: c.Name,
Queries: queries,
Type: c.Type,
Type: cellType,
Axes: axes,
CellColors: colors,
Legend: legend,

View File

@ -368,7 +368,46 @@ func Test_MarshalDashboard_WithEmptyLegacyBounds(t *testing.T) {
Value: "100",
},
},
Type: "line",
Type: "bar",
},
{
ID: "9b5367de-c552-4322-a9e8-7f384cbd235d",
X: 0,
Y: 0,
W: 4,
H: 4,
Name: "Super awesome query",
Queries: []chronograf.DashboardQuery{
{
Command: "select * from cpu",
Label: "CPU Utilization",
Range: &chronograf.Range{
Upper: int64(100),
},
Shifts: []chronograf.TimeShift{},
},
},
Axes: map[string]chronograf.Axis{
"y": chronograf.Axis{
LegacyBounds: [2]int64{},
},
},
CellColors: []chronograf.CellColor{
{
ID: "myid",
Type: "min",
Hex: "#234567",
Name: "Laser",
Value: "0",
},
{
ID: "id2",
Type: "max",
Hex: "#876543",
Name: "Solitude",
Value: "100",
},
},
},
},
Templates: []chronograf.Template{},
@ -418,6 +457,48 @@ func Test_MarshalDashboard_WithEmptyLegacyBounds(t *testing.T) {
Value: "100",
},
},
Type: "bar",
},
{
ID: "9b5367de-c552-4322-a9e8-7f384cbd235d",
X: 0,
Y: 0,
W: 4,
H: 4,
Name: "Super awesome query",
Queries: []chronograf.DashboardQuery{
{
Command: "select * from cpu",
Label: "CPU Utilization",
Range: &chronograf.Range{
Upper: int64(100),
},
Shifts: []chronograf.TimeShift{},
},
},
Axes: map[string]chronograf.Axis{
"y": chronograf.Axis{
Bounds: []string{},
Base: "10",
Scale: "linear",
},
},
CellColors: []chronograf.CellColor{
{
ID: "myid",
Type: "min",
Hex: "#234567",
Name: "Laser",
Value: "0",
},
{
ID: "id2",
Type: "max",
Hex: "#876543",
Name: "Solitude",
Value: "100",
},
},
Type: "line",
},
},