diff --git a/CHANGELOG.md b/CHANGELOG.md index 73d7aad8fb9..9e3f3766162 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * **Graph Panel**: Bar width if bars was only used in series override, [#6528](https://github.com/grafana/grafana/issues/6528) * **UI/Browser**: Fixed issue with page/view header gradient border not showing in Safari, [#6530](https://github.com/grafana/grafana/issues/6530) * **UX**: Panel Drop zone visible after duplicating panel, and when entering fullscreen/edit view, [#6598](https://github.com/grafana/grafana/issues/6598) +* **Templating**: Newly added variable was not visible directly only after dashboard reload, [#6622](https://github.com/grafana/grafana/issues/6622) ### Enhancements * **Singlestat**: Support repeated template variables in prefix/postfix [#6595](https://github.com/grafana/grafana/issues/6595) diff --git a/public/app/features/dashboard/model.ts b/public/app/features/dashboard/model.ts index 999c0470fdd..6b32004cfd5 100644 --- a/public/app/features/dashboard/model.ts +++ b/public/app/features/dashboard/model.ts @@ -98,12 +98,14 @@ export class DashboardModel { var events = this.events; var meta = this.meta; var rows = this.rows; + var variables = this.templating.list; + delete this.events; delete this.meta; // prepare save model - this.rows = _.map(this.rows, row => row.getSaveModel()); - events.emit('prepare-save-model'); + this.rows = _.map(rows, row => row.getSaveModel()); + this.templating.list = _.map(variables, variable => variable.getSaveModel()); var copy = $.extend(true, {}, this); @@ -111,6 +113,8 @@ export class DashboardModel { this.events = events; this.meta = meta; this.rows = rows; + this.templating.list = variables; + return copy; } diff --git a/public/app/features/templating/adhoc_variable.ts b/public/app/features/templating/adhoc_variable.ts index 5ebffb0b0e6..b3c9980c7c7 100644 --- a/public/app/features/templating/adhoc_variable.ts +++ b/public/app/features/templating/adhoc_variable.ts @@ -26,7 +26,7 @@ export class AdhocVariable implements Variable { return Promise.resolve(); } - getModel() { + getSaveModel() { assignModelProperties(this.model, this, this.defaults); return this.model; } diff --git a/public/app/features/templating/constant_variable.ts b/public/app/features/templating/constant_variable.ts index 59659459f85..1dcc473740f 100644 --- a/public/app/features/templating/constant_variable.ts +++ b/public/app/features/templating/constant_variable.ts @@ -24,7 +24,7 @@ export class ConstantVariable implements Variable { assignModelProperties(this, model, this.defaults); } - getModel() { + getSaveModel() { assignModelProperties(this.model, this, this.defaults); return this.model; } diff --git a/public/app/features/templating/custom_variable.ts b/public/app/features/templating/custom_variable.ts index 90ce08cf9e4..4fadcd26742 100644 --- a/public/app/features/templating/custom_variable.ts +++ b/public/app/features/templating/custom_variable.ts @@ -34,7 +34,7 @@ export class CustomVariable implements Variable { return this.variableSrv.setOptionAsCurrent(this, option); } - getModel() { + getSaveModel() { assignModelProperties(this.model, this, this.defaults); return this.model; } diff --git a/public/app/features/templating/datasource_variable.ts b/public/app/features/templating/datasource_variable.ts index d43c0dd486d..234c8c13fd5 100644 --- a/public/app/features/templating/datasource_variable.ts +++ b/public/app/features/templating/datasource_variable.ts @@ -30,7 +30,7 @@ export class DatasourceVariable implements Variable { this.refresh = 1; } - getModel() { + getSaveModel() { assignModelProperties(this.model, this, this.defaults); return this.model; } diff --git a/public/app/features/templating/interval_variable.ts b/public/app/features/templating/interval_variable.ts index a1cfbf324c0..ab1b0e59442 100644 --- a/public/app/features/templating/interval_variable.ts +++ b/public/app/features/templating/interval_variable.ts @@ -34,7 +34,7 @@ export class IntervalVariable implements Variable { this.refresh = 2; } - getModel() { + getSaveModel() { assignModelProperties(this.model, this, this.defaults); return this.model; } diff --git a/public/app/features/templating/partials/editor.html b/public/app/features/templating/partials/editor.html index e485072eed0..8006e356d85 100644 --- a/public/app/features/templating/partials/editor.html +++ b/public/app/features/templating/partials/editor.html @@ -136,7 +136,7 @@