diff --git a/public/app/core/directives/rebuild_on_change.ts b/public/app/core/directives/rebuild_on_change.ts index 847903f22ff..b807d5bc50d 100644 --- a/public/app/core/directives/rebuild_on_change.ts +++ b/public/app/core/directives/rebuild_on_change.ts @@ -32,31 +32,38 @@ function rebuildOnChange($animate) { priority: 600, restrict: 'E', link: function(scope, elem, attrs, ctrl, transclude) { - var childScope, previousElements; - var uncompiledHtml; + var block, childScope, previousElements; function cleanUp() { + if (previousElements) { + previousElements.remove(); + previousElements = null; + } if (childScope) { childScope.$destroy(); childScope = null; - elem.empty(); + } + if (block) { + previousElements = getBlockNodes(block.clone); + $animate.leave(previousElements).then(function() { + previousElements = null; + }); + block = null; } } scope.$watch(attrs.property, function rebuildOnChangeAction(value, oldValue) { - if (value || attrs.showNull) { - // if same value and we have childscope - // ignore this double event - if (value === oldValue && childScope) { - return; - } - + if (childScope && value !== oldValue) { cleanUp(); + } + + if (!childScope && (value || attrs.showNull)) { transclude(function(clone, newScope) { childScope = newScope; + clone[clone.length++] = document.createComment(' end rebuild on change '); + block = {clone: clone}; $animate.enter(clone, elem.parent(), elem); }); - } else { cleanUp(); } diff --git a/public/app/features/panel/all.js b/public/app/features/panel/all.js index 96a119c8b48..47fe256e7cf 100644 --- a/public/app/features/panel/all.js +++ b/public/app/features/panel/all.js @@ -5,4 +5,5 @@ define([ './panel_loader', './query_ctrl', './panel_editor_tab', + './query_editor_row', ], function () {}); diff --git a/public/app/features/panel/metrics_panel_ctrl.ts b/public/app/features/panel/metrics_panel_ctrl.ts index 148d8647f28..14f5a59490b 100644 --- a/public/app/features/panel/metrics_panel_ctrl.ts +++ b/public/app/features/panel/metrics_panel_ctrl.ts @@ -164,12 +164,12 @@ class MetricsPanelCtrl extends PanelCtrl { }; issueQueries(datasource) { + this.updateTimeRange(); + if (!this.panel.targets || this.panel.targets.length === 0) { return this.$q.when([]); } - this.updateTimeRange(); - var metricsQuery = { range: this.range, rangeRaw: this.rangeRaw, diff --git a/public/app/features/panel/partials/query_editor_row.html b/public/app/features/panel/partials/query_editor_row.html new file mode 100644 index 00000000000..9df0dcdbc51 --- /dev/null +++ b/public/app/features/panel/partials/query_editor_row.html @@ -0,0 +1,56 @@ +