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

@ -5,7 +5,7 @@ import { QueryCtrl } from 'app/plugins/sdk';
import { SqlPart } from 'app/core/components/sql_part/sql_part';
import PostgresQuery from './postgres_query';
import sqlPart from './sql_part';
import { auto, IQService } from 'angular';
import { auto } from 'angular';
import { TemplateSrv } from 'app/features/templating/template_srv';
import { CoreEvents } from 'app/types';
import { PanelEvents } from '@grafana/data';
@ -48,7 +48,6 @@ export class PostgresQueryCtrl extends QueryCtrl {
$scope: any,
$injector: auto.IInjectorService,
private templateSrv: TemplateSrv,
private $q: IQService,
private uiSegmentSrv: any
) {
super($scope, $injector);
@ -248,7 +247,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
}
});
this.$q.all([task1, task2]).then(() => {
Promise.all([task1, task2]).then(() => {
this.updateRawSqlAndRefresh();
});
}
@ -481,7 +480,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
break;
}
case 'get-part-actions': {
return this.$q.when([{ text: 'Remove', value: 'remove-part' }]);
return Promise.resolve([{ text: 'Remove', value: 'remove-part' }]);
}
}
}
@ -505,7 +504,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
break;
}
case 'get-part-actions': {
return this.$q.when([{ text: 'Remove', value: 'remove-part' }]);
return Promise.resolve([{ text: 'Remove', value: 'remove-part' }]);
}
}
}
@ -568,7 +567,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
case 'right':
if (['int4', 'int8', 'float4', 'float8', 'timestamp', 'timestamptz'].indexOf(part.datatype) > -1) {
// don't do value lookups for numerical fields
return this.$q.when([]);
return Promise.resolve([]);
} else {
return this.datasource
.metricFindQuery(this.metaBuilder.buildValueQuery(part.params[0]))
@ -583,9 +582,9 @@ export class PostgresQueryCtrl extends QueryCtrl {
.catch(this.handleQueryError.bind(this));
}
case 'op':
return this.$q.when(this.uiSegmentSrv.newOperators(this.metaBuilder.getOperators(part.datatype)));
return Promise.resolve(this.uiSegmentSrv.newOperators(this.metaBuilder.getOperators(part.datatype)));
default:
return this.$q.when([]);
return Promise.resolve([]);
}
}
case 'part-param-changed': {
@ -606,7 +605,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
break;
}
case 'get-part-actions': {
return this.$q.when([{ text: 'Remove', value: 'remove-part' }]);
return Promise.resolve([{ text: 'Remove', value: 'remove-part' }]);
}
}
}
@ -619,7 +618,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
options.push(this.uiSegmentSrv.newSegment({ type: 'macro', value: '$__timeFilter' }));
}
options.push(this.uiSegmentSrv.newSegment({ type: 'expression', value: 'Expression' }));
return this.$q.when(options);
return Promise.resolve(options);
}
addWhereAction(part: any, index: any) {