mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
format & lint
This commit is contained in:
@@ -1,49 +1,49 @@
|
||||
import Filter from "../../interfaces/Filter";
|
||||
|
||||
export const filterInitStates: Filter = {
|
||||
default: false,
|
||||
notDefault: false,
|
||||
real: false,
|
||||
fictional: false,
|
||||
SPK: false,
|
||||
SCS: false,
|
||||
SPE: false,
|
||||
SUP: false,
|
||||
noSUP: false,
|
||||
ręczne: false,
|
||||
'ręczne+SPK': false,
|
||||
'ręczne+SCS': false,
|
||||
mechaniczne: false,
|
||||
'mechaniczne+SPK': false,
|
||||
'mechaniczne+SCS': false,
|
||||
współczesna: false,
|
||||
kształtowa: false,
|
||||
historyczna: false,
|
||||
mieszana: false,
|
||||
SBL: false,
|
||||
PBL: false,
|
||||
minLevel: 0,
|
||||
maxLevel: 20,
|
||||
minOneWayCatenary: 0,
|
||||
minOneWay: 0,
|
||||
minTwoWayCatenary: 0,
|
||||
minTwoWay: 0,
|
||||
'include-selected': false,
|
||||
'no-1track': false,
|
||||
'no-2track': false,
|
||||
free: true,
|
||||
occupied: false,
|
||||
ending: false,
|
||||
nonPublic: false,
|
||||
unavailable: true,
|
||||
abandoned: true,
|
||||
afkStatus: false,
|
||||
endingStatus: false,
|
||||
noSpaceStatus: false,
|
||||
unavailableStatus: false,
|
||||
unsignedStatus: false,
|
||||
|
||||
authors: '',
|
||||
|
||||
onlineFromHours: 0,
|
||||
};
|
||||
import Filter from '../../interfaces/Filter';
|
||||
|
||||
export const filterInitStates: Filter = {
|
||||
default: false,
|
||||
notDefault: false,
|
||||
real: false,
|
||||
fictional: false,
|
||||
SPK: false,
|
||||
SCS: false,
|
||||
SPE: false,
|
||||
SUP: false,
|
||||
noSUP: false,
|
||||
ręczne: false,
|
||||
'ręczne+SPK': false,
|
||||
'ręczne+SCS': false,
|
||||
mechaniczne: false,
|
||||
'mechaniczne+SPK': false,
|
||||
'mechaniczne+SCS': false,
|
||||
współczesna: false,
|
||||
kształtowa: false,
|
||||
historyczna: false,
|
||||
mieszana: false,
|
||||
SBL: false,
|
||||
PBL: false,
|
||||
minLevel: 0,
|
||||
maxLevel: 20,
|
||||
minOneWayCatenary: 0,
|
||||
minOneWay: 0,
|
||||
minTwoWayCatenary: 0,
|
||||
minTwoWay: 0,
|
||||
'include-selected': false,
|
||||
'no-1track': false,
|
||||
'no-2track': false,
|
||||
free: true,
|
||||
occupied: false,
|
||||
ending: false,
|
||||
nonPublic: false,
|
||||
unavailable: true,
|
||||
abandoned: true,
|
||||
afkStatus: false,
|
||||
endingStatus: false,
|
||||
noSpaceStatus: false,
|
||||
unavailableStatus: false,
|
||||
unsignedStatus: false,
|
||||
|
||||
authors: '',
|
||||
|
||||
onlineFromHours: 0
|
||||
};
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
export const headIds = ['station', 'min-lvl', 'status', 'dispatcher', 'dispatcher-lvl', 'routes', 'general'] as const;
|
||||
export const headIds = [
|
||||
'station',
|
||||
'min-lvl',
|
||||
'status',
|
||||
'dispatcher',
|
||||
'dispatcher-lvl',
|
||||
'routes',
|
||||
'general'
|
||||
] as const;
|
||||
|
||||
export const headIconsIds = ['user', 'spawn', 'timetableAll', 'timetableUnconfirmed', 'timetableConfirmed'] as const;
|
||||
export const headIconsIds = [
|
||||
'user',
|
||||
'spawn',
|
||||
'timetableAll',
|
||||
'timetableUnconfirmed',
|
||||
'timetableConfirmed'
|
||||
] as const;
|
||||
|
||||
export type HeadIdsTypes = typeof headIds[number] | typeof headIconsIds[number];
|
||||
export type HeadIdsTypes = (typeof headIds)[number] | (typeof headIconsIds)[number];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export enum DataStatus {
|
||||
Initialized = -1,
|
||||
Loading = 0,
|
||||
Error = 1,
|
||||
Loaded = 2,
|
||||
Warning = 3
|
||||
}
|
||||
export enum DataStatus {
|
||||
Initialized = -1,
|
||||
Loading = 0,
|
||||
Error = 1,
|
||||
Loaded = 2,
|
||||
Warning = 3
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
export const enum JournalFilterType {
|
||||
ACTIVE = 'active',
|
||||
FULFILLED = 'fulfilled',
|
||||
ABANDONED = 'abandoned',
|
||||
ALL = 'all',
|
||||
TWR = 'twr',
|
||||
SKR = 'skr',
|
||||
TWR_SKR = 'twr-skr',
|
||||
}
|
||||
|
||||
export enum JournalFilterSection {
|
||||
TIMETABLE_STATUS = 'timetable-status',
|
||||
TWRSKR = 'twrskr',
|
||||
}
|
||||
export const enum JournalFilterType {
|
||||
ACTIVE = 'active',
|
||||
FULFILLED = 'fulfilled',
|
||||
ABANDONED = 'abandoned',
|
||||
ALL = 'all',
|
||||
TWR = 'twr',
|
||||
SKR = 'skr',
|
||||
TWR_SKR = 'twr-skr'
|
||||
}
|
||||
|
||||
export enum JournalFilterSection {
|
||||
TIMETABLE_STATUS = 'timetable-status',
|
||||
TWRSKR = 'twrskr'
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ export enum TrainFilterSection {
|
||||
TRAIN_TYPE = 'TRAIN_TYPE',
|
||||
TIMETABLE_TYPE = 'TIMETABLE_TYPE',
|
||||
COMMENTS = 'COMMENTS',
|
||||
TIMETABLE = 'TIMETABLE',
|
||||
TIMETABLE = 'TIMETABLE'
|
||||
}
|
||||
|
||||
export const enum TrainFilterType {
|
||||
@@ -17,5 +17,5 @@ export const enum TrainFilterType {
|
||||
freight = 'freight',
|
||||
other = 'other',
|
||||
noTimetable = 'noTimetable',
|
||||
withTimetable = 'withTimetable',
|
||||
withTimetable = 'withTimetable'
|
||||
}
|
||||
|
||||
@@ -1,48 +1,48 @@
|
||||
export default interface Filter {
|
||||
[key: string]: boolean | number | string;
|
||||
default: boolean;
|
||||
notDefault: boolean;
|
||||
real: boolean;
|
||||
fictional: boolean;
|
||||
SPK: boolean;
|
||||
SCS: boolean;
|
||||
SPE: boolean;
|
||||
SUP: boolean;
|
||||
noSUP: boolean;
|
||||
ręczne: boolean;
|
||||
'ręczne+SPK': boolean;
|
||||
'ręczne+SCS': boolean;
|
||||
mechaniczne: boolean;
|
||||
'mechaniczne+SPK': boolean;
|
||||
'mechaniczne+SCS': boolean;
|
||||
SBL: boolean;
|
||||
PBL: 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;
|
||||
'include-selected': boolean;
|
||||
free: boolean;
|
||||
occupied: boolean;
|
||||
nonPublic: boolean;
|
||||
unavailable: boolean;
|
||||
abandoned: boolean;
|
||||
|
||||
endingStatus: boolean;
|
||||
afkStatus: boolean;
|
||||
noSpaceStatus: boolean;
|
||||
unavailableStatus: boolean;
|
||||
unsignedStatus: boolean;
|
||||
|
||||
authors: string;
|
||||
|
||||
onlineFromHours: number;
|
||||
}
|
||||
export default interface Filter {
|
||||
[key: string]: boolean | number | string;
|
||||
default: boolean;
|
||||
notDefault: boolean;
|
||||
real: boolean;
|
||||
fictional: boolean;
|
||||
SPK: boolean;
|
||||
SCS: boolean;
|
||||
SPE: boolean;
|
||||
SUP: boolean;
|
||||
noSUP: boolean;
|
||||
ręczne: boolean;
|
||||
'ręczne+SPK': boolean;
|
||||
'ręczne+SCS': boolean;
|
||||
mechaniczne: boolean;
|
||||
'mechaniczne+SPK': boolean;
|
||||
'mechaniczne+SCS': boolean;
|
||||
SBL: boolean;
|
||||
PBL: 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;
|
||||
'include-selected': boolean;
|
||||
free: boolean;
|
||||
occupied: boolean;
|
||||
nonPublic: boolean;
|
||||
unavailable: boolean;
|
||||
abandoned: boolean;
|
||||
|
||||
endingStatus: boolean;
|
||||
afkStatus: boolean;
|
||||
noSpaceStatus: boolean;
|
||||
unavailableStatus: boolean;
|
||||
unsignedStatus: boolean;
|
||||
|
||||
authors: string;
|
||||
|
||||
onlineFromHours: number;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export default interface FilterOption {
|
||||
id: string;
|
||||
name: string;
|
||||
value: boolean;
|
||||
defaultValue: boolean;
|
||||
}
|
||||
id: string;
|
||||
name: string;
|
||||
value: boolean;
|
||||
defaultValue: boolean;
|
||||
}
|
||||
|
||||
@@ -1,33 +1,38 @@
|
||||
interface Scenery {
|
||||
stationName: string;
|
||||
stationURL: string;
|
||||
stationLines: string;
|
||||
stationProject: string;
|
||||
|
||||
reqLevel: string;
|
||||
supportersOnly: string;
|
||||
signalType: string;
|
||||
controlType: string;
|
||||
SBL: string;
|
||||
twoWayBlock: string;
|
||||
|
||||
routesOneWayCatenary: number;
|
||||
routesOneWayOther: number;
|
||||
routesTwoWayCatenary: number;
|
||||
routesToWayOther: number;
|
||||
|
||||
default: boolean;
|
||||
nonPublic: boolean;
|
||||
unavailable: boolean;
|
||||
hasData: boolean;
|
||||
|
||||
stops: string[];
|
||||
checkpoints: string[];
|
||||
|
||||
currentDispatcher: string;
|
||||
currentDispatcherId: number;
|
||||
currentDispatcherFrom: number;
|
||||
dispatcherHistory: { dispatcherName: string; dispatcherId: number; dispatcherFrom: number; dispatcherTo: number }[];
|
||||
}
|
||||
|
||||
export default Scenery;
|
||||
interface Scenery {
|
||||
stationName: string;
|
||||
stationURL: string;
|
||||
stationLines: string;
|
||||
stationProject: string;
|
||||
|
||||
reqLevel: string;
|
||||
supportersOnly: string;
|
||||
signalType: string;
|
||||
controlType: string;
|
||||
SBL: string;
|
||||
twoWayBlock: string;
|
||||
|
||||
routesOneWayCatenary: number;
|
||||
routesOneWayOther: number;
|
||||
routesTwoWayCatenary: number;
|
||||
routesToWayOther: number;
|
||||
|
||||
default: boolean;
|
||||
nonPublic: boolean;
|
||||
unavailable: boolean;
|
||||
hasData: boolean;
|
||||
|
||||
stops: string[];
|
||||
checkpoints: string[];
|
||||
|
||||
currentDispatcher: string;
|
||||
currentDispatcherId: number;
|
||||
currentDispatcherFrom: number;
|
||||
dispatcherHistory: {
|
||||
dispatcherName: string;
|
||||
dispatcherId: number;
|
||||
dispatcherFrom: number;
|
||||
dispatcherTo: number;
|
||||
}[];
|
||||
}
|
||||
|
||||
export default Scenery;
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
import TrainStop from './TrainStop';
|
||||
|
||||
export enum StopStatus {
|
||||
'arriving' = 'arriving',
|
||||
'departed' = 'departed',
|
||||
'departed-away' = 'departed-away',
|
||||
'online' = 'online',
|
||||
'stopped' = 'stopped',
|
||||
'terminated' = 'terminated',
|
||||
}
|
||||
|
||||
export interface ScheduledTrain {
|
||||
trainId: string;
|
||||
trainNo: number;
|
||||
|
||||
driverName: string;
|
||||
driverId: number;
|
||||
currentStationName: string;
|
||||
currentStationHash: string;
|
||||
category: string;
|
||||
stopInfo: TrainStop;
|
||||
|
||||
terminatesAt: string;
|
||||
beginsAt: string;
|
||||
|
||||
prevStationName: string;
|
||||
nextStationName: string;
|
||||
|
||||
arrivingLine: string | null;
|
||||
departureLine: string | null;
|
||||
|
||||
prevDepartureLine: string | null;
|
||||
nextArrivalLine: string | null;
|
||||
|
||||
signal: string;
|
||||
connectedTrack: string;
|
||||
|
||||
stopLabel: string;
|
||||
stopStatus: StopStatus;
|
||||
stopStatusID: number;
|
||||
}
|
||||
import TrainStop from './TrainStop';
|
||||
|
||||
export enum StopStatus {
|
||||
'arriving' = 'arriving',
|
||||
'departed' = 'departed',
|
||||
'departed-away' = 'departed-away',
|
||||
'online' = 'online',
|
||||
'stopped' = 'stopped',
|
||||
'terminated' = 'terminated'
|
||||
}
|
||||
|
||||
export interface ScheduledTrain {
|
||||
trainId: string;
|
||||
trainNo: number;
|
||||
|
||||
driverName: string;
|
||||
driverId: number;
|
||||
currentStationName: string;
|
||||
currentStationHash: string;
|
||||
category: string;
|
||||
stopInfo: TrainStop;
|
||||
|
||||
terminatesAt: string;
|
||||
beginsAt: string;
|
||||
|
||||
prevStationName: string;
|
||||
nextStationName: string;
|
||||
|
||||
arrivingLine: string | null;
|
||||
departureLine: string | null;
|
||||
|
||||
prevDepartureLine: string | null;
|
||||
nextArrivalLine: string | null;
|
||||
|
||||
signal: string;
|
||||
connectedTrack: string;
|
||||
|
||||
stopLabel: string;
|
||||
stopStatus: StopStatus;
|
||||
stopStatusID: number;
|
||||
}
|
||||
|
||||
@@ -1,65 +1,64 @@
|
||||
import { Availability } from './store/storeTypes';
|
||||
import {ScheduledTrain} from './ScheduledTrain';
|
||||
import StationRoutes from './StationRoutes';
|
||||
|
||||
export default interface Station {
|
||||
name: string;
|
||||
|
||||
generalInfo?: {
|
||||
name: string;
|
||||
url: string;
|
||||
abbr: string;
|
||||
|
||||
reqLevel: number;
|
||||
// supportersOnly: boolean;
|
||||
|
||||
|
||||
lines: string;
|
||||
project: string;
|
||||
projectUrl?: string;
|
||||
|
||||
signalType: string;
|
||||
controlType: string;
|
||||
|
||||
SUP: boolean;
|
||||
authors?: string[];
|
||||
|
||||
availability: Availability;
|
||||
routes: StationRoutes;
|
||||
|
||||
checkpoints: {
|
||||
checkpointName: string;
|
||||
scheduledTrains: ScheduledTrain[];
|
||||
}[];
|
||||
};
|
||||
|
||||
onlineInfo?: {
|
||||
hash: string;
|
||||
name: string;
|
||||
region: string;
|
||||
|
||||
maxUsers: number;
|
||||
currentUsers: number;
|
||||
|
||||
spawns: { spawnName: string; spawnLength: number; isElectrified: boolean }[];
|
||||
dispatcherRate: number;
|
||||
dispatcherName: string;
|
||||
dispatcherExp: number;
|
||||
dispatcherId: number;
|
||||
dispatcherIsSupporter: boolean;
|
||||
|
||||
statusTimestamp: number;
|
||||
// statusTimeString: string;
|
||||
statusID: string;
|
||||
|
||||
stationTrains?: {
|
||||
driverName: string;
|
||||
driverId: number;
|
||||
trainNo: number;
|
||||
trainId: string;
|
||||
stopStatus?: string;
|
||||
}[];
|
||||
|
||||
scheduledTrains?: ScheduledTrain[];
|
||||
};
|
||||
}
|
||||
import { Availability } from './store/storeTypes';
|
||||
import { ScheduledTrain } from './ScheduledTrain';
|
||||
import StationRoutes from './StationRoutes';
|
||||
|
||||
export default interface Station {
|
||||
name: string;
|
||||
|
||||
generalInfo?: {
|
||||
name: string;
|
||||
url: string;
|
||||
abbr: string;
|
||||
|
||||
reqLevel: number;
|
||||
// supportersOnly: boolean;
|
||||
|
||||
lines: string;
|
||||
project: string;
|
||||
projectUrl?: string;
|
||||
|
||||
signalType: string;
|
||||
controlType: string;
|
||||
|
||||
SUP: boolean;
|
||||
authors?: string[];
|
||||
|
||||
availability: Availability;
|
||||
routes: StationRoutes;
|
||||
|
||||
checkpoints: {
|
||||
checkpointName: string;
|
||||
scheduledTrains: ScheduledTrain[];
|
||||
}[];
|
||||
};
|
||||
|
||||
onlineInfo?: {
|
||||
hash: string;
|
||||
name: string;
|
||||
region: string;
|
||||
|
||||
maxUsers: number;
|
||||
currentUsers: number;
|
||||
|
||||
spawns: { spawnName: string; spawnLength: number; isElectrified: boolean }[];
|
||||
dispatcherRate: number;
|
||||
dispatcherName: string;
|
||||
dispatcherExp: number;
|
||||
dispatcherId: number;
|
||||
dispatcherIsSupporter: boolean;
|
||||
|
||||
statusTimestamp: number;
|
||||
// statusTimeString: string;
|
||||
statusID: string;
|
||||
|
||||
stationTrains?: {
|
||||
driverName: string;
|
||||
driverId: number;
|
||||
trainNo: number;
|
||||
trainId: string;
|
||||
stopStatus?: string;
|
||||
}[];
|
||||
|
||||
scheduledTrains?: ScheduledTrain[];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
export default interface StationRoutes {
|
||||
oneWay: {
|
||||
name: string;
|
||||
catenary: boolean;
|
||||
SBL: boolean;
|
||||
TWB: boolean;
|
||||
isInternal: boolean;
|
||||
tracks: number;
|
||||
speed: number;
|
||||
length: number;
|
||||
}[];
|
||||
|
||||
twoWay: {
|
||||
name: string;
|
||||
catenary: boolean;
|
||||
SBL: boolean;
|
||||
TWB: boolean;
|
||||
isInternal: boolean;
|
||||
tracks: number;
|
||||
speed: number;
|
||||
length: number;
|
||||
}[];
|
||||
|
||||
/* [catenary, noCatenary] */
|
||||
oneWayCatenaryRouteNames: string[];
|
||||
oneWayNoCatenaryRouteNames: string[];
|
||||
twoWayCatenaryRouteNames: string[];
|
||||
twoWayNoCatenaryRouteNames: string[];
|
||||
sblRouteNames: string[];
|
||||
}
|
||||
export default interface StationRoutes {
|
||||
oneWay: {
|
||||
name: string;
|
||||
catenary: boolean;
|
||||
SBL: boolean;
|
||||
TWB: boolean;
|
||||
isInternal: boolean;
|
||||
tracks: number;
|
||||
speed: number;
|
||||
length: number;
|
||||
}[];
|
||||
|
||||
twoWay: {
|
||||
name: string;
|
||||
catenary: boolean;
|
||||
SBL: boolean;
|
||||
TWB: boolean;
|
||||
isInternal: boolean;
|
||||
tracks: number;
|
||||
speed: number;
|
||||
length: number;
|
||||
}[];
|
||||
|
||||
/* [catenary, noCatenary] */
|
||||
oneWayCatenaryRouteNames: string[];
|
||||
oneWayNoCatenaryRouteNames: string[];
|
||||
twoWayCatenaryRouteNames: string[];
|
||||
twoWayNoCatenaryRouteNames: string[];
|
||||
sblRouteNames: string[];
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { DataStatus } from '../enums/DataStatus';
|
||||
import Station from './Station';
|
||||
import Train from './Train';
|
||||
|
||||
export interface StoreData {
|
||||
stationList: Station[];
|
||||
trainList: Train[];
|
||||
dispatcherCount: number;
|
||||
|
||||
sceneryDataStatus: DataStatus;
|
||||
dispatcherDataStatus: DataStatus;
|
||||
trainsDataStatus: DataStatus;
|
||||
}
|
||||
import { DataStatus } from '../enums/DataStatus';
|
||||
import Station from './Station';
|
||||
import Train from './Train';
|
||||
|
||||
export interface StoreData {
|
||||
stationList: Station[];
|
||||
trainList: Train[];
|
||||
dispatcherCount: number;
|
||||
|
||||
sceneryDataStatus: DataStatus;
|
||||
dispatcherDataStatus: DataStatus;
|
||||
trainsDataStatus: DataStatus;
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
import TrainStop from "./TrainStop";
|
||||
|
||||
export default interface Timetable {
|
||||
trainNo: number;
|
||||
|
||||
success: boolean;
|
||||
|
||||
data?: {
|
||||
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;
|
||||
|
||||
success: boolean;
|
||||
|
||||
data?: {
|
||||
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,37 +1,37 @@
|
||||
import TrainStop from './TrainStop';
|
||||
|
||||
export default interface Train {
|
||||
trainId: string;
|
||||
|
||||
mass: number;
|
||||
length: number;
|
||||
speed: number;
|
||||
signal: string;
|
||||
distance: number;
|
||||
connectedTrack: string;
|
||||
driverId: number;
|
||||
trainNo: number;
|
||||
driverName: string;
|
||||
driverLevel: number;
|
||||
currentStationName: string;
|
||||
currentStationHash: string;
|
||||
locoType: string;
|
||||
online: boolean;
|
||||
lastSeen: number;
|
||||
region: string;
|
||||
stockList: string[];
|
||||
|
||||
isTimeout: boolean;
|
||||
isSupporter: boolean;
|
||||
|
||||
timetableData?: {
|
||||
timetableId: number;
|
||||
category: string;
|
||||
route: string;
|
||||
followingStops: TrainStop[];
|
||||
TWR: boolean;
|
||||
SKR: boolean;
|
||||
routeDistance: number;
|
||||
sceneries: string[];
|
||||
};
|
||||
}
|
||||
import TrainStop from './TrainStop';
|
||||
|
||||
export default interface Train {
|
||||
trainId: string;
|
||||
|
||||
mass: number;
|
||||
length: number;
|
||||
speed: number;
|
||||
signal: string;
|
||||
distance: number;
|
||||
connectedTrack: string;
|
||||
driverId: number;
|
||||
trainNo: number;
|
||||
driverName: string;
|
||||
driverLevel: number;
|
||||
currentStationName: string;
|
||||
currentStationHash: string;
|
||||
locoType: string;
|
||||
online: boolean;
|
||||
lastSeen: number;
|
||||
region: string;
|
||||
stockList: string[];
|
||||
|
||||
isTimeout: boolean;
|
||||
isSupporter: boolean;
|
||||
|
||||
timetableData?: {
|
||||
timetableId: number;
|
||||
category: string;
|
||||
route: string;
|
||||
followingStops: TrainStop[];
|
||||
TWR: boolean;
|
||||
SKR: boolean;
|
||||
routeDistance: number;
|
||||
sceneries: string[];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
export default interface TrainStop {
|
||||
stopName: string;
|
||||
stopNameRAW: string;
|
||||
stopType: string;
|
||||
stopDistance: number;
|
||||
mainStop: boolean;
|
||||
|
||||
arrivalLine: string | null;
|
||||
// arrivalTimeString: string | null;
|
||||
arrivalTimestamp: number;
|
||||
// arrivalRealTimeString: string | null;
|
||||
arrivalRealTimestamp: number;
|
||||
arrivalDelay: number;
|
||||
|
||||
departureLine: string | null;
|
||||
// departureTimeString: string | null;
|
||||
departureTimestamp: number;
|
||||
// departureRealTimeString: string | null;
|
||||
departureRealTimestamp: number;
|
||||
departureDelay: number;
|
||||
pointId: number;
|
||||
|
||||
comments?: any;
|
||||
|
||||
beginsHere: boolean;
|
||||
terminatesHere: boolean;
|
||||
confirmed: boolean;
|
||||
stopped: boolean;
|
||||
stopTime: number | null;
|
||||
}
|
||||
export default interface TrainStop {
|
||||
stopName: string;
|
||||
stopNameRAW: string;
|
||||
stopType: string;
|
||||
stopDistance: number;
|
||||
mainStop: boolean;
|
||||
|
||||
arrivalLine: string | null;
|
||||
// arrivalTimeString: string | null;
|
||||
arrivalTimestamp: number;
|
||||
// arrivalRealTimeString: string | null;
|
||||
arrivalRealTimestamp: number;
|
||||
arrivalDelay: number;
|
||||
|
||||
departureLine: string | null;
|
||||
// departureTimeString: string | null;
|
||||
departureTimestamp: number;
|
||||
// departureRealTimeString: string | null;
|
||||
departureRealTimestamp: number;
|
||||
departureDelay: number;
|
||||
pointId: number;
|
||||
|
||||
comments?: any;
|
||||
|
||||
beginsHere: boolean;
|
||||
terminatesHere: boolean;
|
||||
confirmed: boolean;
|
||||
stopped: boolean;
|
||||
stopTime: number | null;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { TrainFilterSection, TrainFilterType } from '../../enums/TrainFilterType'
|
||||
|
||||
export interface TrainFilter {
|
||||
id: TrainFilterType;
|
||||
section: TrainFilterSection;
|
||||
isActive: boolean;
|
||||
}
|
||||
import { TrainFilterSection, TrainFilterType } from '../../enums/TrainFilterType';
|
||||
|
||||
export interface TrainFilter {
|
||||
id: TrainFilterType;
|
||||
section: TrainFilterSection;
|
||||
isActive: boolean;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
export interface DispatcherHistory {
|
||||
id: string;
|
||||
|
||||
currentDuration: number;
|
||||
dispatcherId: number;
|
||||
dispatcherName: string;
|
||||
dispatcherLevel: number | null;
|
||||
dispatcherRate: number;
|
||||
dispatcherIsSupporter: boolean;
|
||||
dispatcherStatus?: number;
|
||||
isOnline: boolean;
|
||||
lastOnlineTimestamp: number;
|
||||
region: string;
|
||||
stationHash: string;
|
||||
stationName: string;
|
||||
timestampFrom: number;
|
||||
timestampTo?: number;
|
||||
}
|
||||
export interface DispatcherHistory {
|
||||
id: string;
|
||||
|
||||
currentDuration: number;
|
||||
dispatcherId: number;
|
||||
dispatcherName: string;
|
||||
dispatcherLevel: number | null;
|
||||
dispatcherRate: number;
|
||||
dispatcherIsSupporter: boolean;
|
||||
dispatcherStatus?: number;
|
||||
isOnline: boolean;
|
||||
lastOnlineTimestamp: number;
|
||||
region: string;
|
||||
stationHash: string;
|
||||
stationName: string;
|
||||
timestampFrom: number;
|
||||
timestampTo?: number;
|
||||
}
|
||||
|
||||
@@ -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 | null;
|
||||
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 | null;
|
||||
networkConnectionString: string;
|
||||
isOnline: number;
|
||||
dispatcherRate: number;
|
||||
}
|
||||
|
||||
@@ -49,4 +49,3 @@ export interface ITimetablesDailyStatsResponse {
|
||||
station: string;
|
||||
}[];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,67 +1,67 @@
|
||||
export interface TimetableHistory {
|
||||
id: number;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
|
||||
timetableId: number;
|
||||
trainNo: number;
|
||||
trainCategoryCode: string;
|
||||
|
||||
driverId: number;
|
||||
driverName: string;
|
||||
driverLevel: number | null;
|
||||
driverIsSupporter: boolean;
|
||||
|
||||
route: string;
|
||||
twr: number;
|
||||
skr: number;
|
||||
sceneriesString: string;
|
||||
currentLocation: string[];
|
||||
|
||||
routeDistance: number;
|
||||
currentDistance: number;
|
||||
|
||||
confirmedStopsCount: number;
|
||||
allStopsCount: number;
|
||||
|
||||
beginDate: string;
|
||||
endDate: string;
|
||||
|
||||
scheduledBeginDate: string;
|
||||
scheduledEndDate: string;
|
||||
|
||||
terminated: boolean;
|
||||
fulfilled: boolean;
|
||||
|
||||
authorName?: string;
|
||||
authorId?: number;
|
||||
|
||||
stopsString?: string;
|
||||
|
||||
stockString?: string;
|
||||
stockHistory: string[];
|
||||
|
||||
stockMass?: number;
|
||||
stockLength?: number;
|
||||
maxSpeed?: number;
|
||||
|
||||
hashesString?: string;
|
||||
currentSceneryName?: string;
|
||||
currentSceneryHash?: string;
|
||||
|
||||
routeSceneries?: string;
|
||||
|
||||
checkpointArrivals?: string[];
|
||||
checkpointDepartures?: string[];
|
||||
|
||||
checkpointArrivalsScheduled?: string[];
|
||||
checkpointDeparturesScheduled?: string[];
|
||||
|
||||
checkpointStopTypes?: string[];
|
||||
}
|
||||
|
||||
export interface SceneryTimetableHistory {
|
||||
timetables: TimetableHistory[];
|
||||
// totalCount: number;
|
||||
// sceneryName: string;
|
||||
}
|
||||
export interface TimetableHistory {
|
||||
id: number;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
|
||||
timetableId: number;
|
||||
trainNo: number;
|
||||
trainCategoryCode: string;
|
||||
|
||||
driverId: number;
|
||||
driverName: string;
|
||||
driverLevel: number | null;
|
||||
driverIsSupporter: boolean;
|
||||
|
||||
route: string;
|
||||
twr: number;
|
||||
skr: number;
|
||||
sceneriesString: string;
|
||||
currentLocation: string[];
|
||||
|
||||
routeDistance: number;
|
||||
currentDistance: number;
|
||||
|
||||
confirmedStopsCount: number;
|
||||
allStopsCount: number;
|
||||
|
||||
beginDate: string;
|
||||
endDate: string;
|
||||
|
||||
scheduledBeginDate: string;
|
||||
scheduledEndDate: string;
|
||||
|
||||
terminated: boolean;
|
||||
fulfilled: boolean;
|
||||
|
||||
authorName?: string;
|
||||
authorId?: number;
|
||||
|
||||
stopsString?: string;
|
||||
|
||||
stockString?: string;
|
||||
stockHistory: string[];
|
||||
|
||||
stockMass?: number;
|
||||
stockLength?: number;
|
||||
maxSpeed?: number;
|
||||
|
||||
hashesString?: string;
|
||||
currentSceneryName?: string;
|
||||
currentSceneryHash?: string;
|
||||
|
||||
routeSceneries?: string;
|
||||
|
||||
checkpointArrivals?: string[];
|
||||
checkpointDepartures?: string[];
|
||||
|
||||
checkpointArrivalsScheduled?: string[];
|
||||
checkpointDeparturesScheduled?: string[];
|
||||
|
||||
checkpointStopTypes?: string[];
|
||||
}
|
||||
|
||||
export interface SceneryTimetableHistory {
|
||||
timetables: TimetableHistory[];
|
||||
// totalCount: number;
|
||||
// sceneryName: string;
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
import { JournalTimetableSorter } from '../../types/JournalTimetablesTypes';
|
||||
|
||||
export interface TimetablesQueryParams {
|
||||
driverName?: string;
|
||||
trainNo?: string;
|
||||
timetableId?: string;
|
||||
|
||||
authorName?: string;
|
||||
timestampFrom?: number;
|
||||
timestampTo?: number;
|
||||
issuedFrom?: string;
|
||||
|
||||
countFrom?: number;
|
||||
countLimit?: number;
|
||||
|
||||
fulfilled?: number;
|
||||
terminated?: number;
|
||||
|
||||
twr?: number;
|
||||
skr?: number;
|
||||
|
||||
sortBy?: JournalTimetableSorter['id'];
|
||||
}
|
||||
import { JournalTimetableSorter } from '../../types/JournalTimetablesTypes';
|
||||
|
||||
export interface TimetablesQueryParams {
|
||||
driverName?: string;
|
||||
trainNo?: string;
|
||||
timetableId?: string;
|
||||
|
||||
authorName?: string;
|
||||
timestampFrom?: number;
|
||||
timestampTo?: number;
|
||||
issuedFrom?: string;
|
||||
|
||||
countFrom?: number;
|
||||
countLimit?: number;
|
||||
|
||||
fulfilled?: number;
|
||||
terminated?: number;
|
||||
|
||||
twr?: number;
|
||||
skr?: number;
|
||||
|
||||
sortBy?: JournalTimetableSorter['id'];
|
||||
}
|
||||
|
||||
@@ -1,68 +1,68 @@
|
||||
export interface TimetableStop {
|
||||
stopName: string;
|
||||
stopNameRAW: string;
|
||||
stopType: string;
|
||||
stopDistance: number;
|
||||
pointId: number;
|
||||
|
||||
mainStop: boolean;
|
||||
|
||||
arrivalLine: string;
|
||||
arrivalTimestamp: number;
|
||||
arrivalRealTimestamp: number;
|
||||
arrivalDelay: number;
|
||||
|
||||
departureLine: string;
|
||||
departureTimestamp: number;
|
||||
departureRealTimestamp: number;
|
||||
departureDelay: number;
|
||||
|
||||
comments?: any;
|
||||
|
||||
beginsHere: boolean;
|
||||
terminatesHere: boolean;
|
||||
confirmed: boolean;
|
||||
stopped: boolean;
|
||||
stopTime: number;
|
||||
}
|
||||
|
||||
export interface TrainTimetable {
|
||||
timetableId: number;
|
||||
category: string;
|
||||
route: string;
|
||||
|
||||
stopList: TimetableStop[];
|
||||
|
||||
TWR: boolean;
|
||||
SKR: boolean;
|
||||
sceneries: string[];
|
||||
}
|
||||
|
||||
export interface TrainAPIData {
|
||||
trainNo: number;
|
||||
|
||||
mass: number;
|
||||
length: number;
|
||||
speed: number;
|
||||
stockString: string;
|
||||
|
||||
signal: string;
|
||||
distance: number;
|
||||
connectedTrack: string;
|
||||
|
||||
driverName: string;
|
||||
driverId: number;
|
||||
driverIsSupporter: boolean;
|
||||
driverLevel?: number;
|
||||
|
||||
currentStationName: string;
|
||||
currentStationHash: string;
|
||||
|
||||
online: boolean;
|
||||
lastSeen: number;
|
||||
|
||||
region: string;
|
||||
isTimeout: boolean;
|
||||
|
||||
timetable?: TrainTimetable;
|
||||
}
|
||||
export interface TimetableStop {
|
||||
stopName: string;
|
||||
stopNameRAW: string;
|
||||
stopType: string;
|
||||
stopDistance: number;
|
||||
pointId: number;
|
||||
|
||||
mainStop: boolean;
|
||||
|
||||
arrivalLine: string;
|
||||
arrivalTimestamp: number;
|
||||
arrivalRealTimestamp: number;
|
||||
arrivalDelay: number;
|
||||
|
||||
departureLine: string;
|
||||
departureTimestamp: number;
|
||||
departureRealTimestamp: number;
|
||||
departureDelay: number;
|
||||
|
||||
comments?: any;
|
||||
|
||||
beginsHere: boolean;
|
||||
terminatesHere: boolean;
|
||||
confirmed: boolean;
|
||||
stopped: boolean;
|
||||
stopTime: number;
|
||||
}
|
||||
|
||||
export interface TrainTimetable {
|
||||
timetableId: number;
|
||||
category: string;
|
||||
route: string;
|
||||
|
||||
stopList: TimetableStop[];
|
||||
|
||||
TWR: boolean;
|
||||
SKR: boolean;
|
||||
sceneries: string[];
|
||||
}
|
||||
|
||||
export interface TrainAPIData {
|
||||
trainNo: number;
|
||||
|
||||
mass: number;
|
||||
length: number;
|
||||
speed: number;
|
||||
stockString: string;
|
||||
|
||||
signal: string;
|
||||
distance: number;
|
||||
connectedTrack: string;
|
||||
|
||||
driverName: string;
|
||||
driverId: number;
|
||||
driverIsSupporter: boolean;
|
||||
driverLevel?: number;
|
||||
|
||||
currentStationName: string;
|
||||
currentStationHash: string;
|
||||
|
||||
online: boolean;
|
||||
lastSeen: number;
|
||||
|
||||
region: string;
|
||||
isTimeout: boolean;
|
||||
|
||||
timetable?: TrainTimetable;
|
||||
}
|
||||
|
||||
@@ -1,93 +1,93 @@
|
||||
import { Socket } from 'socket.io-client';
|
||||
import { DataStatus } from '../../enums/DataStatus';
|
||||
import StationAPIData from '../api/StationAPIData';
|
||||
import { TrainAPIData } from '../api/TrainAPIData';
|
||||
import Station from '../Station';
|
||||
import Train from '../Train';
|
||||
import { DispatcherStatsAPIData } from '../api/DispatcherStatsAPIData';
|
||||
import { DriverStatsAPIData } from '../api/DriverStatsAPIData';
|
||||
import { RollingStockGithubData } from '../github_api/StockInfoGithubData';
|
||||
|
||||
export type Availability = 'default' | 'unavailable' | 'nonPublic' | 'abandoned' | 'nonDefault';
|
||||
|
||||
export interface StoreState {
|
||||
stationList: Station[];
|
||||
trainList: Train[];
|
||||
apiData: APIData;
|
||||
rollingStockData?: RollingStockGithubData;
|
||||
|
||||
lastDispatcherStatuses: { hash: string; statusTimestamp: number; statusID: string }[];
|
||||
|
||||
sceneryData: any[][];
|
||||
|
||||
region: { id: string; value: string };
|
||||
trainCount: number;
|
||||
stationCount: number;
|
||||
|
||||
webSocket?: Socket;
|
||||
isOffline: boolean;
|
||||
|
||||
dispatcherStatsName: string;
|
||||
dispatcherStatsData?: DispatcherStatsAPIData;
|
||||
|
||||
driverStatsName: string;
|
||||
driverStatsData?: DriverStatsAPIData;
|
||||
driverStatsStatus: DataStatus;
|
||||
|
||||
chosenModalTrainId?: string;
|
||||
|
||||
currentStatsTab: 'daily' | 'driver' | null;
|
||||
|
||||
dataStatuses: {
|
||||
connection: DataStatus;
|
||||
sceneries: DataStatus;
|
||||
timetables: DataStatus;
|
||||
dispatchers: DataStatus;
|
||||
trains: DataStatus;
|
||||
};
|
||||
|
||||
listenerLaunched: boolean;
|
||||
blockScroll: boolean;
|
||||
modalLastClickedTarget: EventTarget | null;
|
||||
}
|
||||
|
||||
export interface APIData {
|
||||
stations?: StationAPIData[];
|
||||
dispatchers?: string[][];
|
||||
trains?: TrainAPIData[];
|
||||
connectedSocketCount: number;
|
||||
}
|
||||
|
||||
export interface StationRoutesInfo {
|
||||
routeName: string;
|
||||
isElectric: boolean;
|
||||
isInternal: boolean;
|
||||
isRouteSBL: boolean;
|
||||
routeLength: number;
|
||||
routeSpeed: number;
|
||||
routeTracks: number;
|
||||
}
|
||||
|
||||
export interface StationJSONData {
|
||||
name: string;
|
||||
abbr: string;
|
||||
url: string;
|
||||
lines: string;
|
||||
project: string;
|
||||
projectUrl: string;
|
||||
|
||||
reqLevel: number;
|
||||
|
||||
signalType: string;
|
||||
controlType: string;
|
||||
|
||||
SUP: boolean;
|
||||
|
||||
// routes: string;
|
||||
routesInfo: StationRoutesInfo[];
|
||||
|
||||
checkpoints: string | null;
|
||||
authors?: string;
|
||||
|
||||
availability: Availability;
|
||||
}
|
||||
import { Socket } from 'socket.io-client';
|
||||
import { DataStatus } from '../../enums/DataStatus';
|
||||
import StationAPIData from '../api/StationAPIData';
|
||||
import { TrainAPIData } from '../api/TrainAPIData';
|
||||
import Station from '../Station';
|
||||
import Train from '../Train';
|
||||
import { DispatcherStatsAPIData } from '../api/DispatcherStatsAPIData';
|
||||
import { DriverStatsAPIData } from '../api/DriverStatsAPIData';
|
||||
import { RollingStockGithubData } from '../github_api/StockInfoGithubData';
|
||||
|
||||
export type Availability = 'default' | 'unavailable' | 'nonPublic' | 'abandoned' | 'nonDefault';
|
||||
|
||||
export interface StoreState {
|
||||
stationList: Station[];
|
||||
trainList: Train[];
|
||||
apiData: APIData;
|
||||
rollingStockData?: RollingStockGithubData;
|
||||
|
||||
lastDispatcherStatuses: { hash: string; statusTimestamp: number; statusID: string }[];
|
||||
|
||||
sceneryData: any[][];
|
||||
|
||||
region: { id: string; value: string };
|
||||
trainCount: number;
|
||||
stationCount: number;
|
||||
|
||||
webSocket?: Socket;
|
||||
isOffline: boolean;
|
||||
|
||||
dispatcherStatsName: string;
|
||||
dispatcherStatsData?: DispatcherStatsAPIData;
|
||||
|
||||
driverStatsName: string;
|
||||
driverStatsData?: DriverStatsAPIData;
|
||||
driverStatsStatus: DataStatus;
|
||||
|
||||
chosenModalTrainId?: string;
|
||||
|
||||
currentStatsTab: 'daily' | 'driver' | null;
|
||||
|
||||
dataStatuses: {
|
||||
connection: DataStatus;
|
||||
sceneries: DataStatus;
|
||||
timetables: DataStatus;
|
||||
dispatchers: DataStatus;
|
||||
trains: DataStatus;
|
||||
};
|
||||
|
||||
listenerLaunched: boolean;
|
||||
blockScroll: boolean;
|
||||
modalLastClickedTarget: EventTarget | null;
|
||||
}
|
||||
|
||||
export interface APIData {
|
||||
stations?: StationAPIData[];
|
||||
dispatchers?: string[][];
|
||||
trains?: TrainAPIData[];
|
||||
connectedSocketCount: number;
|
||||
}
|
||||
|
||||
export interface StationRoutesInfo {
|
||||
routeName: string;
|
||||
isElectric: boolean;
|
||||
isInternal: boolean;
|
||||
isRouteSBL: boolean;
|
||||
routeLength: number;
|
||||
routeSpeed: number;
|
||||
routeTracks: number;
|
||||
}
|
||||
|
||||
export interface StationJSONData {
|
||||
name: string;
|
||||
abbr: string;
|
||||
url: string;
|
||||
lines: string;
|
||||
project: string;
|
||||
projectUrl: string;
|
||||
|
||||
reqLevel: number;
|
||||
|
||||
signalType: string;
|
||||
controlType: string;
|
||||
|
||||
SUP: boolean;
|
||||
|
||||
// routes: string;
|
||||
routesInfo: StationRoutesInfo[];
|
||||
|
||||
checkpoints: string | null;
|
||||
authors?: string;
|
||||
|
||||
availability: Availability;
|
||||
}
|
||||
|
||||
@@ -1,49 +1,49 @@
|
||||
export default class StorageManager {
|
||||
static registerStorage(name: string) {
|
||||
window.localStorage.setItem(name, '1');
|
||||
}
|
||||
|
||||
static unregisterStorage(name: string) {
|
||||
window.localStorage.removeItem(name);
|
||||
}
|
||||
|
||||
static isRegistered(name: string) {
|
||||
return window.localStorage.getItem(name) ? true : false;
|
||||
}
|
||||
|
||||
static setBooleanValue(key: string, val: boolean) {
|
||||
window.localStorage.setItem(key, val.toString());
|
||||
}
|
||||
|
||||
static setNumericValue(key: string, val: number) {
|
||||
window.localStorage.setItem(key, val.toString());
|
||||
}
|
||||
|
||||
static setStringValue(key: string, val: string) {
|
||||
window.localStorage.setItem(key, val);
|
||||
}
|
||||
|
||||
static setValue(key: string, val: any) {
|
||||
if (typeof val == 'boolean') this.setBooleanValue(key, val);
|
||||
else if (typeof val == 'number') this.setNumericValue(key, val);
|
||||
else if (typeof val == 'string') this.setStringValue(key, val);
|
||||
else this.setStringValue(key, val);
|
||||
}
|
||||
|
||||
static removeValue(key: string) {
|
||||
window.localStorage.removeItem(key);
|
||||
}
|
||||
|
||||
static getBooleanValue(key: string): boolean {
|
||||
return window.localStorage.getItem(key) === 'true' ? true : false;
|
||||
}
|
||||
|
||||
static getStringValue(key: string): string {
|
||||
return window.localStorage.getItem(key) || '';
|
||||
}
|
||||
|
||||
static getNumericValue(key: string): number {
|
||||
const itemValue = window.localStorage.getItem(key);
|
||||
return itemValue ? parseInt(itemValue) : 0;
|
||||
}
|
||||
}
|
||||
export default class StorageManager {
|
||||
static registerStorage(name: string) {
|
||||
window.localStorage.setItem(name, '1');
|
||||
}
|
||||
|
||||
static unregisterStorage(name: string) {
|
||||
window.localStorage.removeItem(name);
|
||||
}
|
||||
|
||||
static isRegistered(name: string) {
|
||||
return window.localStorage.getItem(name) ? true : false;
|
||||
}
|
||||
|
||||
static setBooleanValue(key: string, val: boolean) {
|
||||
window.localStorage.setItem(key, val.toString());
|
||||
}
|
||||
|
||||
static setNumericValue(key: string, val: number) {
|
||||
window.localStorage.setItem(key, val.toString());
|
||||
}
|
||||
|
||||
static setStringValue(key: string, val: string) {
|
||||
window.localStorage.setItem(key, val);
|
||||
}
|
||||
|
||||
static setValue(key: string, val: any) {
|
||||
if (typeof val == 'boolean') this.setBooleanValue(key, val);
|
||||
else if (typeof val == 'number') this.setNumericValue(key, val);
|
||||
else if (typeof val == 'string') this.setStringValue(key, val);
|
||||
else this.setStringValue(key, val);
|
||||
}
|
||||
|
||||
static removeValue(key: string) {
|
||||
window.localStorage.removeItem(key);
|
||||
}
|
||||
|
||||
static getBooleanValue(key: string): boolean {
|
||||
return window.localStorage.getItem(key) === 'true' ? true : false;
|
||||
}
|
||||
|
||||
static getStringValue(key: string): string {
|
||||
return window.localStorage.getItem(key) || '';
|
||||
}
|
||||
|
||||
static getNumericValue(key: string): number {
|
||||
const itemValue = window.localStorage.getItem(key);
|
||||
return itemValue ? parseInt(itemValue) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,130 +1,147 @@
|
||||
import { TrainFilter } from '../interfaces/Trains/TrainFilter';
|
||||
import { TrainFilterType } from '../enums/TrainFilterType';
|
||||
import Train from '../interfaces/Train';
|
||||
import TrainStop from '../interfaces/TrainStop';
|
||||
|
||||
function confirmedPercentage(stops: TrainStop[] | undefined) {
|
||||
if (!stops) return -1;
|
||||
|
||||
return Number(((stops.filter((stop) => stop.confirmed).length / stops.length) * 100).toFixed(0));
|
||||
}
|
||||
|
||||
function currentDelay(stops: TrainStop[] | undefined) {
|
||||
if (!stops) return -Infinity;
|
||||
|
||||
const delay =
|
||||
stops.find((stop, i) => (i == 0 && !stop.confirmed) || (i > 0 && stops[i - 1].confirmed && !stop.confirmed))
|
||||
?.departureDelay || 0;
|
||||
|
||||
return delay;
|
||||
}
|
||||
|
||||
function filterTrainList(trainList: Train[], searchedTrain: string, searchedDriver: string, filters: TrainFilter[]) {
|
||||
return trainList.filter((train) => {
|
||||
const isFiltered = filters.every((f) => {
|
||||
if (f.isActive) return true;
|
||||
|
||||
switch (f.id) {
|
||||
case TrainFilterType.noTimetable:
|
||||
return train.timetableData;
|
||||
|
||||
case TrainFilterType.withTimetable:
|
||||
return !train.timetableData;
|
||||
|
||||
case TrainFilterType.withComments:
|
||||
return !train.timetableData?.followingStops.some((stop) => stop.comments);
|
||||
|
||||
case TrainFilterType.noComments:
|
||||
return train.timetableData?.followingStops.some((stop) => stop.comments);
|
||||
|
||||
case TrainFilterType.twr:
|
||||
return !train.timetableData?.TWR;
|
||||
|
||||
case TrainFilterType.skr:
|
||||
return !train.timetableData?.SKR;
|
||||
|
||||
case TrainFilterType.common:
|
||||
return train.timetableData?.SKR || train.timetableData?.TWR;
|
||||
|
||||
case TrainFilterType.passenger:
|
||||
return !/^[AMRE]\D{2}$/.test(train.timetableData?.category || '');
|
||||
|
||||
case TrainFilterType.freight:
|
||||
return !train.timetableData?.category.startsWith('T');
|
||||
|
||||
case TrainFilterType.other:
|
||||
return !/^[PXZL]\D{2}$/.test(train.timetableData?.category || '');
|
||||
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
(searchedTrain.length > 0 ? train.trainNo.toString().startsWith(searchedTrain) : true) &&
|
||||
(searchedDriver.length > 0 ? train.driverName.toLowerCase().startsWith(searchedDriver.toLowerCase()) : true) &&
|
||||
(!train.timetableData ? train.online : train.timetableData) &&
|
||||
isFiltered
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function sortTrainList(trainList: Train[], sorterActive: { id: string; dir: number }) {
|
||||
return trainList.sort((a: Train, b: Train) => {
|
||||
switch (sorterActive.id) {
|
||||
case 'id':
|
||||
if ((a.timetableData?.timetableId || -1) > (b.timetableData?.timetableId || -1)) return sorterActive.dir;
|
||||
|
||||
return -sorterActive.dir;
|
||||
|
||||
case 'mass':
|
||||
if (a.mass > b.mass) return sorterActive.dir;
|
||||
return -sorterActive.dir;
|
||||
|
||||
case 'routeDistance':
|
||||
if ((a.timetableData?.routeDistance || -1) > (b.timetableData?.routeDistance || -1)) return sorterActive.dir;
|
||||
|
||||
return -sorterActive.dir;
|
||||
|
||||
case 'progress':
|
||||
if (confirmedPercentage(a.timetableData?.followingStops) > confirmedPercentage(b.timetableData?.followingStops))
|
||||
return sorterActive.dir;
|
||||
|
||||
return -sorterActive.dir;
|
||||
|
||||
case 'delay':
|
||||
if (currentDelay(a.timetableData?.followingStops) > currentDelay(b.timetableData?.followingStops))
|
||||
return sorterActive.dir;
|
||||
|
||||
return -sorterActive.dir;
|
||||
|
||||
case 'speed':
|
||||
if (a.speed > b.speed) return sorterActive.dir;
|
||||
return -sorterActive.dir;
|
||||
|
||||
case 'timetable':
|
||||
if (a.trainNo > b.trainNo) return sorterActive.dir;
|
||||
return -sorterActive.dir;
|
||||
|
||||
case 'length':
|
||||
if (a.length > b.length) return sorterActive.dir;
|
||||
return -sorterActive.dir;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
export function filteredTrainList(
|
||||
trainList: Train[],
|
||||
searchedTrain: string,
|
||||
searchedDriver: string,
|
||||
sorterActive: { id: string; dir: number },
|
||||
filters: TrainFilter[]
|
||||
) {
|
||||
const filtered = filterTrainList(trainList, searchedTrain, searchedDriver, filters);
|
||||
return [...sortTrainList(filtered, sorterActive)];
|
||||
}
|
||||
import { TrainFilter } from '../interfaces/Trains/TrainFilter';
|
||||
import { TrainFilterType } from '../enums/TrainFilterType';
|
||||
import Train from '../interfaces/Train';
|
||||
import TrainStop from '../interfaces/TrainStop';
|
||||
|
||||
function confirmedPercentage(stops: TrainStop[] | undefined) {
|
||||
if (!stops) return -1;
|
||||
|
||||
return Number(((stops.filter((stop) => stop.confirmed).length / stops.length) * 100).toFixed(0));
|
||||
}
|
||||
|
||||
function currentDelay(stops: TrainStop[] | undefined) {
|
||||
if (!stops) return -Infinity;
|
||||
|
||||
const delay =
|
||||
stops.find(
|
||||
(stop, i) =>
|
||||
(i == 0 && !stop.confirmed) || (i > 0 && stops[i - 1].confirmed && !stop.confirmed)
|
||||
)?.departureDelay || 0;
|
||||
|
||||
return delay;
|
||||
}
|
||||
|
||||
function filterTrainList(
|
||||
trainList: Train[],
|
||||
searchedTrain: string,
|
||||
searchedDriver: string,
|
||||
filters: TrainFilter[]
|
||||
) {
|
||||
return trainList.filter((train) => {
|
||||
const isFiltered = filters.every((f) => {
|
||||
if (f.isActive) return true;
|
||||
|
||||
switch (f.id) {
|
||||
case TrainFilterType.noTimetable:
|
||||
return train.timetableData;
|
||||
|
||||
case TrainFilterType.withTimetable:
|
||||
return !train.timetableData;
|
||||
|
||||
case TrainFilterType.withComments:
|
||||
return !train.timetableData?.followingStops.some((stop) => stop.comments);
|
||||
|
||||
case TrainFilterType.noComments:
|
||||
return train.timetableData?.followingStops.some((stop) => stop.comments);
|
||||
|
||||
case TrainFilterType.twr:
|
||||
return !train.timetableData?.TWR;
|
||||
|
||||
case TrainFilterType.skr:
|
||||
return !train.timetableData?.SKR;
|
||||
|
||||
case TrainFilterType.common:
|
||||
return train.timetableData?.SKR || train.timetableData?.TWR;
|
||||
|
||||
case TrainFilterType.passenger:
|
||||
return !/^[AMRE]\D{2}$/.test(train.timetableData?.category || '');
|
||||
|
||||
case TrainFilterType.freight:
|
||||
return !train.timetableData?.category.startsWith('T');
|
||||
|
||||
case TrainFilterType.other:
|
||||
return !/^[PXZL]\D{2}$/.test(train.timetableData?.category || '');
|
||||
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
(searchedTrain.length > 0 ? train.trainNo.toString().startsWith(searchedTrain) : true) &&
|
||||
(searchedDriver.length > 0
|
||||
? train.driverName.toLowerCase().startsWith(searchedDriver.toLowerCase())
|
||||
: true) &&
|
||||
(!train.timetableData ? train.online : train.timetableData) &&
|
||||
isFiltered
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function sortTrainList(trainList: Train[], sorterActive: { id: string; dir: number }) {
|
||||
return trainList.sort((a: Train, b: Train) => {
|
||||
switch (sorterActive.id) {
|
||||
case 'id':
|
||||
if ((a.timetableData?.timetableId || -1) > (b.timetableData?.timetableId || -1))
|
||||
return sorterActive.dir;
|
||||
|
||||
return -sorterActive.dir;
|
||||
|
||||
case 'mass':
|
||||
if (a.mass > b.mass) return sorterActive.dir;
|
||||
return -sorterActive.dir;
|
||||
|
||||
case 'routeDistance':
|
||||
if ((a.timetableData?.routeDistance || -1) > (b.timetableData?.routeDistance || -1))
|
||||
return sorterActive.dir;
|
||||
|
||||
return -sorterActive.dir;
|
||||
|
||||
case 'progress':
|
||||
if (
|
||||
confirmedPercentage(a.timetableData?.followingStops) >
|
||||
confirmedPercentage(b.timetableData?.followingStops)
|
||||
)
|
||||
return sorterActive.dir;
|
||||
|
||||
return -sorterActive.dir;
|
||||
|
||||
case 'delay':
|
||||
if (
|
||||
currentDelay(a.timetableData?.followingStops) >
|
||||
currentDelay(b.timetableData?.followingStops)
|
||||
)
|
||||
return sorterActive.dir;
|
||||
|
||||
return -sorterActive.dir;
|
||||
|
||||
case 'speed':
|
||||
if (a.speed > b.speed) return sorterActive.dir;
|
||||
return -sorterActive.dir;
|
||||
|
||||
case 'timetable':
|
||||
if (a.trainNo > b.trainNo) return sorterActive.dir;
|
||||
return -sorterActive.dir;
|
||||
|
||||
case 'length':
|
||||
if (a.length > b.length) return sorterActive.dir;
|
||||
return -sorterActive.dir;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
export function filteredTrainList(
|
||||
trainList: Train[],
|
||||
searchedTrain: string,
|
||||
searchedDriver: string,
|
||||
sorterActive: { id: string; dir: number },
|
||||
filters: TrainFilter[]
|
||||
) {
|
||||
const filtered = filterTrainList(trainList, searchedTrain, searchedDriver, filters);
|
||||
return [...sortTrainList(filtered, sorterActive)];
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
export type JournalDispatcherSearcher = {
|
||||
[key in 'search-dispatcher' | 'search-station' | 'search-date']: string;
|
||||
};
|
||||
|
||||
export interface JournalDispatcherSorter {
|
||||
id: 'timestampFrom' | 'duration';
|
||||
dir: -1 | 1;
|
||||
}
|
||||
export type JournalDispatcherSearcher = {
|
||||
[key in 'search-dispatcher' | 'search-station' | 'search-date']: string;
|
||||
};
|
||||
|
||||
export interface JournalDispatcherSorter {
|
||||
id: 'timestampFrom' | 'duration';
|
||||
dir: -1 | 1;
|
||||
}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
import { JournalFilterType } from '../../scripts/enums/JournalFilterType';
|
||||
|
||||
export type JournalTimetableSearchKey =
|
||||
| 'search-driver'
|
||||
| 'search-train'
|
||||
| 'search-date'
|
||||
| 'search-dispatcher'
|
||||
| 'search-issuedFrom';
|
||||
|
||||
export type JournalTimetableSorterKey = 'timetableId' | 'beginDate' | 'distance' | 'total-stops';
|
||||
|
||||
export type JournalTimetableSearchType = {
|
||||
[key in JournalTimetableSearchKey]: string;
|
||||
};
|
||||
|
||||
export interface JournalFilter {
|
||||
id: JournalFilterType;
|
||||
filterSection: string;
|
||||
isActive: boolean;
|
||||
}
|
||||
|
||||
export interface JournalTimetableSorter {
|
||||
id: JournalTimetableSorterKey;
|
||||
dir: 'asc' | 'desc';
|
||||
}
|
||||
import { JournalFilterType } from '../../scripts/enums/JournalFilterType';
|
||||
|
||||
export type JournalTimetableSearchKey =
|
||||
| 'search-driver'
|
||||
| 'search-train'
|
||||
| 'search-date'
|
||||
| 'search-dispatcher'
|
||||
| 'search-issuedFrom';
|
||||
|
||||
export type JournalTimetableSorterKey = 'timetableId' | 'beginDate' | 'distance' | 'total-stops';
|
||||
|
||||
export type JournalTimetableSearchType = {
|
||||
[key in JournalTimetableSearchKey]: string;
|
||||
};
|
||||
|
||||
export interface JournalFilter {
|
||||
id: JournalFilterType;
|
||||
filterSection: string;
|
||||
isActive: boolean;
|
||||
}
|
||||
|
||||
export interface JournalTimetableSorter {
|
||||
id: JournalTimetableSorterKey;
|
||||
dir: 'asc' | 'desc';
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export const URLs = {
|
||||
stacjownikAPI:
|
||||
import.meta.env.VITE_APP_API_DEV === "1" && !import.meta.env.PROD
|
||||
? 'http://localhost:3001'
|
||||
: 'https://stacjownik.spythere.pl',
|
||||
stacjownikAPIDev: 'localhost:3000',
|
||||
};
|
||||
export const URLs = {
|
||||
stacjownikAPI:
|
||||
import.meta.env.VITE_APP_API_DEV === '1' && !import.meta.env.PROD
|
||||
? 'http://localhost:3001'
|
||||
: 'https://stacjownik.spythere.pl',
|
||||
stacjownikAPIDev: 'localhost:3000'
|
||||
};
|
||||
|
||||
+178
-156
@@ -1,156 +1,178 @@
|
||||
import { HeadIdsTypes } from '../data/stationHeaderNames';
|
||||
import Filter from '../interfaces/Filter';
|
||||
import Station from '../interfaces/Station';
|
||||
|
||||
export const sortStations = (a: Station, b: Station, sorter: { headerName: HeadIdsTypes; dir: number }) => {
|
||||
let diff = 0;
|
||||
|
||||
switch (sorter.headerName) {
|
||||
case 'station':
|
||||
return sorter.dir == 1 ? a.name.localeCompare(b.name) : b.name.localeCompare(a.name);
|
||||
|
||||
case 'min-lvl':
|
||||
diff = (a.generalInfo?.reqLevel || 0) - (b.generalInfo?.reqLevel || 0);
|
||||
break;
|
||||
|
||||
case 'status':
|
||||
diff = (a.onlineInfo?.statusTimestamp || 0) - (b.onlineInfo?.statusTimestamp || 0);
|
||||
break;
|
||||
|
||||
case 'dispatcher':
|
||||
if ((a.onlineInfo?.dispatcherName.toLowerCase() || '') > (b.onlineInfo?.dispatcherName.toLowerCase() || ''))
|
||||
return sorter.dir;
|
||||
if ((a.onlineInfo?.dispatcherName.toLowerCase() || '') < (b.onlineInfo?.dispatcherName.toLowerCase() || ''))
|
||||
return -sorter.dir;
|
||||
break;
|
||||
|
||||
case 'dispatcher-lvl':
|
||||
diff = (a.onlineInfo?.dispatcherExp || 0) - (b.onlineInfo?.dispatcherExp || 0);
|
||||
break;
|
||||
|
||||
case 'user':
|
||||
diff = (b.onlineInfo ? b.onlineInfo.currentUsers : -1) - (a.onlineInfo ? a.onlineInfo.currentUsers : -1);
|
||||
break;
|
||||
|
||||
case 'spawn':
|
||||
diff = (a.onlineInfo ? a.onlineInfo.spawns.length : -1) - (b.onlineInfo ? b.onlineInfo.spawns.length : -1);
|
||||
break;
|
||||
|
||||
case 'timetableConfirmed':
|
||||
diff =
|
||||
(a.onlineInfo?.scheduledTrains
|
||||
? a.onlineInfo.scheduledTrains.filter((train) => train.stopInfo.confirmed).length
|
||||
: -1) -
|
||||
(b.onlineInfo?.scheduledTrains
|
||||
? b.onlineInfo.scheduledTrains.filter((train) => train.stopInfo.confirmed).length
|
||||
: -1);
|
||||
break;
|
||||
|
||||
case 'timetableUnconfirmed':
|
||||
diff =
|
||||
(a.onlineInfo?.scheduledTrains
|
||||
? a.onlineInfo.scheduledTrains.filter((train) => !train.stopInfo.confirmed).length
|
||||
: -1) -
|
||||
(b.onlineInfo?.scheduledTrains
|
||||
? b.onlineInfo.scheduledTrains.filter((train) => !train.stopInfo.confirmed).length
|
||||
: -1);
|
||||
break;
|
||||
|
||||
case 'timetableAll':
|
||||
diff =
|
||||
(a.onlineInfo?.scheduledTrains ? a.onlineInfo.scheduledTrains.length : -1) -
|
||||
(b.onlineInfo?.scheduledTrains ? b.onlineInfo.scheduledTrains.length : -1);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (diff != 0) return Math.sign(diff) * sorter.dir;
|
||||
return a.name.localeCompare(b.name);
|
||||
};
|
||||
|
||||
export const filterStations = (station: Station, filters: Filter) => {
|
||||
if (!station.onlineInfo && filters['free']) return false;
|
||||
|
||||
if (station.onlineInfo) {
|
||||
const { statusID, statusTimestamp } = station.onlineInfo;
|
||||
|
||||
const isEnding = statusID == 'ending' && filters['endingStatus'];
|
||||
const isNotSigned = (statusID == 'not-signed' || statusID == 'unavailable') && filters['unavailableStatus'];
|
||||
const isAFK = statusID == 'brb' && filters['afkStatus'];
|
||||
const isNoSpace = statusID == 'no-space' && filters['noSpaceStatus'];
|
||||
const isOccupied = station.onlineInfo && filters['occupied'];
|
||||
|
||||
const isOnlineInBounds =
|
||||
(filters['onlineFromHours'] < 8 &&
|
||||
statusTimestamp > 0 &&
|
||||
statusTimestamp <= Date.now() + filters['onlineFromHours'] * 3600000) ||
|
||||
(filters['onlineFromHours'] > 0 && statusTimestamp <= 0) ||
|
||||
(filters['onlineFromHours'] == 8 && statusID != 'no-limit');
|
||||
|
||||
if (isEnding || isOnlineInBounds || isNotSigned || isAFK || isNoSpace || isOccupied) return false;
|
||||
}
|
||||
|
||||
if ((station.generalInfo?.availability == 'nonPublic' || !station.generalInfo) && filters['nonPublic']) return false;
|
||||
|
||||
if (station.generalInfo) {
|
||||
const { routes, availability, controlType, lines, reqLevel, signalType, SUP, authors } = station.generalInfo;
|
||||
|
||||
if (availability == 'unavailable' && filters['unavailable'] && !station.onlineInfo) return false;
|
||||
if (availability == 'abandoned' && filters['abandoned'] && !station.onlineInfo) return false;
|
||||
if (availability == 'default' && filters['default']) return false;
|
||||
|
||||
if (
|
||||
availability != 'default' &&
|
||||
filters['notDefault'] &&
|
||||
!(availability == 'abandoned' || availability == 'unavailable')
|
||||
)
|
||||
return false;
|
||||
|
||||
if (filters['real'] && lines) return false;
|
||||
if (filters['fictional'] && !lines) return false;
|
||||
|
||||
const otherAvailability =
|
||||
availability == 'nonPublic' || availability == 'unavailable' || availability == 'abandoned';
|
||||
|
||||
if (reqLevel + (otherAvailability ? 1 : 0) < filters['minLevel']) return false;
|
||||
|
||||
if (reqLevel + (otherAvailability ? 1 : 0) > filters['maxLevel']) return false;
|
||||
|
||||
if (
|
||||
filters['no-1track'] &&
|
||||
(routes.oneWayCatenaryRouteNames.length != 0 || routes.oneWayNoCatenaryRouteNames.length != 0)
|
||||
)
|
||||
return false;
|
||||
|
||||
if (
|
||||
filters['no-2track'] &&
|
||||
(routes.twoWayCatenaryRouteNames.length != 0 || routes.twoWayNoCatenaryRouteNames.length != 0)
|
||||
)
|
||||
return false;
|
||||
|
||||
if (routes.oneWayCatenaryRouteNames.length < filters['minOneWayCatenary']) return false;
|
||||
if (routes.oneWayNoCatenaryRouteNames.length < filters['minOneWay']) return false;
|
||||
|
||||
if (routes.twoWayCatenaryRouteNames.length < filters['minTwoWayCatenary']) return false;
|
||||
if (routes.twoWayNoCatenaryRouteNames.length < filters['minTwoWay']) return false;
|
||||
|
||||
if (filters[controlType]) return false;
|
||||
if (filters[signalType]) return false;
|
||||
|
||||
if (filters['SUP'] && SUP) return false;
|
||||
if (filters['noSUP'] && !SUP) return false;
|
||||
|
||||
if (filters['SBL'] && routes.sblRouteNames.length > 0) return false;
|
||||
if (filters['PBL'] && routes.sblRouteNames.length == 0) return false;
|
||||
|
||||
if (
|
||||
filters['authors'].length > 3 &&
|
||||
!authors?.map((a) => a.toLocaleLowerCase()).includes(filters['authors'].toLocaleLowerCase())
|
||||
)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
import { HeadIdsTypes } from '../data/stationHeaderNames';
|
||||
import Filter from '../interfaces/Filter';
|
||||
import Station from '../interfaces/Station';
|
||||
|
||||
export const sortStations = (
|
||||
a: Station,
|
||||
b: Station,
|
||||
sorter: { headerName: HeadIdsTypes; dir: number }
|
||||
) => {
|
||||
let diff = 0;
|
||||
|
||||
switch (sorter.headerName) {
|
||||
case 'station':
|
||||
return sorter.dir == 1 ? a.name.localeCompare(b.name) : b.name.localeCompare(a.name);
|
||||
|
||||
case 'min-lvl':
|
||||
diff = (a.generalInfo?.reqLevel || 0) - (b.generalInfo?.reqLevel || 0);
|
||||
break;
|
||||
|
||||
case 'status':
|
||||
diff = (a.onlineInfo?.statusTimestamp || 0) - (b.onlineInfo?.statusTimestamp || 0);
|
||||
break;
|
||||
|
||||
case 'dispatcher':
|
||||
if (
|
||||
(a.onlineInfo?.dispatcherName.toLowerCase() || '') >
|
||||
(b.onlineInfo?.dispatcherName.toLowerCase() || '')
|
||||
)
|
||||
return sorter.dir;
|
||||
if (
|
||||
(a.onlineInfo?.dispatcherName.toLowerCase() || '') <
|
||||
(b.onlineInfo?.dispatcherName.toLowerCase() || '')
|
||||
)
|
||||
return -sorter.dir;
|
||||
break;
|
||||
|
||||
case 'dispatcher-lvl':
|
||||
diff = (a.onlineInfo?.dispatcherExp || 0) - (b.onlineInfo?.dispatcherExp || 0);
|
||||
break;
|
||||
|
||||
case 'user':
|
||||
diff =
|
||||
(b.onlineInfo ? b.onlineInfo.currentUsers : -1) -
|
||||
(a.onlineInfo ? a.onlineInfo.currentUsers : -1);
|
||||
break;
|
||||
|
||||
case 'spawn':
|
||||
diff =
|
||||
(a.onlineInfo ? a.onlineInfo.spawns.length : -1) -
|
||||
(b.onlineInfo ? b.onlineInfo.spawns.length : -1);
|
||||
break;
|
||||
|
||||
case 'timetableConfirmed':
|
||||
diff =
|
||||
(a.onlineInfo?.scheduledTrains
|
||||
? a.onlineInfo.scheduledTrains.filter((train) => train.stopInfo.confirmed).length
|
||||
: -1) -
|
||||
(b.onlineInfo?.scheduledTrains
|
||||
? b.onlineInfo.scheduledTrains.filter((train) => train.stopInfo.confirmed).length
|
||||
: -1);
|
||||
break;
|
||||
|
||||
case 'timetableUnconfirmed':
|
||||
diff =
|
||||
(a.onlineInfo?.scheduledTrains
|
||||
? a.onlineInfo.scheduledTrains.filter((train) => !train.stopInfo.confirmed).length
|
||||
: -1) -
|
||||
(b.onlineInfo?.scheduledTrains
|
||||
? b.onlineInfo.scheduledTrains.filter((train) => !train.stopInfo.confirmed).length
|
||||
: -1);
|
||||
break;
|
||||
|
||||
case 'timetableAll':
|
||||
diff =
|
||||
(a.onlineInfo?.scheduledTrains ? a.onlineInfo.scheduledTrains.length : -1) -
|
||||
(b.onlineInfo?.scheduledTrains ? b.onlineInfo.scheduledTrains.length : -1);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (diff != 0) return Math.sign(diff) * sorter.dir;
|
||||
return a.name.localeCompare(b.name);
|
||||
};
|
||||
|
||||
export const filterStations = (station: Station, filters: Filter) => {
|
||||
if (!station.onlineInfo && filters['free']) return false;
|
||||
|
||||
if (station.onlineInfo) {
|
||||
const { statusID, statusTimestamp } = station.onlineInfo;
|
||||
|
||||
const isEnding = statusID == 'ending' && filters['endingStatus'];
|
||||
const isNotSigned =
|
||||
(statusID == 'not-signed' || statusID == 'unavailable') && filters['unavailableStatus'];
|
||||
const isAFK = statusID == 'brb' && filters['afkStatus'];
|
||||
const isNoSpace = statusID == 'no-space' && filters['noSpaceStatus'];
|
||||
const isOccupied = station.onlineInfo && filters['occupied'];
|
||||
|
||||
const isOnlineInBounds =
|
||||
(filters['onlineFromHours'] < 8 &&
|
||||
statusTimestamp > 0 &&
|
||||
statusTimestamp <= Date.now() + filters['onlineFromHours'] * 3600000) ||
|
||||
(filters['onlineFromHours'] > 0 && statusTimestamp <= 0) ||
|
||||
(filters['onlineFromHours'] == 8 && statusID != 'no-limit');
|
||||
|
||||
if (isEnding || isOnlineInBounds || isNotSigned || isAFK || isNoSpace || isOccupied)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
(station.generalInfo?.availability == 'nonPublic' || !station.generalInfo) &&
|
||||
filters['nonPublic']
|
||||
)
|
||||
return false;
|
||||
|
||||
if (station.generalInfo) {
|
||||
const { routes, availability, controlType, lines, reqLevel, signalType, SUP, authors } =
|
||||
station.generalInfo;
|
||||
|
||||
if (availability == 'unavailable' && filters['unavailable'] && !station.onlineInfo)
|
||||
return false;
|
||||
if (availability == 'abandoned' && filters['abandoned'] && !station.onlineInfo) return false;
|
||||
if (availability == 'default' && filters['default']) return false;
|
||||
|
||||
if (
|
||||
availability != 'default' &&
|
||||
filters['notDefault'] &&
|
||||
!(availability == 'abandoned' || availability == 'unavailable')
|
||||
)
|
||||
return false;
|
||||
|
||||
if (filters['real'] && lines) return false;
|
||||
if (filters['fictional'] && !lines) return false;
|
||||
|
||||
const otherAvailability =
|
||||
availability == 'nonPublic' || availability == 'unavailable' || availability == 'abandoned';
|
||||
|
||||
if (reqLevel + (otherAvailability ? 1 : 0) < filters['minLevel']) return false;
|
||||
|
||||
if (reqLevel + (otherAvailability ? 1 : 0) > filters['maxLevel']) return false;
|
||||
|
||||
if (
|
||||
filters['no-1track'] &&
|
||||
(routes.oneWayCatenaryRouteNames.length != 0 || routes.oneWayNoCatenaryRouteNames.length != 0)
|
||||
)
|
||||
return false;
|
||||
|
||||
if (
|
||||
filters['no-2track'] &&
|
||||
(routes.twoWayCatenaryRouteNames.length != 0 || routes.twoWayNoCatenaryRouteNames.length != 0)
|
||||
)
|
||||
return false;
|
||||
|
||||
if (routes.oneWayCatenaryRouteNames.length < filters['minOneWayCatenary']) return false;
|
||||
if (routes.oneWayNoCatenaryRouteNames.length < filters['minOneWay']) return false;
|
||||
|
||||
if (routes.twoWayCatenaryRouteNames.length < filters['minTwoWayCatenary']) return false;
|
||||
if (routes.twoWayNoCatenaryRouteNames.length < filters['minTwoWay']) return false;
|
||||
|
||||
if (filters[controlType]) return false;
|
||||
if (filters[signalType]) return false;
|
||||
|
||||
if (filters['SUP'] && SUP) return false;
|
||||
if (filters['noSUP'] && !SUP) return false;
|
||||
|
||||
if (filters['SBL'] && routes.sblRouteNames.length > 0) return false;
|
||||
if (filters['PBL'] && routes.sblRouteNames.length == 0) return false;
|
||||
|
||||
if (
|
||||
filters['authors'].length > 3 &&
|
||||
!authors?.map((a) => a.toLocaleLowerCase()).includes(filters['authors'].toLocaleLowerCase())
|
||||
)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
+208
-197
@@ -1,197 +1,208 @@
|
||||
import { ScheduledTrain, StopStatus } from '../interfaces/ScheduledTrain';
|
||||
import Train from '../interfaces/Train';
|
||||
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 'unknown';
|
||||
if (stationStatus == -1) 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 | null) => {
|
||||
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]);
|
||||
const isElectrified = spawnArray[3] == 'True';
|
||||
|
||||
return { spawnName, spawnLength, isElectrified };
|
||||
});
|
||||
};
|
||||
|
||||
export const getTimestamp = (date: string | null): number => (date ? new Date(date).getTime() : 0);
|
||||
|
||||
export const getTrainStopStatus = (stopInfo: TrainStop, currentStationName: string, stationName: string) => {
|
||||
let stopStatus = StopStatus['arriving'],
|
||||
stopLabel = '',
|
||||
stopStatusID = -1;
|
||||
|
||||
if (stopInfo.terminatesHere && stopInfo.confirmed) {
|
||||
stopStatus = StopStatus['terminated'];
|
||||
stopLabel = 'Skończył bieg';
|
||||
stopStatusID = 5;
|
||||
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && currentStationName == stationName) {
|
||||
stopStatus = StopStatus['departed'];
|
||||
stopLabel = 'Odprawiony';
|
||||
stopStatusID = 2;
|
||||
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && currentStationName != stationName) {
|
||||
stopStatus = StopStatus['departed-away'];
|
||||
stopLabel = 'Odjechał';
|
||||
stopStatusID = 4;
|
||||
} else if (currentStationName == stationName && !stopInfo.stopped) {
|
||||
stopStatus = StopStatus['online'];
|
||||
stopLabel = 'Na stacji';
|
||||
stopStatusID = 0;
|
||||
} else if (currentStationName == stationName && stopInfo.stopped) {
|
||||
stopStatus = StopStatus['stopped'];
|
||||
stopLabel = 'Postój';
|
||||
stopStatusID = 1;
|
||||
} else if (currentStationName != stationName) {
|
||||
stopStatus = StopStatus['arriving'];
|
||||
stopLabel = 'W drodze';
|
||||
stopStatusID = 3;
|
||||
}
|
||||
|
||||
return { stopStatus, stopLabel, stopStatusID };
|
||||
};
|
||||
|
||||
export function getScheduledTrain(train: Train, trainStopIndex: number, stationName: string): ScheduledTrain {
|
||||
const timetable = train.timetableData!;
|
||||
const followingStops = timetable.followingStops;
|
||||
const trainStop = followingStops[trainStopIndex];
|
||||
|
||||
const trainStopStatus = getTrainStopStatus(trainStop, train.currentStationName, stationName);
|
||||
|
||||
let prevStationName = '',
|
||||
nextStationName = '';
|
||||
|
||||
let prevDepartureLine: string | null = null,
|
||||
nextArrivalLine: string | null = null;
|
||||
|
||||
for (let i = trainStopIndex - 1; i >= 0; i--) {
|
||||
if (/strong|podg/g.test(followingStops[i].stopName)) {
|
||||
prevStationName = followingStops[i].stopNameRAW.replace(/,.*/g, '');
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = trainStopIndex + 1; i < followingStops.length; i++) {
|
||||
if (/strong|podg/g.test(followingStops[i].stopName)) {
|
||||
nextStationName = followingStops[i].stopNameRAW.replace(/,.*/g, '');
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let departureLine: string | null = null;
|
||||
let arrivingLine: string | null = null;
|
||||
|
||||
for (let i = trainStopIndex; i < followingStops.length; i++) {
|
||||
const currentStop = followingStops[i];
|
||||
|
||||
if (currentStop.departureLine == null) continue;
|
||||
|
||||
if (!/-|_|it|sbl/gi.test(currentStop.departureLine)) {
|
||||
departureLine = currentStop.departureLine;
|
||||
nextArrivalLine = followingStops[i + 1]?.arrivalLine || null;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = trainStopIndex; i >= 0; i--) {
|
||||
const currentStop = followingStops[i];
|
||||
|
||||
if (currentStop.arrivalLine == null) continue;
|
||||
|
||||
if (!/-|_|it|sbl/gi.test(currentStop.arrivalLine)) {
|
||||
arrivingLine = currentStop.arrivalLine;
|
||||
prevDepartureLine = followingStops[i - 1]?.departureLine || null;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
trainNo: train.trainNo,
|
||||
trainId: train.trainId,
|
||||
|
||||
signal: train.signal,
|
||||
connectedTrack: train.connectedTrack,
|
||||
|
||||
driverName: train.driverName,
|
||||
driverId: train.driverId,
|
||||
currentStationName: train.currentStationName,
|
||||
currentStationHash: train.currentStationHash,
|
||||
category: timetable.category,
|
||||
beginsAt: timetable.followingStops[0].stopNameRAW,
|
||||
terminatesAt: timetable.followingStops[timetable.followingStops.length - 1].stopNameRAW,
|
||||
|
||||
nextStationName,
|
||||
prevStationName,
|
||||
|
||||
stopInfo: trainStop,
|
||||
stopLabel: trainStopStatus.stopLabel,
|
||||
stopStatus: trainStopStatus.stopStatus,
|
||||
stopStatusID: trainStopStatus.stopStatusID,
|
||||
|
||||
arrivingLine,
|
||||
departureLine,
|
||||
|
||||
nextArrivalLine,
|
||||
prevDepartureLine,
|
||||
};
|
||||
}
|
||||
import { ScheduledTrain, StopStatus } from '../interfaces/ScheduledTrain';
|
||||
import Train from '../interfaces/Train';
|
||||
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 'unknown';
|
||||
if (stationStatus == -1) 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 | null) => {
|
||||
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]);
|
||||
const isElectrified = spawnArray[3] == 'True';
|
||||
|
||||
return { spawnName, spawnLength, isElectrified };
|
||||
});
|
||||
};
|
||||
|
||||
export const getTimestamp = (date: string | null): number => (date ? new Date(date).getTime() : 0);
|
||||
|
||||
export const getTrainStopStatus = (
|
||||
stopInfo: TrainStop,
|
||||
currentStationName: string,
|
||||
stationName: string
|
||||
) => {
|
||||
let stopStatus = StopStatus['arriving'],
|
||||
stopLabel = '',
|
||||
stopStatusID = -1;
|
||||
|
||||
if (stopInfo.terminatesHere && stopInfo.confirmed) {
|
||||
stopStatus = StopStatus['terminated'];
|
||||
stopLabel = 'Skończył bieg';
|
||||
stopStatusID = 5;
|
||||
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && currentStationName == stationName) {
|
||||
stopStatus = StopStatus['departed'];
|
||||
stopLabel = 'Odprawiony';
|
||||
stopStatusID = 2;
|
||||
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && currentStationName != stationName) {
|
||||
stopStatus = StopStatus['departed-away'];
|
||||
stopLabel = 'Odjechał';
|
||||
stopStatusID = 4;
|
||||
} else if (currentStationName == stationName && !stopInfo.stopped) {
|
||||
stopStatus = StopStatus['online'];
|
||||
stopLabel = 'Na stacji';
|
||||
stopStatusID = 0;
|
||||
} else if (currentStationName == stationName && stopInfo.stopped) {
|
||||
stopStatus = StopStatus['stopped'];
|
||||
stopLabel = 'Postój';
|
||||
stopStatusID = 1;
|
||||
} else if (currentStationName != stationName) {
|
||||
stopStatus = StopStatus['arriving'];
|
||||
stopLabel = 'W drodze';
|
||||
stopStatusID = 3;
|
||||
}
|
||||
|
||||
return { stopStatus, stopLabel, stopStatusID };
|
||||
};
|
||||
|
||||
export function getScheduledTrain(
|
||||
train: Train,
|
||||
trainStopIndex: number,
|
||||
stationName: string
|
||||
): ScheduledTrain {
|
||||
const timetable = train.timetableData!;
|
||||
const followingStops = timetable.followingStops;
|
||||
const trainStop = followingStops[trainStopIndex];
|
||||
|
||||
const trainStopStatus = getTrainStopStatus(trainStop, train.currentStationName, stationName);
|
||||
|
||||
let prevStationName = '',
|
||||
nextStationName = '';
|
||||
|
||||
let prevDepartureLine: string | null = null,
|
||||
nextArrivalLine: string | null = null;
|
||||
|
||||
for (let i = trainStopIndex - 1; i >= 0; i--) {
|
||||
if (/strong|podg/g.test(followingStops[i].stopName)) {
|
||||
prevStationName = followingStops[i].stopNameRAW.replace(/,.*/g, '');
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = trainStopIndex + 1; i < followingStops.length; i++) {
|
||||
if (/strong|podg/g.test(followingStops[i].stopName)) {
|
||||
nextStationName = followingStops[i].stopNameRAW.replace(/,.*/g, '');
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let departureLine: string | null = null;
|
||||
let arrivingLine: string | null = null;
|
||||
|
||||
for (let i = trainStopIndex; i < followingStops.length; i++) {
|
||||
const currentStop = followingStops[i];
|
||||
|
||||
if (currentStop.departureLine == null) continue;
|
||||
|
||||
if (!/-|_|it|sbl/gi.test(currentStop.departureLine)) {
|
||||
departureLine = currentStop.departureLine;
|
||||
nextArrivalLine = followingStops[i + 1]?.arrivalLine || null;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = trainStopIndex; i >= 0; i--) {
|
||||
const currentStop = followingStops[i];
|
||||
|
||||
if (currentStop.arrivalLine == null) continue;
|
||||
|
||||
if (!/-|_|it|sbl/gi.test(currentStop.arrivalLine)) {
|
||||
arrivingLine = currentStop.arrivalLine;
|
||||
prevDepartureLine = followingStops[i - 1]?.departureLine || null;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
trainNo: train.trainNo,
|
||||
trainId: train.trainId,
|
||||
|
||||
signal: train.signal,
|
||||
connectedTrack: train.connectedTrack,
|
||||
|
||||
driverName: train.driverName,
|
||||
driverId: train.driverId,
|
||||
currentStationName: train.currentStationName,
|
||||
currentStationHash: train.currentStationHash,
|
||||
category: timetable.category,
|
||||
beginsAt: timetable.followingStops[0].stopNameRAW,
|
||||
terminatesAt: timetable.followingStops[timetable.followingStops.length - 1].stopNameRAW,
|
||||
|
||||
nextStationName,
|
||||
prevStationName,
|
||||
|
||||
stopInfo: trainStop,
|
||||
stopLabel: trainStopStatus.stopLabel,
|
||||
stopStatus: trainStopStatus.stopStatus,
|
||||
stopStatusID: trainStopStatus.stopStatusID,
|
||||
|
||||
arrivingLine,
|
||||
departureLine,
|
||||
|
||||
nextArrivalLine,
|
||||
prevDepartureLine
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user