mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
wyświetlanie RJ dla scenerii offline
This commit is contained in:
@@ -100,7 +100,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
onlineDispatchersCount() {
|
onlineDispatchersCount() {
|
||||||
return this.store.onlineSceneryList.filter(
|
return this.store.activeSceneryList.filter(
|
||||||
(scenery) => scenery.region == this.store.region.id
|
(scenery) => scenery.region == this.store.region.id
|
||||||
).length;
|
).length;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
regionList() {
|
regionList() {
|
||||||
return regionsJSON.map((region) => {
|
return regionsJSON.map((region) => {
|
||||||
const regionStationCount = this.store.onlineSceneryList.filter(
|
const regionStationCount = this.store.activeSceneryList.filter(
|
||||||
(scenery) => scenery.region == region.id
|
(scenery) => scenery.region == region.id
|
||||||
).length;
|
).length;
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,9 @@ export default defineComponent({
|
|||||||
case Status.ActiveDispatcher.UNKNOWN:
|
case Status.ActiveDispatcher.UNKNOWN:
|
||||||
return 'unknown';
|
return 'unknown';
|
||||||
|
|
||||||
|
case Status.ActiveDispatcher.FREE:
|
||||||
|
return 'free';
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (this.dispatcherTimestamp != null && this.dispatcherStatus >= Date.now() + 25500000)
|
if (this.dispatcherTimestamp != null && this.dispatcherStatus >= Date.now() + 25500000)
|
||||||
return 'no-limit';
|
return 'no-limit';
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ import Station from '../../scripts/interfaces/Station';
|
|||||||
import Loading from '../Global/Loading.vue';
|
import Loading from '../Global/Loading.vue';
|
||||||
import styleMixin from '../../mixins/styleMixin';
|
import styleMixin from '../../mixins/styleMixin';
|
||||||
import listObserverMixin from '../../mixins/listObserverMixin';
|
import listObserverMixin from '../../mixins/listObserverMixin';
|
||||||
import { OnlineScenery } from '../../store/typings';
|
import { ActiveScenery } from '../../store/typings';
|
||||||
import { API } from '../../typings/api';
|
import { API } from '../../typings/api';
|
||||||
import { Status } from '../../typings/common';
|
import { Status } from '../../typings/common';
|
||||||
import http from '../../http';
|
import http from '../../http';
|
||||||
@@ -90,7 +90,7 @@ export default defineComponent({
|
|||||||
type: Object as PropType<Station>
|
type: Object as PropType<Station>
|
||||||
},
|
},
|
||||||
onlineScenery: {
|
onlineScenery: {
|
||||||
type: Object as PropType<OnlineScenery>
|
type: Object as PropType<ActiveScenery>
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { PropType, defineComponent } from 'vue';
|
import { PropType, defineComponent } from 'vue';
|
||||||
import Station from '../../scripts/interfaces/Station';
|
import Station from '../../scripts/interfaces/Station';
|
||||||
import { OnlineScenery } from '../../store/typings';
|
import { ActiveScenery } from '../../store/typings';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
props: {
|
props: {
|
||||||
@@ -29,7 +29,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
onlineScenery: {
|
onlineScenery: {
|
||||||
type: Object as PropType<OnlineScenery>
|
type: Object as PropType<ActiveScenery>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ import SceneryInfoUserList from './SceneryInfo/SceneryInfoUserList.vue';
|
|||||||
import SceneryInfoSpawnList from './SceneryInfo/SceneryInfoSpawnList.vue';
|
import SceneryInfoSpawnList from './SceneryInfo/SceneryInfoSpawnList.vue';
|
||||||
import SceneryInfoRoutes from './SceneryInfo/SceneryInfoRoutes.vue';
|
import SceneryInfoRoutes from './SceneryInfo/SceneryInfoRoutes.vue';
|
||||||
import Station from '../../scripts/interfaces/Station';
|
import Station from '../../scripts/interfaces/Station';
|
||||||
import { OnlineScenery } from '../../store/typings';
|
import { ActiveScenery } from '../../store/typings';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
@@ -106,7 +106,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
onlineScenery: {
|
onlineScenery: {
|
||||||
type: Object as PropType<OnlineScenery>
|
type: Object as PropType<ActiveScenery>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<section class="info-dispatcher">
|
<section class="info-dispatcher">
|
||||||
<div class="dispatcher" v-if="onlineScenery">
|
<div class="dispatcher" v-if="onlineScenery && onlineScenery.dispatcherExp != -1">
|
||||||
<span
|
<span
|
||||||
class="dispatcher_level"
|
class="dispatcher_level"
|
||||||
:style="calculateExpStyle(onlineScenery.dispatcherExp, onlineScenery.dispatcherIsSupporter)"
|
:style="calculateExpStyle(onlineScenery.dispatcherExp, onlineScenery.dispatcherIsSupporter)"
|
||||||
@@ -42,14 +42,14 @@ import dateMixin from '../../../mixins/dateMixin';
|
|||||||
import routerMixin from '../../../mixins/routerMixin';
|
import routerMixin from '../../../mixins/routerMixin';
|
||||||
import styleMixin from '../../../mixins/styleMixin';
|
import styleMixin from '../../../mixins/styleMixin';
|
||||||
import StationStatusBadge from '../../Global/StationStatusBadge.vue';
|
import StationStatusBadge from '../../Global/StationStatusBadge.vue';
|
||||||
import { OnlineScenery } from '../../../store/typings';
|
import { ActiveScenery } from '../../../store/typings';
|
||||||
import donatorMixin from '../../../mixins/donatorMixin';
|
import donatorMixin from '../../../mixins/donatorMixin';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
mixins: [styleMixin, dateMixin, routerMixin, donatorMixin],
|
mixins: [styleMixin, dateMixin, routerMixin, donatorMixin],
|
||||||
props: {
|
props: {
|
||||||
onlineScenery: {
|
onlineScenery: {
|
||||||
type: Object as PropType<OnlineScenery>,
|
type: Object as PropType<ActiveScenery>,
|
||||||
required: false
|
required: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -30,12 +30,12 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { PropType, defineComponent } from 'vue';
|
import { PropType, defineComponent } from 'vue';
|
||||||
import { OnlineScenery } from '../../../store/typings';
|
import { ActiveScenery } from '../../../store/typings';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
props: {
|
props: {
|
||||||
onlineScenery: {
|
onlineScenery: {
|
||||||
type: Object as PropType<OnlineScenery>,
|
type: Object as PropType<ActiveScenery>,
|
||||||
required: false
|
required: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -32,14 +32,14 @@
|
|||||||
import { PropType, defineComponent } from 'vue';
|
import { PropType, defineComponent } from 'vue';
|
||||||
import modalTrainMixin from '../../../mixins/modalTrainMixin';
|
import modalTrainMixin from '../../../mixins/modalTrainMixin';
|
||||||
import routerMixin from '../../../mixins/routerMixin';
|
import routerMixin from '../../../mixins/routerMixin';
|
||||||
import { OnlineScenery } from '../../../store/typings';
|
import { ActiveScenery } from '../../../store/typings';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
mixins: [routerMixin, modalTrainMixin],
|
mixins: [routerMixin, modalTrainMixin],
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
onlineScenery: {
|
onlineScenery: {
|
||||||
type: Object as PropType<OnlineScenery>,
|
type: Object as PropType<ActiveScenery>,
|
||||||
required: false
|
required: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
<span>{{ $t('scenery.timetables') }}</span>
|
<span>{{ $t('scenery.timetables') }}</span>
|
||||||
|
|
||||||
<span>
|
<span>
|
||||||
<span class="text--primary">{{ onlineScenery?.scheduledTrainCount.all || 0 }}</span>
|
<span class="text--primary">{{ onlineScenery?.scheduledTrainCount.all ?? 0 }}</span>
|
||||||
<span> / </span>
|
<span> / </span>
|
||||||
<span class="text--grayed">
|
<span class="text--grayed">
|
||||||
{{ onlineScenery?.scheduledTrainCount.confirmed || '0' }}
|
{{ onlineScenery?.scheduledTrainCount.confirmed ?? 0 }}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
@@ -190,7 +190,7 @@ import Station from '../../scripts/interfaces/Station';
|
|||||||
import { useMainStore } from '../../store/mainStore';
|
import { useMainStore } from '../../store/mainStore';
|
||||||
import modalTrainMixin from '../../mixins/modalTrainMixin';
|
import modalTrainMixin from '../../mixins/modalTrainMixin';
|
||||||
import ScheduledTrainStatus from './ScheduledTrainStatus.vue';
|
import ScheduledTrainStatus from './ScheduledTrainStatus.vue';
|
||||||
import { OnlineScenery } from '../../store/typings';
|
import { ActiveScenery } from '../../store/typings';
|
||||||
import { useApiStore } from '../../store/apiStore';
|
import { useApiStore } from '../../store/apiStore';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
@@ -205,7 +205,7 @@ export default defineComponent({
|
|||||||
type: Object as PropType<Station>
|
type: Object as PropType<Station>
|
||||||
},
|
},
|
||||||
onlineScenery: {
|
onlineScenery: {
|
||||||
type: Object as PropType<OnlineScenery>
|
type: Object as PropType<ActiveScenery>
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ import dateMixin from '../../mixins/dateMixin';
|
|||||||
import Station from '../../scripts/interfaces/Station';
|
import Station from '../../scripts/interfaces/Station';
|
||||||
import Loading from '../Global/Loading.vue';
|
import Loading from '../Global/Loading.vue';
|
||||||
import listObserverMixin from '../../mixins/listObserverMixin';
|
import listObserverMixin from '../../mixins/listObserverMixin';
|
||||||
import { OnlineScenery } from '../../store/typings';
|
import { ActiveScenery } from '../../store/typings';
|
||||||
import { API } from '../../typings/api';
|
import { API } from '../../typings/api';
|
||||||
import { Status } from '../../typings/common';
|
import { Status } from '../../typings/common';
|
||||||
import http from '../../http';
|
import http from '../../http';
|
||||||
@@ -87,7 +87,7 @@ export default defineComponent({
|
|||||||
type: Object as PropType<Station>
|
type: Object as PropType<Station>
|
||||||
},
|
},
|
||||||
onlineScenery: {
|
onlineScenery: {
|
||||||
type: Object as PropType<OnlineScenery>
|
type: Object as PropType<ActiveScenery>
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
|
|
||||||
<td class="station_dispatcher-exp">
|
<td class="station_dispatcher-exp">
|
||||||
<span
|
<span
|
||||||
v-if="station.onlineInfo"
|
v-if="station.onlineInfo && station.onlineInfo?.dispatcherExp != -1"
|
||||||
:style="
|
:style="
|
||||||
calculateExpStyle(
|
calculateExpStyle(
|
||||||
station.onlineInfo.dispatcherExp,
|
station.onlineInfo.dispatcherExp,
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ export default defineComponent({
|
|||||||
isSBL: /sbl/gi.test(stop.stopName),
|
isSBL: /sbl/gi.test(stop.stopName),
|
||||||
position: stop.beginsHere ? 'begin' : stop.terminatesHere ? 'end' : 'en-route',
|
position: stop.beginsHere ? 'begin' : stop.terminatesHere ? 'end' : 'en-route',
|
||||||
sceneryHash: '',
|
sceneryHash: '',
|
||||||
sceneryName: this.timetableSceneryNames[currentSceneryIndex],
|
sceneryName: this.train.timetableData!.sceneryNames[currentSceneryIndex],
|
||||||
status: stop.confirmed ? 'confirmed' : stop.stopped ? 'stopped' : 'unconfirmed'
|
status: stop.confirmed ? 'confirmed' : stop.stopped ? 'stopped' : 'unconfirmed'
|
||||||
};
|
};
|
||||||
}) ?? []
|
}) ?? []
|
||||||
@@ -216,19 +216,6 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return activeMinorStopList;
|
return activeMinorStopList;
|
||||||
},
|
|
||||||
|
|
||||||
timetableSceneryNames() {
|
|
||||||
if (!this.train.timetableData?.sceneries) return [];
|
|
||||||
|
|
||||||
return this.train.timetableData?.sceneries
|
|
||||||
.map(
|
|
||||||
(sceneryHash) =>
|
|
||||||
this.store.onlineSceneryList.find((st) => st.hash === sceneryHash)?.name ??
|
|
||||||
this.apiStore.sceneryData.find((sd) => sd.hash === sceneryHash)?.name ??
|
|
||||||
sceneryHash
|
|
||||||
)
|
|
||||||
.reverse();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Availability, OnlineScenery, ScheduledTrain } from '../../store/typings';
|
import { Availability, ActiveScenery, ScheduledTrain } from '../../store/typings';
|
||||||
import { StationRoutes } from './StationRoutes';
|
import { StationRoutes } from './StationRoutes';
|
||||||
|
|
||||||
export default interface Station {
|
export default interface Station {
|
||||||
@@ -8,6 +8,7 @@ export default interface Station {
|
|||||||
name: string;
|
name: string;
|
||||||
url: string;
|
url: string;
|
||||||
abbr: string;
|
abbr: string;
|
||||||
|
hash?: string;
|
||||||
|
|
||||||
reqLevel: number;
|
reqLevel: number;
|
||||||
// supportersOnly: boolean;
|
// supportersOnly: boolean;
|
||||||
@@ -31,5 +32,5 @@ export default interface Station {
|
|||||||
}[];
|
}[];
|
||||||
};
|
};
|
||||||
|
|
||||||
onlineInfo?: OnlineScenery;
|
onlineInfo?: ActiveScenery;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,5 +33,6 @@ export default interface Train {
|
|||||||
SKR: boolean;
|
SKR: boolean;
|
||||||
routeDistance: number;
|
routeDistance: number;
|
||||||
sceneries: string[];
|
sceneries: string[];
|
||||||
|
sceneryNames: string[];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+114
-33
@@ -2,7 +2,7 @@ import { defineStore } from 'pinia';
|
|||||||
import Train from '../scripts/interfaces/Train';
|
import Train from '../scripts/interfaces/Train';
|
||||||
import { parseSpawns, getScheduledTrains, getStationTrains } from './utils';
|
import { parseSpawns, getScheduledTrains, getStationTrains } from './utils';
|
||||||
|
|
||||||
import { OnlineScenery, ScheduledTrain, StoreState } from './typings';
|
import { ActiveScenery, ScheduledTrain, StoreState } from './typings';
|
||||||
|
|
||||||
import { Status } from '../typings/common';
|
import { Status } from '../typings/common';
|
||||||
import Station from '../scripts/interfaces/Station';
|
import Station from '../scripts/interfaces/Station';
|
||||||
@@ -41,6 +41,14 @@ export const useMainStore = defineStore('store', {
|
|||||||
|
|
||||||
const timetable = train.timetable;
|
const timetable = train.timetable;
|
||||||
|
|
||||||
|
const sceneryNames =
|
||||||
|
train.timetable?.sceneries?.map(
|
||||||
|
(sceneryHash) =>
|
||||||
|
this.activeSceneryList.find((st) => st.hash === sceneryHash)?.name ??
|
||||||
|
apiStore.sceneryData.find((sd) => sd.hash === sceneryHash)?.name ??
|
||||||
|
sceneryHash
|
||||||
|
) ?? [];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
trainId: train.driverName + train.trainNo.toString(),
|
trainId: train.driverName + train.trainNo.toString(),
|
||||||
|
|
||||||
@@ -76,43 +84,69 @@ export const useMainStore = defineStore('store', {
|
|||||||
category: timetable.category,
|
category: timetable.category,
|
||||||
followingStops: timetable.stopList,
|
followingStops: timetable.stopList,
|
||||||
routeDistance: timetable.stopList[timetable.stopList.length - 1].stopDistance,
|
routeDistance: timetable.stopList[timetable.stopList.length - 1].stopDistance,
|
||||||
sceneries: timetable.sceneries
|
sceneries: timetable.sceneries,
|
||||||
|
sceneryNames: sceneryNames.reverse()
|
||||||
}
|
}
|
||||||
: undefined
|
: undefined
|
||||||
} as Train;
|
} as Train;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onlineSceneryList(state): OnlineScenery[] {
|
activeSceneryList(state): ActiveScenery[] {
|
||||||
const apiStore = useApiStore();
|
const apiStore = useApiStore();
|
||||||
|
|
||||||
if (state.isOffline) return [];
|
if (state.isOffline) return [];
|
||||||
|
|
||||||
if (!apiStore.activeData?.activeSceneries) return [];
|
if (!apiStore.activeData?.activeSceneries) return [];
|
||||||
|
|
||||||
return apiStore.activeData?.activeSceneries.reduce((list, scenery) => {
|
console.time('d');
|
||||||
|
|
||||||
|
const offlineActiveSceneries = this.trainList.reduce((acc, train) => {
|
||||||
|
if (!train.timetableData) return acc;
|
||||||
|
|
||||||
|
train.timetableData.sceneryNames.forEach((name) => {
|
||||||
|
if (
|
||||||
|
acc.findIndex((v) => v.name == name && v.region == train.region) != -1 ||
|
||||||
|
apiStore.activeData?.activeSceneries?.findIndex(
|
||||||
|
(sc) => sc.stationName === name && sc.region == train.region
|
||||||
|
) != -1
|
||||||
|
)
|
||||||
|
return acc;
|
||||||
|
|
||||||
|
acc.push({
|
||||||
|
name: name,
|
||||||
|
hash: '',
|
||||||
|
region: train.region,
|
||||||
|
maxUsers: 0,
|
||||||
|
currentUsers: 0,
|
||||||
|
spawns: [],
|
||||||
|
dispatcherName: '',
|
||||||
|
dispatcherRate: 0,
|
||||||
|
dispatcherId: -1,
|
||||||
|
dispatcherExp: -1,
|
||||||
|
dispatcherIsSupporter: false,
|
||||||
|
scheduledTrains: [],
|
||||||
|
stationTrains: [],
|
||||||
|
dispatcherStatus: Status.ActiveDispatcher.FREE,
|
||||||
|
dispatcherTimestamp: -1,
|
||||||
|
|
||||||
|
isOnline: false,
|
||||||
|
|
||||||
|
scheduledTrainCount: {
|
||||||
|
all: 0,
|
||||||
|
confirmed: 0,
|
||||||
|
unconfirmed: 0
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
}, [] as ActiveScenery[]);
|
||||||
|
|
||||||
|
const onlineActiveSceneries = apiStore.activeData?.activeSceneries.reduce((list, scenery) => {
|
||||||
if (scenery.isOnline !== 1 && Date.now() - scenery.lastSeen > 1000 * 60 * 2) return list;
|
if (scenery.isOnline !== 1 && Date.now() - scenery.lastSeen > 1000 * 60 * 2) return list;
|
||||||
if (scenery.dispatcherStatus == Status.ActiveDispatcher.UNKNOWN) return list;
|
if (scenery.dispatcherStatus == Status.ActiveDispatcher.UNKNOWN) return list;
|
||||||
|
|
||||||
const station = this.stationList.find((s) => s.name === scenery.stationName);
|
|
||||||
|
|
||||||
const scheduledTrains = getScheduledTrains(this.trainList, scenery, station?.generalInfo);
|
|
||||||
|
|
||||||
const stationTrains = getStationTrains(
|
|
||||||
this.trainList,
|
|
||||||
scheduledTrains,
|
|
||||||
this.region.id,
|
|
||||||
scenery
|
|
||||||
);
|
|
||||||
|
|
||||||
// Remove checkpoint duplicates
|
|
||||||
const uniqueScheduledTrains = scheduledTrains.reduce(
|
|
||||||
(uniqueList, sTrain) =>
|
|
||||||
uniqueList.find((v) => v.trainId === sTrain.trainId)
|
|
||||||
? uniqueList
|
|
||||||
: [...uniqueList, sTrain],
|
|
||||||
[] as ScheduledTrain[]
|
|
||||||
);
|
|
||||||
|
|
||||||
const dispatcherTimestamp =
|
const dispatcherTimestamp =
|
||||||
scenery.dispatcherStatus == Status.ActiveDispatcher.NO_LIMIT
|
scenery.dispatcherStatus == Status.ActiveDispatcher.NO_LIMIT
|
||||||
? Date.now() + 25500000
|
? Date.now() + 25500000
|
||||||
@@ -132,22 +166,69 @@ export const useMainStore = defineStore('store', {
|
|||||||
dispatcherId: scenery.dispatcherId,
|
dispatcherId: scenery.dispatcherId,
|
||||||
dispatcherExp: scenery.dispatcherExp,
|
dispatcherExp: scenery.dispatcherExp,
|
||||||
dispatcherIsSupporter: scenery.dispatcherIsSupporter,
|
dispatcherIsSupporter: scenery.dispatcherIsSupporter,
|
||||||
scheduledTrains: scheduledTrains,
|
scheduledTrains: [],
|
||||||
stationTrains: stationTrains,
|
stationTrains: [],
|
||||||
|
scheduledTrainCount: {
|
||||||
|
all: 0,
|
||||||
|
confirmed: 0,
|
||||||
|
unconfirmed: 0
|
||||||
|
},
|
||||||
|
// scheduledTrains: scheduledTrains,
|
||||||
|
// stationTrains: stationTrains,
|
||||||
dispatcherStatus: scenery.dispatcherStatus,
|
dispatcherStatus: scenery.dispatcherStatus,
|
||||||
dispatcherTimestamp: dispatcherTimestamp,
|
dispatcherTimestamp: dispatcherTimestamp,
|
||||||
|
|
||||||
isOnline: scenery.isOnline == 1,
|
isOnline: scenery.isOnline == 1
|
||||||
|
|
||||||
scheduledTrainCount: {
|
// scheduledTrainCount: {
|
||||||
all: uniqueScheduledTrains.length,
|
// all: uniqueScheduledTrains.length,
|
||||||
confirmed: uniqueScheduledTrains.filter((train) => train.stopInfo.confirmed).length,
|
// confirmed: uniqueScheduledTrains.filter((train) => train.stopInfo.confirmed).length,
|
||||||
unconfirmed: uniqueScheduledTrains.filter((train) => !train.stopInfo.confirmed).length
|
// unconfirmed: uniqueScheduledTrains.filter((train) => !train.stopInfo.confirmed).length
|
||||||
}
|
// }
|
||||||
});
|
});
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}, [] as OnlineScenery[]);
|
}, [] as ActiveScenery[]);
|
||||||
|
|
||||||
|
[...onlineActiveSceneries, ...offlineActiveSceneries].forEach((scenery) => {
|
||||||
|
const station = this.stationList.find((s) => s.name === scenery.name);
|
||||||
|
|
||||||
|
const scheduledTrains = getScheduledTrains(
|
||||||
|
this.trainList,
|
||||||
|
station?.generalInfo,
|
||||||
|
scenery.name,
|
||||||
|
scenery.region
|
||||||
|
);
|
||||||
|
|
||||||
|
const stationTrains = getStationTrains(
|
||||||
|
this.trainList,
|
||||||
|
scheduledTrains,
|
||||||
|
this.region.id,
|
||||||
|
scenery.name
|
||||||
|
);
|
||||||
|
|
||||||
|
// Remove checkpoint duplicates
|
||||||
|
const uniqueScheduledTrains = scheduledTrains.reduce(
|
||||||
|
(uniqueList, sTrain) =>
|
||||||
|
uniqueList.find((v) => v.trainId === sTrain.trainId)
|
||||||
|
? uniqueList
|
||||||
|
: [...uniqueList, sTrain],
|
||||||
|
[] as ScheduledTrain[]
|
||||||
|
);
|
||||||
|
|
||||||
|
scenery.scheduledTrains = scheduledTrains;
|
||||||
|
scenery.stationTrains = stationTrains;
|
||||||
|
|
||||||
|
scenery.scheduledTrainCount = {
|
||||||
|
all: uniqueScheduledTrains.length,
|
||||||
|
confirmed: uniqueScheduledTrains.filter((train) => train.stopInfo.confirmed).length,
|
||||||
|
unconfirmed: uniqueScheduledTrains.filter((train) => !train.stopInfo.confirmed).length
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
console.timeEnd('d');
|
||||||
|
|
||||||
|
return [...onlineActiveSceneries, ...offlineActiveSceneries];
|
||||||
},
|
},
|
||||||
|
|
||||||
stationList(): Station[] {
|
stationList(): Station[] {
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ export const useStationFiltersStore = defineStore('stationFiltersStore', {
|
|||||||
const store = useMainStore();
|
const store = useMainStore();
|
||||||
const savedStationNames = store.stationList.map((s) => s.name);
|
const savedStationNames = store.stationList.map((s) => s.name);
|
||||||
|
|
||||||
const onlineUnsavedStations = store.onlineSceneryList
|
const onlineUnsavedStations = store.activeSceneryList
|
||||||
.filter((os) => !savedStationNames.includes(os.name) && os.region == store.region.id)
|
.filter((os) => !savedStationNames.includes(os.name) && os.region == store.region.id)
|
||||||
.map((os) => ({
|
.map((os) => ({
|
||||||
name: os.name,
|
name: os.name,
|
||||||
@@ -85,7 +85,8 @@ export const useStationFiltersStore = defineStore('stationFiltersStore', {
|
|||||||
...onlineUnsavedStations,
|
...onlineUnsavedStations,
|
||||||
...store.stationList.map((station) => ({
|
...store.stationList.map((station) => ({
|
||||||
...station,
|
...station,
|
||||||
onlineInfo: store.onlineSceneryList.find(
|
// append to 'onlineInfo' object for filtering legacy reasons - to optimize later (hopefully)
|
||||||
|
onlineInfo: store.activeSceneryList.find(
|
||||||
(os) => os.name == station.name && os.region == store.region.id
|
(os) => os.name == station.name && os.region == store.region.id
|
||||||
)
|
)
|
||||||
}))
|
}))
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ export interface StationJSONData {
|
|||||||
availability: Availability;
|
availability: Availability;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OnlineScenery {
|
export interface ActiveScenery {
|
||||||
name: string;
|
name: string;
|
||||||
hash: string;
|
hash: string;
|
||||||
region: string;
|
region: string;
|
||||||
|
|||||||
+11
-26
@@ -187,43 +187,31 @@ export function getCheckpointTrain(
|
|||||||
|
|
||||||
export function getScheduledTrains(
|
export function getScheduledTrains(
|
||||||
trainList: Train[],
|
trainList: Train[],
|
||||||
sceneryData: API.ActiveSceneries.Data,
|
stationGeneralInfo: Station['generalInfo'],
|
||||||
stationGeneralInfo: Station['generalInfo']
|
stationName: string,
|
||||||
|
region: string
|
||||||
|
// sceneryData: API.ActiveSceneries.Data,
|
||||||
): ScheduledTrain[] {
|
): ScheduledTrain[] {
|
||||||
const stationNameLower = sceneryData.stationName.toLocaleLowerCase();
|
|
||||||
|
|
||||||
stationGeneralInfo?.checkpoints.forEach((cp) => (cp.scheduledTrains.length = 0));
|
stationGeneralInfo?.checkpoints.forEach((cp) => (cp.scheduledTrains.length = 0));
|
||||||
|
|
||||||
return trainList.reduce((acc: ScheduledTrain[], train) => {
|
return trainList.reduce((acc: ScheduledTrain[], train) => {
|
||||||
if (!train.timetableData) return acc;
|
if (!train.timetableData) return acc;
|
||||||
if (train.region != sceneryData.region) return acc;
|
if (train.region != region) return acc;
|
||||||
|
|
||||||
const timetable = train.timetableData;
|
const timetable = train.timetableData;
|
||||||
if (!timetable.sceneries.includes(sceneryData.stationHash)) return acc;
|
if (!timetable.sceneryNames.includes(stationName)) return acc;
|
||||||
|
|
||||||
const stopInfoIndex = timetable.followingStops.findIndex((stop) => {
|
const stopInfoIndex = timetable.followingStops.findIndex((stop) => {
|
||||||
const stopNameLower = stop.stopNameRAW.toLocaleLowerCase();
|
return stationName.toLocaleLowerCase() == stop.stopNameRAW.toLocaleLowerCase();
|
||||||
|
|
||||||
return (
|
|
||||||
stationNameLower == stopNameLower ||
|
|
||||||
(!/(po\.|podg\.)/.test(stopNameLower) && stopNameLower.includes(stationNameLower)) ||
|
|
||||||
(!/(po\.|podg\.)/.test(stationNameLower) && stationNameLower.includes(stopNameLower)) ||
|
|
||||||
(stopNameLower.split(', podg.')[0] !== undefined &&
|
|
||||||
stationNameLower.startsWith(stopNameLower.split(', podg.')[0]))
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const checkpointScheduledTrains: ScheduledTrain[] = [];
|
const checkpointScheduledTrains: ScheduledTrain[] = [];
|
||||||
|
|
||||||
if (stopInfoIndex != -1) {
|
if (stopInfoIndex != -1) {
|
||||||
checkpointScheduledTrains.push(
|
checkpointScheduledTrains.push(getCheckpointTrain(train, stopInfoIndex, stationName));
|
||||||
getCheckpointTrain(train, stopInfoIndex, sceneryData.stationName)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stationGeneralInfo?.checkpoints?.forEach((checkpoint) => {
|
stationGeneralInfo?.checkpoints?.forEach((checkpoint) => {
|
||||||
// if (checkpoint.checkpointName.toLocaleLowerCase() == stationNameLower) return;
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
checkpointScheduledTrains.findIndex(
|
checkpointScheduledTrains.findIndex(
|
||||||
(cpTrain) =>
|
(cpTrain) =>
|
||||||
@@ -237,8 +225,7 @@ export function getScheduledTrains(
|
|||||||
(stop) => stop.stopNameRAW.toLowerCase() == checkpoint.checkpointName.toLowerCase()
|
(stop) => stop.stopNameRAW.toLowerCase() == checkpoint.checkpointName.toLowerCase()
|
||||||
);
|
);
|
||||||
|
|
||||||
if (index > -1)
|
if (index > -1) checkpointScheduledTrains.push(getCheckpointTrain(train, index, stationName));
|
||||||
checkpointScheduledTrains.push(getCheckpointTrain(train, index, sceneryData.stationName));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
acc.push(...checkpointScheduledTrains);
|
acc.push(...checkpointScheduledTrains);
|
||||||
@@ -250,14 +237,12 @@ export function getStationTrains(
|
|||||||
trainList: Train[],
|
trainList: Train[],
|
||||||
scheduledTrainList: ScheduledTrain[],
|
scheduledTrainList: ScheduledTrain[],
|
||||||
region: string,
|
region: string,
|
||||||
sceneryData: API.ActiveSceneries.Data
|
stationName: string
|
||||||
): StationTrain[] {
|
): StationTrain[] {
|
||||||
return trainList
|
return trainList
|
||||||
.filter(
|
.filter(
|
||||||
(train) =>
|
(train) =>
|
||||||
train?.region === region &&
|
train?.region === region && train.online && train.currentStationName === stationName
|
||||||
train.online &&
|
|
||||||
train.currentStationName === sceneryData.stationName
|
|
||||||
)
|
)
|
||||||
.map((train) => ({
|
.map((train) => ({
|
||||||
driverName: train.driverName,
|
driverName: train.driverName,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
export namespace Status {
|
export namespace Status {
|
||||||
export enum ActiveDispatcher {
|
export enum ActiveDispatcher {
|
||||||
|
FREE = -3,
|
||||||
INVALID = -2,
|
INVALID = -2,
|
||||||
UNKNOWN = -1,
|
UNKNOWN = -1,
|
||||||
NO_LIMIT = 0,
|
NO_LIMIT = 0,
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
onlineSceneryInfo() {
|
onlineSceneryInfo() {
|
||||||
return this.store.onlineSceneryList.find(
|
return this.store.activeSceneryList.find(
|
||||||
(scenery) =>
|
(scenery) =>
|
||||||
scenery.name === this.station?.toString().replace(/_/g, ' ') &&
|
scenery.name === this.station?.toString().replace(/_/g, ' ') &&
|
||||||
scenery.region == this.store.region.id
|
scenery.region == this.store.region.id
|
||||||
|
|||||||
Reference in New Issue
Block a user