Skip to content

Commit dbf1682

Browse files
feat: add refresh to existing preset dashboards (#1249)
Closes HDX-2046 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent daffcf3 commit dbf1682

File tree

4 files changed

+113
-34
lines changed

4 files changed

+113
-34
lines changed

.changeset/rude-pants-yell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hyperdx/app": minor
3+
---
4+
5+
feat: add refresh to existing preset dashboards

packages/app/src/ClickhousePage.tsx

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
SegmentedControl,
2121
Tabs,
2222
Text,
23+
Tooltip,
2324
} from '@mantine/core';
2425
import ReactCodeMirror from '@uiw/react-codemirror';
2526

@@ -33,6 +34,7 @@ import DBHeatmapChart from './components/DBHeatmapChart';
3334
import { DBSqlRowTable } from './components/DBRowTable';
3435
import DBTableChart from './components/DBTableChart';
3536
import OnboardingModal from './components/OnboardingModal';
37+
import { useDashboardRefresh } from './hooks/useDashboardRefresh';
3638
import { useConnections } from './connection';
3739
import { parseTimeQuery, useNewTimeQuery } from './timeQuery';
3840

@@ -457,6 +459,15 @@ function ClickhousePage() {
457459
// showRelativeInterval: isLive,
458460
});
459461

