This commit is contained in:
purifetchi 2025-01-15 23:16:11 +01:00
parent e2a4487064
commit d7e136a7c3

View file

@ -14,33 +14,19 @@
const totalSize = ref(0); const totalSize = ref(0);
const totalSizePercent = ref(0); const totalSizePercent = ref(0);
const files = ref([]);
const visible = ref(false); const visible = ref(false);
const toast = useToast(); const toast = useToast();
const filename = ref<string>(""); const filename = ref<string>("");
const onRemoveTemplatingFile = (file, removeFileCallback, index) => { const onRemoveTemplatingFile = (file: File, removeFileCallback: (arg0: number) => void, index: number) => {
removeFileCallback(index); removeFileCallback(index);
totalSize.value -= parseInt(formatSize(file.size)); totalSize.value -= parseInt(formatSize(file.size));
totalSizePercent.value = totalSize.value / 10; totalSizePercent.value = totalSize.value / 10;
}; };
const onClearTemplatingUpload = (clear) => { const uploadEvent = (callback: () => void) => {
clear();
totalSize.value = 0;
totalSizePercent.value = 0;
};
const onSelectedFiles = (event) => {
files.value = event.files;
files.value.forEach((file) => {
totalSize.value += parseInt(formatSize(file.size));
});
};
const uploadEvent = (callback) => {
totalSizePercent.value = totalSize.value / 10; totalSizePercent.value = totalSize.value / 10;
callback(); callback();
}; };
@ -59,7 +45,7 @@
} }
}; };
const formatSize = (bytes) => { const formatSize = (bytes: number) => {
const k = 1024; const k = 1024;
const dm = 3; const dm = 3;
const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];