mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Templating: Fixes digest issues in Template Variable Editor (#21079)
* Fix: Adds extra digest after promises * Feature: Adds promise to digest utility
This commit is contained in:
@@ -6,6 +6,7 @@ import DatasourceSrv from '../plugins/datasource_srv';
|
||||
import { VariableSrv } from './all';
|
||||
import { TemplateSrv } from './template_srv';
|
||||
import { AppEvents } from '@grafana/data';
|
||||
import { promiseToDigest } from '../../core/utils/promiseToDigest';
|
||||
|
||||
export class VariableEditorCtrl {
|
||||
/** @ngInject */
|
||||
@@ -122,11 +123,13 @@ export class VariableEditorCtrl {
|
||||
$scope.infoText = '';
|
||||
if ($scope.current.type === 'adhoc' && $scope.current.datasource !== null) {
|
||||
$scope.infoText = 'Adhoc filters are applied automatically to all queries that target this datasource';
|
||||
datasourceSrv.get($scope.current.datasource).then(ds => {
|
||||
if (!ds.getTagKeys) {
|
||||
$scope.infoText = 'This datasource does not support adhoc filters yet.';
|
||||
}
|
||||
});
|
||||
promiseToDigest($scope)(
|
||||
datasourceSrv.get($scope.current.datasource).then(ds => {
|
||||
if (!ds.getTagKeys) {
|
||||
$scope.infoText = 'This datasource does not support adhoc filters yet.';
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -154,9 +157,11 @@ export class VariableEditorCtrl {
|
||||
$scope.currentIsNew = false;
|
||||
$scope.mode = 'edit';
|
||||
$scope.validate();
|
||||
datasourceSrv.get($scope.current.datasource).then(ds => {
|
||||
$scope.currentDatasource = ds;
|
||||
});
|
||||
promiseToDigest($scope)(
|
||||
datasourceSrv.get($scope.current.datasource).then(ds => {
|
||||
$scope.currentDatasource = ds;
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
$scope.duplicate = (variable: { getSaveModel: () => void; name: string }) => {
|
||||
@@ -168,11 +173,13 @@ export class VariableEditorCtrl {
|
||||
|
||||
$scope.update = () => {
|
||||
if ($scope.isValid()) {
|
||||
$scope.runQuery().then(() => {
|
||||
$scope.reset();
|
||||
$scope.mode = 'list';
|
||||
templateSrv.updateIndex();
|
||||
});
|
||||
promiseToDigest($scope)(
|
||||
$scope.runQuery().then(() => {
|
||||
$scope.reset();
|
||||
$scope.mode = 'list';
|
||||
templateSrv.updateIndex();
|
||||
})
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -218,10 +225,12 @@ export class VariableEditorCtrl {
|
||||
};
|
||||
|
||||
$scope.datasourceChanged = async () => {
|
||||
datasourceSrv.get($scope.current.datasource).then(ds => {
|
||||
$scope.current.query = '';
|
||||
$scope.currentDatasource = ds;
|
||||
});
|
||||
promiseToDigest($scope)(
|
||||
datasourceSrv.get($scope.current.datasource).then(ds => {
|
||||
$scope.current.query = '';
|
||||
$scope.currentDatasource = ds;
|
||||
})
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user