mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 21:38:13 +00:00
Finalizacja migracji
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
export const enum DataStatus {
|
||||
Initialized = -1,
|
||||
Loading = 0,
|
||||
Error = 1,
|
||||
Loaded = 2
|
||||
}
|
||||
export const enum DataStatus {
|
||||
Initialized = -1,
|
||||
Loading = 0,
|
||||
Error = 1,
|
||||
Loaded = 2
|
||||
}
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
export default interface Filter {
|
||||
[key: string]: (boolean | number),
|
||||
default: boolean;
|
||||
notDefault: boolean;
|
||||
real: boolean;
|
||||
fictional: boolean;
|
||||
"SPK": boolean;
|
||||
"SCS": boolean;
|
||||
"SPE": boolean;
|
||||
ręczne: boolean;
|
||||
mechaniczne: boolean;
|
||||
współczesna: boolean;
|
||||
kształtowa: boolean;
|
||||
historyczna: boolean;
|
||||
mieszana: boolean;
|
||||
minLevel: number;
|
||||
maxLevel: number;
|
||||
minOneWayCatenary: number;
|
||||
minOneWay: number;
|
||||
minTwoWayCatenary: number;
|
||||
minTwoWay: number;
|
||||
'no-1track': boolean;
|
||||
'no-2track': boolean;
|
||||
free: boolean;
|
||||
occupied: boolean;
|
||||
ending: boolean;
|
||||
nonPublic: boolean;
|
||||
}
|
||||
export default interface Filter {
|
||||
[key: string]: (boolean | number),
|
||||
default: boolean;
|
||||
notDefault: boolean;
|
||||
real: boolean;
|
||||
fictional: boolean;
|
||||
"SPK": boolean;
|
||||
"SCS": boolean;
|
||||
"SPE": boolean;
|
||||
ręczne: boolean;
|
||||
mechaniczne: boolean;
|
||||
współczesna: boolean;
|
||||
kształtowa: boolean;
|
||||
historyczna: boolean;
|
||||
mieszana: boolean;
|
||||
minLevel: number;
|
||||
maxLevel: number;
|
||||
minOneWayCatenary: number;
|
||||
minOneWay: number;
|
||||
minTwoWayCatenary: number;
|
||||
minTwoWay: number;
|
||||
'no-1track': boolean;
|
||||
'no-2track': boolean;
|
||||
free: boolean;
|
||||
occupied: boolean;
|
||||
ending: boolean;
|
||||
nonPublic: boolean;
|
||||
}
|
||||
|
||||
@@ -1,61 +1,61 @@
|
||||
import Train from "./Train";
|
||||
import ScheduledTrain from "./ScheduledTrain";
|
||||
|
||||
export default interface Station {
|
||||
stationName: string;
|
||||
stationHash: string;
|
||||
stationURL: string;
|
||||
|
||||
maxUsers: number;
|
||||
currentUsers: number;
|
||||
|
||||
spawns: { spawnName: string; spawnLength: number }[];
|
||||
|
||||
dispatcherRate: number;
|
||||
dispatcherName: string;
|
||||
dispatcherExp: number;
|
||||
dispatcherId: number;
|
||||
dispatcherIsSupporter: boolean;
|
||||
|
||||
stationLines: string;
|
||||
stationProject: string;
|
||||
|
||||
reqLevel: string;
|
||||
supportersOnly: boolean;
|
||||
|
||||
SBL: string;
|
||||
TWB: string;
|
||||
signalType: string;
|
||||
controlType: string;
|
||||
|
||||
default: boolean;
|
||||
nonPublic: boolean;
|
||||
unavailable: boolean;
|
||||
|
||||
routes: {
|
||||
oneWay: { catenary: number; noCatenary: number };
|
||||
twoWay: { catenary: number; noCatenary: number };
|
||||
};
|
||||
|
||||
checkpoints:
|
||||
| {
|
||||
checkpointName: string;
|
||||
scheduledTrains: ScheduledTrain[];
|
||||
}[]
|
||||
| null;
|
||||
|
||||
stops: string[] | null;
|
||||
|
||||
online: boolean;
|
||||
statusTimestamp: number;
|
||||
statusTimeString: string;
|
||||
statusID: string;
|
||||
|
||||
stationTrains: {
|
||||
driverName: number;
|
||||
trainNo: number;
|
||||
stopStatus?: string;
|
||||
}[];
|
||||
|
||||
scheduledTrains: ScheduledTrain[];
|
||||
}
|
||||
import Train from "./Train";
|
||||
import ScheduledTrain from "./ScheduledTrain";
|
||||
|
||||
export default interface Station {
|
||||
stationName: string;
|
||||
stationHash: string;
|
||||
stationURL: string;
|
||||
|
||||
maxUsers: number;
|
||||
currentUsers: number;
|
||||
|
||||
spawns: { spawnName: string; spawnLength: number }[];
|
||||
|
||||
dispatcherRate: number;
|
||||
dispatcherName: string;
|
||||
dispatcherExp: number;
|
||||
dispatcherId: number;
|
||||
dispatcherIsSupporter: boolean;
|
||||
|
||||
stationLines: string;
|
||||
stationProject: string;
|
||||
|
||||
reqLevel: string;
|
||||
supportersOnly: boolean;
|
||||
|
||||
SBL: string;
|
||||
TWB: string;
|
||||
signalType: string;
|
||||
controlType: string;
|
||||
|
||||
default: boolean;
|
||||
nonPublic: boolean;
|
||||
unavailable: boolean;
|
||||
|
||||
routes: {
|
||||
oneWay: { catenary: number; noCatenary: number };
|
||||
twoWay: { catenary: number; noCatenary: number };
|
||||
};
|
||||
|
||||
checkpoints:
|
||||
| {
|
||||
checkpointName: string;
|
||||
scheduledTrains: ScheduledTrain[];
|
||||
}[]
|
||||
| null;
|
||||
|
||||
stops: string[] | null;
|
||||
|
||||
online: boolean;
|
||||
statusTimestamp: number;
|
||||
statusTimeString: string;
|
||||
statusID: string;
|
||||
|
||||
stationTrains: {
|
||||
driverName: number;
|
||||
trainNo: number;
|
||||
stopStatus?: string;
|
||||
}[];
|
||||
|
||||
scheduledTrains: ScheduledTrain[];
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { DataStatus } from "../enums/DataStatus";
|
||||
import Station from "./Station";
|
||||
import Train from "./Train";
|
||||
|
||||
export interface StoreData {
|
||||
stationList: Station[];
|
||||
trainList: Train[];
|
||||
|
||||
activeTrainCount: number;
|
||||
activeStationCount: number;
|
||||
|
||||
dataConnectionStatus: DataStatus;
|
||||
timetableDataStatus: DataStatus;
|
||||
}
|
||||
import { DataStatus } from "../enums/DataStatus";
|
||||
import Station from "./Station";
|
||||
import Train from "./Train";
|
||||
|
||||
export interface StoreData {
|
||||
stationList: Station[];
|
||||
trainList: Train[];
|
||||
|
||||
activeTrainCount: number;
|
||||
activeStationCount: number;
|
||||
|
||||
dataConnectionStatus: DataStatus;
|
||||
timetableDataStatus: DataStatus;
|
||||
}
|
||||
|
||||
@@ -1,17 +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[];
|
||||
}
|
||||
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[];
|
||||
}
|
||||
|
||||
@@ -1,18 +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;
|
||||
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;
|
||||
}
|
||||
@@ -1,34 +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;
|
||||
}[];
|
||||
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;
|
||||
}[];
|
||||
}
|
||||
@@ -1,19 +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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1,6 +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`
|
||||
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`
|
||||
};
|
||||
+112
-112
@@ -1,113 +1,113 @@
|
||||
import Station from "../interfaces/Station";
|
||||
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 getStatusID = (stationStatus: any): string => {
|
||||
if (!stationStatus) return "not-signed";
|
||||
|
||||
const statusCode = stationStatus[2];
|
||||
const statusTimestamp = stationStatus[3];
|
||||
|
||||
switch (statusCode) {
|
||||
case 0:
|
||||
if (statusTimestamp - Date.now() > 21000000) return "no-limit";
|
||||
|
||||
return "online";
|
||||
|
||||
case 1:
|
||||
return "brb";
|
||||
|
||||
case 2:
|
||||
if (statusTimestamp == 0) return "ending";
|
||||
break;
|
||||
|
||||
case 3:
|
||||
return "no-space";
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return "unavailable";
|
||||
};
|
||||
|
||||
export const getStatusTimestamp = (stationStatus: any): number => {
|
||||
if (!stationStatus) return -2;
|
||||
|
||||
const statusCode = stationStatus[2];
|
||||
const statusTimestamp = stationStatus[3];
|
||||
|
||||
switch (statusCode) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 3:
|
||||
return statusTimestamp;
|
||||
|
||||
case 2:
|
||||
if (statusTimestamp == 0) return 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
};
|
||||
|
||||
export const parseSpawns = (spawnString: string) => {
|
||||
if (!spawnString) return [];
|
||||
if (spawnString === "NO_SPAWN") return [];
|
||||
|
||||
return spawnString.split(";").map(spawn => {
|
||||
const spawnArray = spawn.split(",");
|
||||
const spawnName = spawnArray[6] ? spawnArray[6] : spawnArray[0];
|
||||
const spawnLength = parseInt(spawnArray[2]);
|
||||
|
||||
return { spawnName, spawnLength };
|
||||
});
|
||||
};
|
||||
|
||||
export const getTimestamp = (date: string | null): number => (date ? new Date(date).getTime() : 0);
|
||||
|
||||
export const timestampToString = (timestamp: number | null): string =>
|
||||
timestamp
|
||||
? new Date(timestamp).toLocaleTimeString("pl-PL", {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit"
|
||||
})
|
||||
: "";
|
||||
|
||||
export const getTrainStopStatus = (stopInfo: TrainStop, timetableData: { currentStationName: string }, station: Station) => {
|
||||
let stopStatus = "",
|
||||
stopLabel = "",
|
||||
stopStatusID = -1;
|
||||
|
||||
if (stopInfo.terminatesHere && stopInfo.confirmed) {
|
||||
stopStatus = "terminated";
|
||||
stopLabel = "Skończył bieg";
|
||||
stopStatusID = 5;
|
||||
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && timetableData.currentStationName == station.stationName) {
|
||||
stopStatus = "departed";
|
||||
stopLabel = "Odprawiony";
|
||||
stopStatusID = 2;
|
||||
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && timetableData.currentStationName != station.stationName) {
|
||||
stopStatus = "departed-away";
|
||||
stopLabel = "Odjechał";
|
||||
stopStatusID = 4;
|
||||
} else if (timetableData.currentStationName == station.stationName && !stopInfo.stopped) {
|
||||
stopStatus = "online";
|
||||
stopLabel = "Na stacji";
|
||||
stopStatusID = 0;
|
||||
} else if (timetableData.currentStationName == station.stationName && stopInfo.stopped) {
|
||||
stopStatus = "stopped";
|
||||
stopLabel = "Postój";
|
||||
stopStatusID = 1;
|
||||
} else if (timetableData.currentStationName != station.stationName) {
|
||||
stopStatus = "arriving";
|
||||
stopLabel = "W drodze";
|
||||
stopStatusID = 3;
|
||||
}
|
||||
|
||||
return { stopStatus, stopLabel, stopStatusID };
|
||||
import Station from "../interfaces/Station";
|
||||
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 getStatusID = (stationStatus: any): string => {
|
||||
if (!stationStatus) return "not-signed";
|
||||
|
||||
const statusCode = stationStatus[2];
|
||||
const statusTimestamp = stationStatus[3];
|
||||
|
||||
switch (statusCode) {
|
||||
case 0:
|
||||
if (statusTimestamp - Date.now() > 21000000) return "no-limit";
|
||||
|
||||
return "online";
|
||||
|
||||
case 1:
|
||||
return "brb";
|
||||
|
||||
case 2:
|
||||
if (statusTimestamp == 0) return "ending";
|
||||
break;
|
||||
|
||||
case 3:
|
||||
return "no-space";
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return "unavailable";
|
||||
};
|
||||
|
||||
export const getStatusTimestamp = (stationStatus: any): number => {
|
||||
if (!stationStatus) return -2;
|
||||
|
||||
const statusCode = stationStatus[2];
|
||||
const statusTimestamp = stationStatus[3];
|
||||
|
||||
switch (statusCode) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 3:
|
||||
return statusTimestamp;
|
||||
|
||||
case 2:
|
||||
if (statusTimestamp == 0) return 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
};
|
||||
|
||||
export const parseSpawns = (spawnString: string) => {
|
||||
if (!spawnString) return [];
|
||||
if (spawnString === "NO_SPAWN") return [];
|
||||
|
||||
return spawnString.split(";").map(spawn => {
|
||||
const spawnArray = spawn.split(",");
|
||||
const spawnName = spawnArray[6] ? spawnArray[6] : spawnArray[0];
|
||||
const spawnLength = parseInt(spawnArray[2]);
|
||||
|
||||
return { spawnName, spawnLength };
|
||||
});
|
||||
};
|
||||
|
||||
export const getTimestamp = (date: string | null): number => (date ? new Date(date).getTime() : 0);
|
||||
|
||||
export const timestampToString = (timestamp: number | null): string =>
|
||||
timestamp
|
||||
? new Date(timestamp).toLocaleTimeString("pl-PL", {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit"
|
||||
})
|
||||
: "";
|
||||
|
||||
export const getTrainStopStatus = (stopInfo: TrainStop, timetableData: { currentStationName: string }, station: Station) => {
|
||||
let stopStatus = "",
|
||||
stopLabel = "",
|
||||
stopStatusID = -1;
|
||||
|
||||
if (stopInfo.terminatesHere && stopInfo.confirmed) {
|
||||
stopStatus = "terminated";
|
||||
stopLabel = "Skończył bieg";
|
||||
stopStatusID = 5;
|
||||
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && timetableData.currentStationName == station.stationName) {
|
||||
stopStatus = "departed";
|
||||
stopLabel = "Odprawiony";
|
||||
stopStatusID = 2;
|
||||
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && timetableData.currentStationName != station.stationName) {
|
||||
stopStatus = "departed-away";
|
||||
stopLabel = "Odjechał";
|
||||
stopStatusID = 4;
|
||||
} else if (timetableData.currentStationName == station.stationName && !stopInfo.stopped) {
|
||||
stopStatus = "online";
|
||||
stopLabel = "Na stacji";
|
||||
stopStatusID = 0;
|
||||
} else if (timetableData.currentStationName == station.stationName && stopInfo.stopped) {
|
||||
stopStatus = "stopped";
|
||||
stopLabel = "Postój";
|
||||
stopStatusID = 1;
|
||||
} else if (timetableData.currentStationName != station.stationName) {
|
||||
stopStatus = "arriving";
|
||||
stopLabel = "W drodze";
|
||||
stopStatusID = 3;
|
||||
}
|
||||
|
||||
return { stopStatus, stopLabel, stopStatusID };
|
||||
};
|
||||
Reference in New Issue
Block a user