diff --git a/src/app/directives/dashEditLink.js b/src/app/directives/dashEditLink.js index 1b5173671b0..67e2856e1fe 100644 --- a/src/app/directives/dashEditLink.js +++ b/src/app/directives/dashEditLink.js @@ -107,7 +107,9 @@ function (angular, $) { showEditorPane(null, {}, newValue); } else if (oldValue) { scope.contextSrv.editview = null; - hideEditorPane(); + if (lastEditor === editViewMap[oldValue]) { + hideEditorPane(); + } } }); diff --git a/src/app/features/annotations/annotationsSrv.js b/src/app/features/annotations/annotationsSrv.js index 2dd6da740e2..ec524b44ec5 100644 --- a/src/app/features/annotations/annotationsSrv.js +++ b/src/app/features/annotations/annotationsSrv.js @@ -12,6 +12,7 @@ define([ var promiseCached; var list = []; var timezone; + var self = this; this.init = function() { $rootScope.onAppEvent('refresh', this.clearCache); @@ -33,15 +34,15 @@ define([ } timezone = dashboard.timezone; - var annotations = _.where(dashboard.annotations.list, { enable: true }); + var annotations = _.where(dashboard.annotations.list, {enable: true}); var promises = _.map(annotations, function(annotation) { - var datasource = datasourceSrv.get(annotation.datasource); - - return datasource.annotationQuery(annotation, rangeUnparsed) - .then(this.receiveAnnotationResults) - .then(null, errorHandler); - }, this); + return datasourceSrv.get(annotation.datasource).then(function(datasource) { + return datasource.annotationQuery(annotation, rangeUnparsed) + .then(self.receiveAnnotationResults) + .then(null, errorHandler); + }, this); + }); promiseCached = $q.all(promises) .then(function() { diff --git a/src/app/features/templating/templateValuesSrv.js b/src/app/features/templating/templateValuesSrv.js index baff0a840b8..deb1e49ee5d 100644 --- a/src/app/features/templating/templateValuesSrv.js +++ b/src/app/features/templating/templateValuesSrv.js @@ -97,9 +97,8 @@ function (angular, _, kbn) { return $q.when([]); } - var datasource = datasourceSrv.get(variable.datasource); - return datasource.metricFindQuery(variable.query) - .then(function (results) { + return datasourceSrv.get(variable.datasource).then(function(datasource) { + return datasource.metricFindQuery(variable.query).then(function (results) { variable.options = self.metricNamesToVariableValues(variable, results); if (variable.includeAll) { @@ -117,6 +116,7 @@ function (angular, _, kbn) { return self.setVariableValue(variable, variable.options[0], true); }); + }); }; this.metricNamesToVariableValues = function(variable, metricNames) { @@ -149,19 +149,19 @@ function (angular, _, kbn) { this.addAllOption = function(variable) { var allValue = ''; switch(variable.allFormat) { - case 'wildcard': - allValue = '*'; - break; - case 'regex wildcard': - allValue = '.*'; - break; - case 'regex values': - allValue = '(' + _.pluck(variable.options, 'text').join('|') + ')'; - break; - default: - allValue = '{'; - allValue += _.pluck(variable.options, 'text').join(','); - allValue += '}'; + case 'wildcard': + allValue = '*'; + break; + case 'regex wildcard': + allValue = '.*'; + break; + case 'regex values': + allValue = '(' + _.pluck(variable.options, 'text').join('|') + ')'; + break; + default: + allValue = '{'; + allValue += _.pluck(variable.options, 'text').join(','); + allValue += '}'; } variable.options.unshift({text: 'All', value: allValue});