fix(frontend) : refresh documents locally after upload/delete and improve progress UX
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -28,8 +28,10 @@
|
||||
<div class="mt-1 h-1.5 w-full overflow-hidden rounded-full bg-neutral-200">
|
||||
<div
|
||||
class="h-full rounded-full transition-all"
|
||||
:class="upload.error ? 'bg-red-500' : 'bg-blue-500'"
|
||||
:style="{ width: `${upload.progress}%` }"
|
||||
:class="[
|
||||
upload.error ? 'bg-red-500' : upload.uploading ? 'animate-pulse bg-blue-400' : 'bg-green-500',
|
||||
]"
|
||||
:style="{ width: upload.uploading ? '70%' : `${upload.progress}%` }"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -64,6 +66,7 @@ const isDragging = ref(false)
|
||||
type UploadState = {
|
||||
name: string
|
||||
progress: number
|
||||
uploading: boolean
|
||||
error: boolean
|
||||
}
|
||||
|
||||
@@ -99,19 +102,18 @@ async function processFiles(files: File[]) {
|
||||
|
||||
const state: UploadState = reactive({
|
||||
name: file.name,
|
||||
progress: 0,
|
||||
progress: 30,
|
||||
uploading: true,
|
||||
error: false,
|
||||
})
|
||||
uploads.value.push(state)
|
||||
|
||||
try {
|
||||
await uploadFile(props.taskId, file)
|
||||
state.uploading = false
|
||||
state.progress = 100
|
||||
toast.success({
|
||||
title: 'Succès',
|
||||
message: t('taskDocuments.uploaded'),
|
||||
})
|
||||
} catch {
|
||||
state.uploading = false
|
||||
state.error = true
|
||||
state.progress = 100
|
||||
toast.error({
|
||||
@@ -119,13 +121,13 @@ async function processFiles(files: File[]) {
|
||||
message: t('taskDocuments.uploadError'),
|
||||
})
|
||||
}
|
||||
|
||||
emit('uploaded')
|
||||
}
|
||||
|
||||
// Clean up completed uploads after a delay
|
||||
setTimeout(() => {
|
||||
uploads.value = uploads.value.filter(u => u.error)
|
||||
}, 2000)
|
||||
|
||||
emit('uploaded')
|
||||
}, 1500)
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user