From 7217d40f64559d250509c2ed3dd3a2c423b15880 Mon Sep 17 00:00:00 2001 From: Brandon Farmer Date: Mon, 12 Mar 2018 14:32:09 -0700 Subject: [PATCH] Legacy dashboard cells default to type 'line' Closes #2920, #2919 --- bolt/internal/internal.go | 9 +++- bolt/internal/internal_test.go | 83 +++++++++++++++++++++++++++++++++- 2 files changed, 90 insertions(+), 2 deletions(-) diff --git a/bolt/internal/internal.go b/bolt/internal/internal.go index 729bb8627..c51fe1d19 100644 --- a/bolt/internal/internal.go +++ b/bolt/internal/internal.go @@ -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, diff --git a/bolt/internal/internal_test.go b/bolt/internal/internal_test.go index 47c7067b4..d9d66df49 100644 --- a/bolt/internal/internal_test.go +++ b/bolt/internal/internal_test.go @@ -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", }, },