Fix preferences to map variable error
This commit is contained in:
@ -2,13 +2,13 @@
|
|||||||
<Navbar />
|
<Navbar />
|
||||||
|
|
||||||
<nav v-if="this.trainCoordinates.length>0" class="navbar navbar-light bg-light">
|
<nav v-if="this.trainCoordinates.length>0" class="navbar navbar-light bg-light">
|
||||||
<div class="container-fluid" @change="decideShowStations();">
|
<div class="container-fluid" @change="decideShowStations()">
|
||||||
<input type="checkbox" id="showMainlandStations" v-model="showMainlandStations"/>
|
<input type="checkbox" id="showMainlandStations" v-model="showMainlandStations"/>
|
||||||
<label for="showMainlandStations">Show Mainland Stations</label>
|
<label for="showMainlandStations">Show Mainland Stations</label>
|
||||||
<input type="checkbox" id="showDARTStations" v-model="showDARTStations"/>
|
<input type="checkbox" id="showDARTStations" v-model="showDARTStations"/>
|
||||||
<label for="showDARTStations">Show DART Stations</label>
|
<label for="showDARTStations">Show DART Stations</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="container-fluid" @change="decideShowTrains();">
|
<div class="container-fluid" @change="decideShowTrains()">
|
||||||
<input type="checkbox" id="showLate" v-model="showLate"/>
|
<input type="checkbox" id="showLate" v-model="showLate"/>
|
||||||
<label for="showLate">Show Late Trains</label>
|
<label for="showLate">Show Late Trains</label>
|
||||||
<input type="checkbox" id="showOnTime" v-model="showOnTime"/>
|
<input type="checkbox" id="showOnTime" v-model="showOnTime"/>
|
||||||
@ -81,8 +81,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { store } from '../store/store';
|
import { store } from '../store/store';
|
||||||
import { ref } from 'vue';
|
import { fromLonLat } from 'ol/proj.js';
|
||||||
import { fromLonLat, toLonLat } from 'ol/proj.js';
|
|
||||||
import { getFunctions, httpsCallable, connectFunctionsEmulator } from "firebase/functions";
|
import { getFunctions, httpsCallable, connectFunctionsEmulator } from "firebase/functions";
|
||||||
import app from '../api/firebase';
|
import app from '../api/firebase';
|
||||||
import Navbar from '../components/Navbar.vue';
|
import Navbar from '../components/Navbar.vue';
|
||||||
@ -96,9 +95,9 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
center: fromLonLat([-7.5029786, 53.4494762]),
|
center: fromLonLat([-7.5029786, 53.4494762]),
|
||||||
projection: ref('EPSG:3857'),
|
projection: 'EPSG:3857',
|
||||||
zoom: ref(7),
|
zoom: 7,
|
||||||
rotation: ref(0),
|
rotation: 0,
|
||||||
|
|
||||||
showTrains: [],
|
showTrains: [],
|
||||||
showStations: [],
|
showStations: [],
|
||||||
@ -164,8 +163,9 @@ export default {
|
|||||||
this.showNotYetRunning = response.data.data["showNotYetRunning"]
|
this.showNotYetRunning = response.data.data["showNotYetRunning"]
|
||||||
|
|
||||||
// update the map with the user's preferences
|
// update the map with the user's preferences
|
||||||
this.decideShowTrains()
|
console.log("got preferences")
|
||||||
this.decideShowStations()
|
this.decideShowStations()
|
||||||
|
this.decideShowTrains()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
@ -204,11 +204,11 @@ export default {
|
|||||||
|
|
||||||
// method to determine whether or not to show each train
|
// method to determine whether or not to show each train
|
||||||
decideShowTrains() {
|
decideShowTrains() {
|
||||||
for (let i=0; i<this.showTrains.length; i++) {t
|
for (var i=0; i<this.showTrains.length; i++) {
|
||||||
let isDART = this.getTrainType(i) == "DART";
|
let isDART = this.getTrainType(i) == "DART";
|
||||||
if ((this.showRunning && this.allTrains[i]["TrainStatus"][0] == "R") || (this.showTerminated && this.allTrains[i]["TrainStatus"][0] == "T") || this.showNotYetRunning && this.allTrains[i]["TrainStatus"][0] == "N") {
|
if ((this.showRunning && this.allTrains[i]["TrainStatus"][0] == "R") || (this.showTerminated && this.allTrains[i]["TrainStatus"][0] == "T") || this.showNotYetRunning && this.allTrains[i]["TrainStatus"][0] == "N") {
|
||||||
if ((this.showDART && isDART) || (this.showMainland && !isDART)) {
|
if ((this.showDART && isDART) || (this.showMainland && !isDART)) {
|
||||||
this.showTrains[i] = (this.showLate && this.isTrainLate(i)) || (this.showOnTime && !this.isTrainLate(i)); // || (this.showMainland && !isDART) || (this.showDART && isDART);
|
this.showTrains[i] = (this.showLate && this.isTrainLate(i)) || (this.showOnTime && !this.isTrainLate(i));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.showTrains[i] = false;
|
this.showTrains[i] = false;
|
||||||
@ -223,7 +223,7 @@ export default {
|
|||||||
// method to determine whether or not to show each station
|
// method to determine whether or not to show each station
|
||||||
decideShowStations() {
|
decideShowStations() {
|
||||||
for (var i=0; i<this.showStations.length; i++) {
|
for (var i=0; i<this.showStations.length; i++) {
|
||||||
let isDARTStation = this.getStationType(j) == "DART";
|
let isDARTStation = this.getStationType(i) == "DART";
|
||||||
this.showStations[i] = (this.showDARTStations && isDARTStation) || (this.showMainlandStations && !isDARTStation);
|
this.showStations[i] = (this.showDARTStations && isDARTStation) || (this.showMainlandStations && !isDARTStation);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -371,6 +371,7 @@ export default {
|
|||||||
const getStationData = httpsCallable(functions, 'getStationData');
|
const getStationData = httpsCallable(functions, 'getStationData');
|
||||||
getStationData().then((response) => {
|
getStationData().then((response) => {
|
||||||
if (!response.data) throw new Error("Error fetching station from the database");
|
if (!response.data) throw new Error("Error fetching station from the database");
|
||||||
|
|
||||||
for (var i=0; i<response.data.length; i++) {
|
for (var i=0; i<response.data.length; i++) {
|
||||||
let station = response.data[i];
|
let station = response.data[i];
|
||||||
this.allStations[i] = station;
|
this.allStations[i] = station;
|
||||||
@ -404,12 +405,10 @@ export default {
|
|||||||
connectFunctionsEmulator(functions, host, 5001);
|
connectFunctionsEmulator(functions, host, 5001);
|
||||||
}
|
}
|
||||||
|
|
||||||
// post live train data
|
|
||||||
const postTrainData = httpsCallable(functions, 'postLiveTrainData');
|
const postTrainData = httpsCallable(functions, 'postLiveTrainData');
|
||||||
postTrainData().then((response) => {
|
postTrainData().then(() => {
|
||||||
// post station data
|
|
||||||
const postStationData = httpsCallable(functions, 'postStationData');
|
const postStationData = httpsCallable(functions, 'postStationData');
|
||||||
postStationData().then((reponse) => {
|
postStationData().then(() => {
|
||||||
this.getTrainAndStationData()
|
this.getTrainAndStationData()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user