mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
Migracja z wersji Vue 2 na Vue 3
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
export default interface Filter {
|
||||
[key: string]: (boolean | number),
|
||||
default: boolean;
|
||||
notDefault: boolean;
|
||||
real: boolean;
|
||||
fictional: boolean;
|
||||
SPK: boolean;
|
||||
SCS: boolean;
|
||||
SPE: boolean;
|
||||
"SPK": boolean;
|
||||
"SCS": boolean;
|
||||
"SPE": boolean;
|
||||
ręczne: boolean;
|
||||
mechaniczne: boolean;
|
||||
współczesna: boolean;
|
||||
@@ -23,4 +24,5 @@ export default interface Filter {
|
||||
free: boolean;
|
||||
occupied: boolean;
|
||||
ending: boolean;
|
||||
nonPublic: boolean;
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ export default interface Station {
|
||||
stationTrains: {
|
||||
driverName: number;
|
||||
trainNo: number;
|
||||
stopStatus?: string;
|
||||
}[];
|
||||
|
||||
scheduledTrains: ScheduledTrain[];
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import TrainStop from "./TrainStop";
|
||||
|
||||
export default interface Timetable {
|
||||
trainNo: number;
|
||||
driverName: string;
|
||||
driverId: number;
|
||||
currentStationName: string;
|
||||
currentStationHash: string;
|
||||
timetableId: number;
|
||||
category: string;
|
||||
route: string;
|
||||
TWR: boolean;
|
||||
SKR: boolean;
|
||||
routeDistance: number;
|
||||
followingStops: TrainStop[];
|
||||
followingSceneries: string[];
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
export default interface StationAPIData {
|
||||
dispatcherId: number;
|
||||
dispatcherName: string;
|
||||
dispatcherIsSupporter: boolean;
|
||||
stationName: string;
|
||||
stationHash: string;
|
||||
region: string;
|
||||
maxUsers: number;
|
||||
currentUsers: number;
|
||||
spawn: number;
|
||||
lastSeen: number;
|
||||
dispatcherExp: number;
|
||||
nameFromHeader: string;
|
||||
spawnString: string;
|
||||
networkConnectionString: string;
|
||||
isOnline: number;
|
||||
dispatcherRate: number;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
export default interface TimetableAPIData {
|
||||
trainInfo: {
|
||||
timetableId: number;
|
||||
trainNo: number;
|
||||
trainCategoryCode: string;
|
||||
driverId: number;
|
||||
driverName: string;
|
||||
route: string;
|
||||
twr: boolean;
|
||||
skr: boolean;
|
||||
sceneries: string[];
|
||||
};
|
||||
|
||||
stopPoints: {
|
||||
arrivalLine: string | null;
|
||||
arrivalTime: string | null;
|
||||
arrivalDelay: number;
|
||||
arrivalRealTime: string | null;
|
||||
pointDistance: number;
|
||||
pointName: string;
|
||||
pointNameRAW: string;
|
||||
entryId: number;
|
||||
pointId: number;
|
||||
comments: string | null;
|
||||
confirmed: boolean;
|
||||
isStopped: boolean;
|
||||
pointStopTime: number | null;
|
||||
pointStopType: string;
|
||||
departureLine: string | null;
|
||||
departureTime: string | null;
|
||||
departureDelay: number;
|
||||
departureRealTime: string | null;
|
||||
}[];
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import StationAPIData from "./StationAPIData";
|
||||
|
||||
export default interface TrainAPIData {
|
||||
trainNo: number;
|
||||
driverId: number;
|
||||
driverName: string;
|
||||
driverIsSupporter: boolean;
|
||||
station: StationAPIData;
|
||||
dataSignal: string;
|
||||
dataSceneryConnection: string;
|
||||
dataDistance: number;
|
||||
dataCon: string;
|
||||
dataSpeed: number;
|
||||
dataMass: number;
|
||||
dataLength: number;
|
||||
region: string;
|
||||
isOnline: boolean;
|
||||
lastSeen: number;
|
||||
}
|
||||
@@ -122,6 +122,7 @@ export default class StationFilterManager {
|
||||
free: true,
|
||||
occupied: false,
|
||||
ending: false,
|
||||
nonPublic: false
|
||||
};
|
||||
|
||||
private filters: Filter = { ...this.filterInitStates };
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
export const URLs = {
|
||||
stations: "https://api.td2.info.pl:9640/?method=getStationsOnline",
|
||||
trains: "https://api.td2.info.pl:9640/?method=getTrainsOnline",
|
||||
dispatchers: "https://api.td2.info.pl:9640/?method=readFromSWDR&value=getDispatcherStatusList%3B1",
|
||||
getTimetableURL: (trainNo: string | number) => `https://api.td2.info.pl:9640/?method=readFromSWDR&value=getTimetable%3B${trainNo}%3Beu`
|
||||
};
|
||||
@@ -1,10 +1,9 @@
|
||||
import Station from "../interfaces/Station";
|
||||
import TrainStop from "../interfaces/TrainStop";
|
||||
|
||||
const timetableURL = (trainNo: number) => `https://api.td2.info.pl:9640/?method=readFromSWDR&value=getTimetable%3B${trainNo}%3Beu`;
|
||||
const getLocoURL = (locoType: 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`)
|
||||
|
||||
const getStatusID = (stationStatus: any) => {
|
||||
export const getStatusID = (stationStatus: any): string => {
|
||||
if (!stationStatus) return "not-signed";
|
||||
|
||||
const statusCode = stationStatus[2];
|
||||
@@ -33,7 +32,7 @@ const getStatusID = (stationStatus: any) => {
|
||||
return "unavailable";
|
||||
};
|
||||
|
||||
const getStatusTimestamp = (stationStatus: any) => {
|
||||
export const getStatusTimestamp = (stationStatus: any): number => {
|
||||
if (!stationStatus) return -2;
|
||||
|
||||
const statusCode = stationStatus[2];
|
||||
@@ -56,7 +55,7 @@ const getStatusTimestamp = (stationStatus: any) => {
|
||||
return -1;
|
||||
};
|
||||
|
||||
const parseSpawns = (spawnString: string) => {
|
||||
export const parseSpawns = (spawnString: string) => {
|
||||
if (!spawnString) return [];
|
||||
if (spawnString === "NO_SPAWN") return [];
|
||||
|
||||
@@ -69,9 +68,9 @@ const parseSpawns = (spawnString: string) => {
|
||||
});
|
||||
};
|
||||
|
||||
const getTimestamp = (date: string | null) => (date ? new Date(date).getTime() : 0);
|
||||
export const getTimestamp = (date: string | null): number => (date ? new Date(date).getTime() : 0);
|
||||
|
||||
const timestampToString = (timestamp: number | null) =>
|
||||
export const timestampToString = (timestamp: number | null): string =>
|
||||
timestamp
|
||||
? new Date(timestamp).toLocaleTimeString("pl-PL", {
|
||||
hour: "2-digit",
|
||||
@@ -79,10 +78,10 @@ const timestampToString = (timestamp: number | null) =>
|
||||
})
|
||||
: "";
|
||||
|
||||
const getTrainStopStatus = (stopInfo: TrainStop, timetableData: { currentStationName: string }, station: Station) => {
|
||||
let stopStatus: string = "",
|
||||
stopLabel: string = "",
|
||||
stopStatusID: number = -1;
|
||||
export const getTrainStopStatus = (stopInfo: TrainStop, timetableData: { currentStationName: string }, station: Station) => {
|
||||
let stopStatus = "",
|
||||
stopLabel = "",
|
||||
stopStatusID = -1;
|
||||
|
||||
if (stopInfo.terminatesHere && stopInfo.confirmed) {
|
||||
stopStatus = "terminated";
|
||||
@@ -111,15 +110,4 @@ const getTrainStopStatus = (stopInfo: TrainStop, timetableData: { currentStation
|
||||
}
|
||||
|
||||
return { stopStatus, stopLabel, stopStatusID };
|
||||
};
|
||||
|
||||
export default {
|
||||
timetableURL,
|
||||
getLocoURL,
|
||||
getStatusID,
|
||||
parseSpawns,
|
||||
getTimestamp,
|
||||
timestampToString,
|
||||
getStatusTimestamp,
|
||||
getTrainStopStatus
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user