mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
Poprawka favicon
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
@@ -2,16 +2,22 @@ import TrainStop from "./TrainStop";
|
|||||||
|
|
||||||
export default interface Timetable {
|
export default interface Timetable {
|
||||||
trainNo: number;
|
trainNo: number;
|
||||||
driverName: string;
|
|
||||||
driverId: number;
|
success: boolean;
|
||||||
currentStationName: string;
|
|
||||||
currentStationHash: string;
|
data?: {
|
||||||
timetableId: number;
|
trainNo: number;
|
||||||
category: string;
|
driverName: string;
|
||||||
route: string;
|
driverId: number;
|
||||||
TWR: boolean;
|
currentStationName: string;
|
||||||
SKR: boolean;
|
currentStationHash: string;
|
||||||
routeDistance: number;
|
timetableId: number;
|
||||||
followingStops: TrainStop[];
|
category: string;
|
||||||
followingSceneries: string[];
|
route: string;
|
||||||
|
TWR: boolean;
|
||||||
|
SKR: boolean;
|
||||||
|
routeDistance: number;
|
||||||
|
followingStops: TrainStop[];
|
||||||
|
followingSceneries: string[];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import Station from "../interfaces/Station";
|
import Station from "../interfaces/Station";
|
||||||
|
import Timetable from "../interfaces/Timetable";
|
||||||
import TrainStop from "../interfaces/TrainStop";
|
import TrainStop from "../interfaces/TrainStop";
|
||||||
|
|
||||||
export const getLocoURL = (locoType: string): string => (`https://rj.td2.info.pl/dist/img/thumbnails/${locoType.includes("EN") ? locoType + "rb" : locoType}.png`)
|
export const getLocoURL = (locoType: string): string => (`https://rj.td2.info.pl/dist/img/thumbnails/${locoType.includes("EN") ? locoType + "rb" : locoType}.png`)
|
||||||
@@ -79,7 +80,7 @@ export const timestampToString = (timestamp: number | null): string =>
|
|||||||
})
|
})
|
||||||
: "";
|
: "";
|
||||||
|
|
||||||
export const getTrainStopStatus = (stopInfo: TrainStop, timetableData: { currentStationName: string }, station: Station) => {
|
export const getTrainStopStatus = (stopInfo: TrainStop, currentStationName: string, station: Station) => {
|
||||||
let stopStatus = "",
|
let stopStatus = "",
|
||||||
stopLabel = "",
|
stopLabel = "",
|
||||||
stopStatusID = -1;
|
stopStatusID = -1;
|
||||||
@@ -88,23 +89,23 @@ export const getTrainStopStatus = (stopInfo: TrainStop, timetableData: { current
|
|||||||
stopStatus = "terminated";
|
stopStatus = "terminated";
|
||||||
stopLabel = "Skończył bieg";
|
stopLabel = "Skończył bieg";
|
||||||
stopStatusID = 5;
|
stopStatusID = 5;
|
||||||
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && timetableData.currentStationName == station.name) {
|
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && currentStationName == station.name) {
|
||||||
stopStatus = "departed";
|
stopStatus = "departed";
|
||||||
stopLabel = "Odprawiony";
|
stopLabel = "Odprawiony";
|
||||||
stopStatusID = 2;
|
stopStatusID = 2;
|
||||||
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && timetableData.currentStationName != station.name) {
|
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && currentStationName != station.name) {
|
||||||
stopStatus = "departed-away";
|
stopStatus = "departed-away";
|
||||||
stopLabel = "Odjechał";
|
stopLabel = "Odjechał";
|
||||||
stopStatusID = 4;
|
stopStatusID = 4;
|
||||||
} else if (timetableData.currentStationName == station.name && !stopInfo.stopped) {
|
} else if (currentStationName == station.name && !stopInfo.stopped) {
|
||||||
stopStatus = "online";
|
stopStatus = "online";
|
||||||
stopLabel = "Na stacji";
|
stopLabel = "Na stacji";
|
||||||
stopStatusID = 0;
|
stopStatusID = 0;
|
||||||
} else if (timetableData.currentStationName == station.name && stopInfo.stopped) {
|
} else if (currentStationName == station.name && stopInfo.stopped) {
|
||||||
stopStatus = "stopped";
|
stopStatus = "stopped";
|
||||||
stopLabel = "Postój";
|
stopLabel = "Postój";
|
||||||
stopStatusID = 1;
|
stopStatusID = 1;
|
||||||
} else if (timetableData.currentStationName != station.name) {
|
} else if (currentStationName != station.name) {
|
||||||
stopStatus = "arriving";
|
stopStatus = "arriving";
|
||||||
stopLabel = "W drodze";
|
stopLabel = "W drodze";
|
||||||
stopStatusID = 3;
|
stopStatusID = 3;
|
||||||
|
|||||||
+60
-42
@@ -26,6 +26,7 @@ import ScheduledTrain from '@/scripts/interfaces/ScheduledTrain';
|
|||||||
export interface State {
|
export interface State {
|
||||||
stationList: Station[],
|
stationList: Station[],
|
||||||
trainList: Train[],
|
trainList: Train[],
|
||||||
|
timetableList: Timetable[],
|
||||||
|
|
||||||
sceneryData: any[][],
|
sceneryData: any[][],
|
||||||
|
|
||||||
@@ -85,6 +86,7 @@ export const store = createStore<State>({
|
|||||||
state: () => ({
|
state: () => ({
|
||||||
stationList: [],
|
stationList: [],
|
||||||
trainList: [],
|
trainList: [],
|
||||||
|
timetableList: [],
|
||||||
|
|
||||||
sceneryData: [],
|
sceneryData: [],
|
||||||
|
|
||||||
@@ -237,11 +239,17 @@ export const store = createStore<State>({
|
|||||||
async fetchTimetableData({ commit }) {
|
async fetchTimetableData({ commit }) {
|
||||||
let warnings = 0;
|
let warnings = 0;
|
||||||
|
|
||||||
const reducedList = this.state.trainList.reduce(async (acc: Promise<Timetable[]>, train: Train) => {
|
const timetableList = this.state.trainList.reduce(async (acc: Promise<Timetable[]>, train: Train) => {
|
||||||
const data: { success: boolean; message: TimetableAPIData } = await (await axios.get(URLs.getTimetableURL(train.trainNo, this.state.region.id))).data;
|
const data: { success: boolean; message: TimetableAPIData } = await (await axios.get(URLs.getTimetableURL(train.trainNo, this.state.region.id))).data;
|
||||||
|
|
||||||
if (!data.success) {
|
if (!data.success) {
|
||||||
warnings++;
|
warnings++;
|
||||||
|
|
||||||
|
(await acc).push({
|
||||||
|
trainNo: train.trainNo,
|
||||||
|
success: false
|
||||||
|
});
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,25 +320,30 @@ export const store = createStore<State>({
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
(await acc).push({
|
(await acc).push({
|
||||||
|
data: {
|
||||||
|
trainNo: train.trainNo,
|
||||||
|
driverName: train.driverName,
|
||||||
|
driverId: train.driverId,
|
||||||
|
currentStationName: train.currentStationName,
|
||||||
|
currentStationHash: train.currentStationHash,
|
||||||
|
timetableId: trainInfo.timetableId,
|
||||||
|
category: trainInfo.trainCategoryCode,
|
||||||
|
route: trainInfo.route,
|
||||||
|
TWR: trainInfo.twr,
|
||||||
|
SKR: trainInfo.skr,
|
||||||
|
routeDistance: timetable.stopPoints[timetable.stopPoints.length - 1].pointDistance,
|
||||||
|
followingStops,
|
||||||
|
followingSceneries: trainInfo.sceneries
|
||||||
|
},
|
||||||
|
|
||||||
trainNo: train.trainNo,
|
trainNo: train.trainNo,
|
||||||
driverName: train.driverName,
|
success: true
|
||||||
driverId: train.driverId,
|
|
||||||
currentStationName: train.currentStationName,
|
|
||||||
currentStationHash: train.currentStationHash,
|
|
||||||
timetableId: trainInfo.timetableId,
|
|
||||||
category: trainInfo.trainCategoryCode,
|
|
||||||
route: trainInfo.route,
|
|
||||||
TWR: trainInfo.twr,
|
|
||||||
SKR: trainInfo.skr,
|
|
||||||
routeDistance: timetable.stopPoints[timetable.stopPoints.length - 1].pointDistance,
|
|
||||||
followingStops,
|
|
||||||
followingSceneries: trainInfo.sceneries
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
}, Promise.resolve([]));
|
}, Promise.resolve([]));
|
||||||
|
|
||||||
commit(MUTATIONS.UPDATE_TIMETABLES, (await reducedList));
|
commit(MUTATIONS.UPDATE_TIMETABLES, (await timetableList));
|
||||||
commit(MUTATIONS.SET_TIMETABLE_DATA_STATUS, warnings == 0 ? DataStatus.Loaded : DataStatus.Warning);
|
commit(MUTATIONS.SET_TIMETABLE_DATA_STATUS, warnings == 0 ? DataStatus.Loaded : DataStatus.Warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,9 +359,6 @@ export const store = createStore<State>({
|
|||||||
checkpoints: stationData.checkpoints ? stationData.checkpoints.split(";").map(sub => ({ checkpointName: sub, scheduledTrains: [] })) : [],
|
checkpoints: stationData.checkpoints ? stationData.checkpoints.split(";").map(sub => ({ checkpointName: sub, scheduledTrains: [] })) : [],
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
console.log(state.stationList);
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
@@ -441,9 +451,12 @@ export const store = createStore<State>({
|
|||||||
const stationName = station.name.toLowerCase();
|
const stationName = station.name.toLowerCase();
|
||||||
|
|
||||||
const scheduledTrains: ScheduledTrain[] = timetableList.reduce((acc: ScheduledTrain[], timetable: Timetable) => {
|
const scheduledTrains: ScheduledTrain[] = timetableList.reduce((acc: ScheduledTrain[], timetable: Timetable) => {
|
||||||
if (!timetable.followingSceneries.includes(station.onlineInfo?.hash || "")) return acc;
|
if (!timetable.data)
|
||||||
|
return acc;
|
||||||
|
|
||||||
const stopInfoIndex = timetable.followingStops.findIndex(stop => {
|
if (!timetable.data.followingSceneries.includes(station.onlineInfo?.hash || "")) return acc;
|
||||||
|
|
||||||
|
const stopInfoIndex = timetable.data.followingStops.findIndex(stop => {
|
||||||
const stopName = stop.stopNameRAW.toLowerCase();
|
const stopName = stop.stopNameRAW.toLowerCase();
|
||||||
|
|
||||||
// if (stop.stopName == "ARKADIA ZDRÓJ" && station.name == "Arkadia Zdrój 2019" && stop.pointId != "1583014379097") return false;
|
// if (stop.stopName == "ARKADIA ZDRÓJ" && station.name == "Arkadia Zdrój 2019" && stop.pointId != "1583014379097") return false;
|
||||||
@@ -466,18 +479,18 @@ export const store = createStore<State>({
|
|||||||
|
|
||||||
if (stopInfoIndex == -1) return acc;
|
if (stopInfoIndex == -1) return acc;
|
||||||
|
|
||||||
const trainStop = timetable.followingStops[stopInfoIndex];
|
const trainStop = timetable.data.followingStops[stopInfoIndex];
|
||||||
const trainStopStatus = getTrainStopStatus(trainStop, timetable, station);
|
const trainStopStatus = getTrainStopStatus(trainStop, timetable.data.currentStationName, station);
|
||||||
|
|
||||||
acc.push({
|
acc.push({
|
||||||
trainNo: timetable.trainNo,
|
trainNo: timetable.data.trainNo,
|
||||||
driverName: timetable.driverName,
|
driverName: timetable.data.driverName,
|
||||||
driverId: timetable.driverId,
|
driverId: timetable.data.driverId,
|
||||||
currentStationName: timetable.currentStationName,
|
currentStationName: timetable.data.currentStationName,
|
||||||
currentStationHash: timetable.currentStationHash,
|
currentStationHash: timetable.data.currentStationHash,
|
||||||
category: timetable.category,
|
category: timetable.data.category,
|
||||||
beginsAt: timetable.followingStops[0].stopNameRAW,
|
beginsAt: timetable.data.followingStops[0].stopNameRAW,
|
||||||
terminatesAt: timetable.followingStops[timetable.followingStops.length - 1].stopNameRAW,
|
terminatesAt: timetable.data.followingStops[timetable.data.followingStops.length - 1].stopNameRAW,
|
||||||
nearestStop: "",
|
nearestStop: "",
|
||||||
stopInfo: trainStop,
|
stopInfo: trainStop,
|
||||||
stopLabel: trainStopStatus.stopLabel,
|
stopLabel: trainStopStatus.stopLabel,
|
||||||
@@ -493,22 +506,25 @@ export const store = createStore<State>({
|
|||||||
|
|
||||||
for (const checkpoint of station.generalInfo.checkpoints) {
|
for (const checkpoint of station.generalInfo.checkpoints) {
|
||||||
timetableList.forEach(timetable => {
|
timetableList.forEach(timetable => {
|
||||||
if (!timetable.followingSceneries.includes(station.onlineInfo?.hash || "")) return;
|
if (!timetable.data) return;
|
||||||
|
if (!timetable.data.followingSceneries.includes(station.onlineInfo?.hash || "")) return;
|
||||||
|
|
||||||
timetable.followingStops
|
const timetableData = timetable.data;
|
||||||
|
|
||||||
|
timetableData.followingStops
|
||||||
.filter(trainStop => trainStop.stopNameRAW.toLowerCase() === checkpoint.checkpointName.toLowerCase())
|
.filter(trainStop => trainStop.stopNameRAW.toLowerCase() === checkpoint.checkpointName.toLowerCase())
|
||||||
.forEach(trainStop => {
|
.forEach(trainStop => {
|
||||||
const trainStopStatus = getTrainStopStatus(trainStop, timetable, station);
|
const trainStopStatus = getTrainStopStatus(trainStop, timetableData.currentStationName, station);
|
||||||
|
|
||||||
checkpoint.scheduledTrains.push({
|
checkpoint.scheduledTrains.push({
|
||||||
trainNo: timetable.trainNo,
|
trainNo: timetable.trainNo,
|
||||||
driverName: timetable.driverName,
|
driverName: timetableData.driverName,
|
||||||
driverId: timetable.driverId,
|
driverId: timetableData.driverId,
|
||||||
currentStationName: timetable.currentStationName,
|
currentStationName: timetableData.currentStationName,
|
||||||
currentStationHash: timetable.currentStationHash,
|
currentStationHash: timetableData.currentStationHash,
|
||||||
category: timetable.category,
|
category: timetableData.category,
|
||||||
beginsAt: timetable.followingStops[0].stopNameRAW,
|
beginsAt: timetableData.followingStops[0].stopNameRAW,
|
||||||
terminatesAt: timetable.followingStops[timetable.followingStops.length - 1].stopNameRAW,
|
terminatesAt: timetableData.followingStops[timetableData.followingStops.length - 1].stopNameRAW,
|
||||||
nearestStop: "",
|
nearestStop: "",
|
||||||
stopInfo: trainStop,
|
stopInfo: trainStop,
|
||||||
stopLabel: trainStopStatus.stopLabel,
|
stopLabel: trainStopStatus.stopLabel,
|
||||||
@@ -531,8 +547,10 @@ export const store = createStore<State>({
|
|||||||
});
|
});
|
||||||
|
|
||||||
state.trainList = state.trainList.reduce((acc, train) => {
|
state.trainList = state.trainList.reduce((acc, train) => {
|
||||||
const timetableData = timetableList.find(data => data && data.trainNo === train.trainNo && data.driverId === train.driverId);
|
const timetable = timetableList.find(tt => tt.data && tt.trainNo === train.trainNo && tt.data.driverId === train.driverId);
|
||||||
const allTimetables = timetableList.filter(data => data && data.driverId === train.driverId && data.trainNo !== train.trainNo);
|
const allTimetables = timetableList.filter(tt => tt.data && tt.data.driverId === train.driverId && tt.trainNo !== train.trainNo);
|
||||||
|
|
||||||
|
if (!timetable || !timetable.data) return acc;
|
||||||
|
|
||||||
if (allTimetables.length > 0)
|
if (allTimetables.length > 0)
|
||||||
return acc;
|
return acc;
|
||||||
@@ -541,7 +559,7 @@ export const store = createStore<State>({
|
|||||||
.find(station => station.name === train.currentStationName)
|
.find(station => station.name === train.currentStationName)
|
||||||
?.onlineInfo?.scheduledTrains?.find(stationTrain => stationTrain.trainNo === train.trainNo);
|
?.onlineInfo?.scheduledTrains?.find(stationTrain => stationTrain.trainNo === train.trainNo);
|
||||||
|
|
||||||
acc.push({ ...train, timetableData, stopStatus: trainStopData?.stopStatus || "", stopLabel: trainStopData?.stopLabel || "" });
|
acc.push({ ...train, timetableData: timetable.data, stopStatus: trainStopData?.stopStatus || "", stopLabel: trainStopData?.stopLabel || "" });
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
}, [] as Train[]);
|
}, [] as Train[]);
|
||||||
|
|||||||
Reference in New Issue
Block a user