mirror of
https://github.com/Spythere/pragotron-td2.git
synced 2026-05-03 13:38:14 +00:00
Dodano wybór scenerii
This commit is contained in:
+60
-2
@@ -1,17 +1,56 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="scenery-selector" v-if="selectedStationName.length == 0">
|
||||||
<PragotronVue />
|
<select name="scenery" id="select-scenery" v-model="selectedStationName">
|
||||||
|
<option value="" disabled>Wybierz scenerię</option>
|
||||||
|
<option v-for="name in onlineStationNames" :key="name">{{ name }}</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<PragotronVue v-else />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { provide, ref } from 'vue';
|
||||||
import { defineComponent } from '@vue/runtime-core';
|
import { defineComponent } from '@vue/runtime-core';
|
||||||
import PragotronVue from './components/Pragotron.vue';
|
import PragotronVue from './components/Pragotron.vue';
|
||||||
|
|
||||||
|
import { StationResponse, StationInfo } from '@/interfaces/StationAPI';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
PragotronVue,
|
PragotronVue,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
const selectedStationName = ref('');
|
||||||
|
|
||||||
|
provide('selectedStationName', selectedStationName);
|
||||||
|
|
||||||
|
return {
|
||||||
|
selectedStationName,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
data: () => ({
|
||||||
|
onlineStationNames: [] as string[],
|
||||||
|
}),
|
||||||
|
|
||||||
|
async mounted() {
|
||||||
|
const stationsAPIResponse: StationResponse = await (
|
||||||
|
await fetch('https://api.td2.info.pl:9640/?method=getStationsOnline')
|
||||||
|
).json();
|
||||||
|
|
||||||
|
this.onlineStationNames = stationsAPIResponse.message
|
||||||
|
.reduce((acc, station) => {
|
||||||
|
if (station.region != 'eu') return acc;
|
||||||
|
if (!station.isOnline) return acc;
|
||||||
|
|
||||||
|
acc.push(station.stationName);
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
}, [] as string[])
|
||||||
|
.sort((s1, s2) => (s1 > s2 ? 1 : -1));
|
||||||
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -29,6 +68,14 @@ html {
|
|||||||
font-family: 'Monda', sans-serif;
|
font-family: 'Monda', sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input,
|
||||||
|
button,
|
||||||
|
select,
|
||||||
|
option {
|
||||||
|
font-family: 'Monda', sans-serif;
|
||||||
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
#app {
|
#app {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
@@ -38,4 +85,15 @@ html {
|
|||||||
|
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.scenery-selector {
|
||||||
|
font-size: 1.3em;
|
||||||
|
color: white;
|
||||||
|
|
||||||
|
select {
|
||||||
|
margin-top: 1em;
|
||||||
|
|
||||||
|
width: 14em;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -43,10 +43,80 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent, inject, Ref } from 'vue';
|
||||||
|
|
||||||
|
import stationDataJSON from '@/data/stationList.json';
|
||||||
|
|
||||||
|
import { TrainResponse, TrainInfo } from '@/interfaces/TrainAPI';
|
||||||
|
import { TimetableResponse, TimetableInfo, TimetableStopInfo } from '@/interfaces/TimetableAPI';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
data: () => ({}),
|
data: () => ({
|
||||||
|
currentStationName: '',
|
||||||
|
stationDataJSON,
|
||||||
|
}),
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
const selectedStationName = inject('selectedStationName') as Ref<string>;
|
||||||
|
|
||||||
|
console.log(selectedStationName.value);
|
||||||
|
|
||||||
|
return {
|
||||||
|
selectedStationName,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
async mounted() {
|
||||||
|
/*
|
||||||
|
0: "LCS Żywiec"
|
||||||
|
1: "https://td2.info.pl/scenerie/lcs-zywiec/"
|
||||||
|
2: "97, 139"
|
||||||
|
3: null
|
||||||
|
4: "10"
|
||||||
|
5: "NIE"
|
||||||
|
6: "współczesna"
|
||||||
|
7: "SCS"
|
||||||
|
8: "" - sbl
|
||||||
|
9: "" - blokady
|
||||||
|
10: 3
|
||||||
|
11: 0
|
||||||
|
12: 0
|
||||||
|
13: 0
|
||||||
|
14: "Węgierska Górka;Żywiec;Łodygowice;Wilkowice Bystra;BB Leszczyny;BB Lipnik, podg."
|
||||||
|
15: true
|
||||||
|
16: false
|
||||||
|
17: false
|
||||||
|
*/
|
||||||
|
|
||||||
|
const trainsAPIResponse: TrainResponse = await (
|
||||||
|
await fetch('https://api.td2.info.pl:9640/?method=getTrainsOnline')
|
||||||
|
).json();
|
||||||
|
|
||||||
|
const reducedList = await trainsAPIResponse.message.reduce(async (acc: Promise<string[]>, train: TrainInfo) => {
|
||||||
|
const timetableAPIResponse: TimetableResponse = await (
|
||||||
|
await fetch(`https://api.td2.info.pl:9640/?method=readFromSWDR&value=getTimetable%3B${train.trainNo}%3Beu`)
|
||||||
|
).json();
|
||||||
|
|
||||||
|
const timetable: TimetableInfo = timetableAPIResponse.message;
|
||||||
|
|
||||||
|
if (!timetable.trainInfo) return acc;
|
||||||
|
if (!timetable.stopPoints) return acc;
|
||||||
|
|
||||||
|
const stopInfo: TimetableStopInfo | undefined = timetable.stopPoints.find(
|
||||||
|
(sp) => sp.pointNameRAW == this.selectedStationName
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!stopInfo) return acc;
|
||||||
|
if (!stopInfo.departureLine) return acc;
|
||||||
|
if (stopInfo.confirmed == 1) return acc;
|
||||||
|
|
||||||
|
(await acc).push(stopInfo.pointNameRAW + ': ' + timetable.trainInfo.driverName);
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
}, Promise.resolve([]));
|
||||||
|
|
||||||
|
console.log(reducedList);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
[["Aleksandrów Kujawski","Aleksandrów Kuj."],["Arkadia Zdrój","Arkadia Zdr."],["Babimost","Babimost"],["Bargowice","Bargowice"],["Bełchów","Bełchów"],["Blaszki","Blaszki"],["Borki","Borki"],["Brakowice","Brakowice"],["Buczek","Buczek"],["Buk","Buk"],["Bystra Woda","Bystra Woda"],["Cenorzyce Nowe","Cenorzyce Nowe"],["Chełmik Wołowski","Chełmik Woł."],["Chlorkowice","Chlorkowice"],["Cis","Cis"],["Czerepy","Czerepy"],["Czermin","Czermin"],["Dobrzyca Towarowa","Dobrzyca Tow."],["Dobrzyniec","Dobrzyniec"],["Drzewko","Drzewko"],["Dziewoszyce","Dziewoszyce"],["Falewo","Falewo"],["Glinnik","Glinnik"],["Grabów Miasto","Grabów Miasto"],["Góra Włodowska","Góra Włodowska"],["Głogowo","Głogowo"],["Głębce","Głębce"],["Głęboszów","Głęboszów"],["Imielin","Imielin"],["Jordanowo","Jordanowo"],["Karszynek","Karszynek"],["Kcynia","Kcynia"],["Kieły","Kieły"],["Kolsko","Kolsko"],["Kowalewo","Kowalewo"],["Krzemienice","Krzemienice"],["Krzęcz","Krzęcz"],["Kszęty","Kszęty"],["Kudowa Zdrój","Kudowa Zdrój"],["Głowno","Głowno"],["Ozorków","Ozorków"],["Skrzynki","Skrzynki"],["Żywiec","Żywiec"],["Legno","Legno"],["Lewków","Lewków"],["Ligota Grabowska","Ligota Grab."],["Lisiczki","Lisiczki"],["Lisków","Lisków"],["Lisków Miasto","Lisków Miasto"],["Lublinek","Lublinek"],["Lutol Suchy","Lutol Suchy"],["Luzino","Luzino"],["Lębork","Lębork"],["Milówka","Milówka"],["Modlinków","Modlinków"],["Motławy","Motławy"],["Naterki","Naterki"],["Okoń Główny","Okoń Gł."],["Orniki","Orniki"],["Otwocko","Otwocko"],["Parów","Parów"],["Piaskowo","Piaskowo"],["Pilichowice","Pilichowice"],["Poreńsk","Poreńsk"],["Radostowice","Radostowice"],["Radowice","Radowice"],["Radzikowo","Radzikowo"],["Rajcza","Rajcza"],["Razemsko","Razemsko"],["Rebrowo Dolne","Rebrowo Dol."],["Redlin Sudecki","Redlin Sudecki"],["Santok Zdrój","Santok Zdr."],["Sieniawka","Sieniawka"],["Skawce","Skawce"],["Sowi Bór","Sowi Bór"],["Sroka","Sroka"],["Stare Lipowo","Stare Lipowo"],["Starzynki","Starzynki"],["Stefanowo","Stefanowo"],["Stryków","Stryków"],["Strączki","Strączki"],["Sulechów","Sulechów"],["Szadek","Szadek"],["Sól","Sól"],["Tarkowo","Tarkowo"],["Tartakowo","Tartakowo"],["Testowo","Testowo"],["Trawniczki","Trawniczki"],["Tłoki","Tłoki"],["Wełtawa","Wełtawa"],["Wielichowo","Wielichowo"],["Wijewo","Wijewo"],["Wilczyca","Wilczyca"],["Witaszyczki","Witaszyczki"],["Witonia","Witonia"],["Wodnica","Wodnica"],["Wola","Wola"],["Wola Nowska","Wola Nowska"],["Wschodna","Wschodna"],["Zgierz","Zgierz"],["Zgierz Kontrewers","Zgierz Kontr."],["Zwardoń","Zwardoń"],["Łask","Łask"],["Łaskarzew","Łaskarzew"],["Łebnino","Łebnino"],["Łęczyca","Łęczyca"],["Żerniki","Żerniki"],["Żory","Żory"]]
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
export interface StationInfo {
|
||||||
|
dispatcherId: number;
|
||||||
|
dispatcherName: string;
|
||||||
|
dispatcherIsSupporter: boolean;
|
||||||
|
stationName: string;
|
||||||
|
stationHash: string;
|
||||||
|
region: string;
|
||||||
|
maxUsers: number;
|
||||||
|
currentUsers: number;
|
||||||
|
spawn: number;
|
||||||
|
lastSeen: any;
|
||||||
|
dispatcherExp: number;
|
||||||
|
nameFromHeader: string;
|
||||||
|
spawnString: string;
|
||||||
|
networkConnectionString: string;
|
||||||
|
isOnline: number;
|
||||||
|
dispatcherRate: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StationResponse {
|
||||||
|
success: boolean;
|
||||||
|
respCode: number;
|
||||||
|
message: StationInfo[];
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
export interface TimetableTrainInfo {
|
||||||
|
timetableId: number;
|
||||||
|
trainNo: number;
|
||||||
|
trainCategoryCode: string;
|
||||||
|
driverId: number;
|
||||||
|
driverName: string;
|
||||||
|
route: string;
|
||||||
|
twr: number;
|
||||||
|
skr: number;
|
||||||
|
sceneries: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TimetableStopInfo {
|
||||||
|
arrivalLine?: string;
|
||||||
|
arrivalTime?: Date;
|
||||||
|
arrivalDelay: number;
|
||||||
|
arrivalRealTime?: Date;
|
||||||
|
pointDistance: number;
|
||||||
|
pointName: string;
|
||||||
|
pointNameRAW: string;
|
||||||
|
entryId: number;
|
||||||
|
pointId: string;
|
||||||
|
comments?: any;
|
||||||
|
confirmed: number;
|
||||||
|
isStopped: number;
|
||||||
|
pointStopTime?: number;
|
||||||
|
pointStopType: string;
|
||||||
|
departureLine?: string;
|
||||||
|
departureTime?: Date;
|
||||||
|
departureDelay: number;
|
||||||
|
departureRealTime?: Date;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TimetableInfo {
|
||||||
|
trainInfo?: TimetableTrainInfo;
|
||||||
|
stopPoints?: TimetableStopInfo[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TimetableResponse {
|
||||||
|
success: boolean;
|
||||||
|
respCode: number;
|
||||||
|
message: TimetableInfo;
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
export interface TrainInfo {
|
||||||
|
trainNo: number;
|
||||||
|
driverId: number;
|
||||||
|
driverName: string;
|
||||||
|
driverIsSupporter: boolean;
|
||||||
|
station: any;
|
||||||
|
dataSignal: string;
|
||||||
|
dataSceneryConnection: string;
|
||||||
|
dataDistance: number;
|
||||||
|
dataCon: string;
|
||||||
|
dataSpeed: number;
|
||||||
|
dataMass: number;
|
||||||
|
dataLength: number;
|
||||||
|
region: string;
|
||||||
|
isOnline: number;
|
||||||
|
lastSeen: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TrainResponse {
|
||||||
|
success: boolean;
|
||||||
|
respCode: number;
|
||||||
|
message: TrainInfo[];
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
"strict": true,
|
"strict": true,
|
||||||
"jsx": "preserve",
|
"jsx": "preserve",
|
||||||
"importHelpers": true,
|
"importHelpers": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user