From 93e2ef61fc47e793d78b6c1051cbdbcd975e87e0 Mon Sep 17 00:00:00 2001 From: Cyberes Date: Fri, 14 Jun 2024 12:19:38 -0600 Subject: [PATCH] improve upload flow --- .../src/components/import/ImportHome.vue | 32 ++++++++++++------- .../src/components/import/Upload.vue | 14 +------- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/geo-frontend/src/components/import/ImportHome.vue b/src/geo-frontend/src/components/import/ImportHome.vue index ed16628..a9d4602 100644 --- a/src/geo-frontend/src/components/import/ImportHome.vue +++ b/src/geo-frontend/src/components/import/ImportHome.vue @@ -10,6 +10,7 @@ + @@ -17,6 +18,9 @@ + @@ -24,7 +28,7 @@ {{ item.processing === true ? "processing" : item.feature_count }} @@ -54,17 +58,21 @@ export default { const response = await axios.get('/api/data/item/import/get/mine') this.processQueue = response.data.data }, - async deleteItem(id) { - try { - const response = await axios.delete('/api/data/item/import/delete/' + id, { - headers: { - 'X-CSRFToken': this.userInfo.csrftoken - } - }) - await this.fetchQueueList() - } catch (error) { - alert(`Failed to delete ${id}: ${error.message}`) - } + async deleteItem(item, index) { + if (window.confirm(`Delete "${item.original_filename}" (#${item.id})`)) + try { + this.processQueue.splice(index, 1) + // TODO: add a message popup when delete is completed + const response = await axios.delete('/api/data/item/import/delete/' + item.id, { + headers: { + 'X-CSRFToken': this.userInfo.csrftoken + } + }) + await this.fetchQueueList() + } catch (error) { + alert(`Failed to delete ${item.id}: ${error.message}`) + this.processQueue.splice(index, 0, item) + } } }, async created() { diff --git a/src/geo-frontend/src/components/import/Upload.vue b/src/geo-frontend/src/components/import/Upload.vue index 8d62b1a..0262fe8 100644 --- a/src/geo-frontend/src/components/import/Upload.vue +++ b/src/geo-frontend/src/components/import/Upload.vue @@ -56,6 +56,7 @@ export default { let formData = new FormData() formData.append('file', this.file) try { + this.disableUpload = true const response = await axios.post('/api/data/item/import/upload/', formData, { headers: { 'Content-Type': 'multipart/form-data', @@ -63,7 +64,6 @@ export default { } }) this.uploadMsg = `

${capitalizeFirstLetter(response.data.msg).trim(".")}.

Continue to Import` - this.disableUpload = true await this.fetchQueueList() this.file = null document.getElementById("uploadInput").value = "" @@ -82,18 +82,6 @@ export default { const response = await axios.get('/api/data/item/import/get/mine') this.processQueue = response.data.data }, - async deleteItem(id) { - try { - const response = await axios.delete('/api/data/item/import/delete/' + id, { - headers: { - 'X-CSRFToken': this.userInfo.csrftoken - } - }) - await this.fetchQueueList() - } catch (error) { - alert(`Failed to delete ${id}: ${error.message}`) - } - } }, async created() { },

ID File Name Features
+ {{ item.id }} + {{ item.original_filename }} - +