mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Live: broadcast events when dashboard is saved (#27583)
Co-authored-by: kay delaney <45561153+kaydelaney@users.noreply.github.com> Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
This commit is contained in:
@@ -169,13 +169,21 @@ export class LiveAdmin extends PureComponent<Props, State> {
|
||||
<h5>Namespace</h5>
|
||||
<Select
|
||||
options={namespaces}
|
||||
value={namespaces.find(s => s.value === namespace) || ''}
|
||||
value={namespaces.find(s => s.value === namespace) || namespace || ''}
|
||||
onChange={this.onNamespaceChanged}
|
||||
allowCustomValue={true}
|
||||
backspaceRemovesValue={true}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<h5>Path</h5>
|
||||
<Select options={paths} value={paths.find(s => s.value === path) || ''} onChange={this.onPathChanged} />
|
||||
<Select
|
||||
options={paths}
|
||||
value={paths.find(s => s.value === path) || path || ''}
|
||||
onChange={this.onPathChanged}
|
||||
allowCustomValue={true}
|
||||
backspaceRemovesValue={true}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
|
||||
@@ -3,12 +3,14 @@ import { Unsubscribable, PartialObserver } from 'rxjs';
|
||||
import { getGrafanaLiveSrv } from '@grafana/runtime';
|
||||
import {
|
||||
AppEvents,
|
||||
isLiveChannelStatusEvent,
|
||||
LiveChannel,
|
||||
LiveChannelConfig,
|
||||
LiveChannelConnectionState,
|
||||
LiveChannelMessage,
|
||||
LiveChannelEvent,
|
||||
LiveChannelEventType,
|
||||
LiveChannelScope,
|
||||
LiveChannelStatus,
|
||||
LiveChannelStatusEvent,
|
||||
} from '@grafana/data';
|
||||
import { Input, Button } from '@grafana/ui';
|
||||
import { appEvents } from 'app/core/core';
|
||||
@@ -22,7 +24,7 @@ interface Props {
|
||||
|
||||
interface State {
|
||||
channel?: LiveChannel;
|
||||
status: LiveChannelStatus;
|
||||
status: LiveChannelStatusEvent;
|
||||
count: number;
|
||||
lastTime: number;
|
||||
lastBody: string;
|
||||
@@ -31,7 +33,12 @@ interface State {
|
||||
|
||||
export class LivePanel extends PureComponent<Props, State> {
|
||||
state: State = {
|
||||
status: { id: '?', state: LiveChannelConnectionState.Pending, timestamp: Date.now() },
|
||||
status: {
|
||||
type: LiveChannelEventType.Status,
|
||||
id: '?',
|
||||
state: LiveChannelConnectionState.Pending,
|
||||
timestamp: Date.now(),
|
||||
},
|
||||
count: 0,
|
||||
lastTime: 0,
|
||||
lastBody: '',
|
||||
@@ -39,15 +46,15 @@ export class LivePanel extends PureComponent<Props, State> {
|
||||
};
|
||||
subscription?: Unsubscribable;
|
||||
|
||||
streamObserver: PartialObserver<LiveChannelMessage> = {
|
||||
next: (msg: LiveChannelMessage) => {
|
||||
if (msg.type === 'status') {
|
||||
this.setState({ status: msg.message as LiveChannelStatus });
|
||||
streamObserver: PartialObserver<LiveChannelEvent> = {
|
||||
next: (event: LiveChannelEvent) => {
|
||||
if (isLiveChannelStatusEvent(event)) {
|
||||
this.setState({ status: event });
|
||||
} else {
|
||||
this.setState({
|
||||
count: this.state.count + 1,
|
||||
lastTime: Date.now(),
|
||||
lastBody: JSON.stringify(msg),
|
||||
lastBody: JSON.stringify(event),
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user