462+
// For future use if Live button is added
463+
const [isLive, setIsLive] = useState(false);
464+
465+
const { manualRefreshCooloff, refresh } = useDashboardRefresh({
466+
searchedTimeRange,
467+
onTimeRangeSelect,
468+
isLive,
469+
});
470+
460471
const filters = useMemo(() => {
461472
const { latencyMin, latencyMax } = latencyFilter;
462473
return [
@@ -497,21 +508,35 @@ function ClickhousePage() {
497508
size="xs"
498509
/>
499510
</Group>
500-
<form
501-
onSubmit={e => {
502-
e.preventDefault();
503-
onSearch(displayedTimeInputValue);
504-
return false;
505-
}}
506-
>
507-
<TimePicker
508-
inputValue={displayedTimeInputValue}
509-
setInputValue={setDisplayedTimeInputValue}
510-
onSearch={range => {
511-
onSearch(range);
511+
<Group gap="xs">
512+
<form
513+
onSubmit={e => {
514+
e.preventDefault();
515+
onSearch(displayedTimeInputValue);
516+
return false;
512517
}}
513-
/>
514-
</form>
518+
>
519+
<TimePicker
520+
inputValue={displayedTimeInputValue}
521+
setInputValue={setDisplayedTimeInputValue}
522+
onSearch={onSearch}
523+
/>
524+
</form>
525+
<Tooltip withArrow label="Refresh dashboard" fz="xs" color="gray">
526+
<Button
527+
onClick={refresh}
528+
loading={manualRefreshCooloff}
529+
disabled={manualRefreshCooloff}
530+
color="gray"
531+
variant="outline"
532+
title="Refresh dashboard"
533+
aria-label="Refresh dashboard"
534+
px="xs"
535+
>
536+
<i className="bi bi-arrow-clockwise fs-5"></i>
537+
</Button>
538+
</Tooltip>
539+
</Group>
515540
</Group>
516541
<Tabs
517542
mt="md"

packages/app/src/KubernetesDashboardPage.tsx

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { SourceKind, TSource } from '@hyperdx/common-utils/dist/types';
1111
import {
1212
Badge,
1313
Box,
14+
Button,
1415
Card,
1516
Flex,
1617
Grid,
@@ -34,6 +35,7 @@ import OnboardingModal from './components/OnboardingModal';
3435
import SourceSchemaPreview from './components/SourceSchemaPreview';
3536
import { SourceSelectControlled } from './components/SourceSelect';
3637
import { useQueriedChartConfig } from './hooks/useChartConfig';
38+
import { useDashboardRefresh } from './hooks/useDashboardRefresh';
3739
import {
3840
convertDateRangeToGranularityString,
3941
convertV1ChartConfigToV2,
@@ -856,6 +858,7 @@ function KubernetesDashboardPage() {
856858
displayedTimeInputValue,
857859
setDisplayedTimeInputValue,
858860
onSearch,
861+
onTimeRangeSelect,
859862
} = useTimeQuery({
860863
defaultValue: 'Past 1h',
861864
defaultTimeRange: [
@@ -864,6 +867,15 @@ function KubernetesDashboardPage() {
864867
],
865868
});
866869

870+
// For future use if Live button is added
871+
const [isLive, setIsLive] = React.useState(false);
872+
873+
const { manualRefreshCooloff, refresh } = useDashboardRefresh({
874+
searchedTimeRange: dateRange,
875+
onTimeRangeSelect,
876+
isLive,
877+
});
878+
867879
const whereClause = searchQuery;
868880

869881
const [_searchQuery, _setSearchQuery] = React.useState<string | null>(null);
@@ -925,23 +937,37 @@ function KubernetesDashboardPage() {
925937
/>
926938
</Group>
927939

928-
<form
929-
data-testid="kubernetes-time-form"
930-
onSubmit={e => {
931-
e.preventDefault();
932-
onSearch(displayedTimeInputValue);
933-
return false;
934-
}}
935-
>
936-
<TimePicker
937-
data-testid="kubernetes-time-picker"
938-
inputValue={displayedTimeInputValue}
939-
setInputValue={setDisplayedTimeInputValue}
940-
onSearch={range => {
941-
onSearch(range);
940+
<Group gap="xs">
941+
<form
942+
data-testid="kubernetes-time-form"
943+
onSubmit={e => {
944+
e.preventDefault();
945+
onSearch(displayedTimeInputValue);
946+
return false;
942947
}}
943-
/>
944-
</form>
948+
>
949+
<TimePicker
950+
data-testid="kubernetes-time-picker"
951+
inputValue={displayedTimeInputValue}
952+
setInputValue={setDisplayedTimeInputValue}
953+
onSearch={onSearch}
954+
/>
955+
</form>
956+
<Tooltip withArrow label="Refresh dashboard" fz="xs" color="gray">
957+
<Button
958+
onClick={refresh}
959+
loading={manualRefreshCooloff}
960+
disabled={manualRefreshCooloff}
961+
color="gray"
962+
variant="outline"
963+
title="Refresh dashboard"
964+
aria-label="Refresh dashboard"
965+
px="xs"
966+
>
967+
<i className="bi bi-arrow-clockwise fs-5"></i>
968+
</Button>
969+
</Tooltip>
970+
</Group>
945971
</Group>
946972
{metricSource && (
947973
<KubernetesFilters

packages/app/src/ServicesDashboardPage.tsx

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
SegmentedControl,
2323
Tabs,
2424
Text,
25+
Tooltip,
2526
} from '@mantine/core';
2627

2728
import {
@@ -43,6 +44,7 @@ import { SQLInlineEditorControlled } from '@/components/SQLInlineEditor';
4344
import { TimePicker } from '@/components/TimePicker';
4445
import WhereLanguageControlled from '@/components/WhereLanguageControlled';
4546
import { useQueriedChartConfig } from '@/hooks/useChartConfig';
47+
import { useDashboardRefresh } from '@/hooks/useDashboardRefresh';
4648
import { useJsonColumns } from '@/hooks/useMetadata';
4749
import { withAppNav } from '@/layout';
4850
import SearchInputV2 from '@/SearchInputV2';
@@ -895,12 +897,21 @@ function ServicesDashboardPage() {
895897
const [displayedTimeInputValue, setDisplayedTimeInputValue] =
896898
useState(DEFAULT_INTERVAL);
897899

898-
const { searchedTimeRange, onSearch } = useNewTimeQuery({
900+
const { searchedTimeRange, onSearch, onTimeRangeSelect } = useNewTimeQuery({
899901
initialDisplayValue: DEFAULT_INTERVAL,
900902
initialTimeRange: defaultTimeRange,
901903
setDisplayedTimeInputValue,
902904
});
903905

906+
// For future use if Live button is added
907+
const [isLive, setIsLive] = useState(false);
908+
909+
const { manualRefreshCooloff, refresh } = useDashboardRefresh({
910+
searchedTimeRange,
911+
onTimeRangeSelect,
912+
isLive,
913+
});
914+
904915
const onSubmit = useCallback(() => {
905916
onSearch(displayedTimeInputValue);
906917
handleSubmit(values => {
@@ -990,10 +1001,22 @@ function ServicesDashboardPage() {
9901001
<TimePicker
9911002
inputValue={displayedTimeInputValue}
9921003
setInputValue={setDisplayedTimeInputValue}
993-
onSearch={range => {
994-
onSearch(range);
995-
}}
1004+
onSearch={onSearch}
9961005
/>
1006+
<Tooltip withArrow label="Refresh dashboard" fz="xs" color="gray">
1007+
<Button
1008+
onClick={refresh}
1009+
loading={manualRefreshCooloff}
1010+
disabled={manualRefreshCooloff}
1011+
color="gray"
1012+
variant="outline"
1013+
title="Refresh dashboard"
1014+
aria-label="Refresh dashboard"
1015+
px="xs"
1016+
>
1017+
<i className="bi bi-arrow-clockwise fs-5"></i>
1018+
</Button>
1019+
</Tooltip>
9971020
<Button variant="outline" type="submit" px="sm">
9981021
<i className="bi bi-play"></i>
9991022
</Button>

0 commit comments

Comments
 (0)