From 4bc4f975c5c4e753ce408b7754f91b44a680a577 Mon Sep 17 00:00:00 2001 From: Kostiantyn Miakshyn Date: Sat, 26 Oct 2024 20:25:18 +0200 Subject: [PATCH] feat: Show loading indicator on file assembling Signed-off-by: Kostiantyn Miakshyn --- l10n/messages.pot | 3 +++ lib/components/UploadPicker.vue | 20 ++++++++++++++++---- lib/uploader.ts | 17 +++++++++++++++-- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/l10n/messages.pot b/l10n/messages.pot index af7df9cb..2e985e69 100644 --- a/l10n/messages.pot +++ b/l10n/messages.pot @@ -79,6 +79,9 @@ msgstr "" msgid "Preview image" msgstr "" +msgid "Processing..." +msgstr "" + msgid "Rename" msgstr "" diff --git a/lib/components/UploadPicker.vue b/lib/components/UploadPicker.vue index bc297e6a..d510650f 100644 --- a/lib/components/UploadPicker.vue +++ b/lib/components/UploadPicker.vue @@ -126,6 +126,11 @@ +
+ +

{{ t('Processing...') }}

+
+ upload.status === UploadStatus.FAILED).length !== 0 }, isUploading() { - return this.queue?.length > 0 + return this.queue?.filter((upload: Upload) => upload.status === UploadStatus.UPLOADING).length !== 0 }, isAssembling() { return this.queue?.filter((upload: Upload) => upload.status === UploadStatus.ASSEMBLING).length !== 0 @@ -394,7 +401,6 @@ export default Vue.extend({ return Array.isArray(this.content) ? this.content : await this.content(path) }, - /** * Start uploading */ @@ -507,6 +513,12 @@ $progress-width: 200px; &--paused &__progress { animation: breathing 3s ease-out infinite normal; } + + &__loading { + display: flex; + margin-left: 8px; + gap: 8px; + } } @keyframes breathing { diff --git a/lib/uploader.ts b/lib/uploader.ts index 08c387f3..8d4dec75 100644 --- a/lib/uploader.ts +++ b/lib/uploader.ts @@ -7,7 +7,14 @@ import type { WebDAVClient } from 'webdav' import type { IDirectory } from './utils/fileTree' import { getCurrentUser } from '@nextcloud/auth' -import { FileType, Folder, Permission, davGetClient, davRemoteURL, davRootPath } from '@nextcloud/files' +import { + davGetClient, + davRemoteURL, + davRootPath, + FileType, + Folder, + Permission, +} from '@nextcloud/files' import { encodePath } from '@nextcloud/paths' import { normalize } from 'path' @@ -509,6 +516,11 @@ export class Uploader { await Promise.all(chunksQueue) this.updateStats() + // re-add upload because it was reset + this._uploadQueue.push(upload) + upload.status = UploadStatus.ASSEMBLING + this.updateStats() + upload.response = await axios.request({ method: 'MOVE', url: `${tempUrl}/.file`, @@ -520,8 +532,9 @@ export class Uploader { }, }) - this.updateStats() + this._uploadQueue.push(upload) upload.status = UploadStatus.FINISHED + this.updateStats() logger.debug(`Successfully uploaded ${file.name}`, { file, upload }) resolve(upload) } catch (error) {