Browse Source

AlertSrv is deprecated in Grafana 5.4+ #137 (#138)

master
rozetko 6 years ago committed by GitHub
parent
commit
dd9ef7128e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 29
      src/module.ts
  2. 13
      src/services/analytic_service.ts

29
src/module.ts

@ -145,8 +145,7 @@ class GraphCtrl extends MetricsPanelCtrl {
private keybindingSrv,
private backendSrv: BackendSrv,
private popoverSrv,
private contextSrv,
private alertSrv: AlertSrv
private contextSrv
) {
super($scope, $injector);
@ -157,7 +156,7 @@ class GraphCtrl extends MetricsPanelCtrl {
this.processor = new DataProcessor(this.panel);
this.analyticService = new AnalyticService(this.backendURL, $http, this.backendSrv, this.alertSrv);
this.analyticService = new AnalyticService(this.backendURL, $http);
this.runBackendConnectivityCheck();
@ -227,10 +226,12 @@ class GraphCtrl extends MetricsPanelCtrl {
async runBackendConnectivityCheck() {
if(this.backendURL === '' || this.backendURL === undefined) {
this.alertSrv.set(
appEvents.emit(
'alert-warning',
[
`Dashboard variable $${BACKEND_VARIABLE_NAME} is missing`,
`Please set $${BACKEND_VARIABLE_NAME}`,
'warning', 4000
`Please set $${BACKEND_VARIABLE_NAME}`
]
);
return;
}
@ -238,10 +239,12 @@ class GraphCtrl extends MetricsPanelCtrl {
let connected = await this.analyticService.isBackendOk();
if(connected) {
this.updateAnalyticUnitTypes();
this.alertSrv.set(
appEvents.emit(
'alert-success',
[
'Connected to Hastic server',
`Hastic server: "${this.backendURL}"`,
'success', 4000
`Hastic server: "${this.backendURL}"`
]
);
}
}
@ -516,10 +519,12 @@ class GraphCtrl extends MetricsPanelCtrl {
panelUrl
);
} catch(e) {
this.alertSrv.set(
appEvents.emit(
'alert-error',
[
'Error while saving analytic unit',
e.message,
'error', 7000
e.message
]
);
}
this.$scope.$digest();

13
src/services/analytic_service.ts

@ -5,8 +5,7 @@ import { SegmentsSet } from '../models/segment_set';
import { AnalyticUnitId, AnalyticUnit, AnalyticSegment } from '../models/analytic_unit';
import { ServerInfo } from '../models/info';
import { Threshold } from '../models/threshold';
import { BackendSrv } from 'grafana/app/core/services/backend_srv';
import { AlertSrv } from 'grafana/app/core/services/alert_srv';
import { appEvents } from 'grafana/app/core/core';
export class AnalyticService {
@ -14,9 +13,7 @@ export class AnalyticService {
constructor(
private _backendURL: string,
private $http,
private _backendSrv: BackendSrv,
private _alertSrv: AlertSrv
private $http
) {
this.isBackendOk();
}
@ -202,10 +199,12 @@ export class AnalyticService {
}
private displayConnectionAlert() {
this._alertSrv.set(
appEvents.emit(
'alert-success',
[
'No connection to Hastic server',
`Hastic server: "${this._backendURL}"`,
'warning', 4000
]
);
}

Loading…
Cancel
Save