From aa90ed8cc4eedddd85174253473afda5eb9225be Mon Sep 17 00:00:00 2001 From: Cyberes Date: Mon, 8 Jul 2024 21:03:35 -0600 Subject: [PATCH] improve loading on site page --- .../geo_lib/daemon/workers/importer.py | 3 +- .../src/components/import/Process.vue | 29 ++++++++++++------- .../src/components/import/Upload.vue | 5 ---- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/geo-backend/geo_lib/daemon/workers/importer.py b/src/geo-backend/geo_lib/daemon/workers/importer.py index 3a97a3c..6a529b5 100644 --- a/src/geo-backend/geo_lib/daemon/workers/importer.py +++ b/src/geo-backend/geo_lib/daemon/workers/importer.py @@ -45,6 +45,7 @@ def import_worker(): geofetures = [] messages = [] try: + # The actual import. geojson_data, kml_conv_messages = kml_to_geojson(item['raw_kml']) messages.extend(kml_conv_messages) geofetures, typing_messages = geojson_to_geofeature(geojson_data) @@ -61,7 +62,7 @@ def import_worker(): messages.append(create_import_log_msg(f'{err_name}: {err_msg}')) log_to_db(msg, level=DatabaseLogLevel.ERROR, user_id=item['user_id'], source=DatabaseLogSource.IMPORT) traceback.print_exc() - features = [] + features = [] # dummy data if success: features = [json.loads(x.model_dump_json()) for x in geofetures] with CursorFromConnectionFromPool(cursor_factory=RealDictCursor) as cursor: diff --git a/src/geo-frontend/src/components/import/Process.vue b/src/geo-frontend/src/components/import/Process.vue index c305209..33fa9dc 100644 --- a/src/geo-frontend/src/components/import/Process.vue +++ b/src/geo-frontend/src/components/import/Process.vue @@ -38,6 +38,7 @@ export default { return { msg: "", importResponse: {}, + currentId: null, } }, mixins: [authMixin], @@ -53,18 +54,24 @@ export default { }, beforeRouteEnter(to, from, next) { next(async vm => { - axios.get('/api/data/item/import/get/' + vm.id).then(response => { - if (!response.data.success) { - vm.handleError(response.data.msg) - } else { - if (Object.keys(response.data).length > 0) { - vm.importResponse = response.data + if (vm.currentId !== vm.id) { + vm.msg = "" + vm.importResponse = [] + vm.currentId = null + axios.get('/api/data/item/import/get/' + vm.id).then(response => { + if (!response.data.success) { + vm.handleError(response.data.msg) + } else { + vm.currentId = vm.id + if (Object.keys(response.data).length > 0) { + vm.importResponse = response.data + } + vm.msg = response.data.msg } - vm.msg = response.data.msg - } - }).catch(error => { - vm.handleError(error.message) - }); + }).catch(error => { + vm.handleError(error.message) + }) + } }) }, }; diff --git a/src/geo-frontend/src/components/import/Upload.vue b/src/geo-frontend/src/components/import/Upload.vue index 0262fe8..a01e67e 100644 --- a/src/geo-frontend/src/components/import/Upload.vue +++ b/src/geo-frontend/src/components/import/Upload.vue @@ -36,7 +36,6 @@ export default { file: null, disableUpload: false, uploadMsg: "", - processQueue: [] } }, methods: { @@ -78,10 +77,6 @@ export default { this.uploadMsg = error.response.data.msg } }, - async fetchQueueList() { - const response = await axios.get('/api/data/item/import/get/mine') - this.processQueue = response.data.data - }, }, async created() { },