begin work on frontend processing

This commit is contained in:
Cyberes 2024-08-20 16:47:00 -06:00
parent 03fe3d8eb4
commit 2d5525ccce
2 changed files with 14 additions and 8 deletions

View File

@ -72,7 +72,7 @@ def fetch_import_queue(request, id):
if queue.user_id != request.user.id: if queue.user_id != request.user.id:
return JsonResponse({'success': False, 'msg': 'not authorized to view this item', 'code': 403}, status=400) return JsonResponse({'success': False, 'msg': 'not authorized to view this item', 'code': 403}, status=400)
if not lock_manager.is_locked('data_importqueue', queue.id) and (len(queue.geofeatures) or len(queue.log)): if not lock_manager.is_locked('data_importqueue', queue.id) and (len(queue.geofeatures) or len(queue.log)):
return JsonResponse({'success': True, 'geofeatures': queue.geofeatures, 'log': queue.log}, status=200) return JsonResponse({'success': True, 'geofeatures': queue.geofeatures, 'log': queue.log, 'msg': None}, status=200)
return JsonResponse({'success': True, 'geofeatures': [], 'log': [], 'msg': 'uploaded data still processing'}, status=200) return JsonResponse({'success': True, 'geofeatures': [], 'log': [], 'msg': 'uploaded data still processing'}, status=200)
except ImportQueue.DoesNotExist: except ImportQueue.DoesNotExist:
return JsonResponse({'success': False, 'msg': 'ID does not exist', 'code': 404}, status=400) return JsonResponse({'success': False, 'msg': 'ID does not exist', 'code': 404}, status=400)
@ -88,7 +88,7 @@ def fetch_queued(request):
item['processing'] = not (len(item['geofeatures']) and len(item['log'])) and lock_manager.is_locked('data_importqueue', item['id']) item['processing'] = not (len(item['geofeatures']) and len(item['log'])) and lock_manager.is_locked('data_importqueue', item['id'])
item['feature_count'] = count item['feature_count'] = count
del item['geofeatures'] del item['geofeatures']
return JsonResponse({'data': data}) return JsonResponse({'data': data, 'msg': None})
@login_required_401 @login_required_401

View File

@ -7,14 +7,15 @@
<div id="importMessages"> <div id="importMessages">
<h2>Messages</h2> <h2>Messages</h2>
<li v-for="(item, index) in importResponse.log" :key="`item-${index}`"> <li v-for="(item, index) in workerLog" :key="`item-${index}`">
<p class="font-bold">{{ item }}</p> <p class="font-bold">{{ item }}</p>
</li> </li>
</div> </div>
<div> <div>
<li v-for="(item, index) in importResponse.geofeatures" :key="`item-${index}`"> <li v-for="(item, index) in itemsForUser" :key="`item-${index}`">
<h2>{{ item.name }}</h2>
<pre> <pre>
{{ parseGeoJson(item) }} {{ item }}
</pre> </pre>
</li> </li>
</div> </div>
@ -45,8 +46,9 @@ export default {
data() { data() {
return { return {
msg: "", msg: "",
importResponse: {},
currentId: null, currentId: null,
itemsForUser: [],
workerLog: []
} }
}, },
mixins: [authMixin], mixins: [authMixin],
@ -73,7 +75,8 @@ export default {
next(async vm => { next(async vm => {
if (vm.currentId !== vm.id) { if (vm.currentId !== vm.id) {
vm.msg = "" vm.msg = ""
vm.importResponse = [] vm.messages = []
vm.itemsForUser = []
vm.currentId = null vm.currentId = null
axios.get('/api/data/item/import/get/' + vm.id).then(response => { axios.get('/api/data/item/import/get/' + vm.id).then(response => {
if (!response.data.success) { if (!response.data.success) {
@ -81,9 +84,12 @@ export default {
} else { } else {
vm.currentId = vm.id vm.currentId = vm.id
if (Object.keys(response.data).length > 0) { if (Object.keys(response.data).length > 0) {
vm.importResponse = response.data response.data.geofeatures.forEach((item) => {
vm.itemsForUser.push(vm.parseGeoJson(item))
})
} }
vm.msg = response.data.msg vm.msg = response.data.msg
vm.workerLog = response.data.log
} }
}).catch(error => { }).catch(error => {
vm.handleError(error.message) vm.handleError(error.message)