mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
Optymalizacja i cleanup kodu
This commit is contained in:
@@ -2,125 +2,128 @@
|
||||
<div class="scenery-info">
|
||||
<div class="info-header">
|
||||
<div class="scenery-name">
|
||||
<div v-if="stationInfo.stationProject" style="color: salmon; font-size: 0.6em; line-height: 0.7em;">
|
||||
{{ stationInfo.stationProject }}
|
||||
<div v-if="station.generalInfo?.project" style="color: salmon; font-size: 0.6em; line-height: 0.7em;">
|
||||
{{ station.generalInfo.project }}
|
||||
</div>
|
||||
|
||||
<a v-if="stationInfo.stationURL" :href="stationInfo.stationURL" target="_blank" rel="noopener noreferrer">{{
|
||||
stationInfo.stationName
|
||||
<a v-if="station.generalInfo?.url" :href="station.generalInfo.url" target="_blank" rel="noopener noreferrer">{{
|
||||
station.name
|
||||
}}</a>
|
||||
|
||||
<span v-else>{{ stationInfo.stationName }}</span>
|
||||
<span v-else>{{ station.name }}</span>
|
||||
</div>
|
||||
<div class="scenery-hash" v-if="stationInfo.stationHash">#{{ stationInfo.stationHash }}</div>
|
||||
<div class="scenery-hash" v-if="station.onlineInfo?.hash">#{{ station.onlineInfo.hash }}</div>
|
||||
</div>
|
||||
|
||||
<section v-if="!timetableOnly">
|
||||
<div class="info-stats" :class="!stationInfo.stationHash ? 'no-stats' : ''">
|
||||
<div class="info-stats" :class="!station.onlineInfo ? 'no-stats' : ''">
|
||||
<span class="likes">
|
||||
<img :src="likeIcon" alt="icon-like" />
|
||||
<span>{{ stationInfo.dispatcherRate }}</span>
|
||||
<span>{{ station.onlineInfo?.dispatcherRate || '0' }}</span>
|
||||
</span>
|
||||
|
||||
<span class="users">
|
||||
<img :src="userIcon" alt="icon-user" />
|
||||
<span>{{ stationInfo.currentUsers }}</span>
|
||||
<span>{{ station.onlineInfo?.currentUsers || '0' }}</span>
|
||||
/
|
||||
<span>{{ stationInfo.maxUsers }}</span>
|
||||
<span>{{ station.onlineInfo?.maxUsers || '0' }}</span>
|
||||
</span>
|
||||
|
||||
<span class="spawns">
|
||||
<img :src="spawnIcon" alt="icon-spawn" />
|
||||
<span>{{ stationInfo.spawns.length }}</span>
|
||||
<span>{{ station.onlineInfo?.spawns.length || '0' }}</span>
|
||||
</span>
|
||||
|
||||
<span class="schedules">
|
||||
<img :src="timetableIcon" alt="icon-timetable" />
|
||||
<span>
|
||||
<span style="color: #eee">{{ stationInfo.scheduledTrains.length }}</span>
|
||||
<span style="color: #eee">{{ station.onlineInfo?.scheduledTrains?.length || '0' }}</span>
|
||||
/
|
||||
<span style="color: #bbb">{{
|
||||
stationInfo.scheduledTrains.filter((train) => train.stopInfo.confirmed).length
|
||||
}}</span>
|
||||
<span style="color: #bbb"
|
||||
>{{ station.onlineInfo?.scheduledTrains?.filter((train) => train.stopInfo.confirmed).length || '0' }}
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="info-brief">
|
||||
<img
|
||||
v-if="stationInfo.controlType"
|
||||
:src="require(`@/assets/icon-${stationInfo.controlType}.svg`)"
|
||||
:alt="stationInfo.controlType"
|
||||
:title="$t('desc.control-type') + $t(`controls.${stationInfo.controlType}`)"
|
||||
v-if="station.generalInfo?.controlType"
|
||||
:src="require(`@/assets/icon-${station.generalInfo.controlType}.svg`)"
|
||||
:alt="station.generalInfo.controlType"
|
||||
:title="$t('desc.control-type') + $t(`controls.${station.generalInfo.controlType}`)"
|
||||
/>
|
||||
|
||||
<img
|
||||
v-if="stationInfo.signalType"
|
||||
:src="require(`@/assets/icon-${stationInfo.signalType}.svg`)"
|
||||
:alt="stationInfo.signalType"
|
||||
:title="$t('desc.signals-type') + $t(`signals.${stationInfo.signalType}`)"
|
||||
v-if="station.generalInfo?.signalType"
|
||||
:src="require(`@/assets/icon-${station.generalInfo.signalType}.svg`)"
|
||||
:alt="station.generalInfo.signalType"
|
||||
:title="$t('desc.signals-type') + $t(`signals.${station.generalInfo.signalType}`)"
|
||||
/>
|
||||
|
||||
<img
|
||||
v-if="stationInfo.SBL && stationInfo.SBL !== ''"
|
||||
v-if="station.generalInfo && station.generalInfo.SBL !== ''"
|
||||
:src="SBLIcon"
|
||||
:alt="$t('desc.SBL') + `${stationInfo.SBL}`"
|
||||
:title="$t('desc.SBL') + `${stationInfo.SBL}`"
|
||||
:alt="$t('desc.SBL') + `${station.generalInfo.SBL}`"
|
||||
:title="$t('desc.SBL') + `${station.generalInfo.SBL}`"
|
||||
/>
|
||||
|
||||
<img
|
||||
v-if="stationInfo.TWB && stationInfo.TWB !== ''"
|
||||
v-if="station.generalInfo && station.generalInfo.TWB !== ''"
|
||||
:src="TWBIcon"
|
||||
alt="two way route blockade"
|
||||
:title="`${stationInfo.TWB === 'TAK' ? $t('desc.TWB-all') : $t('desc.TWB-routes') + stationInfo.TWB}`"
|
||||
:title="
|
||||
`${
|
||||
station.generalInfo.TWB === 'TAK' ? $t('desc.TWB-all') : $t('desc.TWB-routes') + station.generalInfo.TWB
|
||||
}`
|
||||
"
|
||||
/>
|
||||
|
||||
<img v-if="stationInfo.default" :src="td2Icon" alt="default scenery" :title="$t('desc.default')" />
|
||||
<img v-if="station.generalInfo?.default" :src="td2Icon" alt="default scenery" :title="$t('desc.default')" />
|
||||
|
||||
<img
|
||||
v-if="stationInfo.nonPublic || !stationInfo.reqLevel"
|
||||
v-if="station.generalInfo?.nonPublic || !station.generalInfo?.reqLevel"
|
||||
:src="lockIcon"
|
||||
alt="non public scenery"
|
||||
:title="$t('desc.non-public')"
|
||||
/>
|
||||
|
||||
<img
|
||||
v-if="stationInfo.unavailable"
|
||||
v-if="station.generalInfo?.unavailable"
|
||||
:src="unavailableIcon"
|
||||
alt="icon unavailable"
|
||||
:title="$t('desc.unavailable')"
|
||||
/>
|
||||
|
||||
<img
|
||||
v-if="stationInfo.stationLines && stationInfo.stationLines != ''"
|
||||
v-if="station.generalInfo && station.generalInfo.lines != ''"
|
||||
:src="realIcon"
|
||||
alt="real scenery"
|
||||
:title="`${$t('desc.real')} ${stationInfo.stationLines}`"
|
||||
:title="`${$t('desc.real')} ${station.generalInfo.lines}`"
|
||||
/>
|
||||
|
||||
<img
|
||||
v-if="stationInfo.reqLevel < 0"
|
||||
:src="unknownIcon"
|
||||
alt="icon-unknown"
|
||||
:title="$t('desc.unknown')"
|
||||
/>
|
||||
<img v-if="!station.generalInfo" :src="unknownIcon" alt="icon-unknown" :title="$t('desc.unknown')" />
|
||||
</div>
|
||||
|
||||
<div class="info-dispatcher">
|
||||
<div class="dispatcher" v-if="stationInfo.stationHash">
|
||||
<div class="dispatcher" v-if="station.onlineInfo">
|
||||
<span
|
||||
class="dispatcher_level"
|
||||
:style="calculateExpStyle(stationInfo.dispatcherExp, stationInfo.dispatcherIsSupporter)"
|
||||
:style="calculateExpStyle(station.onlineInfo.dispatcherExp, station.onlineInfo.dispatcherIsSupporter)"
|
||||
>
|
||||
{{ stationInfo.dispatcherExp > 1 ? stationInfo.dispatcherExp : 'L' }}
|
||||
{{ station.onlineInfo.dispatcherExp > 1 ? station.onlineInfo.dispatcherExp : 'L' }}
|
||||
</span>
|
||||
|
||||
<span class="dispatcher_name">{{ stationInfo.dispatcherName }}</span>
|
||||
<span class="dispatcher_name">{{ station.onlineInfo.dispatcherName }}</span>
|
||||
</div>
|
||||
|
||||
<span class="status-badge" :class="stationInfo.statusID">
|
||||
{{ $t(`status.${stationInfo.statusID}`) }}
|
||||
{{ stationInfo.statusID == 'online' ? stationInfo.statusTimeString : '' }}
|
||||
<span class="status-badge" v-if="station.onlineInfo" :class="station.onlineInfo.statusID">
|
||||
{{ $t(`status.${station.onlineInfo.statusID}`) }}
|
||||
{{ station.onlineInfo.statusID == 'online' ? station.onlineInfo.statusTimeString : '' }}
|
||||
</span>
|
||||
|
||||
<span class="status-badge free" v-else>
|
||||
{{ $t('status.free') }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -153,16 +156,18 @@
|
||||
<img :src="spawnIcon" alt="icon-spawn" />
|
||||
</h3>
|
||||
|
||||
<span
|
||||
class="spawn"
|
||||
v-for="(spawn, i) in stationInfo.spawns"
|
||||
:key="spawn.spawnName + stationInfo.dispatcherName + i"
|
||||
>
|
||||
<span class="spawn_name">{{ spawn.spawnName }}</span>
|
||||
<span class="spawn_length">{{ spawn.spawnLength }}m</span>
|
||||
<span v-if="station.onlineInfo">
|
||||
<span
|
||||
class="spawn"
|
||||
v-for="(spawn, i) in station.onlineInfo.spawns"
|
||||
:key="spawn.spawnName + station.onlineInfo?.dispatcherName + i"
|
||||
>
|
||||
<span class="spawn_name">{{ spawn.spawnName }}</span>
|
||||
<span class="spawn_length">{{ spawn.spawnLength }}m</span>
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<span class="spawn none" v-if="!stationInfo.spawns || stationInfo.spawns.length == 0"
|
||||
<span class="spawn none" v-if="!station.onlineInfo || station.onlineInfo.spawns.length == 0"
|
||||
>{{ $t('scenery.no-spawns') }}
|
||||
</span>
|
||||
</div>
|
||||
@@ -178,7 +183,7 @@ import { computed, defineComponent } from '@vue/runtime-core';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
stationInfo: {
|
||||
station: {
|
||||
type: Object as () => Station,
|
||||
default: {},
|
||||
},
|
||||
@@ -206,10 +211,14 @@ export default defineComponent({
|
||||
|
||||
setup(props) {
|
||||
const computedStationTrains = computed(() => {
|
||||
if (!props.stationInfo) return [];
|
||||
if (!props.station) return [];
|
||||
if (!props.station.onlineInfo) return [];
|
||||
if (!props.station.onlineInfo.stationTrains) return [];
|
||||
|
||||
return props.stationInfo.stationTrains.map((train) => {
|
||||
const scheduledTrainStatus = props.stationInfo?.scheduledTrains.find((st) => st.trainNo === train.trainNo);
|
||||
return props.station.onlineInfo.stationTrains.map((train) => {
|
||||
const scheduledTrainStatus = props.station.onlineInfo?.scheduledTrains?.find(
|
||||
(st) => st.trainNo === train.trainNo
|
||||
);
|
||||
|
||||
return {
|
||||
...train,
|
||||
|
||||
@@ -19,16 +19,15 @@
|
||||
<div
|
||||
class="checkpoints"
|
||||
v-if="
|
||||
stationInfo &&
|
||||
stationInfo.scheduledTrains.length > 0 &&
|
||||
stationInfo.checkpoints
|
||||
station &&
|
||||
station.generalInfo?.checkpoints
|
||||
"
|
||||
>
|
||||
<button
|
||||
v-for="cp in station.generalInfo.checkpoints"
|
||||
:key="cp.checkpointName"
|
||||
class="checkpoint_item btn--text"
|
||||
:class="{ current: selectedCheckpoint === cp.checkpointName }"
|
||||
v-for="cp in stationInfo.checkpoints"
|
||||
:key="cp.checkpointName"
|
||||
@click="selectCheckpoint(cp)"
|
||||
>
|
||||
{{ cp.checkpointName }}
|
||||
@@ -144,7 +143,7 @@ export default defineComponent({
|
||||
components: { SelectBox },
|
||||
|
||||
props: {
|
||||
stationInfo: {
|
||||
station: {
|
||||
type: Object as () => Station,
|
||||
},
|
||||
timetableOnly: {
|
||||
@@ -167,18 +166,18 @@ export default defineComponent({
|
||||
const selectedCheckpoint = ref("");
|
||||
|
||||
const computedScheduledTrains = computed(() => {
|
||||
if (!props.stationInfo) return [];
|
||||
if (!props.station) return [];
|
||||
|
||||
let scheduledTrains =
|
||||
props.stationInfo.checkpoints?.find(
|
||||
props.station.generalInfo?.checkpoints.find(
|
||||
(cp) => cp.checkpointName === selectedCheckpoint.value
|
||||
)?.scheduledTrains || props.stationInfo.scheduledTrains;
|
||||
)?.scheduledTrains || props.station.onlineInfo?.scheduledTrains || [];
|
||||
|
||||
// if (props.stationInfo.checkpoints)
|
||||
// scheduledTrains = props.stationInfo.checkpoints.find(
|
||||
// if (props.station.checkpoints)
|
||||
// scheduledTrains = props.station.checkpoints.find(
|
||||
// (cp) => cp.checkpointName === selectedCheckpoint.value
|
||||
// )?.scheduledTrains;
|
||||
// else scheduledTrains = props.stationInfo.scheduledTrains;
|
||||
// else scheduledTrains = props.station.scheduledTrains;
|
||||
|
||||
return (
|
||||
scheduledTrains?.sort((a, b) => {
|
||||
@@ -206,11 +205,14 @@ export default defineComponent({
|
||||
|
||||
methods: {
|
||||
loadSelectedOption() {
|
||||
if (!this.stationInfo) return;
|
||||
if (this.stationInfo.checkpoints.length == 0) return;
|
||||
if (!this.station) return;
|
||||
if(!this.station.generalInfo) return;
|
||||
if(!this.station.generalInfo.checkpoints) return;
|
||||
if (this.station.generalInfo.checkpoints.length == 0) return;
|
||||
|
||||
if (this.selectedCheckpoint != "") return;
|
||||
|
||||
this.selectedCheckpoint = this.stationInfo.checkpoints[0].checkpointName;
|
||||
this.selectedCheckpoint = this.station.generalInfo.checkpoints[0].checkpointName;
|
||||
},
|
||||
|
||||
selectCheckpoint(cp: { checkpointName: string }) {
|
||||
|
||||
@@ -36,149 +36,157 @@
|
||||
<tr
|
||||
class="station"
|
||||
v-for="(station, i) in stations"
|
||||
:key="i + station.stationHash"
|
||||
@click="() => setScenery(station.stationName)"
|
||||
:key="i + station.name"
|
||||
@click="() => setScenery(station.name)"
|
||||
>
|
||||
<td
|
||||
class="station_name"
|
||||
:class="{
|
||||
'default-station': station.default,
|
||||
online: station.online,
|
||||
'station-unavailable': station.unavailable,
|
||||
'default-station': station.generalInfo?.default,
|
||||
online: station.onlineInfo,
|
||||
'station-unavailable': station.generalInfo?.unavailable,
|
||||
}"
|
||||
>
|
||||
<b v-if="station.stationProject" style="color: salmon;">{{ station.stationProject }}</b>
|
||||
{{ station.stationName }}
|
||||
<b v-if="station.generalInfo?.project" style="color: salmon;">{{ station.generalInfo.project }}</b>
|
||||
{{ station.name }}
|
||||
</td>
|
||||
|
||||
<td class="station_level">
|
||||
<span :style="calculateExpStyle(station.reqLevel, station.supportersOnly)">
|
||||
{{ station.reqLevel > -1 ? (station.reqLevel >= 2 ? station.reqLevel : 'L') : '?' }}
|
||||
<td class="station_level" >
|
||||
<span v-if="station.generalInfo">
|
||||
<span :style="calculateExpStyle(station.generalInfo.reqLevel, station.generalInfo.supportersOnly)">
|
||||
{{ station.generalInfo.reqLevel > -1 ? (station.generalInfo.reqLevel >= 2 ? station.generalInfo.reqLevel : 'L') : '?' }}
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<span v-else>?</span>
|
||||
</td>
|
||||
|
||||
<td class="station_status">
|
||||
<span class="status-badge" :class="station.statusID">
|
||||
{{ $t(`status.${station.statusID}`) }}
|
||||
{{ station.statusID == 'online' ? station.statusTimeString : '' }}
|
||||
<td class="station_status" >
|
||||
<span class="status-badge" :class="station.onlineInfo.statusID" v-if="station.onlineInfo">
|
||||
{{ $t(`status.${station.onlineInfo.statusID}`) }}
|
||||
{{ station.onlineInfo.statusID == 'online' ? station.onlineInfo.statusTimeString : '' }}
|
||||
</span>
|
||||
|
||||
<span class="status-badge free" v-else>
|
||||
{{ $t('status.free') }}
|
||||
</span>
|
||||
</td>
|
||||
|
||||
<td class="station_dispatcher-name">
|
||||
{{ station.online ? station.dispatcherName : '' }}
|
||||
{{ station.onlineInfo ? station.onlineInfo.dispatcherName : '' }}
|
||||
</td>
|
||||
|
||||
<td class="station_dispatcher-exp">
|
||||
<span
|
||||
v-if="station.online"
|
||||
:style="calculateExpStyle(station.dispatcherExp, station.dispatcherIsSupporter)"
|
||||
v-if="station.onlineInfo"
|
||||
:style="calculateExpStyle(station.onlineInfo.dispatcherExp, station.onlineInfo.dispatcherIsSupporter)"
|
||||
>
|
||||
{{ 2 > station.dispatcherExp ? 'L' : station.dispatcherExp }}
|
||||
{{ 2 > station.onlineInfo.dispatcherExp ? 'L' : station.onlineInfo.dispatcherExp }}
|
||||
</span>
|
||||
</td>
|
||||
|
||||
<td class="station_tracks twoway">
|
||||
<span
|
||||
v-if="station.routes && station.routes.twoWay.catenary > 0"
|
||||
v-if="station.generalInfo && station.generalInfo.routes.twoWay.catenary > 0"
|
||||
class="track catenary"
|
||||
:title="`Liczba zelektryfikowanych szlaków dwutorowych: ${station.routes.twoWay.catenary}`"
|
||||
:title="`Liczba zelektryfikowanych szlaków dwutorowych: ${station.generalInfo.routes.twoWay.catenary}`"
|
||||
>
|
||||
{{ station.routes.twoWay.catenary }}
|
||||
{{ station.generalInfo.routes.twoWay.catenary }}
|
||||
</span>
|
||||
|
||||
<span
|
||||
v-if="station.routes && station.routes.twoWay.noCatenary > 0"
|
||||
v-if="station.generalInfo && station.generalInfo.routes.twoWay.noCatenary > 0"
|
||||
class="track no-catenary"
|
||||
:title="`Liczba niezelektryfikowanych szlaków dwutorowych: ${station.routes.twoWay.noCatenary}`"
|
||||
:title="`Liczba niezelektryfikowanych szlaków dwutorowych: ${station.generalInfo.routes.twoWay.noCatenary}`"
|
||||
>
|
||||
{{ station.routes.twoWay.noCatenary }}
|
||||
{{ station.generalInfo.routes.twoWay.noCatenary }}
|
||||
</span>
|
||||
|
||||
<span class="separator"></span>
|
||||
|
||||
<span
|
||||
v-if="station.routes && station.routes.oneWay.catenary > 0"
|
||||
v-if="station.generalInfo && station.generalInfo.routes.oneWay.catenary > 0"
|
||||
class="track catenary"
|
||||
:title="`Liczba zelektryfikowanych szlaków jednotorowych: ${station.routes.oneWay.catenary}`"
|
||||
:title="`Liczba zelektryfikowanych szlaków jednotorowych: ${station.generalInfo.routes.oneWay.catenary}`"
|
||||
>
|
||||
{{ station.routes.oneWay.catenary }}
|
||||
{{ station.generalInfo.routes.oneWay.catenary }}
|
||||
</span>
|
||||
|
||||
<span
|
||||
v-if="station.routes && station.routes.oneWay.noCatenary > 0"
|
||||
v-if="station.generalInfo && station.generalInfo.routes.oneWay.noCatenary > 0"
|
||||
class="track no-catenary"
|
||||
:title="`Liczba niezelektryfikowanych szlaków jednotorowych: ${station.routes.oneWay.noCatenary}`"
|
||||
:title="`Liczba niezelektryfikowanych szlaków jednotorowych: ${station.generalInfo.routes.oneWay.noCatenary}`"
|
||||
>
|
||||
{{ station.routes.oneWay.noCatenary }}
|
||||
{{ station.generalInfo.routes.oneWay.noCatenary }}
|
||||
</span>
|
||||
</td>
|
||||
|
||||
<td class="station_info">
|
||||
<img
|
||||
class="icon-info"
|
||||
v-if="station.controlType"
|
||||
:src="require(`@/assets/icon-${station.controlType}.svg`)"
|
||||
:alt="station.controlType"
|
||||
:title="$t('desc.control-type') + $t(`controls.${station.controlType}`)"
|
||||
v-if="station.generalInfo?.controlType"
|
||||
:src="require(`@/assets/icon-${station.generalInfo.controlType}.svg`)"
|
||||
:alt="station.generalInfo.controlType"
|
||||
:title="$t('desc.control-type') + $t(`controls.${station.generalInfo.controlType}`)"
|
||||
/>
|
||||
|
||||
<img
|
||||
class="icon-info"
|
||||
v-if="station.signalType"
|
||||
:src="require(`@/assets/icon-${station.signalType}.svg`)"
|
||||
:alt="station.signalType"
|
||||
:title="$t('desc.signals-type') + $t(`signals.${station.signalType}`)"
|
||||
v-if="station.generalInfo?.signalType"
|
||||
:src="require(`@/assets/icon-${station.generalInfo.signalType}.svg`)"
|
||||
:alt="station.generalInfo.signalType"
|
||||
:title="$t('desc.signals-type') + $t(`signals.${station.generalInfo.signalType}`)"
|
||||
/>
|
||||
|
||||
<img
|
||||
v-if="station.SBL && station.SBL !== ''"
|
||||
v-if="station.generalInfo?.SBL && station.generalInfo?.SBL !== ''"
|
||||
:src="SBLIcon"
|
||||
alt="SBL"
|
||||
:title="$t('desc.SBL') + `${station.SBL}`"
|
||||
:title="$t('desc.SBL') + `${station.generalInfo.SBL}`"
|
||||
/>
|
||||
|
||||
<img
|
||||
v-if="station.nonPublic && station.reqLevel > -1"
|
||||
v-if="station.generalInfo?.nonPublic && station.generalInfo?.reqLevel > -1"
|
||||
:src="lockIcon"
|
||||
alt="non-public"
|
||||
:title="$t('desc.non-public')"
|
||||
/>
|
||||
|
||||
<img
|
||||
v-if="station.unavailable"
|
||||
v-if="station.generalInfo?.unavailable"
|
||||
:src="unavailableIcon"
|
||||
alt="icon-unavailable"
|
||||
:title="$t('desc.unavailable')"
|
||||
/>
|
||||
|
||||
<img
|
||||
v-if="station.reqLevel < 0"
|
||||
v-if="!station.generalInfo"
|
||||
:src="unknownIcon"
|
||||
alt="icon-unknown"
|
||||
:title="$t('desc.unknown')"
|
||||
/>
|
||||
</td>
|
||||
|
||||
<td class="station_users" :class="{ inactive: !station.online }">
|
||||
<td class="station_users" :class="{ inactive: !station.onlineInfo }">
|
||||
<span>
|
||||
<span class="highlight">{{ station.currentUsers }}</span>
|
||||
<span class="highlight">{{ station.onlineInfo?.currentUsers || "0" }}</span>
|
||||
/
|
||||
<span>{{ station.maxUsers }}</span>
|
||||
<span>{{ station.onlineInfo?.maxUsers || "0" }}</span>
|
||||
</span>
|
||||
</td>
|
||||
|
||||
<td class="station_spawns" :class="{ inactive: !station.online }">
|
||||
<span class="highlight">{{ station.spawns.length }}</span>
|
||||
<td class="station_spawns" :class="{ inactive: !station.onlineInfo }">
|
||||
<span class="highlight">{{ station.onlineInfo?.spawns.length || "0" }}</span>
|
||||
</td>
|
||||
|
||||
<td class="station_schedules" :class="{ inactive: !station.online }">
|
||||
<td class="station_schedules" :class="{ inactive: !station.onlineInfo }">
|
||||
<span>
|
||||
<span class="highlight">
|
||||
{{ station.scheduledTrains.length }}
|
||||
{{ station.onlineInfo?.scheduledTrains?.length || "0" }}
|
||||
</span>
|
||||
/
|
||||
<span style="color: #bbb">
|
||||
{{ station.scheduledTrains.filter((train) => train.stopInfo.confirmed).length }}
|
||||
{{ station.onlineInfo?.scheduledTrains?.filter((train) => train.stopInfo.confirmed).length || "0" }}
|
||||
</span>
|
||||
</span>
|
||||
</td>
|
||||
@@ -259,13 +267,13 @@ export default defineComponent({
|
||||
|
||||
methods: {
|
||||
setScenery(name: string) {
|
||||
const station = this.stations.find((station) => station.stationName === name);
|
||||
const station = this.stations.find((station) => station.name === name);
|
||||
|
||||
if (!station) return;
|
||||
|
||||
this.$router.push({
|
||||
name: 'SceneryView',
|
||||
query: { station: station.stationName.replaceAll(' ', '_') },
|
||||
query: { station: station.name.replaceAll(' ', '_') },
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,57 +1,96 @@
|
||||
import ScheduledTrain from "./ScheduledTrain";
|
||||
|
||||
export default interface Station {
|
||||
stationName: string;
|
||||
stationHash: string;
|
||||
stationURL: string;
|
||||
name: string;
|
||||
|
||||
maxUsers: number;
|
||||
currentUsers: number;
|
||||
generalInfo?: {
|
||||
name: string;
|
||||
url: string;
|
||||
|
||||
spawns: { spawnName: string; spawnLength: number }[];
|
||||
reqLevel: number;
|
||||
supportersOnly: boolean;
|
||||
|
||||
dispatcherRate: number;
|
||||
dispatcherName: string;
|
||||
dispatcherExp: number;
|
||||
dispatcherId: number;
|
||||
dispatcherIsSupporter: boolean;
|
||||
lines: string;
|
||||
project: string;
|
||||
|
||||
stationLines: string;
|
||||
stationProject: string;
|
||||
SBL: string;
|
||||
TWB: string;
|
||||
signalType: string;
|
||||
controlType: string;
|
||||
|
||||
reqLevel: number;
|
||||
supportersOnly: boolean;
|
||||
default: boolean;
|
||||
nonPublic: boolean;
|
||||
unavailable: boolean;
|
||||
|
||||
SBL: string;
|
||||
TWB: string;
|
||||
signalType: string;
|
||||
controlType: string;
|
||||
routes: {
|
||||
oneWay: { catenary: number; noCatenary: number };
|
||||
twoWay: { catenary: number; noCatenary: number };
|
||||
};
|
||||
|
||||
default: boolean;
|
||||
nonPublic: boolean;
|
||||
unavailable: boolean;
|
||||
|
||||
routes: {
|
||||
oneWay: { catenary: number; noCatenary: number };
|
||||
twoWay: { catenary: number; noCatenary: number };
|
||||
checkpoints: {
|
||||
checkpointName: string;
|
||||
scheduledTrains: ScheduledTrain[];
|
||||
}[];
|
||||
};
|
||||
|
||||
onlineInfo?: {
|
||||
hash: string;
|
||||
name: string;
|
||||
|
||||
checkpoints: {
|
||||
checkpointName: string;
|
||||
scheduledTrains: ScheduledTrain[];
|
||||
}[];
|
||||
maxUsers: number;
|
||||
currentUsers: number;
|
||||
|
||||
spawns: { spawnName: string; spawnLength: number }[];
|
||||
dispatcherRate: number;
|
||||
dispatcherName: string;
|
||||
dispatcherExp: number;
|
||||
dispatcherId: number;
|
||||
dispatcherIsSupporter: boolean;
|
||||
|
||||
statusTimestamp: number;
|
||||
statusTimeString: string;
|
||||
statusID: string;
|
||||
|
||||
stationTrains?: {
|
||||
driverName: string;
|
||||
trainNo: number;
|
||||
stopStatus?: string;
|
||||
}[];
|
||||
|
||||
scheduledTrains?: ScheduledTrain[];
|
||||
}
|
||||
|
||||
// stationName: string;
|
||||
// stationHash: string;
|
||||
// stationURL: string;
|
||||
|
||||
// maxUsers: number;
|
||||
// currentUsers: number;
|
||||
|
||||
|
||||
online: boolean;
|
||||
statusTimestamp: number;
|
||||
statusTimeString: string;
|
||||
statusID: string;
|
||||
// stationLines: string;
|
||||
// stationProject: string;
|
||||
|
||||
stationTrains: {
|
||||
driverName: number;
|
||||
trainNo: number;
|
||||
stopStatus?: string;
|
||||
}[];
|
||||
// reqLevel: number;
|
||||
// supportersOnly: boolean;
|
||||
|
||||
// SBL: string;
|
||||
// TWB: string;
|
||||
// signalType: string;
|
||||
// controlType: string;
|
||||
|
||||
// default: boolean;
|
||||
// nonPublic: boolean;
|
||||
// unavailable: boolean;
|
||||
|
||||
// routes: {
|
||||
// oneWay: { catenary: number; noCatenary: number };
|
||||
// twoWay: { catenary: number; noCatenary: number };
|
||||
// };
|
||||
|
||||
// checkpoints: {
|
||||
// checkpointName: string;
|
||||
// scheduledTrains: ScheduledTrain[];
|
||||
// }[];
|
||||
|
||||
scheduledTrains: ScheduledTrain[];
|
||||
}
|
||||
|
||||
@@ -5,48 +5,48 @@ import StorageManager from './storageManager';
|
||||
const sortStations = (a: Station, b: Station, sorter: { index: number; dir: number }) => {
|
||||
switch (sorter.index) {
|
||||
case 1:
|
||||
if (a.reqLevel > b.reqLevel) return sorter.dir;
|
||||
if (a.reqLevel < b.reqLevel) return -sorter.dir;
|
||||
if ((a.generalInfo?.reqLevel || -1 ) > (b.generalInfo?.reqLevel || -1)) return sorter.dir;
|
||||
if ((a.generalInfo?.reqLevel || -1) < (b.generalInfo?.reqLevel || -1)) return -sorter.dir;
|
||||
|
||||
break;
|
||||
case 2:
|
||||
if (a.statusTimestamp > b.statusTimestamp) return sorter.dir;
|
||||
if (a.statusTimestamp < b.statusTimestamp) return -sorter.dir;
|
||||
if ((a.onlineInfo?.statusTimestamp || 0) > (b.onlineInfo?.statusTimestamp || 0)) return sorter.dir;
|
||||
if ((a.onlineInfo?.statusTimestamp || 0) < (b.onlineInfo?.statusTimestamp || 0)) return -sorter.dir;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if (a.dispatcherName.toLowerCase() > b.dispatcherName.toLowerCase()) return sorter.dir;
|
||||
if (a.dispatcherName.toLowerCase() < b.dispatcherName.toLowerCase()) return -sorter.dir;
|
||||
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 4:
|
||||
if (a.dispatcherExp > b.dispatcherExp) return sorter.dir;
|
||||
if (a.dispatcherExp < b.dispatcherExp) return -sorter.dir;
|
||||
if ((a.onlineInfo?.dispatcherExp || 0) > (b.onlineInfo?.dispatcherExp || 0)) return sorter.dir;
|
||||
if ((a.onlineInfo?.dispatcherExp || 0) < (b.onlineInfo?.dispatcherExp || 0)) return -sorter.dir;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
if (a.currentUsers > b.currentUsers) return sorter.dir;
|
||||
if (a.currentUsers < b.currentUsers) return -sorter.dir;
|
||||
if ((a.onlineInfo?.currentUsers || 0) > (b.onlineInfo?.currentUsers || 0)) return sorter.dir;
|
||||
if ((a.onlineInfo?.currentUsers || 0) < (b.onlineInfo?.currentUsers || 0)) return -sorter.dir;
|
||||
|
||||
if (a.maxUsers > b.maxUsers) return sorter.dir;
|
||||
if (a.maxUsers < b.maxUsers) return -sorter.dir;
|
||||
if ((a.onlineInfo?.maxUsers || 0) > (b.onlineInfo?.maxUsers || 0)) return sorter.dir;
|
||||
if ((a.onlineInfo?.maxUsers || 0) < (b.onlineInfo?.maxUsers || 0)) return -sorter.dir;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
if (a.spawns > b.spawns) return sorter.dir;
|
||||
if (a.spawns < b.spawns) return -sorter.dir;
|
||||
if ((a.onlineInfo?.spawns.length || 0) > (b.onlineInfo?.spawns.length || 0)) return sorter.dir;
|
||||
if ((a.onlineInfo?.spawns.length || 0) < (b.onlineInfo?.spawns.length || 0)) return -sorter.dir;
|
||||
|
||||
break;
|
||||
|
||||
case 9:
|
||||
if (a.scheduledTrains.length > b.scheduledTrains.length) return sorter.dir;
|
||||
if (a.scheduledTrains.length < b.scheduledTrains.length) return -sorter.dir;
|
||||
if ((a.onlineInfo?.scheduledTrains?.length || 0) > (b.onlineInfo?.scheduledTrains?.length || 0)) return sorter.dir;
|
||||
if ((a.onlineInfo?.scheduledTrains?.length || 0) < (b.onlineInfo?.scheduledTrains?.length || 0)) return -sorter.dir;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (a.stationName.toLowerCase() >= b.stationName.toLowerCase()) return sorter.dir;
|
||||
if (a.name.toLowerCase() >= b.name.toLowerCase()) return sorter.dir;
|
||||
|
||||
return -sorter.dir;
|
||||
}
|
||||
@@ -54,61 +54,63 @@ const sortStations = (a: Station, b: Station, sorter: { index: number; dir: numb
|
||||
const filterStations = (station: Station, filters: Filter) => {
|
||||
const returnMode = false;
|
||||
|
||||
if ((station.nonPublic || !station.reqLevel) && filters['nonPublic']) return returnMode;
|
||||
if ((station.generalInfo?.nonPublic || !station.generalInfo) && filters['nonPublic']) return returnMode;
|
||||
|
||||
if (station.online && station.statusID == 'ending' && filters['ending']) return returnMode;
|
||||
if (station.onlineInfo?.statusID == 'ending' && filters['ending']) return returnMode;
|
||||
|
||||
if (station.online
|
||||
&& station.statusTimestamp > 0
|
||||
if (station.onlineInfo
|
||||
&& station.onlineInfo.statusTimestamp > 0
|
||||
&& filters['onlineFromHours'] < 8
|
||||
&& station.statusTimestamp <= Date.now() + filters['onlineFromHours'] * 3600000)
|
||||
&& station.onlineInfo.statusTimestamp <= Date.now() + filters['onlineFromHours'] * 3600000)
|
||||
return returnMode;
|
||||
|
||||
if (filters['onlineFromHours'] > 0 && station.statusTimestamp <= 0) return returnMode;
|
||||
if (filters['onlineFromHours'] == 8 && station.statusID != 'no-limit') return returnMode;
|
||||
if (filters['onlineFromHours'] > 0 && station.onlineInfo && station.onlineInfo.statusTimestamp <= 0) return returnMode;
|
||||
if (filters['onlineFromHours'] == 8 && station.onlineInfo?.statusID != 'no-limit') return returnMode;
|
||||
|
||||
if (station.statusID == 'ending' && filters['endingStatus']) return returnMode;
|
||||
if ((station.statusID == 'not-signed' || station.statusID == 'unavailable') && filters['unavailableStatus']) return returnMode;
|
||||
if (station.statusID == 'brb' && filters['afkStatus']) return returnMode;
|
||||
if (station.statusID == 'no-space' && filters['noSpaceStatus']) return returnMode;
|
||||
if (station.onlineInfo?.statusID == 'ending' && filters['endingStatus']) return returnMode;
|
||||
if ((station.onlineInfo?.statusID == 'not-signed' || station.onlineInfo?.statusID == 'unavailable') && filters['unavailableStatus']) return returnMode;
|
||||
if (station.onlineInfo?.statusID == 'brb' && filters['afkStatus']) return returnMode;
|
||||
if (station.onlineInfo?.statusID == 'no-space' && filters['noSpaceStatus']) return returnMode;
|
||||
|
||||
if (station.online && filters['occupied']) return returnMode;
|
||||
if (!station.online && filters['free']) return returnMode;
|
||||
if (station.unavailable && filters['unavailable']) return returnMode;
|
||||
if (station.onlineInfo && filters['occupied']) return returnMode;
|
||||
if (!station.onlineInfo && filters['free']) return returnMode;
|
||||
if (station.generalInfo?.unavailable && filters['unavailable']) return returnMode;
|
||||
|
||||
if (station.default && filters['default']) return returnMode;
|
||||
if (!station.default && filters['notDefault']) return returnMode;
|
||||
if (station.generalInfo) {
|
||||
if (station.generalInfo.default && filters['default']) return returnMode;
|
||||
if (!station.generalInfo.default && filters['notDefault']) return returnMode;
|
||||
|
||||
if (filters['real'] && station.stationLines != '') return returnMode;
|
||||
if (filters['fictional'] && station.stationLines == '') return returnMode;
|
||||
if (filters['real'] && station.generalInfo.lines != '') return returnMode;
|
||||
if (filters['fictional'] && station.generalInfo.lines == '') return returnMode;
|
||||
|
||||
if (station.reqLevel == -1) return true;
|
||||
if (station.reqLevel < filters['minLevel']) return returnMode;
|
||||
if (station.reqLevel > filters['maxLevel']) return returnMode;
|
||||
if (station.generalInfo.reqLevel == -1) return true;
|
||||
if (station.generalInfo.reqLevel < filters['minLevel']) return returnMode;
|
||||
if (station.generalInfo.reqLevel > filters['maxLevel']) return returnMode;
|
||||
|
||||
if (filters['no-1track'] && (station.routes.oneWay.catenary != 0 || station.routes.oneWay.noCatenary != 0)) return returnMode;
|
||||
if (filters['no-2track'] && (station.routes.twoWay.catenary != 0 || station.routes.twoWay.noCatenary != 0)) return returnMode;
|
||||
if (filters['no-1track'] && (station.generalInfo.routes.oneWay.catenary != 0 || station.generalInfo.routes.oneWay.noCatenary != 0)) return returnMode;
|
||||
if (filters['no-2track'] && (station.generalInfo.routes.twoWay.catenary != 0 || station.generalInfo.routes.twoWay.noCatenary != 0)) return returnMode;
|
||||
|
||||
if (station.routes.oneWay.catenary < filters['minOneWayCatenary']) return returnMode;
|
||||
if (station.routes.oneWay.noCatenary < filters['minOneWay']) return returnMode;
|
||||
if (station.generalInfo.routes.oneWay.catenary < filters['minOneWayCatenary']) return returnMode;
|
||||
if (station.generalInfo.routes.oneWay.noCatenary < filters['minOneWay']) return returnMode;
|
||||
|
||||
if (station.routes.twoWay.catenary < filters['minTwoWayCatenary']) return returnMode;
|
||||
if (station.routes.twoWay.noCatenary < filters['minTwoWay']) return returnMode;
|
||||
if (station.generalInfo.routes.twoWay.catenary < filters['minTwoWayCatenary']) return returnMode;
|
||||
if (station.generalInfo.routes.twoWay.noCatenary < filters['minTwoWay']) return returnMode;
|
||||
|
||||
if (filters[station.controlType]) return returnMode;
|
||||
if (filters[station.signalType]) return returnMode;
|
||||
if (filters[station.generalInfo.controlType]) return returnMode;
|
||||
if (filters[station.generalInfo.signalType]) return returnMode;
|
||||
|
||||
if (filters['SPK'] && (station.controlType === 'SPK' || station.controlType.includes('+SPK'))) return returnMode;
|
||||
if (filters['SCS'] && (station.controlType === 'SCS' || station.controlType.includes('+SCS'))) return returnMode;
|
||||
if (filters['SPE'] && (station.controlType === 'SPE' || station.controlType.includes('+SPE'))) return returnMode;
|
||||
if (filters['SPK'] && (station.generalInfo.controlType === 'SPK' || station.generalInfo.controlType.includes('+SPK'))) return returnMode;
|
||||
if (filters['SCS'] && (station.generalInfo.controlType === 'SCS' || station.generalInfo.controlType.includes('+SCS'))) return returnMode;
|
||||
if (filters['SPE'] && (station.generalInfo.controlType === 'SPE' || station.generalInfo.controlType.includes('+SPE'))) return returnMode;
|
||||
|
||||
if (filters['SCS'] && filters['SPK'] && (station.controlType.includes('SPK') || station.controlType.includes('SCS'))) return returnMode;
|
||||
if (filters['SCS'] && filters['SPK'] && (station.generalInfo.controlType.includes('SPK') || station.generalInfo.controlType.includes('SCS'))) return returnMode;
|
||||
|
||||
if (filters['mechaniczne'] && station.controlType.includes('mechaniczne')) return returnMode;
|
||||
if (filters['mechaniczne'] && station.generalInfo.controlType.includes('mechaniczne')) return returnMode;
|
||||
|
||||
if (filters['ręczne'] && station.controlType.includes('ręczne')) return returnMode;
|
||||
if (filters['ręczne'] && station.generalInfo.controlType.includes('ręczne')) return returnMode;
|
||||
|
||||
if (filters['SBL'] && station.SBL) return returnMode;
|
||||
if (filters['SBL'] && station.generalInfo.SBL) return returnMode;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -87,23 +87,23 @@ export const getTrainStopStatus = (stopInfo: TrainStop, timetableData: { current
|
||||
stopStatus = "terminated";
|
||||
stopLabel = "Skończył bieg";
|
||||
stopStatusID = 5;
|
||||
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && timetableData.currentStationName == station.stationName) {
|
||||
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && timetableData.currentStationName == station.name) {
|
||||
stopStatus = "departed";
|
||||
stopLabel = "Odprawiony";
|
||||
stopStatusID = 2;
|
||||
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && timetableData.currentStationName != station.stationName) {
|
||||
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && timetableData.currentStationName != station.name) {
|
||||
stopStatus = "departed-away";
|
||||
stopLabel = "Odjechał";
|
||||
stopStatusID = 4;
|
||||
} else if (timetableData.currentStationName == station.stationName && !stopInfo.stopped) {
|
||||
} else if (timetableData.currentStationName == station.name && !stopInfo.stopped) {
|
||||
stopStatus = "online";
|
||||
stopLabel = "Na stacji";
|
||||
stopStatusID = 0;
|
||||
} else if (timetableData.currentStationName == station.stationName && stopInfo.stopped) {
|
||||
} else if (timetableData.currentStationName == station.name && stopInfo.stopped) {
|
||||
stopStatus = "stopped";
|
||||
stopLabel = "Postój";
|
||||
stopStatusID = 1;
|
||||
} else if (timetableData.currentStationName != station.stationName) {
|
||||
} else if (timetableData.currentStationName != station.name) {
|
||||
stopStatus = "arriving";
|
||||
stopLabel = "W drodze";
|
||||
stopStatusID = 3;
|
||||
|
||||
+103
-110
@@ -24,6 +24,7 @@ import { DataStatus } from "@/scripts/enums/DataStatus";
|
||||
import { getLocoURL, getStatusID, getStatusTimestamp, getTimestamp, getTrainStopStatus, parseSpawns, timestampToString } from "@/scripts/utils/storeUtils";
|
||||
import { URLs } from '@/scripts/utils/apiURLs';
|
||||
import StorageManager from '@/scripts/managers/storageManager';
|
||||
import ScheduledTrain from '@/scripts/interfaces/ScheduledTrain';
|
||||
|
||||
export interface State {
|
||||
stationList: Station[],
|
||||
@@ -42,27 +43,31 @@ export interface State {
|
||||
listenerLaunched: boolean;
|
||||
}
|
||||
|
||||
interface SceneryData {
|
||||
id: number;
|
||||
name: string;
|
||||
url: string;
|
||||
project_lines: string;
|
||||
project_name: string;
|
||||
req_level?: number;
|
||||
supporters_only: boolean;
|
||||
signal_type: string;
|
||||
control_type: string;
|
||||
sbl_routes: string;
|
||||
twb_routes: string;
|
||||
track_oneway_e: number;
|
||||
track_oneway_ne: number;
|
||||
track_twoway_e: number;
|
||||
track_twoway_ne: number;
|
||||
checkpoints?: string;
|
||||
is_default: boolean;
|
||||
is_nonpublic: boolean;
|
||||
is_unavailable: boolean;
|
||||
}
|
||||
|
||||
// interface SceneryData {
|
||||
// id: number;
|
||||
// name: string;
|
||||
// url: string;
|
||||
// project_lines: string;
|
||||
// project_name: string;
|
||||
// req_level?: number;
|
||||
// supporters_only: boolean;
|
||||
// signal_type: string;
|
||||
// control_type: string;
|
||||
// sbl_routes: string;
|
||||
// twb_routes: string;
|
||||
// track_oneway_e: number;
|
||||
// track_oneway_ne: number;
|
||||
// track_twoway_e: number;
|
||||
// track_twoway_ne: number;
|
||||
// checkpoints?: string;
|
||||
// is_default: boolean;
|
||||
// is_nonpublic: boolean;
|
||||
// is_unavailable: boolean;
|
||||
// }
|
||||
type StationJSONData = [string, string, string, string, string, string, string, string, string, string, number, number, number, number, string | null, boolean, boolean, boolean];
|
||||
|
||||
// const initStationData = (initData: any[][])
|
||||
|
||||
export const key: InjectionKey<Store<State>> = Symbol()
|
||||
|
||||
@@ -109,7 +114,7 @@ export const store = createStore<State>({
|
||||
if (state.listenerLaunched) return;
|
||||
|
||||
const queryDate = new Date();
|
||||
|
||||
|
||||
const nextRefreshDate = new Date();
|
||||
|
||||
if (queryDate.getHours() < 8)
|
||||
@@ -128,8 +133,7 @@ export const store = createStore<State>({
|
||||
sceneryDataQuery += "?time=" + queryDate.getTime();
|
||||
}
|
||||
|
||||
const sceneryData = await (await axios.get(sceneryDataQuery)).data;
|
||||
// const sceneryData = await (await axios.get(sceneryDataQuery)).data;
|
||||
const sceneryData: StationJSONData = await (await axios.get(sceneryDataQuery)).data;
|
||||
|
||||
commit(MUTATIONS.SET_SCENERY_DATA, sceneryData);
|
||||
commit(MUTATIONS.SET_SCENERY_DATA_STATUS, DataStatus.Loaded);
|
||||
@@ -152,7 +156,7 @@ export const store = createStore<State>({
|
||||
const onlineDispatchersData: string[][] = await response[2].data.message;
|
||||
|
||||
|
||||
const updatedStationList = onlineStationsData.reduce((acc, station) => {
|
||||
const updatedStationList: Station['onlineInfo'][] = onlineStationsData.reduce((acc, station) => {
|
||||
if (station.region !== this.state.region.id || !station.isOnline) return acc;
|
||||
|
||||
const stationStatus = onlineDispatchersData.find((status: string[]) => status[0] == station.stationHash && status[1] == this.state.region.id);
|
||||
@@ -165,8 +169,8 @@ export const store = createStore<State>({
|
||||
.map(train => ({ driverName: train.driverName, trainNo: train.trainNo }));
|
||||
|
||||
acc.push({
|
||||
stationName: station.stationName,
|
||||
stationHash: station.stationHash,
|
||||
name: station.stationName,
|
||||
hash: station.stationHash,
|
||||
maxUsers: station.maxUsers,
|
||||
currentUsers: station.currentUsers,
|
||||
spawns: parseSpawns(station.spawnString),
|
||||
@@ -178,11 +182,11 @@ export const store = createStore<State>({
|
||||
stationTrains,
|
||||
statusTimestamp,
|
||||
statusID,
|
||||
statusTimeString: timestampToString(statusTimestamp)
|
||||
statusTimeString: timestampToString(statusTimestamp),
|
||||
});
|
||||
|
||||
return acc;
|
||||
}, [] as any);
|
||||
}, [] as Station['onlineInfo'][]);
|
||||
|
||||
const updatedTrainList = await Promise.all(
|
||||
onlineTrainsData
|
||||
@@ -312,7 +316,7 @@ export const store = createStore<State>({
|
||||
},
|
||||
|
||||
mutations: {
|
||||
SET_SCENERY_DATA(state, data: any[][]) {
|
||||
SET_SCENERY_DATA(state, data: StationJSONData[]) {
|
||||
// state.sceneryData = [...data];
|
||||
|
||||
// state.stationList = data.map(scenery => ({
|
||||
@@ -359,48 +363,37 @@ export const store = createStore<State>({
|
||||
// spawns: []
|
||||
// }));
|
||||
|
||||
|
||||
state.stationList = data.map(station => ({
|
||||
stationName: station[0] as string,
|
||||
stationURL: station[1] as string,
|
||||
stationLines: station[2] as string,
|
||||
stationProject: station[3] as string,
|
||||
reqLevel: Number(station[4] as string),
|
||||
supportersOnly: station[5] == "TAK",
|
||||
signalType: station[6] as string,
|
||||
controlType: station[7] as string,
|
||||
SBL: station[8] as string,
|
||||
TWB: station[9] as string,
|
||||
routes: {
|
||||
oneWay: {
|
||||
catenary: station[10] as number,
|
||||
noCatenary: station[11] as number
|
||||
name: station[0],
|
||||
|
||||
generalInfo: {
|
||||
name: station[0],
|
||||
url: station[1],
|
||||
lines: station[2],
|
||||
project: station[3],
|
||||
reqLevel: station[4] == "" ? -1 : Number(station[4]),
|
||||
supportersOnly: station[5] == "TAK",
|
||||
signalType: station[6],
|
||||
controlType: station[7],
|
||||
SBL: station[8],
|
||||
TWB: station[9],
|
||||
routes: {
|
||||
oneWay: {
|
||||
catenary: station[10],
|
||||
noCatenary: station[11]
|
||||
},
|
||||
twoWay: {
|
||||
catenary: station[12],
|
||||
noCatenary: station[13]
|
||||
}
|
||||
},
|
||||
twoWay: {
|
||||
catenary: station[12] as number,
|
||||
noCatenary: station[13] as number
|
||||
}
|
||||
},
|
||||
checkpoints: station[14] ? (station[14] as string).split(";").map(sub => ({ checkpointName: sub, scheduledTrains: [] })) : [],
|
||||
checkpoints: station[14] ? (station[14]).split(";").map(sub => ({ checkpointName: sub, scheduledTrains: [] })) : [],
|
||||
|
||||
default: station[15] as boolean,
|
||||
nonPublic: station[16] as boolean,
|
||||
unavailable: station[17] as boolean,
|
||||
|
||||
stationHash: "",
|
||||
maxUsers: 0,
|
||||
currentUsers: 0,
|
||||
dispatcherName: "",
|
||||
dispatcherRate: 0,
|
||||
dispatcherExp: -1,
|
||||
dispatcherId: 0,
|
||||
dispatcherIsSupporter: false,
|
||||
online: false,
|
||||
statusTimestamp: -3,
|
||||
statusID: "free",
|
||||
statusTimeString: "",
|
||||
stationTrains: [],
|
||||
scheduledTrains: [],
|
||||
spawns: []
|
||||
default: station[15],
|
||||
nonPublic: station[16],
|
||||
unavailable: station[17],
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
@@ -422,55 +415,45 @@ export const store = createStore<State>({
|
||||
state.region = region;
|
||||
},
|
||||
|
||||
UPDATE_STATIONS(state, updatedStationList: any[]) {
|
||||
UPDATE_STATIONS(state, updatedStationList: Station['onlineInfo'][]) {
|
||||
|
||||
state.stationList = state.stationList.reduce((acc: Station[], station) => {
|
||||
const onlineStationData = updatedStationList.find(updatedStation => updatedStation.stationName === station.stationName);
|
||||
const listedStationData = state.stationList.find(data => data.stationName === station.stationName);
|
||||
const onlineStationData = updatedStationList.find(updatedStation => updatedStation?.name === station.name);
|
||||
const listedStationData = state.stationList.find(data => data.name === station.name);
|
||||
|
||||
if (onlineStationData)
|
||||
acc.push({
|
||||
...station,
|
||||
...onlineStationData,
|
||||
online: true
|
||||
name: station.name,
|
||||
generalInfo: station.generalInfo,
|
||||
onlineInfo: onlineStationData,
|
||||
});
|
||||
else if (listedStationData)
|
||||
acc.push({
|
||||
...station,
|
||||
stationHash: "",
|
||||
maxUsers: 0,
|
||||
currentUsers: 0,
|
||||
dispatcherName: "",
|
||||
dispatcherRate: 0,
|
||||
dispatcherExp: -1,
|
||||
dispatcherId: 0,
|
||||
dispatcherIsSupporter: false,
|
||||
online: false,
|
||||
statusID: "free",
|
||||
statusTimestamp: -3,
|
||||
statusTimeString: "",
|
||||
stationTrains: [],
|
||||
scheduledTrains: []
|
||||
onlineInfo: undefined
|
||||
});
|
||||
|
||||
return acc;
|
||||
}, [] as Station[]);
|
||||
|
||||
updatedStationList
|
||||
.filter(uStation => !state.stationList.some(station => uStation.stationName === station.stationName))
|
||||
.filter(uStation => !state.stationList.some(station => uStation?.name === station.name))
|
||||
.forEach(uStation => {
|
||||
if (!uStation) return;
|
||||
|
||||
state.stationList.push({
|
||||
...uStation,
|
||||
scheduledTrains: [],
|
||||
stationTrains: uStation.stationTrains || [],
|
||||
subStations: [],
|
||||
online: true,
|
||||
reqLevel: -1,
|
||||
nonPublic: true
|
||||
name: uStation.name,
|
||||
|
||||
onlineInfo: {
|
||||
...uStation,
|
||||
scheduledTrains: [],
|
||||
stationTrains: uStation.stationTrains || []
|
||||
},
|
||||
generalInfo: undefined
|
||||
});
|
||||
});
|
||||
|
||||
state.stationCount = state.stationList.filter(station => station.online).length;
|
||||
state.stationCount = state.stationList.filter(station => station.onlineInfo).length;
|
||||
state.dataConnectionStatus = DataStatus.Loaded;
|
||||
},
|
||||
|
||||
@@ -490,10 +473,10 @@ export const store = createStore<State>({
|
||||
|
||||
UPDATE_TIMETABLES(state, timetableList: Timetable[]) {
|
||||
state.stationList = state.stationList.map(station => {
|
||||
const stationName = station.stationName.toLowerCase();
|
||||
const stationName = station.name.toLowerCase();
|
||||
|
||||
const scheduledTrains: Station["scheduledTrains"] = timetableList.reduce((acc: Station["scheduledTrains"], timetable: Timetable) => {
|
||||
if (!timetable.followingSceneries.includes(station.stationHash)) return acc;
|
||||
const scheduledTrains: ScheduledTrain[] = timetableList.reduce((acc: ScheduledTrain[], timetable: Timetable) => {
|
||||
if (!timetable.followingSceneries.includes(station.onlineInfo?.hash || "")) return acc;
|
||||
|
||||
const stopInfoIndex = timetable.followingStops.findIndex(stop => {
|
||||
const stopName = stop.stopNameRAW.toLowerCase();
|
||||
@@ -504,9 +487,12 @@ export const store = createStore<State>({
|
||||
if (stationName.includes(stopName) && !stop.stopName.includes("po.") && !stop.stopName.includes("podg.")) return true;
|
||||
if (stopName.includes("podg.") && stopName.split(", podg.")[0] && stationName.includes(stopName.split(", podg.")[0])) return true;
|
||||
|
||||
if (station.checkpoints && station.checkpoints.length > 0 && station.checkpoints.some(cp => cp.checkpointName.toLowerCase().includes(stop.stopNameRAW.toLowerCase()))) return true;
|
||||
|
||||
// if (station.stops && station.stops.includes(stop.stopNameRAW)) return true;
|
||||
if (station.generalInfo
|
||||
&& station.generalInfo.checkpoints
|
||||
&& station.generalInfo.checkpoints.length > 0
|
||||
&& station.generalInfo.checkpoints.some(cp => cp.checkpointName.toLowerCase().includes(stop.stopNameRAW.toLowerCase())))
|
||||
|
||||
return true;
|
||||
|
||||
return false;
|
||||
});
|
||||
@@ -535,10 +521,10 @@ export const store = createStore<State>({
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
if (station.checkpoints) {
|
||||
station.checkpoints.forEach(cp => (cp.scheduledTrains.length = 0));
|
||||
if (station.generalInfo && station.generalInfo.checkpoints.length > 0) {
|
||||
station.generalInfo.checkpoints.forEach(cp => (cp.scheduledTrains.length = 0));
|
||||
|
||||
for (const checkpoint of station.checkpoints) {
|
||||
for (const checkpoint of station.generalInfo.checkpoints) {
|
||||
timetableList.forEach(timetable => {
|
||||
timetable.followingStops
|
||||
.filter(trainStop => trainStop.stopNameRAW.toLowerCase() === checkpoint.checkpointName.toLowerCase())
|
||||
@@ -565,15 +551,22 @@ export const store = createStore<State>({
|
||||
}
|
||||
}
|
||||
|
||||
return { ...station, scheduledTrains };
|
||||
|
||||
return {
|
||||
...station,
|
||||
onlineInfo: station.onlineInfo ? {
|
||||
...station.onlineInfo,
|
||||
scheduledTrains
|
||||
} : undefined
|
||||
};
|
||||
});
|
||||
|
||||
state.trainList = state.trainList.reduce((acc, train) => {
|
||||
const timetableData = timetableList.find(data => data && data.trainNo === train.trainNo);
|
||||
|
||||
const trainStopData = state.stationList
|
||||
.find(station => station.stationName === train.currentStationName)
|
||||
?.scheduledTrains.find(stationTrain => stationTrain.trainNo === train.trainNo);
|
||||
.find(station => station.name === train.currentStationName)
|
||||
?.onlineInfo?.scheduledTrains?.find(stationTrain => stationTrain.trainNo === train.trainNo);
|
||||
|
||||
acc.push({ ...train, timetableData, stopStatus: trainStopData?.stopStatus || "", stopLabel: trainStopData?.stopLabel || "" });
|
||||
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
</div>
|
||||
|
||||
<div class="scenery-wrapper" v-if="stationInfo">
|
||||
<SceneryInfo :stationInfo="stationInfo" :timetableOnly="timetableOnly" />
|
||||
<SceneryInfo :station="stationInfo" :timetableOnly="timetableOnly" />
|
||||
|
||||
<SceneryTimetable
|
||||
:stationInfo="stationInfo"
|
||||
:station="stationInfo"
|
||||
:timetableOnly="timetableOnly"
|
||||
:dataStatus="data.timetableDataStatus"
|
||||
/>
|
||||
@@ -60,7 +60,7 @@ export default defineComponent({
|
||||
const stationInfo = computed(() =>
|
||||
data.value.stationList.find(
|
||||
(station) =>
|
||||
station.stationName ===
|
||||
station.name ===
|
||||
route.query.station?.toString().replace(/_/g, " ")
|
||||
)
|
||||
);
|
||||
|
||||
@@ -103,7 +103,7 @@ export default defineComponent({
|
||||
});
|
||||
|
||||
const focusedStationInfo = computed(() =>
|
||||
computedStations.value.find((station) => station.stationName === focusedStationName)
|
||||
computedStations.value.find((station) => station.name === focusedStationName)
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user