mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 16:15:42 -06:00
* Add and configure eslint-plugin-import * Fix the lint:ts npm command * Autofix + prettier all the files * Manually fix remaining files * Move jquery code in jest-setup to external file to safely reorder imports * Resolve issue caused by circular dependencies within Prometheus * Update .betterer.results * Fix missing // @ts-ignore * ignore iconBundle.ts * Fix missing // @ts-ignore
30 lines
970 B
TypeScript
30 lines
970 B
TypeScript
import { combineLatest, Observable, of } from 'rxjs';
|
|
import { mergeMap } from 'rxjs/operators';
|
|
|
|
import { ArrayDataFrame, PanelData } from '@grafana/data';
|
|
|
|
import { DashboardQueryRunnerResult } from './DashboardQueryRunner/types';
|
|
|
|
export function mergePanelAndDashData(
|
|
panelObservable: Observable<PanelData>,
|
|
dashObservable: Observable<DashboardQueryRunnerResult>
|
|
): Observable<PanelData> {
|
|
return combineLatest([panelObservable, dashObservable]).pipe(
|
|
mergeMap((combined) => {
|
|
const [panelData, dashData] = combined;
|
|
|
|
if (Boolean(dashData.annotations?.length) || Boolean(dashData.alertState)) {
|
|
if (!panelData.annotations) {
|
|
panelData.annotations = [];
|
|
}
|
|
|
|
const annotations = panelData.annotations.concat(new ArrayDataFrame(dashData.annotations));
|
|
const alertState = dashData.alertState;
|
|
return of({ ...panelData, annotations, alertState });
|
|
}
|
|
|
|
return of(panelData);
|
|
})
|
|
);
|
|
}
|