diff --git a/src/controllers/analytic_controller.ts b/src/controllers/analytic_controller.ts index 0ae3902..6e11dac 100644 --- a/src/controllers/analytic_controller.ts +++ b/src/controllers/analytic_controller.ts @@ -132,7 +132,7 @@ export class AnalyticController { }); this.labelingAnomaly.saving = false; - + var anomaly = this.labelingAnomaly; this.dropLabeling(); this._runStatusWaiter(anomaly); @@ -256,7 +256,7 @@ export class AnalyticController { } var rangeDist = +options.xaxis.max - +options.xaxis.min; - + let labeledSegmentBorderColor = tinycolor(LABELED_SEGMENT_BORDER_COLOR).toRgbString(); labeledSegmentBorderColor = addAlphaToRGB(labeledSegmentBorderColor, REGION_STROKE_ALPHA); let deletedSegmentFillColor = tinycolor(DELETED_SEGMENT_FILL_COLOR).toRgbString(); @@ -402,6 +402,9 @@ export class AnalyticController { return this._serverInfo; } + public get serverStatus() { + return this._analyticService.isUp; + } } function addAlphaToRGB(colorString: string, alpha: number): string { diff --git a/src/module.ts b/src/module.ts index c4afc24..3430298 100644 --- a/src/module.ts +++ b/src/module.ts @@ -16,7 +16,6 @@ import { PanelInfo } from './models/info'; import { axesEditorComponent } from './axes_editor'; import { MetricsPanelCtrl, alertTab } from 'grafana/app/plugins/sdk'; -import { BackendSrv } from 'grafana/app/core/services/backend_srv'; import { appEvents } from 'grafana/app/core/core' import config from 'grafana/app/core/config'; @@ -28,6 +27,7 @@ const BACKEND_VARIABLE_NAME = 'HASTIC_SERVER_URL'; class GraphCtrl extends MetricsPanelCtrl { static template = template; + analyticService: AnalyticService; hiddenSeries: any = {}; seriesList: any = []; dataList: any = []; @@ -148,7 +148,7 @@ class GraphCtrl extends MetricsPanelCtrl { /** @ngInject */ constructor( - $scope, $injector, private annotationsSrv, + $scope, $injector, $http, private annotationsSrv, private keybindingSrv, private backendSrv, private popoverSrv, private contextSrv, private alertSrv @@ -163,11 +163,11 @@ class GraphCtrl extends MetricsPanelCtrl { this.processor = new DataProcessor(this.panel); - var anomalyService = new AnalyticService(this.backendURL, backendSrv as BackendSrv); + this.analyticService = new AnalyticService(this.backendURL, $http, this.alertSrv); this.runBackendConnectivityCheck(); - this.analyticsController = new AnalyticController(this.panel, anomalyService, this.events); + this.analyticsController = new AnalyticController(this.panel, this.analyticService, this.events); this.anomalyTypes = this.panel.anomalyTypes; keybindingSrv.bind('d', this.onDKey.bind(this)); @@ -224,11 +224,12 @@ class GraphCtrl extends MetricsPanelCtrl { return; } - var as = new AnalyticService(this.backendURL, this.backendSrv); - var isOK = await as.isBackendOk(); - if(!isOK) { + let connected = await this.analyticService.isBackendOk(); + if(connected) { this.alertSrv.set( - 'Can`t connect to Hastic server', `Hastic server: "${this.backendURL}"`, 'warning', 4000 + 'Connected to Hastic server', + `Hastic server: "${this.backendURL}"`, + 'success', 4000 ); } } diff --git a/src/partials/tab_analytics.html b/src/partials/tab_analytics.html index 69ebff7..96a90de 100644 --- a/src/partials/tab_analytics.html +++ b/src/partials/tab_analytics.html @@ -1,148 +1,160 @@ -
Analytic Units
-
-
- - - - - -
- - - - Type +
+ - - -
- + + +
+