Alerting: update panel alert tab (#33850)

This commit is contained in:
Domas
2021-05-17 10:39:42 +03:00
committed by GitHub
parent 7c9ac0f990
commit a26507e9c4
28 changed files with 670 additions and 146 deletions

View File

@@ -63,7 +63,7 @@ class GraphElement {
data: any[] = [];
panelWidth: number;
eventManager: EventManager;
thresholdManager: ThresholdManager;
thresholdManager?: ThresholdManager;
timeRegionManager: TimeRegionManager;
legendElem: HTMLElement;
@@ -76,7 +76,10 @@ class GraphElement {
this.panelWidth = 0;
this.eventManager = new EventManager(this.ctrl);
this.thresholdManager = new ThresholdManager(this.ctrl);
// unified alerting does not support threshold for graphs, at least for now
if (!config.featureToggles.ngalert) {
this.thresholdManager = new ThresholdManager(this.ctrl);
}
this.timeRegionManager = new TimeRegionManager(this.ctrl);
// @ts-ignore
this.tooltip = new GraphTooltip(this.elem, this.ctrl.dashboard, this.scope, () => {
@@ -379,8 +382,9 @@ class GraphElement {
}
msg.appendTo(this.elem);
}
this.thresholdManager.draw(plot);
if (this.thresholdManager) {
this.thresholdManager.draw(plot);
}
this.timeRegionManager.draw(plot);
}
@@ -451,7 +455,9 @@ class GraphElement {
}
// give space to alert editing
this.thresholdManager.prepare(this.elem, this.data);
if (this.thresholdManager) {
this.thresholdManager.prepare(this.elem, this.data);
}
// un-check dashes if lines are unchecked
this.panel.dashes = this.panel.lines ? this.panel.dashes : false;
@@ -460,7 +466,9 @@ class GraphElement {
const options: any = this.buildFlotOptions(this.panel);
this.prepareXAxis(options, this.panel);
this.configureYAxisOptions(this.data, options);
this.thresholdManager.addFlotOptions(options, this.panel);
if (this.thresholdManager) {
this.thresholdManager.addFlotOptions(options, this.panel);
}
this.timeRegionManager.addFlotOptions(options, this.panel);
this.eventManager.addFlotEvents(this.annotations, options);
this.sortedSeries = this.sortSeries(this.data, this.panel);