Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 54 additions & 6 deletions packages/app/src/DBDashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,8 @@ function DBDashboardPage({ presetConfig }: { presetConfig?: Dashboard }) {
parseAsString.withDefault('lucene'),
);

const [isLive, setIsLive] = useState(false);

const { control, watch, setValue, handleSubmit } = useForm<{
granularity: SQLInterval | 'auto';
where: SearchCondition;
Expand Down Expand Up @@ -583,6 +585,17 @@ function DBDashboardPage({ presetConfig }: { presetConfig?: Dashboard }) {
// showRelativeInterval: isLive,
});

const {
granularityOverride,
isRefreshEnabled,
manualRefreshCooloff,
refresh,
} = useDashboardRefresh({
searchedTimeRange,
onTimeRangeSelect,
isLive,
});

const onSubmit = () => {
onSearch(displayedTimeInputValue);
handleSubmit(data => {
Expand Down Expand Up @@ -629,8 +642,9 @@ function DBDashboardPage({ presetConfig }: { presetConfig?: Dashboard }) {
dateRange={searchedTimeRange}
onEditClick={() => setEditedTile(chart)}
granularity={
granularity ?? undefined
// isRefreshEnabled ? granularityOverride : granularityQuery
isRefreshEnabled
? granularityOverride
: (granularity ?? undefined)
}
filters={[
{
Expand Down Expand Up @@ -697,13 +711,12 @@ function DBDashboardPage({ presetConfig }: { presetConfig?: Dashboard }) {
[
dashboard,
searchedTimeRange,
// isRefreshEnabled,
// granularityOverride,
// granularityQuery,
isRefreshEnabled,
granularityOverride,
granularity,
highlightedTileId,
confirm,
setDashboard,
granularity,
where,
whereLanguage,
onTimeRangeSelect,
Expand Down Expand Up @@ -934,6 +947,41 @@ function DBDashboardPage({ presetConfig }: { presetConfig?: Dashboard }) {
}}
/>
<GranularityPickerControlled control={control} name="granularity" />
<Tooltip
withArrow
label={
isRefreshEnabled
? `Auto-refreshing with ${granularityOverride} interval`
: 'Enable auto-refresh'
}
fz="xs"
color="gray"
>
<Button
onClick={() => setIsLive(prev => !prev)}
color={isLive ? 'green' : 'gray'}
mr={6}
size="sm"
variant="outline"
title={isLive ? 'Disable auto-refresh' : 'Enable auto-refresh'}
>
Live
</Button>
</Tooltip>
<Tooltip withArrow label="Refresh dashboard" fz="xs" color="gray">
<Button
onClick={refresh}
loading={manualRefreshCooloff}
disabled={manualRefreshCooloff}
color="gray"
mr={6}
variant="outline"
title="Refresh dashboard"
px="xs"
>
<i className="bi bi-arrow-clockwise text-slate-400 fs-5"></i>
</Button>
</Tooltip>
<Button variant="outline" type="submit" color="green">
<i className="bi bi-play"></i>
</Button>
Expand Down