Browse Source

Single analytic unit in webhook image #357 (#392)

master
Alexandr Velikiy 5 years ago committed by rozetko
parent
commit
b9e18c9ff2
  1. 21
      src/panel/graph_panel/controllers/analytic_controller.ts
  2. 19
      src/panel/graph_panel/graph_ctrl.ts

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

@ -62,6 +62,7 @@ export class AnalyticController {
private _panelObject: any,
private _emitter: Emitter,
private _analyticService?: AnalyticService,
private _analyticUnitsToShow?: AnalyticUnitId | AnalyticUnitId[],
) {
this._labelingDataAddedSegments = new SegmentArray<AnalyticSegment>();
this._labelingDataRemovedSegments = new SegmentArray<AnalyticSegment>();
@ -242,6 +243,25 @@ export class AnalyticController {
});
}
private _showOnlySpecifiedAnalyticUnits() {
if(this._analyticUnitsToShow === undefined) {
return;
}
if(!_.isArray(this._analyticUnitsToShow)) {
this._analyticUnitsToShow = [this._analyticUnitsToShow];
}
this.analyticUnits.forEach(analyticUnit => {
const shouldShow = _.includes(this._analyticUnitsToShow, analyticUnit.id);
if(shouldShow) {
analyticUnit.visible = true;
} else {
analyticUnit.visible = false;
}
});
}
stopAnalyticUnitsDetectionsFetching() {
this.analyticUnits.forEach(analyticUnit => this._detectionRunners.delete(analyticUnit.id));
}
@ -345,6 +365,7 @@ export class AnalyticController {
options.grid.markings = [];
}
this._showOnlySpecifiedAnalyticUnits();
for(let i = 0; i < this.analyticUnits.length; i++) {
const analyticUnit = this.analyticUnits[i];
if(!analyticUnit.visible) {

19
src/panel/graph_panel/graph_ctrl.ts

@ -58,6 +58,8 @@ class GraphCtrl extends MetricsPanelCtrl {
private _grafanaUrl: string;
private _panelId: string;
private _analyticUnitsToShow: AnalyticUnitId | AnalyticUnitId[];
private _dataTimerange: {
from?: number,
to?: number
@ -149,7 +151,7 @@ class GraphCtrl extends MetricsPanelCtrl {
/** @ngInject */
constructor(
$scope, $injector, private $http,
$scope, $injector, private $http, private $location,
private annotationsSrv,
private backendSrv: BackendSrv,
private popoverSrv,
@ -167,11 +169,15 @@ class GraphCtrl extends MetricsPanelCtrl {
const grafanaUrlRegex = /^(.+)\/d/;
const parsedUrl = window.location.href.match(grafanaUrlRegex);
const params = this.$location.search();
// api-rendering parameter is added for webhook images rendering
// We disable alerts in this case
if(window.location.search.includes('api-rendering')) {
if(params.apiRendering !== undefined) {
appEvents.emit = function() { };
}
this._analyticUnitsToShow = params.analyticUnitId;
if(parsedUrl !== null) {
this._grafanaUrl = parsedUrl[1];
} else {
@ -315,7 +321,14 @@ class GraphCtrl extends MetricsPanelCtrl {
}
}
this.analyticsController = new AnalyticController(this._grafanaUrl, this._panelId, this.panel, this.events, this.analyticService);
this.analyticsController = new AnalyticController(
this._grafanaUrl,
this._panelId,
this.panel,
this.events,
this.analyticService,
this._analyticUnitsToShow
);
this._updatePanelInfo();
this.analyticsController.updateServerInfo();

Loading…
Cancel
Save