Skip to content

Commit c459400

Browse files
committed
Show file size in download button tooltip
Adds the dataset file size to the download button tooltip, so hovering shows something like "Download (1.5 GB)" instead of just "Download". Uses the existing bytesToString formatter. Falls back to plain "Download" for empty or zero-size datasets.
1 parent 34b9310 commit c459400

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

client/src/components/History/Content/Dataset/DatasetDownload.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import DatasetDownload from "./DatasetDownload.vue";
88
const localVue = getLocalVue();
99

1010
const items = [
11-
{ id: "item_id", extension: "ext", meta_files: [{ file_type: "a" }, { file_type: "b" }] },
12-
{ id: "item_id", extension: "ext", meta_files: [] },
11+
{ id: "item_id", extension: "ext", file_size: 1024, meta_files: [{ file_type: "a" }, { file_type: "b" }] },
12+
{ id: "item_id", extension: "ext", file_size: 0, meta_files: [] },
1313
];
1414

1515
describe("DatasetDownload", () => {

client/src/components/History/Content/Dataset/DatasetDownload.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { computed } from "vue";
66
77
import type { HDADetailed } from "@/api";
88
import { prependPath } from "@/utils/redirect";
9+
import { bytesToString } from "@/utils/utils";
910
1011
interface Props {
1112
item: HDADetailed;
@@ -27,6 +28,13 @@ const metaDownloadUrl = computed(() => {
2728
const downloadUrl = computed(() => {
2829
return prependPath(`api/datasets/${props.item.id}/display?to_ext=${props.item.extension}`);
2930
});
31+
const downloadTitle = computed(() => {
32+
const size = props.item.file_size;
33+
if (size) {
34+
return `Download (${bytesToString(size)})`;
35+
}
36+
return "Download";
37+
});
3038
3139
function onDownload(resource: string, extension = "") {
3240
emit("on-download", `${resource}${extension}`);
@@ -43,7 +51,7 @@ function onDownload(resource: string, extension = "") {
4351
size="sm"
4452
variant="link"
4553
toggle-class="text-decoration-none"
46-
title="Download"
54+
:title="downloadTitle"
4755
class="download-btn"
4856
data-description="dataset download">
4957
<template v-slot:button-content>
@@ -68,7 +76,7 @@ function onDownload(resource: string, extension = "") {
6876
v-else
6977
v-g-tooltip.hover
7078
class="download-btn px-1"
71-
title="Download"
79+
:title="downloadTitle"
7280
size="sm"
7381
variant="link"
7482
:href="downloadUrl"

0 commit comments

Comments
 (0)