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'),
|
os.path.join(BASE_DIR, '../geo-frontend/dist/static'),
|
||||||
]
|
]
|
||||||
|
|
||||||
APPEND_SLASH = False
|
APPEND_SLASH = True
|
||||||
|
|
|
@ -45,7 +45,6 @@ def import_worker():
|
||||||
geofetures = []
|
geofetures = []
|
||||||
messages = []
|
messages = []
|
||||||
try:
|
try:
|
||||||
# The actual import.
|
|
||||||
geojson_data, kml_conv_messages = kml_to_geojson(item['raw_kml'])
|
geojson_data, kml_conv_messages = kml_to_geojson(item['raw_kml'])
|
||||||
messages.extend(kml_conv_messages)
|
messages.extend(kml_conv_messages)
|
||||||
geofetures, typing_messages = geojson_to_geofeature(geojson_data)
|
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"
|
import {getCookie} from "./auth.js"
|
||||||
|
|
||||||
export class UserInfo {
|
export class UserInfo {
|
||||||
private username: String;
|
username: String;
|
||||||
private id: BigInteger;
|
id: BigInteger;
|
||||||
private csrftoken: String;
|
csrftoken: String;
|
||||||
|
|
||||||
constructor(username: String, userId: BigInteger) {
|
constructor(username: String, userId: BigInteger) {
|
||||||
this.username = username
|
this.username = username
|
||||||
|
|
|
@ -1,12 +1,19 @@
|
||||||
import {createStore} from 'vuex'
|
import {createStore} from 'vuex'
|
||||||
import {UserInfo} from './store-types'
|
import {UserInfo} from './store-types'
|
||||||
|
import {ImportQueueItem} from "@/assets/js/import/import-types";
|
||||||
|
|
||||||
|
|
||||||
export default createStore({
|
export default createStore({
|
||||||
state: {
|
state: {
|
||||||
userInfo: UserInfo
|
userInfo: UserInfo,
|
||||||
|
importQueue: ImportQueueItem
|
||||||
|
|
||||||
}, mutations: {
|
}, mutations: {
|
||||||
userInfo(state, payload) {
|
userInfo(state, payload) {
|
||||||
state.userInfo = payload
|
state.userInfo = payload
|
||||||
|
},
|
||||||
|
importQueue(state, payload) {
|
||||||
|
state.importQueue = payload
|
||||||
}
|
}
|
||||||
}, getters: {
|
}, getters: {
|
||||||
// alertExists: (state) => (message) => {
|
// alertExists: (state) => (message) => {
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
|
<a href="/#/import">Import</a>
|
||||||
|
|
||||||
<p>username: {{ userInfo.username }}</p>
|
<p>username: {{ userInfo.username }}</p>
|
||||||
<p>id: {{ userInfo.id }}</p>
|
<p>id: {{ userInfo.id }}</p>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -3,36 +3,8 @@
|
||||||
<div>
|
<div>
|
||||||
<a href="/#/import/upload">Upload Files</a>
|
<a href="/#/import/upload">Upload Files</a>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
|
||||||
<button @click="fetchQueueList">Refresh</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<table>
|
<Importqueue/>
|
||||||
<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>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -40,38 +12,42 @@
|
||||||
import {mapState} from "vuex"
|
import {mapState} from "vuex"
|
||||||
import {authMixin} from "@/assets/js/authMixin.js";
|
import {authMixin} from "@/assets/js/authMixin.js";
|
||||||
import axios from "axios";
|
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 {
|
export default {
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(["userInfo"]),
|
...mapState(["userInfo", "importQueue"]),
|
||||||
},
|
},
|
||||||
components: {},
|
components: {Importqueue},
|
||||||
mixins: [authMixin],
|
mixins: [authMixin],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {}
|
||||||
processQueue: []
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async fetchQueueList() {
|
async fetchQueueList() {
|
||||||
const response = await axios.get('/api/data/item/import/get/mine')
|
const response = await axios.get(IMPORT_QUEUE_LIST_URL)
|
||||||
this.processQueue = response.data.data
|
const ourImportQueue = response.data.data.map((item) => new ImportQueueItem(item))
|
||||||
|
this.$store.commit('importQueue', ourImportQueue)
|
||||||
},
|
},
|
||||||
async deleteItem(item, index) {
|
async deleteItem(item, index) {
|
||||||
if (window.confirm(`Delete "${item.original_filename}" (#${item.id})`))
|
if (window.confirm(`Delete "${item.original_filename}" (#${item.id})`))
|
||||||
try {
|
try {
|
||||||
this.processQueue.splice(index, 1)
|
this.importQueue.splice(index, 1)
|
||||||
// TODO: add a message popup when delete is completed
|
// TODO: add a message popup when delete is completed
|
||||||
const response = await axios.delete('/api/data/item/import/delete/' + item.id, {
|
const response = await axios.delete('/api/data/item/import/delete/' + item.id, {
|
||||||
headers: {
|
headers: {
|
||||||
'X-CSRFToken': this.userInfo.csrftoken
|
'X-CSRFToken': this.userInfo.csrftoken
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
if (!response.data.success) {
|
||||||
|
throw new Error("server reported failure")
|
||||||
|
}
|
||||||
await this.fetchQueueList()
|
await this.fetchQueueList()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
alert(`Failed to delete ${item.id}: ${error.message}`)
|
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>
|
||||||
|
|
||||||
<div v-if="uploadMsg !== ''" class="w-[90%] m-auto mt-10" v-html="uploadMsg"></div>
|
<div v-if="uploadMsg !== ''" class="w-[90%] m-auto mt-10" v-html="uploadMsg"></div>
|
||||||
|
|
||||||
|
<Importqueue/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -22,14 +24,17 @@ import {mapState} from "vuex"
|
||||||
import {authMixin} from "@/assets/js/authMixin.js";
|
import {authMixin} from "@/assets/js/authMixin.js";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import {capitalizeFirstLetter} from "@/assets/js/string.js";
|
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
|
// 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 {
|
export default {
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(["userInfo"]),
|
...mapState(["userInfo", "importQueue"]),
|
||||||
},
|
},
|
||||||
components: {},
|
components: {Importqueue},
|
||||||
mixins: [authMixin],
|
mixins: [authMixin],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -39,6 +44,11 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
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) {
|
onFileChange(e) {
|
||||||
this.file = e.target.files[0]
|
this.file = e.target.files[0]
|
||||||
const fileType = this.file.name.split('.').pop().toLowerCase()
|
const fileType = this.file.name.split('.').pop().toLowerCase()
|
||||||
|
|
Loading…
Reference in New Issue