Browse Source

Images in webhooks don't have detections #387 (#393)

master
rozetko 5 years ago committed by GitHub
parent
commit
4efc585f67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/panel/graph_panel/controllers/analytic_controller.ts
  2. 15
      src/panel/graph_panel/graph_ctrl.ts
  3. 17
      src/panel/graph_panel/services/analytic_service.ts

5
src/panel/graph_panel/controllers/analytic_controller.ts

@ -67,7 +67,10 @@ export class AnalyticController {
this._labelingDataAddedSegments = new SegmentArray<AnalyticSegment>(); this._labelingDataAddedSegments = new SegmentArray<AnalyticSegment>();
this._labelingDataRemovedSegments = new SegmentArray<AnalyticSegment>(); this._labelingDataRemovedSegments = new SegmentArray<AnalyticSegment>();
this._analyticUnitsSet = new AnalyticUnitsSet([]); this._analyticUnitsSet = new AnalyticUnitsSet([]);
this.fetchAnalyticUnits(); }
async init() {
await this.fetchAnalyticUnits();
} }
get helpSectionText() { return helpSectionText; } get helpSectionText() { return helpSectionText; }

15
src/panel/graph_panel/graph_ctrl.ts

@ -250,8 +250,6 @@ class GraphCtrl extends MetricsPanelCtrl {
this.$graphElem = $(elem[0]).find('#graphPanel'); this.$graphElem = $(elem[0]).find('#graphPanel');
this.$legendElem = $(elem[0]).find('#graphLegend'); this.$legendElem = $(elem[0]).find('#graphLegend');
this.onHasticDatasourceChange();
this.events.on('render', this.onRender.bind(this)); this.events.on('render', this.onRender.bind(this));
this.events.on('data-received', this.onDataReceived.bind(this)); this.events.on('data-received', this.onDataReceived.bind(this));
this.events.on('data-error', this.onDataError.bind(this)); this.events.on('data-error', this.onDataError.bind(this));
@ -285,6 +283,9 @@ class GraphCtrl extends MetricsPanelCtrl {
this.refresh(); this.refresh();
} }
}); });
// TODO: maybe it's not the best idea
await this.onHasticDatasourceChange();
} }
onInitEditMode() { onInitEditMode() {
@ -330,14 +331,21 @@ class GraphCtrl extends MetricsPanelCtrl {
this._analyticUnitsToShow this._analyticUnitsToShow
); );
if(this.analyticService.isUp) {
await this.analyticsController.init();
this._updatePanelInfo(); this._updatePanelInfo();
this.analyticsController.updateServerInfo(); this.analyticsController.updateServerInfo();
}
this._graphRenderer = new GraphRenderer( this._graphRenderer = new GraphRenderer(
this.$graphElem, this.timeSrv, this.contextSrv, this.$scope, this.analyticsController this.$graphElem, this.timeSrv, this.contextSrv, this.$scope, this.analyticsController
); );
this._graphLegend = new GraphLegend(this.$legendElem, this.popoverSrv, this.$scope, this.analyticsController); this._graphLegend = new GraphLegend(this.$legendElem, this.popoverSrv, this.$scope, this.analyticsController);
this.onRender();
if(!this.analyticService.isUp) {
this.refresh();
}
} }
issueQueries(datasource) { issueQueries(datasource) {
@ -429,6 +437,7 @@ class GraphCtrl extends MetricsPanelCtrl {
this._dataTimerange.to this._dataTimerange.to
); );
} }
this.seriesList = seriesList; this.seriesList = seriesList;
this.render(); this.render();

17
src/panel/graph_panel/services/analytic_service.ts

@ -96,11 +96,12 @@ export class AnalyticService {
return this.delete('/analyticUnits', { id }); return this.delete('/analyticUnits', { id });
} }
private async _isDatasourceOk(): Promise<boolean> { private async _checkDatasourceAvailability(): Promise<void> {
if(!this._checkDatasourceConfig()) { if(!this._checkDatasourceConfig()) {
this._isUp = false; this._isUp = false;
return false; return;
} }
try {
const response = await this.get('/'); const response = await this.get('/');
if(!isHasticServerResponse(response)) { if(!isHasticServerResponse(response)) {
this.displayWrongUrlAlert(); this.displayWrongUrlAlert();
@ -109,7 +110,13 @@ export class AnalyticService {
this.displayUnsupportedVersionAlert(response.packageVersion); this.displayUnsupportedVersionAlert(response.packageVersion);
this._isUp = false; this._isUp = false;
} }
return this._isUp;
this._isUp = true;
} catch(e) {
console.error(e);
this.displayNoConnectionAlert();
this._isUp = false;
}
} }
async updateSegments( async updateSegments(
@ -240,8 +247,8 @@ export class AnalyticService {
} }
async isDatasourceAvailable(): Promise<boolean> { async isDatasourceAvailable(): Promise<boolean> {
const connected = await this._isDatasourceOk(); await this._checkDatasourceAvailability();
if(!connected) { if(!this._isUp) {
return false; return false;
} }
const message = [ const message = [

Loading…
Cancel
Save