diff --git a/public/app/features/dashboard/dashboardSrv.js b/public/app/features/dashboard/dashboardSrv.js index 9ddce2dbea8..4b2071701bc 100644 --- a/public/app/features/dashboard/dashboardSrv.js +++ b/public/app/features/dashboard/dashboardSrv.js @@ -174,6 +174,11 @@ function (angular, $, kbn, _, moment) { var newPanel = angular.copy(panel); newPanel.id = this.getNextPanelId(); + delete newPanel.repeat; + delete newPanel.repeatIteration; + delete newPanel.repeatPanelId; + delete newPanel.scopedVars; + var currentRow = this.rows[rowIndex]; currentRow.panels.push(newPanel); return newPanel; diff --git a/public/app/features/dashboard/dynamicDashboardSrv.js b/public/app/features/dashboard/dynamicDashboardSrv.js index 8e3c24f7202..c4433f75c89 100644 --- a/public/app/features/dashboard/dynamicDashboardSrv.js +++ b/public/app/features/dashboard/dynamicDashboardSrv.js @@ -53,6 +53,10 @@ function (angular, _) { row.panels = _.without(row.panels, panel); j = j - 1; } + // clean up left over scoped vars + else if (panel.scopedVars && panel.repeatIteration !== this.iteration) { + delete panel.scopedVars; + } } } }; @@ -116,6 +120,7 @@ function (angular, _) { panel = copy.panels[i]; panel.scopedVars = {}; panel.scopedVars[variable.name] = option; + panel.repeatIteration = self.iteration; } }); }; diff --git a/public/app/plugins/datasource/influxdb/queryCtrl.js b/public/app/plugins/datasource/influxdb/queryCtrl.js index a57737cba93..973bffea02e 100644 --- a/public/app/plugins/datasource/influxdb/queryCtrl.js +++ b/public/app/plugins/datasource/influxdb/queryCtrl.js @@ -136,7 +136,7 @@ function (angular, _, InfluxQueryBuilder) { $scope.addTemplateVariableSegments = function(segments) { _.each(templateSrv.variables, function(variable) { - segments.unshift(new MetricSegment({ type: 'template', value: '$' + variable.name, expandable: true })); + segments.unshift(new MetricSegment({ type: 'template', value: '/$' + variable.name + '/', expandable: true })); }); return segments; }; diff --git a/public/test/specs/dashboardSrv-specs.js b/public/test/specs/dashboardSrv-specs.js index 93f6c04aa13..3c173655783 100644 --- a/public/test/specs/dashboardSrv-specs.js +++ b/public/test/specs/dashboardSrv-specs.js @@ -81,6 +81,15 @@ define([ expect(dashboard.rows[0].panels[1].id).to.be(11); }); + it('duplicate panel should remove repeat data', function() { + var panel = { span: 4, attr: '123', id: 10, repeat: 'asd', scopedVars: { test: 'asd' }}; + dashboard.rows = [{ panels: [panel] }]; + dashboard.duplicatePanel(panel, dashboard.rows[0]); + + expect(dashboard.rows[0].panels[1].repeat).to.be(null); + expect(dashboard.rows[0].panels[1].scopedVars.test).to.be(undefined); + }); + }); describe('when creating dashboard with editable false', function() {