Types: Adds type safety to appEvents (#19418)

* Types: Add type safety to appEvents
This commit is contained in:
kay delaney
2019-10-14 09:27:47 +01:00
committed by GitHub
parent e7c37cc316
commit 99411bf37a
138 changed files with 991 additions and 508 deletions

View File

@ -9,9 +9,10 @@ import { DataSourceSrv as DataSourceService, getDataSourceSrv as getDataSourceSe
// Types
import { DataSourceApi, DataSourceSelectItem } from '@grafana/ui';
import { ScopedVars } from '@grafana/data';
import { ScopedVars, AppEvents } from '@grafana/data';
import { auto } from 'angular';
import { TemplateSrv } from '../templating/template_srv';
import { GrafanaRootScope } from 'app/routes/GrafanaCtrl';
export class DatasourceSrv implements DataSourceService {
datasources: { [name: string]: DataSourceApi };
@ -20,7 +21,7 @@ export class DatasourceSrv implements DataSourceService {
constructor(
private $q: any,
private $injector: auto.IInjectorService,
private $rootScope: any,
private $rootScope: GrafanaRootScope,
private templateSrv: TemplateSrv
) {
this.init();
@ -86,7 +87,7 @@ export class DatasourceSrv implements DataSourceService {
deferred.resolve(instance);
})
.catch(err => {
this.$rootScope.appEvent('alert-error', [dsConfig.name + ' plugin failed', err.toString()]);
this.$rootScope.appEvent(AppEvents.alertError, [dsConfig.name + ' plugin failed', err.toString()]);
});
return deferred.promise;