Dashboards: Support an auto refresh interval that is based on the query range (#70479)

This commit is contained in:
Ryan McKinley
2023-06-26 09:46:23 -07:00
committed by GitHub
parent 2233886f80
commit 698b07518a
16 changed files with 126 additions and 38 deletions

View File

@@ -7,6 +7,7 @@ import { defaultIntervals, RefreshPicker } from '@grafana/ui';
import { TimePickerWithHistory } from 'app/core/components/TimePicker/TimePickerWithHistory';
import { appEvents } from 'app/core/core';
import { t } from 'app/core/internationalization';
import { AutoRefreshInterval } from 'app/core/services/context_srv';
import { getTimeSrv } from 'app/features/dashboard/services/TimeSrv';
import { ShiftTimeEvent, ShiftTimeEventDirection, ZoomOutEvent } from '../../../../types/events';
@@ -87,6 +88,11 @@ export class DashNavTimeControls extends Component<Props> {
const fiscalYearStartMonth = dashboard.fiscalYearStartMonth;
const hideIntervalPicker = dashboard.panelInEdit?.isEditing;
let text: string | undefined = undefined;
if (dashboard.refresh === AutoRefreshInterval) {
text = getTimeSrv().getAutoRefreshInteval().interval;
}
return (
<>
<TimePickerWithHistory
@@ -109,6 +115,8 @@ export class DashNavTimeControls extends Component<Props> {
isOnCanvas={isOnCanvas}
tooltip={t('dashboard.toolbar.refresh', 'Refresh dashboard')}
noIntervalPicker={hideIntervalPicker}
showAutoInterval={true}
text={text}
/>
</>
);