π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
fix(nc-gui): show uploading loader
Ramesh Mane95990ef3bc45
diff --git a/packages/nc-gui/components/cell/attachment/index.vue b/packages/nc-gui/components/cell/attachment/index.vueindex 661482ef83..99153c0509 100644--- a/packages/nc-gui/components/cell/attachment/index.vue+++ b/packages/nc-gui/components/cell/attachment/index.vue@@ -66,6 +66,8 @@ const {removeFile,updateAttachmentTitle,isEditAllowed,+ isSharedForm,+ isUploading,} = useProvideAttachmentCell(updateModelValue)const { dragging } = useSortable(sortableRef, visibleItems, updateModelValue, isReadonly)@@ -355,18 +357,19 @@ onUnmounted(() => {<divclass="flex":class="{- 'w-full': !visibleItems.length,+ 'w-full': !visibleItems.length || isUploading,}"><NcTooltip:disabled="isEditAllowed || !isAllowed":title="$t('tooltip.sourceDataIsReadonly')"+ class="flex items-center justify-between":class="{- 'w-full': !visibleItems.length,+ 'w-full': !visibleItems.length || isUploading,}"><NcButton- v-if="visibleItems.length"+ v-if="visibleItems.length || isUploading"data-testid="attachment-cell-file-picker-button"type="secondary"size="small"@@ -410,6 +413,14 @@ onUnmounted(() => {{{ $t('labels.toUpload') }}</span></div>++ <div+ v-if="isUploading && !isSharedForm"+ class="flex items-center gap-1.5 h-full pb-1 text-bodyDefaultSm !text-nc-content-gray-muted"+ >+ <GeneralLoader class="!text-inherit" />+ <div>{{ $t('labels.uploading') }}</div>+ </div></NcTooltip></div>@@ -418,7 +429,9 @@ onUnmounted(() => {:class="{'top-0 bottom-0 -right-1 left-0': !visibleItems.length,'-top-1 -left-1 -right-1 bottom-0': visibleItems.length,- 'hidden': visibleItems.length && (!isOverDropZone || isReadonly || dragging || !currentCellRef),+ 'hidden':+ (visibleItems.length && (!isOverDropZone || isReadonly || dragging || !currentCellRef)) ||+ (isUploading && !visibleItems.length),'border-nc-border-medium': !visibleItems.length && !isOverDropZone,'border-nc-fill-primary': isOverDropZone && isEditAllowed,}"diff --git a/packages/nc-gui/components/cell/attachment/utils.ts b/packages/nc-gui/components/cell/attachment/utils.tsindex dd98b5c8bc..d09a0fe5b6 100644--- a/packages/nc-gui/components/cell/attachment/utils.ts+++ b/packages/nc-gui/components/cell/attachment/utils.ts@@ -62,6 +62,13 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState(const permissionGranted = ref(false)+ // User can drag and drop files multiple times so we have to keep track of that and reduce count after upload are done+ const uploadingCount = ref(0)++ const isUploading = computed(() => {+ return uploadingCount.value > 0+ })+const { base } = storeToRefs(useBase())const { api, isLoading } = useApi()@@ -227,6 +234,7 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState(}if (files.length) {+ uploadingCount.value++try {const data = await batchUploadFiles(files, [NOCO, base.value.id, meta.value?.id, column.value?.id].join('/'))@@ -243,6 +251,8 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState(}} catch (e: any) {message.error((await extractSdkResponseErrorMsg(e)) || t('msg.error.internalError'))+ } finally {+ uploadingCount.value--}} else if (imageUrls.length) {const data = await uploadViaUrl(imageUrls)@@ -253,6 +263,7 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState(}async function uploadViaUrl(url: AttachmentReqType | AttachmentReqType[], returnError = false) {+ uploadingCount.value++const imageUrl = Array.isArray(url) ? url : [url]try {const data = await api.storage.uploadByUrl(@@ -269,6 +280,8 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState(}message.error("File couldn't be uploaded. Verify URL & try again.")return null+ } finally {+ uploadingCount.value--}}@@ -568,6 +581,7 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState(updateAttachmentTitle,isEditAllowed,isSharedForm,+ isUploading,}},'useAttachmentCell',