Dashboard: keep live timeseries moving left (v2) (#37769)

This commit is contained in:
Ryan McKinley
2021-08-20 14:48:55 -07:00
committed by GitHub
parent 32e11434da
commit 8c4c05493b
10 changed files with 197 additions and 41 deletions

View File

@@ -53,6 +53,11 @@ export function GeneralSettingsUnconnected({ dashboard, updateTimeZone }: Props)
setRenderCounter(renderCounter + 1);
};
const onLiveNowChange = (v: boolean) => {
dashboard.liveNow = v;
setRenderCounter(renderCounter + 1);
};
const onTimeZoneChange = (timeZone: TimeZone) => {
dashboard.timezone = timeZone;
setRenderCounter(renderCounter + 1);
@@ -113,10 +118,12 @@ export function GeneralSettingsUnconnected({ dashboard, updateTimeZone }: Props)
onRefreshIntervalChange={onRefreshIntervalChange}
onNowDelayChange={onNowDelayChange}
onHideTimePickerChange={onHideTimePickerChange}
onLiveNowChange={onLiveNowChange}
refreshIntervals={dashboard.timepicker.refresh_intervals}
timePickerHidden={dashboard.timepicker.hidden}
nowDelay={dashboard.timepicker.nowDelay}
timezone={dashboard.timezone}
liveNow={dashboard.liveNow}
/>
<CollapsableSection label="Panel options" isOpen={true}>

View File

@@ -10,10 +10,12 @@ interface Props {
onRefreshIntervalChange: (interval: string[]) => void;
onNowDelayChange: (nowDelay: string) => void;
onHideTimePickerChange: (hide: boolean) => void;
onLiveNowChange: (liveNow: boolean) => void;
refreshIntervals: string[];
timePickerHidden: boolean;
nowDelay: string;
timezone: TimeZone;
liveNow: boolean;
}
interface State {
@@ -43,6 +45,10 @@ export class TimePickerSettings extends PureComponent<Props, State> {
this.props.onHideTimePickerChange(!this.props.timePickerHidden);
};
onLiveNowChange = () => {
this.props.onLiveNowChange(!this.props.liveNow);
};
onTimeZoneChange = (timeZone?: string) => {
if (typeof timeZone !== 'string') {
return;
@@ -79,6 +85,12 @@ export class TimePickerSettings extends PureComponent<Props, State> {
<Field label="Hide time picker">
<Switch value={!!this.props.timePickerHidden} onChange={this.onHideTimePickerChange} />
</Field>
<Field
label="Refresh live dashboards"
description="Continuously re-draw panels where the time range references 'now'"
>
<Switch value={!!this.props.liveNow} onChange={this.onLiveNowChange} />
</Field>
</CollapsableSection>
);
}