Upload check
This commit is contained in:
parent
9ce9e54c26
commit
b06b1b6a03
@ -72,6 +72,7 @@
|
|||||||
methods: {
|
methods: {
|
||||||
upload() {
|
upload() {
|
||||||
this.uploadVisible = true
|
this.uploadVisible = true
|
||||||
|
this.$refs.upload.check()
|
||||||
},
|
},
|
||||||
zoomout() {
|
zoomout() {
|
||||||
this.$parent.$parent.zoomUpdated(9)
|
this.$parent.$parent.zoomUpdated(9)
|
||||||
|
@ -239,9 +239,9 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
show (index) {
|
show (index) {
|
||||||
if(this.featureLookup[index]===undefined) {
|
if(this.featureLookup===undefined || this.featureLookup[index]===undefined) {
|
||||||
console.error("Lookup " + index + " failed ");
|
console.error("Lookup " + index + " failed ");
|
||||||
return;
|
this.buildLookup()
|
||||||
}
|
}
|
||||||
this.featureLookup[index].forEach((element, i) => {
|
this.featureLookup[index].forEach((element, i) => {
|
||||||
if (element instanceof L.Polyline) {
|
if (element instanceof L.Polyline) {
|
||||||
@ -281,6 +281,29 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
buildLookup () {
|
||||||
|
this.featureLookup = {};
|
||||||
|
this.groundnetLayerGroup.eachLayer((layer) => {
|
||||||
|
if (layer instanceof L.Polyline) {
|
||||||
|
// console.log(layer._latlngs)
|
||||||
|
layer._latlngs.forEach(latlng => {
|
||||||
|
if (latlng.attributes.index) {
|
||||||
|
if( this.featureLookup[latlng.attributes.index] == undefined) {
|
||||||
|
this.featureLookup[latlng.attributes.index] = [];
|
||||||
|
}
|
||||||
|
this.featureLookup[latlng.attributes.index].push(layer);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else if (layer instanceof L.RunwayNode || layer instanceof L.ParkingSpot || layer instanceof L.HoldNode) {
|
||||||
|
if( this.featureLookup[layer.glueindex] == undefined) {
|
||||||
|
this.featureLookup[layer.glueindex] = [];
|
||||||
|
}
|
||||||
|
this.featureLookup[layer.glueindex].push(layer);
|
||||||
|
} else {
|
||||||
|
console.warn(layer)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
getPointCoords (index) {
|
getPointCoords (index) {
|
||||||
if(this.featureLookup[index]===undefined) {
|
if(this.featureLookup[index]===undefined) {
|
||||||
console.error("Lookup " + index + " failed ");
|
console.error("Lookup " + index + " failed ");
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog title="Upload" :visible.sync="visible" width="30%" center>
|
<el-dialog title="Upload" :visible.sync="visible" width="30%" center>
|
||||||
|
<el-progress :percentage="Number(((progress / max)*100).toPrecision(3))" v-if="max>0"></el-progress>
|
||||||
|
<span v-if="results.length>0" style="color: red">{{results.length}} Errors please correct first</span><br/>
|
||||||
<span style="center">Upload {{icao}} to groundweb.</span><br/>
|
<span style="center">Upload {{icao}} to groundweb.</span><br/>
|
||||||
<span style="center">E-Mail : {{this.$store.state.Settings.settings.email}}</span><br/>
|
<span style="center">E-Mail : {{this.$store.state.Settings.settings.email}}</span><br/>
|
||||||
<span style="center"><el-checkbox v-model="gplv2">I agree to release the groundnet under GPL v2</el-checkbox></span><br/>
|
<span style="center"><el-checkbox v-model="gplv2">I agree to release the groundnet under GPL v2</el-checkbox></span><br/>
|
||||||
<span style="center" v-if="message.length>0">{{message}}</span><br/>
|
<span style="center" v-if="message.length>0">{{message}}</span><br/>
|
||||||
<span slot="footer" class="dialog-footer">
|
<span slot="footer" class="dialog-footer">
|
||||||
<el-button @click="upload" :disabled="!gplv2">Ok</el-button>
|
<el-button @click="upload" :disabled="!comittable">Ok</el-button>
|
||||||
</span>
|
</span>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
@ -13,6 +15,7 @@
|
|||||||
<script lang="js">
|
<script lang="js">
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
import fileUrl from 'file-url'
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
@ -23,7 +26,7 @@
|
|||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
gplv2: false, message: ''
|
gplv2: false, message: '', progress: 0, max: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -82,6 +85,97 @@
|
|||||||
// do the uploading
|
// do the uploading
|
||||||
console.log("File uploading started!");
|
console.log("File uploading started!");
|
||||||
xhr.send(formData);
|
xhr.send(formData);
|
||||||
|
},
|
||||||
|
pollData () {
|
||||||
|
var workery = this.worker
|
||||||
|
var view = this
|
||||||
|
workery.polling = setInterval(() => {
|
||||||
|
if (workery != null) {
|
||||||
|
view.max = Number(workery.max)
|
||||||
|
view.progress = Number(workery.progress)
|
||||||
|
view.scanning = Boolean(workery.checking)
|
||||||
|
workery.view = view
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
|
},
|
||||||
|
featuresMapper(o) {
|
||||||
|
if (o instanceof L.ParkingSpot) {
|
||||||
|
return { 'index': Number(o['id']),
|
||||||
|
'_leaflet_id': o._leaflet_id,
|
||||||
|
'type': 'parking',
|
||||||
|
'name': o.options.attributes.name,
|
||||||
|
'radius': String(o.options.attributes.radius),
|
||||||
|
'lat': o._latlng.lat,
|
||||||
|
'lng': o._latlng.lng };
|
||||||
|
} else if (o instanceof L.RunwayNode) {
|
||||||
|
console.log(o)
|
||||||
|
return { 'index': Number(o['glueindex']), '_leaflet_id': o._leaflet_id, 'type': 'runway' };
|
||||||
|
} else if (o instanceof L.HoldNode) {
|
||||||
|
console.log(o)
|
||||||
|
return { 'index': Number(o['glueindex']), '_leaflet_id': o._leaflet_id, 'type': o.holdPointType };
|
||||||
|
} else if (o instanceof L.Polyline) {
|
||||||
|
console.log(o)
|
||||||
|
return { 'start': Number(o['begin']), 'end': Number(o['end']), '_leaflet_id': o._leaflet_id, 'type': 'poly', 'isPushBackRoute': o.options.attributes.isPushBackRoute };
|
||||||
|
} else {
|
||||||
|
console.log('Unknown Type ')
|
||||||
|
console.log(typeof o)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
check () {
|
||||||
|
try {
|
||||||
|
this.scanning = true
|
||||||
|
const winURL = process.env.NODE_ENV === 'development'
|
||||||
|
? `http://localhost:9080/src/renderer/utils/check.js`
|
||||||
|
: `file://${process.resourcesPath}/workers/check.js`
|
||||||
|
console.log('make a check worker: ', path.resolve(__dirname, 'check.js'))
|
||||||
|
|
||||||
|
const worker = new Worker(winURL)
|
||||||
|
console.log(fileUrl('src/renderer/utils/check.js'))
|
||||||
|
|
||||||
|
worker.checking = this.checking
|
||||||
|
worker.max = this.max
|
||||||
|
worker.view = this
|
||||||
|
worker.editLayer = this.$parent.$parent.$refs.editLayer
|
||||||
|
worker.progress = 0
|
||||||
|
// var worker = new Worker(fileUrl('src/renderer/utils/worker.js'))
|
||||||
|
this.worker = worker
|
||||||
|
var xml = []
|
||||||
|
this.$parent.$parent.$parent.$refs.editLayer.groundnetLayerGroup.eachLayer(l => {
|
||||||
|
console.log(l)
|
||||||
|
xml.push(l)
|
||||||
|
})
|
||||||
|
|
||||||
|
var features = xml.map(this.featuresMapper).filter(n => n)
|
||||||
|
|
||||||
|
worker.postMessage(['check', features ] )
|
||||||
|
this.pollData()
|
||||||
|
// the reply
|
||||||
|
var store = this.$store
|
||||||
|
worker.onmessage = function (e) {
|
||||||
|
if (e.data === 'checkStarted') {
|
||||||
|
this.progress = 0
|
||||||
|
this.max = 4
|
||||||
|
} else if (e.data[0] === 'DONE') {
|
||||||
|
console.log('DONE')
|
||||||
|
store.dispatch('setResults', e.data[1])
|
||||||
|
worker.terminate()
|
||||||
|
worker.view.max = 0
|
||||||
|
worker.view.checkDialogVisible = false
|
||||||
|
clearInterval(this.polling)
|
||||||
|
this.checking = false
|
||||||
|
} else if (e.data.length > 0) {
|
||||||
|
if (e.data[0] === 'max') {
|
||||||
|
this.max = e.data[1]
|
||||||
|
}
|
||||||
|
if (e.data[0] === 'progress') {
|
||||||
|
this.progress += e.data[1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// console.log(e.data)
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -101,7 +195,14 @@
|
|||||||
},
|
},
|
||||||
set: function (newValue) {
|
set: function (newValue) {
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
comittable: function () {
|
||||||
|
return this.$store.state.Check.results.length === 0 && this.gplv2 && this.max === 0
|
||||||
|
},
|
||||||
|
results: function () {
|
||||||
|
return this.$store.state.Check.results
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user