continue working in import
This commit is contained in:
parent
aa90ed8cc4
commit
d2a4c49f7b
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
python3 ./daemon.py
|
|
@ -134,4 +134,4 @@ STATICFILES_DIRS = [
|
|||
os.path.join(BASE_DIR, '../geo-frontend/dist/static'),
|
||||
]
|
||||
|
||||
APPEND_SLASH = False
|
||||
APPEND_SLASH = True
|
||||
|
|
|
@ -45,7 +45,6 @@ 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)
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
export class ImportQueueItem {
|
||||
id: number;
|
||||
original_filename: string;
|
||||
raw_kml_hash: string;
|
||||
data: object;
|
||||
log: any[];
|
||||
timestamp: string;
|
||||
processing: boolean;
|
||||
feature_count: number;
|
||||
|
||||
constructor(data: any) {
|
||||
this.id = data.id;
|
||||
this.original_filename = data.original_filename;
|
||||
this.raw_kml_hash = data.raw_kml_hash;
|
||||
this.data = data.data;
|
||||
this.log = data.log;
|
||||
this.timestamp = data.timestamp;
|
||||
this.processing = data.processing;
|
||||
this.feature_count = data.feature_count;
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
export const IMPORT_QUEUE_LIST_URL = "/api/data/item/import/get/mine"
|
|
@ -1,9 +1,9 @@
|
|||
import {getCookie} from "./auth.js"
|
||||
|
||||
export class UserInfo {
|
||||
private username: String;
|
||||
private id: BigInteger;
|
||||
private csrftoken: String;
|
||||
username: String;
|
||||
id: BigInteger;
|
||||
csrftoken: String;
|
||||
|
||||
constructor(username: String, userId: BigInteger) {
|
||||
this.username = username
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
import {createStore} from 'vuex'
|
||||
import {UserInfo} from './store-types'
|
||||
import {ImportQueueItem} from "@/assets/js/import/import-types";
|
||||
|
||||
|
||||
export default createStore({
|
||||
state: {
|
||||
userInfo: UserInfo
|
||||
userInfo: UserInfo,
|
||||
importQueue: ImportQueueItem
|
||||
|
||||
}, mutations: {
|
||||
userInfo(state, payload) {
|
||||
state.userInfo = payload
|
||||
},
|
||||
importQueue(state, payload) {
|
||||
state.importQueue = payload
|
||||
}
|
||||
}, getters: {
|
||||
// alertExists: (state) => (message) => {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<template>
|
||||
<a href="/#/import">Import</a>
|
||||
|
||||
<p>username: {{ userInfo.username }}</p>
|
||||
<p>id: {{ userInfo.id }}</p>
|
||||
</template>
|
||||
|
|
|
@ -3,36 +3,8 @@
|
|||
<div>
|
||||
<a href="/#/import/upload">Upload Files</a>
|
||||
</div>
|
||||
<div>
|
||||
<button @click="fetchQueueList">Refresh</button>
|
||||
</div>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>File Name</th>
|
||||
<th>Features</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(item, index) in processQueue" :key="`item-${index}`">
|
||||
<td>
|
||||
<a :href="`/#/import/process/${item.id}`">{{ item.id }}</a>
|
||||
</td>
|
||||
<td>
|
||||
<a :href="`/#/import/process/${item.id}`">{{ item.original_filename }}</a>
|
||||
</td>
|
||||
<td>
|
||||
{{ item.processing === true ? "processing" : item.feature_count }}
|
||||
</td>
|
||||
<td>
|
||||
<button @click="deleteItem(item, index)">Delete</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<Importqueue/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -40,38 +12,42 @@
|
|||
import {mapState} from "vuex"
|
||||
import {authMixin} from "@/assets/js/authMixin.js";
|
||||
import axios from "axios";
|
||||
|
||||
import {IMPORT_QUEUE_LIST_URL} from "@/assets/js/import/url.js";
|
||||
import {ImportQueueItem} from "@/assets/js/import/import-types.ts"
|
||||
import Importqueue from "@/components/import/parts/importqueue.vue";
|
||||
|
||||
export default {
|
||||
computed: {
|
||||
...mapState(["userInfo"]),
|
||||
...mapState(["userInfo", "importQueue"]),
|
||||
},
|
||||
components: {},
|
||||
components: {Importqueue},
|
||||
mixins: [authMixin],
|
||||
data() {
|
||||
return {
|
||||
processQueue: []
|
||||
}
|
||||
return {}
|
||||
},
|
||||
methods: {
|
||||
async fetchQueueList() {
|
||||
const response = await axios.get('/api/data/item/import/get/mine')
|
||||
this.processQueue = response.data.data
|
||||
const response = await axios.get(IMPORT_QUEUE_LIST_URL)
|
||||
const ourImportQueue = response.data.data.map((item) => new ImportQueueItem(item))
|
||||
this.$store.commit('importQueue', ourImportQueue)
|
||||
},
|
||||
async deleteItem(item, index) {
|
||||
if (window.confirm(`Delete "${item.original_filename}" (#${item.id})`))
|
||||
try {
|
||||
this.processQueue.splice(index, 1)
|
||||
this.importQueue.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
|
||||
}
|
||||
})
|
||||
if (!response.data.success) {
|
||||
throw new Error("server reported failure")
|
||||
}
|
||||
await this.fetchQueueList()
|
||||
} catch (error) {
|
||||
alert(`Failed to delete ${item.id}: ${error.message}`)
|
||||
this.processQueue.splice(index, 0, item)
|
||||
this.importQueue.splice(index, 0, item)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
</div>
|
||||
|
||||
<div v-if="uploadMsg !== ''" class="w-[90%] m-auto mt-10" v-html="uploadMsg"></div>
|
||||
|
||||
<Importqueue/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
@ -22,14 +24,17 @@ import {mapState} from "vuex"
|
|||
import {authMixin} from "@/assets/js/authMixin.js";
|
||||
import axios from "axios";
|
||||
import {capitalizeFirstLetter} from "@/assets/js/string.js";
|
||||
import {IMPORT_QUEUE_LIST_URL} from "@/assets/js/import/url.js";
|
||||
import {ImportQueueItem} from "@/assets/js/import/import-types.ts"
|
||||
import Importqueue from "@/components/import/parts/importqueue.vue";
|
||||
|
||||
// TODO: after import, don't disable the upload, instead add the new item to a table at the button and then prompt the user to continue
|
||||
|
||||
export default {
|
||||
computed: {
|
||||
...mapState(["userInfo"]),
|
||||
...mapState(["userInfo", "importQueue"]),
|
||||
},
|
||||
components: {},
|
||||
components: {Importqueue},
|
||||
mixins: [authMixin],
|
||||
data() {
|
||||
return {
|
||||
|
@ -39,6 +44,11 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
async fetchQueueList() {
|
||||
const response = await axios.get(IMPORT_QUEUE_LIST_URL)
|
||||
const ourImportQueue = response.data.data.map((item) => new ImportQueueItem(item))
|
||||
this.$store.commit('importQueue', ourImportQueue)
|
||||
},
|
||||
onFileChange(e) {
|
||||
this.file = e.target.files[0]
|
||||
const fileType = this.file.name.split('.').pop().toLowerCase()
|
||||
|
|
Loading…
Reference in New Issue