Chore/Tech debt: Remove (most) instances of $q angular service use (#20668)

* Chore/Tech debt: Remove (most) instances of $q angular service use
Removes instances where the angular $q service is used and replaces
it with native Promises.
This commit is contained in:
kay delaney
2019-12-05 09:04:03 +00:00
committed by GitHub
parent 62f0aca3e6
commit 880fbcb09a
58 changed files with 320 additions and 467 deletions

View File

@@ -1,7 +1,6 @@
import _ from 'lodash';
import ResponseParser from './response_parser';
import { BackendSrv } from 'app/core/services/backend_srv';
import { IQService } from 'angular';
import { TemplateSrv } from 'app/features/templating/template_srv';
import { TimeSrv } from 'app/features/dashboard/services/TimeSrv';
//Types
@@ -17,13 +16,12 @@ export class MssqlDatasource {
constructor(
instanceSettings: any,
private backendSrv: BackendSrv,
private $q: IQService,
private templateSrv: TemplateSrv,
private timeSrv: TimeSrv
) {
this.name = instanceSettings.name;
this.id = instanceSettings.id;
this.responseParser = new ResponseParser(this.$q);
this.responseParser = new ResponseParser();
this.interval = (instanceSettings.jsonData || {}).timeInterval || '1m';
}
@@ -80,7 +78,7 @@ export class MssqlDatasource {
});
if (queries.length === 0) {
return this.$q.when({ data: [] });
return Promise.resolve({ data: [] });
}
return this.backendSrv
@@ -98,7 +96,7 @@ export class MssqlDatasource {
annotationQuery(options: any) {
if (!options.annotation.rawQuery) {
return this.$q.reject({ message: 'Query missing in annotation definition' });
return Promise.reject({ message: 'Query missing in annotation definition' });
}
const query = {