feat: add fetching loader, progress tooltip with speed/ETA on hover
This commit is contained in:
1 file changed
+26
-14
@@ -124,7 +124,7 @@ export default function DownloadClientsWidget({
|
|||||||
integrationIds.includes(id) ? [id] : [],
|
integrationIds.includes(id) ? [id] : [],
|
||||||
);
|
);
|
||||||
|
|
||||||
const { data: currentItems = [] } = clientApi.widget.downloads.getJobsAndStatuses.useQuery({
|
const { data: currentItems = [], isFetching } = clientApi.widget.downloads.getJobsAndStatuses.useQuery({
|
||||||
integrationIds,
|
integrationIds,
|
||||||
limitPerIntegration: options.limitPerIntegration,
|
limitPerIntegration: options.limitPerIntegration,
|
||||||
});
|
});
|
||||||
@@ -326,19 +326,29 @@ export default function DownloadClientsWidget({
|
|||||||
sortable: true,
|
sortable: true,
|
||||||
width: width < 400 ? 80 : 120,
|
width: width < 400 ? 80 : 120,
|
||||||
...getColumnMeta("progress"),
|
...getColumnMeta("progress"),
|
||||||
render: (record) => (
|
render: (record) => {
|
||||||
<Group gap={4} wrap="nowrap" style={{ flex: 1 }}>
|
const pct = Math.floor(record.progress * 100);
|
||||||
<Text size="xs" fw={500} w={36} ta="right" style={{ flexShrink: 0 }}>
|
const tooltipLabel = [
|
||||||
{`${Math.floor(record.progress * 100)}%`}
|
`${formatBytes(record.received)} / ${formatBytes(record.size)}`,
|
||||||
</Text>
|
record.downSpeed ? `↓ ${formatByteRate(record.downSpeed)}` : null,
|
||||||
<Progress
|
record.time !== 0 ? `ETA: ${dayjs().add(record.time, "milliseconds").fromNow(true)}` : null,
|
||||||
value={Math.floor(record.progress * 100)}
|
].filter(Boolean).join(" · ");
|
||||||
color={progressColor(record.state, record.progress)}
|
return (
|
||||||
size="sm"
|
<Tooltip label={tooltipLabel} withArrow openDelay={300} position="top">
|
||||||
style={{ flex: 1 }}
|
<Group gap={4} wrap="nowrap" style={{ flex: 1 }}>
|
||||||
/>
|
<Text size="xs" fw={500} w={36} ta="right" style={{ flexShrink: 0 }}>
|
||||||
</Group>
|
{`${pct}%`}
|
||||||
),
|
</Text>
|
||||||
|
<Progress
|
||||||
|
value={pct}
|
||||||
|
color={progressColor(record.state, record.progress)}
|
||||||
|
size="sm"
|
||||||
|
style={{ flex: 1 }}
|
||||||
|
/>
|
||||||
|
</Group>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
shouldIncludeColumn("size") && {
|
shouldIncludeColumn("size") && {
|
||||||
accessor: "size",
|
accessor: "size",
|
||||||
@@ -550,6 +560,8 @@ export default function DownloadClientsWidget({
|
|||||||
stripedColor={{ dark: "dark.7", light: "gray.0" }}
|
stripedColor={{ dark: "dark.7", light: "gray.0" }}
|
||||||
highlightOnHoverColor={{ dark: "dark.5", light: "gray.1" }}
|
highlightOnHoverColor={{ dark: "dark.5", light: "gray.1" }}
|
||||||
verticalAlign="center"
|
verticalAlign="center"
|
||||||
|
fetching={isFetching && currentItems.length === 0}
|
||||||
|
loaderBackgroundBlur={2}
|
||||||
fz={size.fontSize}
|
fz={size.fontSize}
|
||||||
records={sortedData}
|
records={sortedData}
|
||||||
columns={effectiveColumns}
|
columns={effectiveColumns}
|
||||||
|
|||||||
Reference in new issue
Block a user