Adding the ability to track file upload percentage and currently uploaded/total upload
This commit is contained in:
parent
ae0af1f996
commit
7634992946
@ -10,6 +10,8 @@
|
||||
<div class="upload-info">
|
||||
<div class="upload-speed">{{ uploadSpeed.toFixed(2) }} MB/s</div>
|
||||
<div class="upload-eta">{{ formattedETA }} remaining</div>
|
||||
<div class="upload-percentage"> {{ getProgress }} % Completed </div>
|
||||
<div class="upload-fraction"> / {{ getTotalSize }} </div>
|
||||
</div>
|
||||
<button
|
||||
class="action"
|
||||
@ -72,6 +74,8 @@ export default {
|
||||
"filesInUploadCount",
|
||||
"uploadSpeed",
|
||||
"getETA",
|
||||
"getProgress",
|
||||
"getTotalSize"
|
||||
]),
|
||||
...mapWritableState(useFileStore, ["reload"]),
|
||||
...mapActions(useUploadStore, ["reset"]),
|
||||
|
||||
@ -47,6 +47,16 @@ export const useUploadStore = defineStore("upload", {
|
||||
const sum = state.progress.reduce((acc, val) => +acc + +val) as number;
|
||||
return Math.ceil((sum / totalSize) * 100);
|
||||
},
|
||||
getTotalSize: (state) => {
|
||||
if (state.sizes.length === 0) {
|
||||
return '0 Bytes';
|
||||
}
|
||||
|
||||
const totalSize = state.sizes.reduce((a, b) => a + b, 0);
|
||||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
const i = Math.floor(Math.log(totalSize) / Math.log(1024));
|
||||
return parseFloat((totalSize / Math.pow(1024, i)).toFixed(2)) + ' ' + sizes[i];
|
||||
},
|
||||
filesInUploadCount: (state) => {
|
||||
return Object.keys(state.uploads).length + state.queue.length;
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user