Lista pociągów: dodano pociągi bez rozkładów

This commit is contained in:
2021-05-18 19:48:05 +02:00
parent 24da09c64a
commit ce825dace6
11 changed files with 99 additions and 64 deletions
+3
View File
@@ -30,3 +30,6 @@ node_modules
firebase.json firebase.json
.env .env
.fake
.ionide
+10 -2
View File
@@ -10335,6 +10335,7 @@
"resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.2.0.tgz", "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.2.0.tgz",
"integrity": "sha512-TitGhqSQ61RJljMmhIGvfWzJ2zk9m1Qug049Ugml6QP3t0e95o0XJjk29roNEiPKJQBEi8Ord5hFuSuELzSp8Q==", "integrity": "sha512-TitGhqSQ61RJljMmhIGvfWzJ2zk9m1Qug049Ugml6QP3t0e95o0XJjk29roNEiPKJQBEi8Ord5hFuSuELzSp8Q==",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"chalk": "^4.1.0", "chalk": "^4.1.0",
"hash-sum": "^2.0.0", "hash-sum": "^2.0.0",
@@ -10346,6 +10347,7 @@
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"color-convert": "^2.0.1" "color-convert": "^2.0.1"
} }
@@ -10355,6 +10357,7 @@
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz",
"integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"ansi-styles": "^4.1.0", "ansi-styles": "^4.1.0",
"supports-color": "^7.1.0" "supports-color": "^7.1.0"
@@ -10365,6 +10368,7 @@
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"color-name": "~1.1.4" "color-name": "~1.1.4"
} }
@@ -10373,19 +10377,22 @@
"version": "1.1.4", "version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true "dev": true,
"optional": true
}, },
"has-flag": { "has-flag": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true "dev": true,
"optional": true
}, },
"loader-utils": { "loader-utils": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz", "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz",
"integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==", "integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"big.js": "^5.2.2", "big.js": "^5.2.2",
"emojis-list": "^3.0.0", "emojis-list": "^3.0.0",
@@ -10397,6 +10404,7 @@
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"has-flag": "^4.0.0" "has-flag": "^4.0.0"
} }
+23 -7
View File
@@ -1,22 +1,27 @@
<template> <template>
<div class="train-table"> <div class="train-table">
<div class="no-trains" v-if="computedTrains.length == 0"> <div class="no-trains" v-if="computedTrains.length == 0 && timetableLoaded">
{{ $t("trains.no-trains") }} {{ $t("trains.no-trains") }}
</div> </div>
<div
class="no-trains"
v-if="computedTrains.length == 0 && !timetableLoaded"
>
{{ $t("trains.loading") }}
</div>
<ul class="train-list"> <ul class="train-list">
<li <li
class="train-row" class="train-row"
v-for="(train, i) in computedTrains" v-for="(train, i) in computedTrains"
:key="i" :key="i"
:id="train.timetableData.timetableId" :id="train.driverId + train.trainNo"
:ref="train.timetableData.timetableId"
> >
<!-- :ref="train.timetableData.timetableId" -->
<span class="wrapper"> <span class="wrapper">
<span <span class="info" v-if="train.timetableData">
class="info" <!-- @click="changeScheduleShowState(train.timetableData.timetableId)" -->
@click="changeScheduleShowState(train.timetableData.timetableId)"
>
<div class="info-main"> <div class="info-main">
<div class="info-top"> <div class="info-top">
<div class="top-category"> <div class="top-category">
@@ -152,6 +157,7 @@
</span> </span>
<TrainSchedule <TrainSchedule
v-if="train.timetableData"
:followingStops="train.timetableData.followingStops" :followingStops="train.timetableData.followingStops"
:currentStationName="train.currentStationName" :currentStationName="train.currentStationName"
@click="changeScheduleShowState(train.timetableData.timetableId)" @click="changeScheduleShowState(train.timetableData.timetableId)"
@@ -169,12 +175,14 @@ import Train from "@/scripts/interfaces/Train";
import TrainSchedule from "@/components/TrainsView/TrainSchedule.vue"; import TrainSchedule from "@/components/TrainsView/TrainSchedule.vue";
import TrainStop from "@/scripts/interfaces/TrainStop"; import TrainStop from "@/scripts/interfaces/TrainStop";
import { DataStatus } from "@/scripts/enums/DataStatus";
@Component({ @Component({
components: { TrainSchedule }, components: { TrainSchedule },
}) })
export default class TrainTable extends Vue { export default class TrainTable extends Vue {
@Prop() computedTrains!: Train[]; @Prop() computedTrains!: Train[];
@Prop() timetableDataStatus!: DataStatus;
showedSchedule = 0; showedSchedule = 0;
@@ -194,6 +202,14 @@ export default class TrainTable extends Vue {
signalIcon: string = require("@/assets/icon-signal.svg"); signalIcon: string = require("@/assets/icon-signal.svg");
routeIcon: string = require("@/assets/icon-route.svg"); routeIcon: string = require("@/assets/icon-route.svg");
get timetableLoaded() {
return this.timetableDataStatus == DataStatus.Loaded;
}
get timetableError() {
return this.timetableDataStatus == DataStatus.Error;
}
focusOnTrain(timetableId: number) { focusOnTrain(timetableId: number) {
const currentEl: HTMLElement = this.$refs[timetableId][0]; const currentEl: HTMLElement = this.$refs[timetableId][0];
+1
View File
@@ -88,6 +88,7 @@
}, },
"trains": { "trains": {
"no-trains": "Oops! No trains online!", "no-trains": "Oops! No trains online!",
"loading": "Loading train data...",
"stats": "TRAFFIC STATISTICS", "stats": "TRAFFIC STATISTICS",
"stats-speed": "TRAINS SPEED (MIN | AVG | MAX) [km/h]", "stats-speed": "TRAINS SPEED (MIN | AVG | MAX) [km/h]",
"stats-length": "TIMETABLES LENGTH (MIN | AVG | MAX) [km]", "stats-length": "TIMETABLES LENGTH (MIN | AVG | MAX) [km]",
+1
View File
@@ -88,6 +88,7 @@
}, },
"trains": { "trains": {
"no-trains": "Brak pociągów online!", "no-trains": "Brak pociągów online!",
"loading": "Pobieranie danych o pociągach...",
"stats": "STATYSTYKI RUCHU", "stats": "STATYSTYKI RUCHU",
"stats-speed": "PRĘDKOŚCI POCIĄGÓW (MIN | ŚR | MAX) [km/h]", "stats-speed": "PRĘDKOŚCI POCIĄGÓW (MIN | ŚR | MAX) [km/h]",
"stats-length": "DŁUGOŚCI ROZKŁADÓW (MIN | ŚR | MAX) [km]", "stats-length": "DŁUGOŚCI ROZKŁADÓW (MIN | ŚR | MAX) [km]",
+1 -3
View File
@@ -1,8 +1,6 @@
const enum DataStatus { export const enum DataStatus {
Initialized = -1, Initialized = -1,
Loading = 0, Loading = 0,
Error = 1, Error = 1,
Loaded = 2 Loaded = 2
} }
export default DataStatus;
+1 -1
View File
@@ -1,4 +1,4 @@
import DataStatus from "../enums/DataStatus"; import { DataStatus } from "../enums/DataStatus";
import Station from "./Station"; import Station from "./Station";
import Train from "./Train"; import Train from "./Train";
+10 -11
View File
@@ -8,7 +8,7 @@ import Train from "@/scripts/interfaces/Train";
import TrainStop from "@/scripts/interfaces/TrainStop"; import TrainStop from "@/scripts/interfaces/TrainStop";
import utils from "@/scripts/utils/storeUtils"; import utils from "@/scripts/utils/storeUtils";
import DataStatus from "@/scripts/enums/DataStatus"; import { DataStatus } from "@/scripts/enums/DataStatus";
import { StoreData } from "@/scripts/interfaces/StoreData"; import { StoreData } from "@/scripts/interfaces/StoreData";
interface TimetableData { interface TimetableData {
@@ -59,7 +59,7 @@ export default class Store extends VuexModule {
private dataConnectionStatus: DataStatus = DataStatus.Loading; private dataConnectionStatus: DataStatus = DataStatus.Loading;
private sceneryDataStatus: DataStatus = DataStatus.Loading; private sceneryDataStatus: DataStatus = DataStatus.Loading;
private timetableLoaded: DataStatus = DataStatus.Loading; private timetableDataStatus: DataStatus = DataStatus.Loading;
private stationList: Station[] = []; private stationList: Station[] = [];
private trainList: Train[] = []; private trainList: Train[] = [];
@@ -74,7 +74,7 @@ export default class Store extends VuexModule {
activeStationCount: this.stationCount, activeStationCount: this.stationCount,
dataConnectionStatus: this.dataConnectionStatus, dataConnectionStatus: this.dataConnectionStatus,
timetableDataStatus: this.timetableLoaded timetableDataStatus: this.timetableDataStatus
}; };
} }
@@ -87,12 +87,13 @@ export default class Store extends VuexModule {
} }
get getTimetableDataStatus() { get getTimetableDataStatus() {
return this.timetableLoaded; return this.timetableDataStatus;
} }
get getDataStatus() { get getDataStatus() {
return this.dataConnectionStatus; return this.dataConnectionStatus;
} }
get getSceneryDataStatus() { get getSceneryDataStatus() {
return this.sceneryDataStatus; return this.sceneryDataStatus;
} }
@@ -481,17 +482,15 @@ export default class Store extends VuexModule {
this.trainList = this.trainList.reduce((acc, train) => { this.trainList = this.trainList.reduce((acc, train) => {
const timetableData = timetableList.find(data => data && data.trainNo === train.trainNo); const timetableData = timetableList.find(data => data && data.trainNo === train.trainNo);
if (timetableData) { const trainStopData = this.stationList
const trainData = this.stationList .find(station => station.stationName === train.currentStationName)
.find(station => station.stationName === train.currentStationName) ?.scheduledTrains.find(stationTrain => stationTrain.trainNo === train.trainNo);
?.scheduledTrains.find(stationTrain => stationTrain.trainNo === train.trainNo);
acc.push({ ...train, timetableData, stopStatus: trainData?.stopStatus || "", stopLabel: trainData?.stopLabel || "" }); acc.push({ ...train, timetableData, stopStatus: trainStopData?.stopStatus || "", stopLabel: trainStopData?.stopLabel || "" });
}
return acc; return acc;
}, [] as Train[]); }, [] as Train[]);
this.timetableLoaded = DataStatus.Loaded; this.timetableDataStatus = DataStatus.Loaded;
} }
} }
+1 -1
View File
@@ -33,7 +33,7 @@ import Station from "@/scripts/interfaces/Station";
import SceneryInfo from "@/components/SceneryView/SceneryInfo.vue"; import SceneryInfo from "@/components/SceneryView/SceneryInfo.vue";
import SceneryTimetable from "@/components/SceneryView/SceneryTimetable.vue"; import SceneryTimetable from "@/components/SceneryView/SceneryTimetable.vue";
import { StoreData } from "@/scripts/interfaces/StoreData"; import { StoreData } from "@/scripts/interfaces/StoreData";
import DataStatus from "@/scripts/enums/DataStatus"; import { DataStatus } from "@/scripts/enums/DataStatus";
import ActionButton from "@/components/Global/ActionButton.vue"; import ActionButton from "@/components/Global/ActionButton.vue";
@Component({ @Component({
+1 -1
View File
@@ -74,7 +74,7 @@ import FilterCard from "@/components/StationsView/FilterCard.vue";
import DonationModal from "@/components/Global/DonationModal.vue"; import DonationModal from "@/components/Global/DonationModal.vue";
import ActionButton from "@/components/Global/ActionButton.vue"; import ActionButton from "@/components/Global/ActionButton.vue";
import { StoreData } from "@/scripts/interfaces/StoreData"; import { StoreData } from "@/scripts/interfaces/StoreData";
import DataStatus from "@/scripts/enums/DataStatus"; import { DataStatus } from "@/scripts/enums/DataStatus";
@Component({ @Component({
components: { components: {
+47 -38
View File
@@ -19,7 +19,10 @@
/> />
</div> </div>
<TrainTable :computedTrains="computedTrains" /> <TrainTable
:computedTrains="computedTrains"
:timetableDataStatus="timetableDataStatus"
/>
</div> </div>
</section> </section>
</template> </template>
@@ -35,6 +38,7 @@ import TrainTable from "@/components/TrainsView/TrainTable.vue";
import TrainStats from "@/components/TrainsView/TrainStats.vue"; import TrainStats from "@/components/TrainsView/TrainStats.vue";
import TrainOptions from "@/components/TrainsView/TrainOptions.vue"; import TrainOptions from "@/components/TrainsView/TrainOptions.vue";
import ActionButton from "@/components/Global/ActionButton.vue"; import ActionButton from "@/components/Global/ActionButton.vue";
import { DataStatus } from "@/scripts/enums/DataStatus";
@Component({ @Component({
components: { components: {
@@ -46,6 +50,7 @@ import ActionButton from "@/components/Global/ActionButton.vue";
}) })
export default class TrainsView extends Vue { export default class TrainsView extends Vue {
@Getter("getTrainList") trains!: Train[]; @Getter("getTrainList") trains!: Train[];
@Getter("getTimetableDataStatus") timetableDataStatus!: DataStatus;
// Passed in route as query parameters // Passed in route as query parameters
@Prop() readonly queryTrain!: string; @Prop() readonly queryTrain!: string;
@@ -76,50 +81,54 @@ export default class TrainsView extends Vue {
} }
get computedTrains() { get computedTrains() {
return this.trains return this.timetableDataStatus != DataStatus.Loaded
.filter( ? []
(train) => : this.trains
train.timetableData && .filter(
(this.searchedTrain.length > 0 (train) =>
? train.trainNo.toString().includes(this.searchedTrain) train.online &&
: true) && (this.searchedTrain.length > 0
(this.searchedDriver.length > 0 ? train.trainNo.toString().includes(this.searchedTrain)
? train.driverName : true) &&
.toLowerCase() (this.searchedDriver.length > 0
.includes(this.searchedDriver.toLowerCase()) ? train.driverName
: true) .toLowerCase()
) .includes(this.searchedDriver.toLowerCase())
.sort((a, b) => { : true)
switch (this.sorterActive.id) { )
case "mass": .sort((a, b) => {
if (a.mass > b.mass) return this.sorterActive.dir; switch (this.sorterActive.id) {
else return -this.sorterActive.dir; case "mass":
if (a.mass > b.mass) return this.sorterActive.dir;
return -this.sorterActive.dir;
case "distance": case "distance":
if (!a.timetableData || !b.timetableData) return 0; if (
(a.timetableData?.routeDistance || -1) >
(b.timetableData?.routeDistance || -1)
)
return this.sorterActive.dir;
if (a.timetableData.routeDistance > b.timetableData.routeDistance) return -this.sorterActive.dir;
return this.sorterActive.dir;
else return -this.sorterActive.dir;
case "speed": case "speed":
if (a.speed > b.speed) return this.sorterActive.dir; if (a.speed > b.speed) return this.sorterActive.dir;
else return -this.sorterActive.dir; return -this.sorterActive.dir;
case "timetable": case "timetable":
if (a.trainNo > b.trainNo) return this.sorterActive.dir; if (a.trainNo > b.trainNo) return this.sorterActive.dir;
else return -this.sorterActive.dir; return -this.sorterActive.dir;
case "length": case "length":
if (a.length > b.length) return this.sorterActive.dir; if (a.length > b.length) return this.sorterActive.dir;
else return -this.sorterActive.dir; return -this.sorterActive.dir;
default: default:
break; break;
} }
return 0; return 0;
}); });
} }
} }
</script> </script>