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