Copy missing properties from Dashboards

When creating new dashboards to set defaults, not all properties of the
dashboard were being copied. This ensures that they are so that zero
values are not used for things like the ID and Name.
pull/10616/head
Tim Raymond 2017-07-31 17:24:43 -04:00
parent f7191b1cba
commit e703107644
1 changed files with 8 additions and 0 deletions

View File

@ -235,7 +235,11 @@ func ValidDashboardRequest(d *chronograf.Dashboard) error {
// DashboardDefaults updates the dashboard with the default values
// if none are specified
func DashboardDefaults(d chronograf.Dashboard) (newDash chronograf.Dashboard) {
newDash.ID = d.ID
newDash.Templates = d.Templates
newDash.Name = d.Name
newDash.Cells = make([]chronograf.DashboardCell, len(d.Cells))
for i, c := range d.Cells {
CorrectWidthHeight(&c)
newDash.Cells[i] = c
@ -246,7 +250,11 @@ func DashboardDefaults(d chronograf.Dashboard) (newDash chronograf.Dashboard) {
// AddQueryConfigs updates all the celsl in the dashboard to have query config
// objects corresponding to their influxql queries.
func AddQueryConfigs(d chronograf.Dashboard) (newDash chronograf.Dashboard) {
newDash.ID = d.ID
newDash.Templates = d.Templates
newDash.Name = d.Name
newDash.Cells = make([]chronograf.DashboardCell, len(d.Cells))
for i, c := range d.Cells {
AddQueryConfig(&c)
newDash.Cells[i] = c