mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* First try * Update * app with drilldowns * Progres * Progress * update * Update * update * Update * Update * Progress * Update * Progress * Update * Progress * logs url sync * related metrics * Progress * progress * Progress * Update * Update * Update * Update * Update * fix * Update * update * Update * update * Update * Update * Update * Update * Update * Update * Update * Update * Update * Update * update * Update * Update * Settings * Update * Tweaks * update * Improve auto queries * Update * Update * Fixes * Update * Update * Update * fix * Update * Removing logs view, cleanup * Update * Update * disabled not implemented buttons * Update * Feature toggle on dashboard menu * remove unused prometheus change * removed bit * Fix failing test * chore: added `/public/app/features/trails/` to CODEOWNERS * go mod tidy * go mod tidy * fix: added missing arg * Moved panel action * Moved panel action --------- Co-authored-by: André Pereira <adrapereira@gmail.com> Co-authored-by: Darren Janeczek <darren.janeczek@grafana.com>
56 lines
1.5 KiB
TypeScript
56 lines
1.5 KiB
TypeScript
import React from 'react';
|
|
|
|
import { LoadingState, PanelData, DataFrame } from '@grafana/data';
|
|
import {
|
|
SceneObjectState,
|
|
SceneFlexItem,
|
|
SceneObjectBase,
|
|
sceneGraph,
|
|
SceneComponentProps,
|
|
SceneByFrameRepeater,
|
|
SceneLayout,
|
|
} from '@grafana/scenes';
|
|
|
|
interface ByFrameRepeaterState extends SceneObjectState {
|
|
body: SceneLayout;
|
|
getLayoutChild(data: PanelData, frame: DataFrame, frameIndex: number): SceneFlexItem;
|
|
}
|
|
|
|
export class ByFrameRepeater extends SceneObjectBase<ByFrameRepeaterState> {
|
|
public constructor(state: ByFrameRepeaterState) {
|
|
super(state);
|
|
|
|
this.addActivationHandler(() => {
|
|
const data = sceneGraph.getData(this);
|
|
|
|
this._subs.add(
|
|
data.subscribeToState((data) => {
|
|
if (data.data?.state === LoadingState.Done) {
|
|
this.performRepeat(data.data);
|
|
}
|
|
})
|
|
);
|
|
|
|
if (data.state.data) {
|
|
this.performRepeat(data.state.data);
|
|
}
|
|
});
|
|
}
|
|
|
|
private performRepeat(data: PanelData) {
|
|
const newChildren: SceneFlexItem[] = [];
|
|
|
|
for (let seriesIndex = 0; seriesIndex < data.series.length; seriesIndex++) {
|
|
const layoutChild = this.state.getLayoutChild(data, data.series[seriesIndex], seriesIndex);
|
|
newChildren.push(layoutChild);
|
|
}
|
|
|
|
this.state.body.setState({ children: newChildren });
|
|
}
|
|
|
|
public static Component = ({ model }: SceneComponentProps<SceneByFrameRepeater>) => {
|
|
const { body } = model.useState();
|
|
return <body.Component model={body} />;
|
|
};
|
|
}
|