This commit is contained in:
Keith Paterson 2021-06-01 14:44:43 +02:00
parent e52fcf9572
commit 091e7853eb
2 changed files with 11 additions and 6 deletions

View File

@ -12,9 +12,8 @@ You should have received a copy of the GNU General Public License along with FG
<template> <template>
<div> <div>
<div v-for="item in traffic" v-bind:key="item.id"> <div v-for="item in traffic" v-bind:key="item.id">
<div v-if="direction == 0">{{ item.departure.time }} {{ item.callsign }} {{ item.departure.port }} --> {{ item.arrival.port }}</div> <div v-if="direction == 0">{{ item.departure.time }} {{ item.callsign }} {{ item.departure.port }} --> {{ item.arrival.port }} {{ item['required-aircraft'] }} {{ item.flighttype }}</div>
<div v-if="direction == 1">{{ item.arrival.time }} {{ item.callsign }} {{ item.departure.port }} --> {{ item.arrival.port }}</div> <div v-if="direction == 1">{{ item.arrival.time }} {{ item.callsign }} {{ item.departure.port }} --> {{ item.arrival.port }} {{ item['required-aircraft'] }} {{ item.flighttype }}</div>
</div> </div>
</div> </div>
</template> </template>
@ -68,12 +67,17 @@ export default {
}, },
traffic: function () { traffic: function () {
if (this.filename) { if (this.filename) {
return this.trafficFile.filter(f => f.callsign).filter(f => var aircraftLookup = this.trafficFile.filter(a => a['required-aircraft'])
.reduce((req, acc) => {
req[acc['required-aircraft']] = acc
return req
}, {})
var ret = this.trafficFile.filter(f => f.callsign).filter(f =>
(f.departure.port === this.$store.state.Airports.currentAirport.icao && this.direction === 0) || (f.departure.port === this.$store.state.Airports.currentAirport.icao && this.direction === 0) ||
(f.arrival.port === this.$store.state.Airports.currentAirport.icao && this.direction === 1) (f.arrival.port === this.$store.state.Airports.currentAirport.icao && this.direction === 1)
) ).map(obj => ({ ...obj, flighttype: aircraftLookup[obj['required-aircraft']].flighttype }))
return ret
} }
console.debug(this.filename)
}, },
aircraft: function () { aircraft: function () {
if (this.filename) { if (this.filename) {

View File

@ -68,6 +68,7 @@ function flightMapper(params) {
return { return {
id: `${btoa(buildId(params))}`, id: `${btoa(buildId(params))}`,
callsign: params.find('callsign').text(), callsign: params.find('callsign').text(),
'required-aircraft': params.find('required-aircraft').text(),
arrival: { arrival: {
port: params.find('arrival/port').text(), port: params.find('arrival/port').text(),
time: params.find('arrival/time').text() time: params.find('arrival/time').text()