mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
checkpointy; hotfixy
This commit is contained in:
@@ -101,7 +101,7 @@ export default defineComponent({
|
||||
|
||||
onlineDispatchersCount() {
|
||||
return this.store.activeSceneryList.filter(
|
||||
(scenery) => scenery.region == this.store.region.id
|
||||
(scenery) => scenery.region == this.store.region.id && scenery.dispatcherId != -1
|
||||
).length;
|
||||
},
|
||||
|
||||
|
||||
@@ -33,12 +33,12 @@
|
||||
{{ (i > 0 && '•') || '' }}
|
||||
|
||||
<button
|
||||
:key="cp.checkpointName"
|
||||
:key="cp"
|
||||
class="checkpoint_item"
|
||||
:class="{ current: chosenCheckpoint === cp.checkpointName }"
|
||||
:class="{ current: chosenCheckpoint === cp }"
|
||||
@click="setCheckpoint(cp)"
|
||||
>
|
||||
{{ cp.checkpointName }}
|
||||
{{ cp }}
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
@@ -231,7 +231,7 @@ export default defineComponent({
|
||||
const chosenCheckpoint = ref(
|
||||
props.station?.generalInfo?.checkpoints?.length == 0
|
||||
? ''
|
||||
: props.station?.generalInfo?.checkpoints[0].checkpointName || null
|
||||
: props.station?.generalInfo?.checkpoints[0] ?? null
|
||||
);
|
||||
|
||||
return {
|
||||
@@ -278,12 +278,11 @@ export default defineComponent({
|
||||
loadSelectedOption() {
|
||||
if (!this.station) return;
|
||||
|
||||
this.chosenCheckpoint =
|
||||
this.station.generalInfo?.checkpoints[0]?.checkpointName || this.station.name;
|
||||
this.chosenCheckpoint = this.station.generalInfo?.checkpoints[0] ?? this.station.name;
|
||||
},
|
||||
|
||||
setCheckpoint(cp: { checkpointName: string }) {
|
||||
this.chosenCheckpoint = cp.checkpointName;
|
||||
setCheckpoint(cp: string) {
|
||||
this.chosenCheckpoint = cp;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -42,14 +42,13 @@ export interface Filter {
|
||||
nonPublic: boolean;
|
||||
unavailable: boolean;
|
||||
abandoned: boolean;
|
||||
|
||||
endingStatus: boolean;
|
||||
afkStatus: boolean;
|
||||
noSpaceStatus: boolean;
|
||||
unavailableStatus: boolean;
|
||||
unsignedStatus: boolean;
|
||||
|
||||
authors: string;
|
||||
|
||||
onlineFromHours: number;
|
||||
withActiveTimetables: boolean;
|
||||
withoutActiveTimetables: boolean;
|
||||
}
|
||||
|
||||
+16
-1
@@ -7,7 +7,8 @@
|
||||
"addons",
|
||||
"blockades",
|
||||
"signals",
|
||||
"status"
|
||||
"status",
|
||||
"timetables"
|
||||
],
|
||||
|
||||
"options": [
|
||||
@@ -228,6 +229,20 @@
|
||||
"section": "status",
|
||||
"value": true,
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"id": "withActiveTimetables",
|
||||
"name": "withActiveTimetables",
|
||||
"section": "timetables",
|
||||
"value": true,
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"id": "withoutActiveTimetables",
|
||||
"name": "withoutActiveTimetables",
|
||||
"section": "timetables",
|
||||
"value": true,
|
||||
"defaultValue": true
|
||||
}
|
||||
],
|
||||
"sliders": [
|
||||
|
||||
+5
-1
@@ -165,7 +165,8 @@
|
||||
"signals": "TYP SYGNALIZACJI",
|
||||
"addons": "DODATKOWE PROGRAMY",
|
||||
"blockades": "BLOKADY LINIOWE",
|
||||
"status": "STATUS ONLINE"
|
||||
"status": "STATUS ONLINE",
|
||||
"timetables": "AKTYWNE ROZKŁADY JAZDY"
|
||||
},
|
||||
|
||||
"all-available": "WSZYSTKIE DOSTĘPNE",
|
||||
@@ -209,6 +210,9 @@
|
||||
"free": "WOLNA",
|
||||
"occupied": "ZAJĘTA",
|
||||
|
||||
"withActiveTimetables": "AKTYWNE RJ",
|
||||
"withoutActiveTimetables": "BEZ AKTYWNYCH RJ",
|
||||
|
||||
"sliders": {
|
||||
"min-lvl": "MIN. WYMAGANY POZIOM DYŻURNEGO",
|
||||
"max-lvl": "MAKS. WYMAGANY POZIOM DYŻURNEGO",
|
||||
|
||||
@@ -26,10 +26,7 @@ export default interface Station {
|
||||
availability: Availability;
|
||||
routes: StationRoutes;
|
||||
|
||||
checkpoints: {
|
||||
checkpointName: string;
|
||||
scheduledTrains: ScheduledTrain[];
|
||||
}[];
|
||||
checkpoints: string[];
|
||||
};
|
||||
|
||||
onlineInfo?: ActiveScenery;
|
||||
|
||||
@@ -93,7 +93,7 @@ export const sortStations = (
|
||||
};
|
||||
|
||||
export const filterStations = (station: Station, filters: Filter) => {
|
||||
if (!station.onlineInfo && filters['free']) return false;
|
||||
if (filters['free'] && !station.onlineInfo) return false;
|
||||
|
||||
if (station.onlineInfo) {
|
||||
const { dispatcherStatus } = station.onlineInfo;
|
||||
@@ -112,7 +112,10 @@ export const filterStations = (station: Station, filters: Filter) => {
|
||||
|
||||
const isOccupied = station.onlineInfo && filters['occupied'];
|
||||
|
||||
if (isEnding || isNotSigned || isAFK || isNoSpace || isOccupied) return false;
|
||||
const isActiveFree =
|
||||
dispatcherStatus == Status.ActiveDispatcher.FREE && filters['withActiveTimetables'];
|
||||
|
||||
if (isEnding || isNotSigned || isAFK || isNoSpace || isOccupied || isActiveFree) return false;
|
||||
|
||||
if (
|
||||
filters['onlineFromHours'] > 0 &&
|
||||
|
||||
+14
-21
@@ -166,31 +166,28 @@ export const useMainStore = defineStore('store', {
|
||||
dispatcherId: scenery.dispatcherId,
|
||||
dispatcherExp: scenery.dispatcherExp,
|
||||
dispatcherIsSupporter: scenery.dispatcherIsSupporter,
|
||||
dispatcherStatus: scenery.dispatcherStatus,
|
||||
dispatcherTimestamp: dispatcherTimestamp,
|
||||
|
||||
isOnline: scenery.isOnline == 1,
|
||||
|
||||
scheduledTrains: [],
|
||||
stationTrains: [],
|
||||
scheduledTrainCount: {
|
||||
all: 0,
|
||||
confirmed: 0,
|
||||
unconfirmed: 0
|
||||
},
|
||||
// scheduledTrains: scheduledTrains,
|
||||
// stationTrains: stationTrains,
|
||||
dispatcherStatus: scenery.dispatcherStatus,
|
||||
dispatcherTimestamp: dispatcherTimestamp,
|
||||
|
||||
isOnline: scenery.isOnline == 1
|
||||
|
||||
// scheduledTrainCount: {
|
||||
// all: uniqueScheduledTrains.length,
|
||||
// confirmed: uniqueScheduledTrains.filter((train) => train.stopInfo.confirmed).length,
|
||||
// unconfirmed: uniqueScheduledTrains.filter((train) => !train.stopInfo.confirmed).length
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
return list;
|
||||
}, [] as ActiveScenery[]);
|
||||
|
||||
[...onlineActiveSceneries, ...offlineActiveSceneries].forEach((scenery) => {
|
||||
const allActiveSceneries = [...onlineActiveSceneries, ...offlineActiveSceneries];
|
||||
|
||||
for (let i = 0, n = allActiveSceneries.length; i < n; i++) {
|
||||
const scenery = allActiveSceneries[i];
|
||||
|
||||
const station = this.stationList.find((s) => s.name === scenery.name);
|
||||
|
||||
const scheduledTrains = getScheduledTrains(
|
||||
@@ -224,11 +221,11 @@ export const useMainStore = defineStore('store', {
|
||||
confirmed: uniqueScheduledTrains.filter((train) => train.stopInfo.confirmed).length,
|
||||
unconfirmed: uniqueScheduledTrains.filter((train) => !train.stopInfo.confirmed).length
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
console.timeEnd('d');
|
||||
|
||||
return [...onlineActiveSceneries, ...offlineActiveSceneries];
|
||||
return allActiveSceneries;
|
||||
},
|
||||
|
||||
stationList(): Station[] {
|
||||
@@ -268,11 +265,7 @@ export const useMainStore = defineStore('store', {
|
||||
...scenery,
|
||||
authors: scenery.authors?.split(',').map((a) => a.trim()),
|
||||
routes: routes,
|
||||
checkpoints: scenery.checkpoints
|
||||
? scenery.checkpoints
|
||||
.split(';')
|
||||
.map((sub) => ({ checkpointName: sub, scheduledTrains: [] }))
|
||||
: []
|
||||
checkpoints: scenery.checkpoints?.split(';') ?? []
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
@@ -48,6 +48,8 @@ const filterInitStates: Filter = {
|
||||
noSpaceStatus: false,
|
||||
unavailableStatus: false,
|
||||
unsignedStatus: false,
|
||||
withActiveTimetables: false,
|
||||
withoutActiveTimetables: false,
|
||||
|
||||
authors: '',
|
||||
|
||||
|
||||
+29
-60
@@ -102,51 +102,33 @@ export function getCheckpointTrain(
|
||||
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];
|
||||
let prevDepartureLine: string | null = null,
|
||||
nextArrivalLine: string | null = null;
|
||||
|
||||
if (currentStop.departureLine == null) continue;
|
||||
for (let i = trainStopIndex; i >= 0; i--) {
|
||||
const stop = followingStops[i];
|
||||
|
||||
if (!/-|_|it|sbl/gi.test(currentStop.departureLine)) {
|
||||
departureLine = currentStop.departureLine;
|
||||
nextArrivalLine = followingStops[i + 1]?.arrivalLine || null;
|
||||
if (/strong|podg/g.test(stop.stopName) && !prevStationName && i <= trainStopIndex - 1)
|
||||
prevStationName = stop.stopNameRAW.replace(/,.*/g, '');
|
||||
|
||||
break;
|
||||
if (stop.arrivalLine != null && !arrivingLine && !/-|_|it|sbl/gi.test(stop.arrivalLine)) {
|
||||
arrivingLine = stop.arrivalLine;
|
||||
prevDepartureLine = followingStops[i - 1]?.departureLine || null;
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = trainStopIndex; i >= 0; i--) {
|
||||
const currentStop = followingStops[i];
|
||||
for (let i = trainStopIndex; i < followingStops.length; i++) {
|
||||
const stop = followingStops[i];
|
||||
|
||||
if (currentStop.arrivalLine == null) continue;
|
||||
if (/strong|podg/g.test(stop.stopName) && !nextStationName && i > trainStopIndex)
|
||||
nextStationName = stop.stopNameRAW.replace(/,.*/g, '');
|
||||
|
||||
if (!/-|_|it|sbl/gi.test(currentStop.arrivalLine)) {
|
||||
arrivingLine = currentStop.arrivalLine;
|
||||
prevDepartureLine = followingStops[i - 1]?.departureLine || null;
|
||||
|
||||
break;
|
||||
if (stop.departureLine && !departureLine && !/-|_|it|sbl/gi.test(stop.departureLine)) {
|
||||
departureLine = stop.departureLine;
|
||||
nextArrivalLine = followingStops[i + 1]?.arrivalLine || null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,8 +159,8 @@ export function getCheckpointTrain(
|
||||
|
||||
region: train.region,
|
||||
|
||||
arrivingLine,
|
||||
departureLine,
|
||||
arrivingLine: arrivingLine,
|
||||
departureLine: departureLine,
|
||||
|
||||
nextArrivalLine,
|
||||
prevDepartureLine
|
||||
@@ -192,7 +174,7 @@ export function getScheduledTrains(
|
||||
region: string
|
||||
// sceneryData: API.ActiveSceneries.Data,
|
||||
): ScheduledTrain[] {
|
||||
stationGeneralInfo?.checkpoints.forEach((cp) => (cp.scheduledTrains.length = 0));
|
||||
// stationGeneralInfo?.checkpoints.forEach((cp) => (cp.scheduledTrains.length = 0));
|
||||
|
||||
return trainList.reduce((acc: ScheduledTrain[], train) => {
|
||||
if (!train.timetableData) return acc;
|
||||
@@ -201,32 +183,19 @@ export function getScheduledTrains(
|
||||
const timetable = train.timetableData;
|
||||
if (!timetable.sceneryNames.includes(stationName)) return acc;
|
||||
|
||||
const stopInfoIndex = timetable.followingStops.findIndex((stop) => {
|
||||
return stationName.toLocaleLowerCase() == stop.stopNameRAW.toLocaleLowerCase();
|
||||
});
|
||||
const checkpoints = [stationName];
|
||||
if (stationGeneralInfo?.checkpoints) checkpoints.push(...stationGeneralInfo.checkpoints);
|
||||
|
||||
const checkpointScheduledTrains: ScheduledTrain[] = [];
|
||||
|
||||
if (stopInfoIndex != -1) {
|
||||
checkpointScheduledTrains.push(getCheckpointTrain(train, stopInfoIndex, stationName));
|
||||
}
|
||||
|
||||
stationGeneralInfo?.checkpoints?.forEach((checkpoint) => {
|
||||
for (let i = 0; i < timetable.followingStops.length; i++) {
|
||||
if (
|
||||
checkpointScheduledTrains.findIndex(
|
||||
(cpTrain) =>
|
||||
cpTrain.checkpointName.toLocaleLowerCase() ==
|
||||
checkpoint.checkpointName.toLocaleLowerCase()
|
||||
) != -1
|
||||
)
|
||||
return;
|
||||
|
||||
const index = timetable.followingStops.findIndex(
|
||||
(stop) => stop.stopNameRAW.toLowerCase() == checkpoint.checkpointName.toLowerCase()
|
||||
);
|
||||
|
||||
if (index > -1) checkpointScheduledTrains.push(getCheckpointTrain(train, index, stationName));
|
||||
});
|
||||
new RegExp(`^(${checkpoints.join('|')})$`, 'i').test(
|
||||
timetable.followingStops[i].stopNameRAW
|
||||
)
|
||||
) {
|
||||
checkpointScheduledTrains.push(getCheckpointTrain(train, i, stationName));
|
||||
}
|
||||
}
|
||||
|
||||
acc.push(...checkpointScheduledTrains);
|
||||
return acc;
|
||||
|
||||
@@ -169,11 +169,7 @@ export default defineComponent({
|
||||
loadSelectedCheckpoint() {
|
||||
if (!this.stationInfo?.generalInfo?.checkpoints) return;
|
||||
if (this.stationInfo.generalInfo.checkpoints.length == 0) return;
|
||||
this.selectedCheckpoint = this.stationInfo.generalInfo.checkpoints[0].checkpointName;
|
||||
},
|
||||
|
||||
selectCheckpoint(cp: { checkpointName: string }) {
|
||||
this.selectedCheckpoint = cp.checkpointName;
|
||||
this.selectedCheckpoint = this.stationInfo.generalInfo.checkpoints[0];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user