The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/features/canvas/runtime/root.tsx

54 lines
1.3 KiB

import React from 'react';
import { CanvasElementOptions, CanvasFrameOptions } from 'app/features/canvas';
import { FrameState } from './frame';
import { Scene } from './scene';
export class RootElement extends FrameState {
constructor(public options: CanvasFrameOptions, public scene: Scene, private changeCallback: () => void) {
super(options, scene);
this.sizeStyle = {
height: '100%',
width: '100%',
};
}
isRoot(): this is RootElement {
return true;
}
// root type can not change
onChange(options: CanvasElementOptions) {
this.revId++;
this.options = { ...options } as CanvasFrameOptions;
this.changeCallback();
}
getSaveModel(): CanvasFrameOptions {
const { placement, constraint, ...rest } = this.options;
return {
...rest, // everything except placement & constraint
elements: this.elements.map((v) => v.getSaveModel()),
};
}
setRootRef = (target: HTMLDivElement) => {
this.div = target;
};
render() {
return (
<div
onContextMenu={(event) => event.preventDefault()}
key={this.UID}
ref={this.setRootRef}
style={{ ...this.sizeStyle, ...this.dataStyle }}
>
{this.elements.map((v) => v.render())}
</div>
);
}
}