Skip to content

Commit 47a0104

Browse files
authored
Merge pull request galaxyproject#22273 from dannon/ds-size
Show file size for CRAM datasets and in download tooltip
2 parents 138202c + c459400 commit 47a0104

3 files changed

Lines changed: 13 additions & 5 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"

lib/galaxy/datatypes/binary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ def set_index_file(self, dataset: HasFileName, index_file) -> bool:
11391139
def set_peek(self, dataset: DatasetProtocol, **kwd) -> None:
11401140
if not dataset.dataset.purged:
11411141
dataset.peek = "CRAM binary alignment file"
1142-
dataset.blurb = "binary data"
1142+
dataset.blurb = nice_size(dataset.get_size())
11431143
else:
11441144
dataset.peek = "file does not exist"
11451145
dataset.blurb = "file purged from disk"

0 commit comments

Comments
 (0)