mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
Poprawki w działaniu ładowania pociągów
This commit is contained in:
@@ -124,9 +124,9 @@
|
||||
<div class="users-content">
|
||||
<div
|
||||
class="user"
|
||||
v-for="train in stationInfo.stationTrains"
|
||||
v-for="train in computedStationTrains"
|
||||
:key="train.trainNo + train.driverName"
|
||||
:class="{'no-timetable': !hasTimetable(train.trainNo)}"
|
||||
:class="{'no-timetable': !train.hasTimetable}"
|
||||
>
|
||||
<a
|
||||
:href="`https://rj.td2.info.pl/train#${train.trainNo};eu`"
|
||||
@@ -245,18 +245,24 @@ export default class StationCard extends styleMixin {
|
||||
: `${this.stationInfo.dispatcherExp}`;
|
||||
}
|
||||
|
||||
get computedStationTrains() {
|
||||
return this.stationInfo.stationTrains.map(stationTrain => ({
|
||||
...stationTrain,
|
||||
hasTimetable: this.trains.find(train => train.timetableData && train.trainNo === stationTrain.trainNo)
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
get computedScheduledTrains() {
|
||||
console.log(this.stationInfo.stationName, "test");
|
||||
|
||||
return this.stationInfo.scheduledTrains.sort((a, b) => {
|
||||
if (a.arrivalTime > b.arrivalTime) return 1;
|
||||
else if ((a.arrivalTime < b.arrivalTime)) return -1;
|
||||
|
||||
return a.departureTime > b.departureTime ? 1 : -1;
|
||||
})
|
||||
}
|
||||
|
||||
hasTimetable(trainNo: number) {
|
||||
return this.trains.find(train => train.timetableData && train.trainNo === trainNo);
|
||||
}
|
||||
|
||||
timestampToTime(timestamp: number) {
|
||||
|
||||
@@ -145,7 +145,6 @@ import Vue from "vue";
|
||||
import { Component, Prop } from "vue-property-decorator";
|
||||
|
||||
import Station from "@/scripts/interfaces/Station";
|
||||
import Train from "@/scripts/interfaces/Train";
|
||||
|
||||
import styleMixin from "@/mixins/styleMixin";
|
||||
|
||||
|
||||
+9
-9
@@ -97,7 +97,7 @@ export default class Store extends VuexModule {
|
||||
this.context.commit('setJSONData');
|
||||
|
||||
this.context.dispatch('fetchOnlineData');
|
||||
setInterval(() => this.context.dispatch('fetchOnlineData'), 20000);
|
||||
setInterval(() => this.context.dispatch('fetchOnlineData'), 5000);
|
||||
}
|
||||
|
||||
@Action({ commit: 'updateTimetableData' })
|
||||
@@ -304,16 +304,14 @@ export default class Store extends VuexModule {
|
||||
|
||||
@Mutation
|
||||
private updateOnlineTrains(updatedTrainList) {
|
||||
this.trainList =
|
||||
this.trainList.length == 0
|
||||
? updatedTrainList
|
||||
: this.trainList.reduce((acc, train) => {
|
||||
const onlineTrainData = updatedTrainList.find(updatedTrain => train.trainNo === updatedTrain.trainNo);
|
||||
this.trainList = updatedTrainList.reduce((acc, updatedTrain) => {
|
||||
const trainData = this.trainList.find(train => train.trainNo === updatedTrain.trainNo);
|
||||
|
||||
if (onlineTrainData) acc.push({ ...train, ...onlineTrainData });
|
||||
if (trainData) acc.push({ ...updatedTrain, ...trainData });
|
||||
else acc.push({ ...updatedTrain });
|
||||
|
||||
return acc;
|
||||
}, [] as Train[]);
|
||||
return acc;
|
||||
}, [] as Train[]);
|
||||
|
||||
this.trainCount = this.trainList.filter(train => train.online).length;
|
||||
this.dataConnectionStatus = Status.Loaded;
|
||||
@@ -347,6 +345,8 @@ export default class Store extends VuexModule {
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
// console.log('gituwa');
|
||||
|
||||
return { ...station, scheduledTrains };
|
||||
});
|
||||
|
||||
|
||||
@@ -124,8 +124,6 @@ export default class StationsView extends Vue {
|
||||
const dir: number = this.sorterActive.dir;
|
||||
// const scheduledTrainList = this.scheduledTrains;
|
||||
|
||||
|
||||
|
||||
return this.stationList
|
||||
.filter((station) => {
|
||||
if (!station.reqLevel || station.reqLevel == "-1") return true;
|
||||
|
||||
Reference in New Issue
Block a user