forked from galaxyproject/galaxy
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathZipImportSummary.vue
More file actions
111 lines (96 loc) · 3.92 KB
/
ZipImportSummary.vue
File metadata and controls
111 lines (96 loc) · 3.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<script setup lang="ts">
import { faFile, faNetworkWired } from "@fortawesome/free-solid-svg-icons";
import { BPagination } from "bootstrap-vue";
import { computed } from "vue";
import type { CardBadge } from "@/components/Common/GCard.types";
import { usePagination } from "@/composables/pagination";
import type { ImportableFile } from "@/composables/zipExplorer";
import { bytesToString } from "@/utils/utils";
import ZipFileEntrySummaryCard from "./ZipFileEntrySummaryCard.vue";
import GCard from "@/components/Common/GCard.vue";
interface Props {
filesToImport: ImportableFile[];
}
const props = defineProps<Props>();
const workflowFiles = computed(() => {
return props.filesToImport.filter((file) => file.type === "workflow");
});
const regularFiles = computed(() => {
return props.filesToImport.filter((file) => file.type === "file");
});
const totalFileSize = computed(() => {
return regularFiles.value.reduce((total, file) => total + file.size, 0);
});
const allItems = computed(() => [...workflowFiles.value, ...regularFiles.value]);
const { currentPage, itemsPerPage, paginatedItems, totalItems, showPagination, onPageChange } = usePagination(allItems);
const paginatedWorkflows = computed(() => paginatedItems.value.filter((item) => item.type === "workflow"));
const paginatedFiles = computed(() => paginatedItems.value.filter((item) => item.type === "file"));
const workflowBadges: CardBadge[] = [
{
id: "workflow-count",
label: `${workflowFiles.value.length} workflow${workflowFiles.value.length > 1 ? "s" : ""}`,
title: "Number of Workflows to import",
},
];
const fileBadges: CardBadge[] = [
{
id: "file-count",
label: `${regularFiles.value.length} file${regularFiles.value.length > 1 ? "s" : ""}`,
title: "Number of Files to import",
},
{
id: "total-size",
label: bytesToString(totalFileSize.value, true, undefined),
title: "Total Size of Files to import",
variant: "info",
},
];
</script>
<template>
<div class="w-100">
<div class="d-flex flex-grow-1">
<GCard
v-if="paginatedWorkflows.length > 0"
id="zip-workflows-summary"
title="Workflows to Import"
title-size="md"
:title-icon="{ icon: faNetworkWired }"
:badges="workflowBadges">
<template v-slot:description>
<p v-localize>The following workflows will be imported from the archive into your account.</p>
<div class="d-flex flex-wrap">
<ZipFileEntrySummaryCard v-for="file in paginatedWorkflows" :key="file.path" :file="file" />
</div>
</template>
</GCard>
<GCard
v-if="paginatedFiles.length > 0"
id="zip-files-summary"
title="Files to Import"
title-size="md"
:title-icon="{ icon: faFile }"
:badges="fileBadges">
<template v-slot:description>
<p v-localize>
The following files will be imported from the archive into your
<b>currently active Galaxy history</b>.
</p>
<div class="d-flex flex-wrap">
<ZipFileEntrySummaryCard v-for="file in paginatedFiles" :key="file.path" :file="file" />
</div>
</template>
</GCard>
</div>
<div v-if="showPagination" class="d-flex justify-content-center py-3 mt-3">
<BPagination
:value="currentPage"
:total-rows="totalItems"
:per-page="itemsPerPage"
align="center"
size="sm"
first-number
last-number
@change="onPageChange" />
</div>
</div>
</template>