portree_kid 2020-07-27 21:28:52 +02:00
parent febd720588
commit ed35aab63b

View File

@ -4,12 +4,11 @@
<el-progress :percentage="Number(((progress / max)*100).toPrecision(3))" v-if="max>0"></el-progress> <el-progress :percentage="Number(((progress / max)*100).toPrecision(3))" v-if="max>0"></el-progress>
</span> </span>
<span v-if="results.length>0" style="color: red">{{results.length}} Errors please correct first</span><br/> <span v-if="results.length>0" style="color: red">{{results.length}} Errors please correct first</span><br/>
<span style="center">E-Mail : {{this.$store.state.Settings.settings.email}}</span><br/> <span class="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 class="center"><el-checkbox v-model="gplv2" class="center">I agree to release the groundnet under GPL v2</el-checkbox></span><br/>
<span style="center" v-if="message">{{message}}</span><br/> <span :class="textClass" v-if="message">{{message}}</span><br/>
<span style="error" v-if="error">{{message}}</span><br/>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="upload" :disabled="!comittable">Ok</el-button> <el-button @click="handleOkClicked" :disabled="!comittable">{{buttonText}}</el-button>
</span> </span>
</el-dialog> </el-dialog>
</template> </template>
@ -30,7 +29,7 @@
}, },
data () { data () {
return { return {
gplv2: false, message: null, error: false, progress: 0, max: 0, azure: false gplv2: false, message: null, error: false, progress: 0, max: 0, azure: false, success: false, uploading: false, buttonText: 'Upload'
} }
}, },
methods: { methods: {
@ -38,6 +37,7 @@
if(JSON.parse(e.srcElement.response).status==='OK') { if(JSON.parse(e.srcElement.response).status==='OK') {
this.message = null; this.message = null;
this.azure = true; this.azure = true;
this.error = false;
} else { } else {
this.message = 'Azure down'; this.message = 'Azure down';
} }
@ -45,12 +45,32 @@
}, },
status () { status () {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
var parent = this.$parent;
this.message = 'Checking for Groundweb health' this.message = 'Checking for Groundweb health'
xhr.open('GET', 'http://groundweb.azurewebsites.net/groundnets/status', true); xhr.open('GET', 'http://groundweb.azurewebsites.net/groundnets/status', true);
xhr.onreadystatechange = function () {
if (xhr.status !== 200){
parent.$refs.upload.message = 'Azure down';
parent.$refs.upload.error = true;
console.error(xhr);
}
}
xhr.addEventListener("load", this.reqListener); xhr.addEventListener("load", this.reqListener);
xhr.send(); try {
xhr.send();
} catch (err) {
console.error(err);
this.error = true;
}
}, },
upload () { handleOkClicked () {
if( this.success ) {
// Upload success close
Vue.set(this.$parent, 'uploadVisible', false)
return;
}
this.uploading = true;
var f = path.join(this.$store.state.Settings.settings.airportsDirectory, var f = path.join(this.$store.state.Settings.settings.airportsDirectory,
this.icao[0], this.icao[0],
this.icao[1], this.icao[1],
@ -78,13 +98,23 @@
var parent = this.$parent; var parent = this.$parent;
var messageField = this.message; var messageField = this.message;
// action after uploading happens // action after uploading happens
xhr.onreadystatechange = function () {
if (xhr.status !== 200){
parent.$refs.upload.message = 'Upload Error'
parent.$refs.upload.error = true;
console.error(xhr);
}
}
xhr.onload = function(e) { xhr.onload = function(e) {
console.log("File uploading completed! "); console.log("File uploading completed! ");
console.log(e); console.log(e);
parent.$refs.upload.uploading = false
if (e.srcElement.status===500) { if (e.srcElement.status===500) {
parent.$refs.upload.message == e.srcElement.statusText parent.$refs.upload.message == e.srcElement.statusText
} else if(JSON.parse(e.srcElement.response).message.match('[A-Z0-9]* Imported Successfully')) { } else if(JSON.parse(e.srcElement.response).message.match('[A-Z0-9]* Imported Successfully')) {
Vue.set(parent, 'uploadVisible', false) parent.$refs.upload.success = true
parent.$refs.upload.message = 'Uploaded Successfully'
parent.$refs.upload.buttonText = 'Ok'
parent.$store.commit('UPLOAD_WIP', parent.$store.state.Airports.currentAirport.icao) parent.$store.commit('UPLOAD_WIP', parent.$store.state.Airports.currentAirport.icao)
} else if(JSON.parse(e.srcElement.response).message === 'XML Errors') { } else if(JSON.parse(e.srcElement.response).message === 'XML Errors') {
@ -139,14 +169,19 @@
this.worker = worker this.worker = worker
var groundnet = [] var groundnet = []
if (!this.$parent.$parent.$parent.$refs.editLayer.groundnetLayerGroup) {
this.message = 'Groundnet not visible'
}
if (!this.$parent.$parent.$parent.$refs.pavementLayer.pavement) {
this.message = 'Pavement not visible'
}
this.$parent.$parent.$parent.$refs.editLayer.groundnetLayerGroup.eachLayer(l => { this.$parent.$parent.$parent.$refs.editLayer.groundnetLayerGroup.eachLayer(l => {
console.log(l) console.log(l)
if (l instanceof L.Polyline) { if (l instanceof L.Polyline) {
l._latlngs[0].glueindex = this.begin; l._latlngs[0].glueindex = this.begin;
l._latlngs.slice(-1)[0].glueindex = this.end; l._latlngs.slice(-1)[0].glueindex = this.end;
l.extensions(this) l.extensions(this)
} }
groundnet.push(l) groundnet.push(l)
}) })
var features = groundnet.map(mapper.checkMapper).filter(n => n) var features = groundnet.map(mapper.checkMapper).filter(n => n)
@ -199,6 +234,9 @@
Vue.set(this.$parent, 'uploadVisible', newValue) Vue.set(this.$parent, 'uploadVisible', newValue)
} }
}, },
textClass: function () {
return !this.error?'center':'error'
},
title: function () { title: function () {
return `Upload ${this.$parent.$parent.$parent.icao} to groundweb.` return `Upload ${this.$parent.$parent.$parent.icao} to groundweb.`
}, },
@ -210,17 +248,17 @@
} }
}, },
comittable: function () { comittable: function () {
return this.$store.state.Check.results.filter(a => a.id>=0).length === 0 && this.gplv2 && this.max === 0 && this.azure return this.$store.state.Check.results.filter(a => a.id>=0).length === 0 && this.gplv2 && this.max === 0 && this.azure && !this.uploading
}, },
results: function () { results: function () {
return this.$store.state.Check.results.filter(a => a.id>=0) return this.$store.state.Check.results.filter(a => a.id>=0)
} }
} }
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.center { text-align: center; vertical-align: middle;} .center { text-align: center; vertical-align: middle; padding: 5px; font-size: 12pt; font-weight: normal;}
.error { text-align: center; background-color: red;} .error { text-align: center; color: red; padding: 5px; font-size: 12pt; font-weight: normal;}
.el-dialog--center .el-dialog__body { padding: 5px;}
</style> </style>