Skip to content

Commit 5a27778

Browse files
committed
fix: manual refersh
1 parent e67a8ca commit 5a27778

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

thingconnect.pulse.client/src/pages/History.tsx

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,9 @@ import {
1616
VStack,
1717
Tabs,
1818
Center,
19-
Box,
2019
EmptyState,
2120
} from '@chakra-ui/react';
22-
import {
23-
Download,
24-
TrendingUp,
25-
AlertCircle,
26-
RefreshCw,
27-
Icon,
28-
Database,
29-
SearchX,
30-
} from 'lucide-react';
21+
import { Download, TrendingUp, AlertCircle, RefreshCw, SearchX } from 'lucide-react';
3122
import { Page } from '@/components/layout/Page';
3223
import { PageSection } from '@/components/layout/PageSection';
3324

@@ -113,22 +104,23 @@ export default function History() {
113104
data: historyData,
114105
isLoading: isHistoryDataLoading,
115106
refetch,
107+
isRefetching: isHistoryDataRefetching,
116108
} = useQuery({
117109
queryKey: ['history', selectedEndpoint, dateRange, bucket],
118110
queryFn: () => {
119111
if (!selectedEndpoint) return null;
112+
const latestTo = new Date().toISOString();
120113

121114
return HistoryService.getEndpointHistory({
122115
id: selectedEndpoint,
123116
from: new Date(dateRange.from).toISOString(),
124-
to: new Date(dateRange.to).toISOString(),
117+
to: latestTo,
125118
bucket,
126119
});
127120
},
128121
enabled: !!selectedEndpoint,
129122
retry: 1,
130123
});
131-
132124
const handleExportCSV = async () => {
133125
if (!selectedEndpoint) return;
134126

@@ -238,8 +230,17 @@ export default function History() {
238230
<IconButton
239231
size='xs'
240232
variant='subtle'
241-
onClick={() => void refetch()}
242-
disabled={isHistoryDataLoading || !selectedEndpoint}
233+
onClick={() => {
234+
setDateRange(prev => ({
235+
...prev,
236+
to: new Date(new Date().getTime() - new Date().getTimezoneOffset() * 60000)
237+
.toISOString()
238+
.slice(0, 16),
239+
}));
240+
void refetch();
241+
}}
242+
loading={isHistoryDataRefetching || isHistoryDataLoading}
243+
disabled={!selectedEndpoint}
243244
>
244245
<RefreshCw />
245246
</IconButton>
@@ -248,8 +249,8 @@ export default function History() {
248249
size='xs'
249250
colorPalette='blue'
250251
onClick={() => void handleExportCSV()}
251-
loading={isExporting}
252-
disabled={!historyData || isHistoryDataLoading}
252+
loading={isExporting || isHistoryDataLoading}
253+
disabled={!historyData}
253254
>
254255
<Download size={16} />
255256
Export CSV

0 commit comments

Comments
 (0)