mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
Ładowanie danych nt pociągów i rozkładów jazdy z API Stacjownika
This commit is contained in:
+13
-13
@@ -50,9 +50,9 @@
|
||||
</span>
|
||||
|
||||
<img src="@/assets/icon-dispatcher.svg" alt="icon dispatcher" />
|
||||
<span class="text--primary">{{ data.activeStationCount }}</span>
|
||||
<span class="text--primary">{{ dispatcherCount }}</span>
|
||||
<span class="text--grayed">|</span>
|
||||
<span class="text--primary">{{ data.activeTrainCount }}</span>
|
||||
<span class="text--primary">{{ trainCount }}</span>
|
||||
<img src="@/assets/icon-train.svg" alt="icon train" />
|
||||
</div>
|
||||
</span>
|
||||
@@ -70,9 +70,9 @@
|
||||
<main class="app_main">
|
||||
<router-view v-slot="{ Component }">
|
||||
<!-- <transition name="view-anim" mode="out-in"> -->
|
||||
<keep-alive>
|
||||
<component :is="Component" />
|
||||
</keep-alive>
|
||||
<keep-alive>
|
||||
<component :is="Component" />
|
||||
</keep-alive>
|
||||
<!-- </transition> -->
|
||||
</router-view>
|
||||
</main>
|
||||
@@ -92,7 +92,7 @@
|
||||
import Clock from '@/components/App/Clock.vue';
|
||||
|
||||
import StorageManager from '@/scripts/managers/storageManager';
|
||||
import { computed, ComputedRef, defineComponent, provide, ref } from 'vue';
|
||||
import { computed, ComputedRef, defineComponent, provide, reactive, Ref, ref } from 'vue';
|
||||
import { GETTERS } from './constants/storeConstants';
|
||||
import { StoreData } from './scripts/interfaces/StoreData';
|
||||
import { useStore } from './store';
|
||||
@@ -116,8 +116,8 @@ export default defineComponent({
|
||||
() => store.getters[GETTERS.currentRegion]
|
||||
);
|
||||
|
||||
const dataStatus = computed(() => data.value);
|
||||
const sceneryDataStatus = computed(() => data.value.sceneryDataStatus);
|
||||
const dataStatus = computed(() => data.value.sceneryDataStatus);
|
||||
// const sceneryDataStatus = computed(() => data.value.sceneryDataStatus);
|
||||
|
||||
const isFilterCardVisible = ref(false);
|
||||
|
||||
@@ -129,13 +129,13 @@ export default defineComponent({
|
||||
isFilterCardVisible,
|
||||
|
||||
dataStatus,
|
||||
sceneryDataStatus,
|
||||
dispatcherDataStatus: computed(() => data.value.dispatcherDataStatus),
|
||||
|
||||
timetableCount: data.value.trainList.filter((train) => train.timetableData).length,
|
||||
onlineDispatcherCount: data.value.stationList.filter(
|
||||
(station) => station.onlineInfo && station.onlineInfo.statusTimestamp > 0
|
||||
).length,
|
||||
trainCount: computed(() => data.value.trainList.length),
|
||||
|
||||
dispatcherCount: computed(
|
||||
() => data.value.stationList.filter((station) => station.onlineInfo).length
|
||||
),
|
||||
|
||||
openFilterCard() {
|
||||
isFilterCardVisible.value = true;
|
||||
|
||||
@@ -195,18 +195,9 @@ export default defineComponent({
|
||||
|
||||
watch: {
|
||||
dataStatus(storeData: StoreData) {
|
||||
const dataConnectionStatus = storeData.dataConnectionStatus;
|
||||
const sceneryDataStatus = storeData.sceneryDataStatus;
|
||||
const trainsDataStatus = storeData.trainsDataStatus;
|
||||
const dispatcherDataStatus = storeData.dispatcherDataStatus;
|
||||
const timetableDataStatus = storeData.timetableDataStatus;
|
||||
|
||||
if (dataConnectionStatus == DataStatus.Error) {
|
||||
this.setSignalStatus(dataConnectionStatus);
|
||||
this.indicator.status = dataConnectionStatus;
|
||||
this.indicator.message = 'data-status.S1a-connection';
|
||||
return;
|
||||
}
|
||||
|
||||
if (sceneryDataStatus == DataStatus.Error) {
|
||||
this.setSignalStatus(sceneryDataStatus);
|
||||
@@ -229,20 +220,6 @@ export default defineComponent({
|
||||
return;
|
||||
}
|
||||
|
||||
if (timetableDataStatus == DataStatus.Warning) {
|
||||
this.setSignalStatus(timetableDataStatus);
|
||||
this.indicator.status = timetableDataStatus;
|
||||
this.indicator.message = 'data-status.S5-timetables';
|
||||
return;
|
||||
}
|
||||
|
||||
if (timetableDataStatus == DataStatus.Loading) {
|
||||
this.setSignalStatus(timetableDataStatus);
|
||||
this.indicator.status = timetableDataStatus;
|
||||
this.indicator.message = 'data-status.S3';
|
||||
return;
|
||||
}
|
||||
|
||||
this.setSignalStatus(DataStatus.Loaded);
|
||||
|
||||
this.indicator.status = DataStatus.Loaded;
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
<template>
|
||||
<span class="stop-date">
|
||||
<span
|
||||
class="date arrival"
|
||||
v-if="!stop.beginsHere"
|
||||
:class="{
|
||||
delayed: stop.arrivalDelay > 0 && stop.confirmed,
|
||||
preponed: stop.arrivalDelay < 0 && stop.confirmed,
|
||||
'on-time': stop.arrivalDelay == 0 && stop.confirmed,
|
||||
}"
|
||||
>
|
||||
<span v-if="stop.arrivalDelay != 0 && stop.confirmed">
|
||||
<s>{{ timestampToString(stop.arrivalTimestamp) }}</s>
|
||||
{{ timestampToString(stop.arrivalRealTimestamp) }}
|
||||
({{ stop.arrivalDelay > 0 ? '+' : '' }}{{ stop.arrivalDelay }})
|
||||
</span>
|
||||
|
||||
<span v-else>
|
||||
{{ timestampToString(stop.arrivalTimestamp) }}
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<span class="date stop" v-if="stop.stopTime" :class="stop.stopType.replace(', ', '-')">
|
||||
{{ stop.stopTime }} {{ stop.stopType == '' ? 'pt' : stop.stopType }}
|
||||
</span>
|
||||
|
||||
<span
|
||||
class="date departure"
|
||||
v-if="!stop.terminatesHere && stop.stopTime != 0"
|
||||
:class="{
|
||||
delayed: stop.departureDelay > 0 && stop.confirmed,
|
||||
preponed: stop.departureDelay < 0 && stop.confirmed,
|
||||
}"
|
||||
>
|
||||
<span v-if="stop.departureDelay != 0 && stop.confirmed">
|
||||
<s>{{ timestampToString(stop.departureTimestamp) }}</s>
|
||||
{{ timestampToString(stop.departureRealTimestamp) }}
|
||||
|
||||
({{ stop.departureDelay > 0 ? '+' : '' }}{{ stop.departureDelay }})
|
||||
</span>
|
||||
|
||||
<span v-else>
|
||||
{{ timestampToString(stop.departureTimestamp) }}
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import dateMixin from '@/mixins/dateMixin';
|
||||
import TrainStop from '@/scripts/interfaces/TrainStop';
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
export default defineComponent({
|
||||
mixins: [dateMixin],
|
||||
|
||||
props: {
|
||||
stop: {
|
||||
type: Object as () => TrainStop,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
||||
setup() {
|
||||
return {};
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
$preponedClr: lime;
|
||||
$delayedClr: salmon;
|
||||
$dateClr: #525151;
|
||||
$stopExchangeClr: #db8e29;
|
||||
$stopDefaultClr: #252525;
|
||||
|
||||
.stop-date {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.date {
|
||||
background: $dateClr;
|
||||
padding: 0.3em 0.5em;
|
||||
}
|
||||
|
||||
.stop {
|
||||
&.ph,
|
||||
&.ph-pm,
|
||||
&.pm {
|
||||
background: $stopExchangeClr;
|
||||
}
|
||||
|
||||
background: $stopDefaultClr;
|
||||
}
|
||||
|
||||
.arrival,
|
||||
.departure {
|
||||
&.delayed {
|
||||
s {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
span {
|
||||
color: $delayedClr;
|
||||
}
|
||||
}
|
||||
|
||||
&.preponed {
|
||||
s {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
span {
|
||||
color: $preponedClr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
<span class="status-badge" v-if="station.onlineInfo" :class="station.onlineInfo.statusID">
|
||||
{{ $t(`status.${station.onlineInfo.statusID}`) }}
|
||||
{{ station.onlineInfo.statusID == 'online' ? station.onlineInfo.statusTimeString : '' }}
|
||||
{{ station.onlineInfo.statusID == 'online' ? timestampToString(station.onlineInfo.statusTimestamp) : '' }}
|
||||
</span>
|
||||
|
||||
<span class="status-badge free" v-else>
|
||||
@@ -31,9 +31,10 @@ import { defineComponent } from 'vue';
|
||||
|
||||
import styleMixin from '@/mixins/styleMixin';
|
||||
import Station from '@/scripts/interfaces/Station';
|
||||
import dateMixin from '@/mixins/dateMixin';
|
||||
|
||||
export default defineComponent({
|
||||
mixins: [styleMixin],
|
||||
mixins: [styleMixin, dateMixin ],
|
||||
props: {
|
||||
station: {
|
||||
type: Object as () => Station,
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
</div>
|
||||
|
||||
<transition name="scenery-timetable-list-anim" mode="out-in">
|
||||
<div :key="timetableDataStatus + selectedCheckpoint">
|
||||
<span class="timetable-item loading" v-if="timetableDataStatus == 0 && computedScheduledTrains.length == 0">
|
||||
<div :key="trainsDataStatus + selectedCheckpoint">
|
||||
<span class="timetable-item loading" v-if="trainsDataStatus == 0 && computedScheduledTrains.length == 0">
|
||||
{{ $t('app.loading') }}
|
||||
</span>
|
||||
|
||||
@@ -65,18 +65,26 @@
|
||||
</span>
|
||||
|
||||
<span class="timetable-schedule">
|
||||
<span class="schedule-arrival">
|
||||
<span
|
||||
class="arrival-time begins"
|
||||
v-if="scheduledTrain.stopInfo.beginsHere"
|
||||
v-html="$t('timetables.begins')"
|
||||
>
|
||||
<span class="schedule-arrival">
|
||||
<span class="arrival-time begins" v-if="scheduledTrain.stopInfo.beginsHere">
|
||||
{{ $t('timetables.begins') }}
|
||||
</span>
|
||||
|
||||
<span class="arrival-time" v-else>
|
||||
{{ scheduledTrain.stopInfo.arrivalTimeString }} ({{ scheduledTrain.stopInfo.arrivalDelay }})
|
||||
<div v-if="scheduledTrain.stopInfo.arrivalDelay == 0">
|
||||
<span>{{ timestampToString(scheduledTrain.stopInfo.arrivalTimestamp) }}</span>
|
||||
</div>
|
||||
<div v-else>
|
||||
<s style="margin-right: 0.2em;" class="text--grayed">{{
|
||||
timestampToString(scheduledTrain.stopInfo.arrivalTimestamp)
|
||||
}}</s>
|
||||
<span>
|
||||
{{ timestampToString(scheduledTrain.stopInfo.arrivalRealTimestamp) }}
|
||||
({{ scheduledTrain.stopInfo.arrivalDelay > 0 ? '+' : ''
|
||||
}}{{ scheduledTrain.stopInfo.arrivalDelay }})
|
||||
</span>
|
||||
</div>
|
||||
</span>
|
||||
|
||||
</span>
|
||||
|
||||
<span class="schedule-stop">
|
||||
@@ -88,15 +96,25 @@
|
||||
</span>
|
||||
|
||||
<span class="schedule-departure">
|
||||
<span
|
||||
class="departure-time terminates"
|
||||
v-if="scheduledTrain.stopInfo.terminatesHere"
|
||||
v-html="$t('timetables.terminates')"
|
||||
>
|
||||
<span class="departure-time terminates" v-if="scheduledTrain.stopInfo.terminatesHere">
|
||||
{{ $t('timetables.terminates') }}
|
||||
</span>
|
||||
|
||||
<span class="departure-time" v-else>
|
||||
{{ scheduledTrain.stopInfo.departureTimeString }} ({{ scheduledTrain.stopInfo.departureDelay }})
|
||||
<div v-if="scheduledTrain.stopInfo.departureDelay == 0">
|
||||
<span>{{ timestampToString(scheduledTrain.stopInfo.departureTimestamp) }}</span>
|
||||
</div>
|
||||
<div v-else>
|
||||
<s style="margin-right: 0.2em;" class="text--grayed">{{
|
||||
timestampToString(scheduledTrain.stopInfo.departureTimestamp)
|
||||
}}</s>
|
||||
|
||||
<span>
|
||||
{{ timestampToString(scheduledTrain.stopInfo.departureRealTimestamp) }}
|
||||
({{ scheduledTrain.stopInfo.departureDelay > 0 ? '+' : ''
|
||||
}}{{ scheduledTrain.stopInfo.departureDelay }})
|
||||
</span>
|
||||
</div>
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
@@ -115,10 +133,13 @@ import { useStore } from '@/store';
|
||||
import { GETTERS } from '@/constants/storeConstants';
|
||||
import { DataStatus } from '@/scripts/enums/DataStatus';
|
||||
import { ComputedRef } from 'vue';
|
||||
import dateMixin from '@/mixins/dateMixin';
|
||||
|
||||
export default defineComponent({
|
||||
components: { SelectBox },
|
||||
|
||||
mixins: [dateMixin],
|
||||
|
||||
props: {
|
||||
station: {
|
||||
type: Object as () => Station,
|
||||
@@ -142,7 +163,7 @@ export default defineComponent({
|
||||
|
||||
const store = useStore();
|
||||
|
||||
const timetableDataStatus = computed(() => store.getters[GETTERS.timetableDataStatus]) as ComputedRef<DataStatus>;
|
||||
const trainsDataStatus = computed(() => store.getters[GETTERS.trainsDataStatus]) as ComputedRef<DataStatus>;
|
||||
|
||||
const selectedCheckpoint = ref(
|
||||
props.station?.generalInfo?.checkpoints?.length == 0
|
||||
@@ -176,7 +197,7 @@ export default defineComponent({
|
||||
currentURL,
|
||||
selectedCheckpoint,
|
||||
computedScheduledTrains,
|
||||
timetableDataStatus,
|
||||
trainsDataStatus,
|
||||
};
|
||||
},
|
||||
|
||||
@@ -317,11 +338,12 @@ h3 {
|
||||
&-schedule {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(30px, 1fr));
|
||||
font-size: 1.3em;
|
||||
font-size: 1.15em;
|
||||
|
||||
@include smallScreen() {
|
||||
width: 100%;
|
||||
margin: 0.5em 0;
|
||||
font-size: 1.4em;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -378,7 +400,6 @@ h3 {
|
||||
.general-info {
|
||||
.info-number {
|
||||
color: $accentCol;
|
||||
|
||||
}
|
||||
|
||||
.info-route {
|
||||
@@ -396,6 +417,8 @@ h3 {
|
||||
}
|
||||
|
||||
.general-status {
|
||||
margin-left: 0.5em;
|
||||
|
||||
span.arriving {
|
||||
color: #aaa;
|
||||
}
|
||||
@@ -449,6 +472,6 @@ h3 {
|
||||
|
||||
.arrival-time.begins,
|
||||
.departure-time.terminates {
|
||||
font-size: 0.75em;
|
||||
font-size: 0.85em;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
<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 : '' }}
|
||||
{{ station.onlineInfo.statusID == 'online' ? timestampToString(station.onlineInfo.statusTimestamp) : '' }}
|
||||
</span>
|
||||
|
||||
<span class="status-badge free" v-else>
|
||||
@@ -102,7 +102,7 @@
|
||||
<td class="station_dispatcher-exp">
|
||||
<span
|
||||
v-if="station.onlineInfo"
|
||||
:style="calculateExpStyle(station.onlineInfo.dispatcherExp, station.onlineInfo.dispatcherIsSupporter)"
|
||||
:style="calculateExpStyle(station.onlineInfo.dispatcherExp)"
|
||||
>
|
||||
{{ 2 > station.onlineInfo.dispatcherExp ? 'L' : station.onlineInfo.dispatcherExp }}
|
||||
</span>
|
||||
@@ -231,6 +231,8 @@ import { computed, ComputedRef, defineComponent } from '@vue/runtime-core';
|
||||
import { useStore } from '@/store';
|
||||
import { GETTERS } from '@/constants/storeConstants';
|
||||
import Station from '@/scripts/interfaces/Station';
|
||||
import { StoreData } from '@/scripts/interfaces/StoreData';
|
||||
import dateMixin from '@/mixins/dateMixin';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
@@ -248,7 +250,7 @@ export default defineComponent({
|
||||
changeSorter: { type: Function, required: true },
|
||||
},
|
||||
|
||||
mixins: [styleMixin],
|
||||
mixins: [styleMixin, dateMixin],
|
||||
|
||||
data: () => ({
|
||||
likeIcon: require('@/assets/icon-like.svg'),
|
||||
@@ -275,10 +277,10 @@ export default defineComponent({
|
||||
setup() {
|
||||
const store = useStore();
|
||||
|
||||
const dataConnectionStatus: ComputedRef<DataStatus> = computed(() => store.getters[GETTERS.dataStatus]);
|
||||
const data: ComputedRef<StoreData> = computed(() => store.getters[GETTERS.allData]);
|
||||
|
||||
const isDataLoaded = computed(() => {
|
||||
return dataConnectionStatus.value == DataStatus.Loaded;
|
||||
return data.value.sceneryDataStatus == DataStatus.Loaded;
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
@@ -22,51 +22,8 @@
|
||||
<span class="content" v-html="stop.comments"> </span>
|
||||
</span>
|
||||
</span>
|
||||
<span class="stop-date">
|
||||
<span
|
||||
class="date arrival"
|
||||
v-if="!stop.beginsHere"
|
||||
:class="{
|
||||
delayed: stop.arrivalDelay > 0 && stop.confirmed,
|
||||
preponed: stop.arrivalDelay < 0 && stop.confirmed,
|
||||
'on-time': stop.arrivalDelay == 0 && stop.confirmed,
|
||||
}"
|
||||
>
|
||||
<span v-if="stop.arrivalDelay != 0 && stop.confirmed">
|
||||
<s>{{ stop.arrivalTimeString }}</s>
|
||||
{{ stop.arrivalRealTimeString }}
|
||||
({{ stop.arrivalDelay > 0 ? '+' : '' }}{{ stop.arrivalDelay }})
|
||||
</span>
|
||||
|
||||
<span v-else>
|
||||
{{ stop.arrivalTimeString }}
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<span class="date stop" v-if="stop.stopTime" :class="stop.stopType.replace(', ', '-')">
|
||||
{{ stop.stopTime }} {{ stop.stopType == '' ? 'pt' : stop.stopType }}
|
||||
</span>
|
||||
|
||||
<span
|
||||
class="date departure"
|
||||
v-if="!stop.terminatesHere && stop.stopTime != 0"
|
||||
:class="{
|
||||
delayed: stop.departureDelay > 0 && stop.confirmed,
|
||||
preponed: stop.departureDelay < 0 && stop.confirmed,
|
||||
}"
|
||||
>
|
||||
<span v-if="stop.departureDelay != 0 && stop.confirmed">
|
||||
<s>{{ stop.departureTimeString }}</s>
|
||||
{{ stop.departureRealTimeString }}
|
||||
|
||||
({{ stop.departureDelay > 0 ? '+' : '' }}{{ stop.departureDelay }})
|
||||
</span>
|
||||
|
||||
<span v-else>
|
||||
{{ stop.departureTimeString }}
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
<stop-date :stop="stop" />
|
||||
</span>
|
||||
|
||||
<div class="stop_line" v-if="i < followingStops.length - 1">
|
||||
@@ -88,10 +45,13 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import TrainStop from '@/scripts/interfaces/TrainStop';
|
||||
import { computed, defineComponent } from '@vue/runtime-core';
|
||||
import dateMixin from '@/mixins/dateMixin';
|
||||
import TrainStop from '@/scripts/interfaces/TrainStop';
|
||||
import StopDate from '../Global/StopDate.vue';
|
||||
|
||||
export default defineComponent({
|
||||
components: { StopDate },
|
||||
props: {
|
||||
followingStops: {
|
||||
type: Array as () => TrainStop[],
|
||||
@@ -99,6 +59,8 @@ export default defineComponent({
|
||||
},
|
||||
},
|
||||
|
||||
mixins: [dateMixin],
|
||||
|
||||
emits: ['click'],
|
||||
|
||||
data: () => ({
|
||||
@@ -159,12 +121,6 @@ $barClr: #b1b1b1;
|
||||
$confirmedClr: #18d818;
|
||||
$stoppedClr: #f55f31;
|
||||
$haltClr: #f8bb36;
|
||||
|
||||
$preponedClr: lime;
|
||||
$delayedClr: salmon;
|
||||
$dateClr: #525151;
|
||||
$stopExchangeClr: #db8e29;
|
||||
$stopDefaultClr: #252525;
|
||||
$stopNameClr: #22a8d1;
|
||||
|
||||
@keyframes blink {
|
||||
@@ -220,49 +176,6 @@ $stopNameClr: #22a8d1;
|
||||
}
|
||||
}
|
||||
|
||||
.stop-date {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.date {
|
||||
background: $dateClr;
|
||||
padding: 0.3em 0.5em;
|
||||
}
|
||||
|
||||
.stop {
|
||||
&.ph,
|
||||
&.ph-pm,
|
||||
&.pm {
|
||||
background: $stopExchangeClr;
|
||||
}
|
||||
|
||||
background: $stopDefaultClr;
|
||||
}
|
||||
|
||||
.arrival,
|
||||
.departure {
|
||||
&.delayed {
|
||||
s {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
span {
|
||||
color: $delayedClr;
|
||||
}
|
||||
}
|
||||
|
||||
&.preponed {
|
||||
s {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
span {
|
||||
color: $preponedClr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ul.stop_list > li.stop {
|
||||
position: relative;
|
||||
|
||||
|
||||
@@ -80,7 +80,6 @@ export default defineComponent({
|
||||
setup(props) {
|
||||
const store = useStore();
|
||||
|
||||
const timetableDataStatus: ComputedRef<DataStatus> = computed(() => store.getters[GETTERS.timetableDataStatus]);
|
||||
const trainsDataStatus: ComputedRef<DataStatus> = computed(() => store.getters[GETTERS.trainsDataStatus]);
|
||||
|
||||
const searchedTrain = inject('searchedTrain') as Ref<string>;
|
||||
@@ -108,9 +107,6 @@ export default defineComponent({
|
||||
|
||||
sorterActive: inject('sorterActive') as { id: string | number; dir: number },
|
||||
trainsDataStatus: computed(() => trainsDataStatus.value),
|
||||
timetableLoaded: computed(() => timetableDataStatus.value === DataStatus.Loaded),
|
||||
timetableWarning: computed(() => timetableDataStatus.value === DataStatus.Warning),
|
||||
timetableError: computed(() => timetableDataStatus.value === DataStatus.Error),
|
||||
distanceLimitExceeded: computed(
|
||||
() => props.trains.findIndex(({ timetableData }) => timetableData && timetableData.routeDistance > 200) != -1
|
||||
),
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
</div>
|
||||
|
||||
<train-info :train="train" />
|
||||
<train-schedule :followingStops="train.timetableData?.followingStops" ref="card-inner" tabindex="0" />
|
||||
<train-schedule v-if="train.timetableData" :followingStops="train.timetableData.followingStops" ref="card-inner" tabindex="0" />
|
||||
</section>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
export const ACTIONS = {
|
||||
synchronizeData: "synchronizeData",
|
||||
fetchOnlineData: "fetchOnlineData",
|
||||
fetchTimetableData: "fetchTimetableData"
|
||||
loadStaticStationData: "loadStaticStationData"
|
||||
}
|
||||
|
||||
export const MUTATIONS = {
|
||||
SET_SCENERY_DATA: "SET_SCENERY_DATA",
|
||||
SET_DATA_CONNECTION_STATUS: "SET_DATA_CONNECTION_STATUS",
|
||||
|
||||
SET_SCENERY_DATA: "SET_SCENERY_DATA",
|
||||
SET_SCENERY_DATA_STATUS: "SET_SCENERY_DATA_STATUS",
|
||||
SET_TIMETABLE_DATA_STATUS: "SET_TIMETABLE_DATA_STATUS",
|
||||
SET_DISPATCHER_DATA_STATUS: "SET_DISPATCHER_DATA_STATUS",
|
||||
SET_TRAINS_DATA_STATUS: "SET_TRAINS_DATA_STATUS",
|
||||
|
||||
SET_REGION: "SET_REGION",
|
||||
UPDATE_STATIONS: "UPDATE_STATIONS",
|
||||
UPDATE_TRAINS: "UPDATE_TRAINS",
|
||||
UPDATE_TIMETABLES: "UPDATE_TIMETABLES"
|
||||
}
|
||||
|
||||
export const GETTERS = {
|
||||
@@ -24,11 +20,9 @@ export const GETTERS = {
|
||||
trainList: "trainList",
|
||||
allData: "allData",
|
||||
|
||||
timetableDataStatus: "timetableDataStatus",
|
||||
sceneryDataStatus: "sceneryDataStatus",
|
||||
dispatcherDataStatus: "dispatcherDataStatus",
|
||||
dispatcherDataSWDRStatus: "dispatcherDataSWDRStatus",
|
||||
swdrDataStatus: "swdrDataStatus",
|
||||
trainsDataStatus: "trainsDataStatus",
|
||||
|
||||
dataStatus: "dataStatus",
|
||||
currentRegion: "currentRegion"
|
||||
}
|
||||
@@ -26,6 +26,15 @@ export default defineComponent({
|
||||
hour: "2-digit",
|
||||
minute: "2-digit"
|
||||
})
|
||||
},
|
||||
|
||||
timestampToString(timestamp: number | null) {
|
||||
return timestamp
|
||||
? new Date(timestamp).toLocaleTimeString("pl-PL", {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit"
|
||||
})
|
||||
: "";
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
+3
-2
@@ -30,8 +30,9 @@ const routes: Array<RouteRecordRaw> = [
|
||||
]
|
||||
|
||||
const router = createRouter({
|
||||
scrollBehavior(to, from) {
|
||||
if (to.name == "SceneryView")
|
||||
scrollBehavior(to, from) {
|
||||
|
||||
if (to.name == "SceneryView" && from.name)
|
||||
return { el: `.app_main` };
|
||||
|
||||
if (from.name == "SceneryView" && to.name == "StationsView")
|
||||
|
||||
@@ -46,7 +46,7 @@ export default interface Station {
|
||||
dispatcherIsSupporter: boolean;
|
||||
|
||||
statusTimestamp: number;
|
||||
statusTimeString: string;
|
||||
// statusTimeString: string;
|
||||
statusID: string;
|
||||
|
||||
stationTrains?: {
|
||||
|
||||
@@ -6,13 +6,8 @@ export interface StoreData {
|
||||
stationList: Station[];
|
||||
trainList: Train[];
|
||||
|
||||
activeTrainCount: number;
|
||||
activeStationCount: number;
|
||||
|
||||
dataConnectionStatus: DataStatus;
|
||||
|
||||
timetableDataStatus: DataStatus;
|
||||
sceneryDataStatus: DataStatus;
|
||||
dispatcherDataStatus: DataStatus;
|
||||
trainsDataStatus: DataStatus;
|
||||
trainsDataStatus: DataStatus;
|
||||
}
|
||||
|
||||
@@ -27,8 +27,6 @@ export default interface Train {
|
||||
TWR: boolean;
|
||||
SKR: boolean;
|
||||
routeDistance: number;
|
||||
sceneries: string[];
|
||||
};
|
||||
|
||||
stopStatus: string;
|
||||
stopLabel: string;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default interface TrainStop {
|
||||
export default interface TrainStop {
|
||||
stopName: string;
|
||||
stopNameRAW: string;
|
||||
stopType: string;
|
||||
@@ -6,19 +6,19 @@ export default interface TrainStop {
|
||||
mainStop: boolean;
|
||||
|
||||
arrivalLine: string | null;
|
||||
arrivalTimeString: string | null;
|
||||
// arrivalTimeString: string | null;
|
||||
arrivalTimestamp: number;
|
||||
arrivalRealTimeString: string | null;
|
||||
// arrivalRealTimeString: string | null;
|
||||
arrivalRealTimestamp: number;
|
||||
arrivalDelay: number;
|
||||
|
||||
departureLine: string | null;
|
||||
departureTimeString: string | null;
|
||||
// departureTimeString: string | null;
|
||||
departureTimestamp: number;
|
||||
departureRealTimeString: string | null;
|
||||
// departureRealTimeString: string | null;
|
||||
departureRealTimestamp: number;
|
||||
departureDelay: number;
|
||||
pointId: string;
|
||||
pointId: number;
|
||||
|
||||
comments?: any;
|
||||
|
||||
|
||||
@@ -1,19 +1,62 @@
|
||||
import StationAPIData from "./StationAPIData";
|
||||
|
||||
export default interface TrainAPIData {
|
||||
trainNo: number;
|
||||
driverId: number;
|
||||
|
||||
mass: number;
|
||||
length: number;
|
||||
speed: number;
|
||||
stockString: string;
|
||||
|
||||
signal: string;
|
||||
distance: number;
|
||||
connectedTrack: string;
|
||||
|
||||
driverName: string;
|
||||
driverId: number;
|
||||
driverIsSupporter: boolean;
|
||||
station: StationAPIData;
|
||||
dataSignal: string;
|
||||
dataSceneryConnection: string;
|
||||
dataDistance: number;
|
||||
dataCon: string;
|
||||
dataSpeed: number;
|
||||
dataMass: number;
|
||||
dataLength: number;
|
||||
region: string;
|
||||
isOnline: boolean;
|
||||
|
||||
currentStationName: string;
|
||||
currentStationHash: string;
|
||||
|
||||
online: boolean;
|
||||
lastSeen: number;
|
||||
|
||||
region: string;
|
||||
|
||||
timetable?: {
|
||||
timetableId: number;
|
||||
category: string;
|
||||
route: string;
|
||||
|
||||
stopList: {
|
||||
stopName: string;
|
||||
stopNameRAW: string;
|
||||
stopType: string;
|
||||
stopDistance: number;
|
||||
pointId: number;
|
||||
|
||||
mainStop: boolean;
|
||||
|
||||
arrivalLine: string;
|
||||
arrivalTimestamp: number;
|
||||
arrivalRealTimestamp: number;
|
||||
arrivalDelay: number;
|
||||
|
||||
departureLine: string;
|
||||
departureTimestamp: number;
|
||||
departureRealTimestamp: number;
|
||||
departureDelay: number;
|
||||
|
||||
comments?: any;
|
||||
|
||||
beginsHere: boolean;
|
||||
terminatesHere: boolean;
|
||||
confirmed: boolean;
|
||||
stopped: boolean;
|
||||
stopTime: number;
|
||||
}[];
|
||||
|
||||
TWR: boolean;
|
||||
SKR: boolean;
|
||||
sceneries: string[];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,8 +2,9 @@ export const URLs = {
|
||||
sceneryData: "https://spythere.github.io/api/stationData.json",
|
||||
sceneryDataDev: "http://127.0.0.1:8000/data",
|
||||
stations: "https://api.td2.info.pl:9640/?method=getStationsOnline",
|
||||
trains: "https://api.td2.info.pl:9640/?method=getTrainsOnline",
|
||||
dispatchers: "https://api.td2.info.pl:9640/?method=readFromSWDR&value=getDispatcherStatusList%3B1",
|
||||
stacjownikAPI: "https://stacjownik.herokuapp.com",
|
||||
getTimetableURL: (trainNo: string | number, region = "eu") => `https://api.td2.info.pl:9640/?method=readFromSWDR&value=getTimetable%3B${trainNo}%3B${region}`
|
||||
stacjownikAPIDev: "http://localhost:3001"
|
||||
// trains: "https://api.td2.info.pl:9640/?method=getTrainsOnline",
|
||||
// getTimetableURL: (trainNo: string | number, region = "eu") => `https://api.td2.info.pl:9640/?method=readFromSWDR&value=getTimetable%3B${trainNo}%3B${region}`
|
||||
};
|
||||
@@ -1,5 +1,4 @@
|
||||
import Station from "../interfaces/Station";
|
||||
import Timetable from "../interfaces/Timetable";
|
||||
import Train from "../interfaces/Train";
|
||||
import TrainStop from "../interfaces/TrainStop";
|
||||
|
||||
export const getLocoURL = (locoType: string): string => (`https://rj.td2.info.pl/dist/img/thumbnails/${locoType.includes("EN") ? locoType + "rb" : locoType}.png`)
|
||||
@@ -72,15 +71,7 @@ export const parseSpawns = (spawnString: string) => {
|
||||
|
||||
export const getTimestamp = (date: string | null): number => (date ? new Date(date).getTime() : 0);
|
||||
|
||||
export const timestampToString = (timestamp: number | null): string =>
|
||||
timestamp
|
||||
? new Date(timestamp).toLocaleTimeString("pl-PL", {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit"
|
||||
})
|
||||
: "";
|
||||
|
||||
export const getTrainStopStatus = (stopInfo: TrainStop, currentStationName: string, station: Station) => {
|
||||
export const getTrainStopStatus = (stopInfo: TrainStop, currentStationName: string, stationName: string) => {
|
||||
let stopStatus = "",
|
||||
stopLabel = "",
|
||||
stopStatusID = -1;
|
||||
@@ -89,27 +80,49 @@ export const getTrainStopStatus = (stopInfo: TrainStop, currentStationName: stri
|
||||
stopStatus = "terminated";
|
||||
stopLabel = "Skończył bieg";
|
||||
stopStatusID = 5;
|
||||
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && currentStationName == station.name) {
|
||||
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && currentStationName == stationName) {
|
||||
stopStatus = "departed";
|
||||
stopLabel = "Odprawiony";
|
||||
stopStatusID = 2;
|
||||
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && currentStationName != station.name) {
|
||||
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && currentStationName != stationName) {
|
||||
stopStatus = "departed-away";
|
||||
stopLabel = "Odjechał";
|
||||
stopStatusID = 4;
|
||||
} else if (currentStationName == station.name && !stopInfo.stopped) {
|
||||
} else if (currentStationName == stationName && !stopInfo.stopped) {
|
||||
stopStatus = "online";
|
||||
stopLabel = "Na stacji";
|
||||
stopStatusID = 0;
|
||||
} else if (currentStationName == station.name && stopInfo.stopped) {
|
||||
} else if (currentStationName == stationName && stopInfo.stopped) {
|
||||
stopStatus = "stopped";
|
||||
stopLabel = "Postój";
|
||||
stopStatusID = 1;
|
||||
} else if (currentStationName != station.name) {
|
||||
} else if (currentStationName != stationName) {
|
||||
stopStatus = "arriving";
|
||||
stopLabel = "W drodze";
|
||||
stopStatusID = 3;
|
||||
}
|
||||
|
||||
return { stopStatus, stopLabel, stopStatusID };
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
export function getScheduledTrain(train: Train, trainStop: TrainStop, stationName: string) {
|
||||
const timetable = train.timetableData!;
|
||||
const trainStopStatus = getTrainStopStatus(trainStop, train.currentStationName, stationName);
|
||||
|
||||
return {
|
||||
trainNo: train.trainNo,
|
||||
driverName: train.driverName,
|
||||
driverId: train.driverId,
|
||||
currentStationName: train.currentStationName,
|
||||
currentStationHash: train.currentStationHash,
|
||||
category: timetable.category,
|
||||
beginsAt: timetable.followingStops[0].stopNameRAW,
|
||||
terminatesAt: timetable.followingStops[timetable.followingStops.length - 1].stopNameRAW,
|
||||
nearestStop: "",
|
||||
stopInfo: trainStop,
|
||||
stopLabel: trainStopStatus.stopLabel,
|
||||
stopStatus: trainStopStatus.stopStatus,
|
||||
stopStatusID: trainStopStatus.stopStatusID
|
||||
}
|
||||
}
|
||||
+173
-394
@@ -7,19 +7,16 @@ import axios from "axios";
|
||||
|
||||
import Station from "@/scripts/interfaces/Station";
|
||||
import Train from "@/scripts/interfaces/Train";
|
||||
import TrainStop from "@/scripts/interfaces/TrainStop";
|
||||
|
||||
import { StoreData } from "@/scripts/interfaces/StoreData";
|
||||
|
||||
import TimetableAPIData from '@/scripts/interfaces/api/TimetableAPIData';
|
||||
import StationAPIData from '@/scripts/interfaces/api/StationAPIData';
|
||||
import TrainAPIData from '@/scripts/interfaces/api/TrainAPIData';
|
||||
import Timetable from '@/scripts/interfaces/Timetable';
|
||||
|
||||
import { ACTIONS, MUTATIONS } from "@/constants/storeConstants";
|
||||
import { DataStatus } from "@/scripts/enums/DataStatus";
|
||||
|
||||
import { getLocoURL, getStatusID, getStatusTimestamp, getTimestamp, getTrainStopStatus, parseSpawns, timestampToString } from "@/scripts/utils/storeUtils";
|
||||
import { getLocoURL, getScheduledTrain, getStatusID, getStatusTimestamp, parseSpawns } from "@/scripts/utils/storeUtils";
|
||||
import { URLs } from '@/scripts/utils/apiURLs';
|
||||
import ScheduledTrain from '@/scripts/interfaces/ScheduledTrain';
|
||||
import StationRoutes from '@/scripts/interfaces/StationRoutes';
|
||||
@@ -27,7 +24,7 @@ import StationRoutes from '@/scripts/interfaces/StationRoutes';
|
||||
export interface State {
|
||||
stationList: Station[],
|
||||
trainList: Train[],
|
||||
timetableList: Timetable[],
|
||||
// timetableList: Timetable[],
|
||||
|
||||
sceneryData: any[][],
|
||||
|
||||
@@ -68,13 +65,14 @@ interface StationJSONData {
|
||||
unavailable: boolean;
|
||||
}
|
||||
|
||||
|
||||
export const key: InjectionKey<Store<State>> = Symbol()
|
||||
|
||||
export const store = createStore<State>({
|
||||
state: () => ({
|
||||
stationList: [],
|
||||
trainList: [],
|
||||
timetableList: [],
|
||||
// timetableList: [],
|
||||
|
||||
sceneryData: [],
|
||||
|
||||
@@ -100,247 +98,213 @@ export const store = createStore<State>({
|
||||
stationList: state.stationList,
|
||||
trainList: state.trainList,
|
||||
|
||||
activeTrainCount: state.trainCount,
|
||||
activeStationCount: state.stationCount,
|
||||
|
||||
dataConnectionStatus: state.dataConnectionStatus,
|
||||
timetableDataStatus: state.timetableDataStatus,
|
||||
sceneryDataStatus: state.sceneryDataStatus,
|
||||
|
||||
dispatcherDataStatus: state.dispatcherDataStatus,
|
||||
trainsDataStatus: state.trainsDataStatus
|
||||
}),
|
||||
timetableDataStatus: (state): DataStatus => state.timetableDataStatus,
|
||||
|
||||
sceneryDataStatus: (state): DataStatus => state.sceneryDataStatus,
|
||||
trainsDataStatus: (state): DataStatus => state.trainsDataStatus,
|
||||
dataStatus: (state): DataStatus => state.dataConnectionStatus,
|
||||
|
||||
currentRegion: (state): { id: string; value: string } => state.region
|
||||
},
|
||||
|
||||
actions: {
|
||||
async synchronizeData({ commit, dispatch, state }) {
|
||||
if (state.listenerLaunched) return;
|
||||
|
||||
// Nowy parametr żądania co godzinę
|
||||
const sceneryData: StationJSONData = await (await axios.get(`${URLs.sceneryData}?time=${Math.floor(Date.now() / 1800000)}`)).data;
|
||||
|
||||
commit(MUTATIONS.SET_TIMETABLE_DATA_STATUS, DataStatus.Loading);
|
||||
commit(MUTATIONS.SET_SCENERY_DATA, sceneryData);
|
||||
commit(MUTATIONS.SET_SCENERY_DATA_STATUS, DataStatus.Loaded);
|
||||
dispatch(ACTIONS.fetchOnlineData);
|
||||
|
||||
await dispatch(ACTIONS.loadStaticStationData);
|
||||
await dispatch(ACTIONS.fetchOnlineData);
|
||||
|
||||
setInterval(() => dispatch(ACTIONS.fetchOnlineData), Math.floor(Math.random() * 5000) + 25000);
|
||||
},
|
||||
|
||||
async fetchOnlineData({ commit, dispatch }) {
|
||||
commit(MUTATIONS.SET_DATA_CONNECTION_STATUS, DataStatus.Loading);
|
||||
async loadStaticStationData({ commit }) {
|
||||
// Nowy parametr żądania co godzinę
|
||||
const sceneryData: StationJSONData = await (await axios.get(`${URLs.sceneryData}?time=${Math.floor(Date.now() / 1800000)}`)).data;
|
||||
|
||||
Promise.all([axios.get(URLs.stations), axios.get(URLs.trains), axios.get(URLs.dispatchers)])
|
||||
.then(async response => {
|
||||
const onlineStationsData: { success: boolean, message: StationAPIData[] } = response[0].data;
|
||||
const onlineTrainsData: { success: boolean, message: TrainAPIData[] } = await response[1].data;
|
||||
const onlineDispatchersData: { success: boolean, message: string[][] } = await response[2].data;
|
||||
|
||||
if (!onlineStationsData.success) {
|
||||
// commit(MUTATIONS.SET_DATA_CONNECTION_STATUS, DataStatus.Error);
|
||||
commit(MUTATIONS.SET_SCENERY_DATA_STATUS, DataStatus.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
commit(MUTATIONS.SET_SCENERY_DATA_STATUS, DataStatus.Loaded);
|
||||
commit(MUTATIONS.SET_DISPATCHER_DATA_STATUS, onlineDispatchersData.success ? DataStatus.Loaded : DataStatus.Warning);
|
||||
commit(MUTATIONS.SET_TRAINS_DATA_STATUS, onlineTrainsData.success ? DataStatus.Loaded : DataStatus.Warning);
|
||||
|
||||
const updatedStationList: Station['onlineInfo'][] = onlineStationsData.message.reduce((acc, station) => {
|
||||
if (station.region !== this.state.region.id || !station.isOnline) return acc;
|
||||
|
||||
const stationStatus = onlineDispatchersData.success ? onlineDispatchersData.message.find((status: string[]) => status[0] == station.stationHash && status[1] == this.state.region.id) : -1;
|
||||
|
||||
const statusTimestamp = getStatusTimestamp(stationStatus);
|
||||
const statusID = getStatusID(stationStatus);
|
||||
|
||||
const stationTrains = onlineTrainsData.success ? onlineTrainsData.message
|
||||
.filter(train => train.region === this.state.region.id && train.isOnline && train.station.stationName === station.stationName)
|
||||
.map(train => ({ driverName: train.driverName, trainNo: train.trainNo })) : [];
|
||||
|
||||
|
||||
acc.push({
|
||||
name: station.stationName,
|
||||
hash: station.stationHash,
|
||||
maxUsers: station.maxUsers,
|
||||
currentUsers: station.currentUsers,
|
||||
spawns: parseSpawns(station.spawnString),
|
||||
dispatcherName: station.dispatcherName,
|
||||
dispatcherRate: station.dispatcherRate,
|
||||
dispatcherId: station.dispatcherId,
|
||||
dispatcherExp: station.dispatcherExp,
|
||||
dispatcherIsSupporter: station.dispatcherIsSupporter,
|
||||
stationTrains,
|
||||
statusTimestamp,
|
||||
statusID,
|
||||
statusTimeString: timestampToString(statusTimestamp),
|
||||
});
|
||||
|
||||
return acc;
|
||||
}, [] as Station['onlineInfo'][]);
|
||||
|
||||
const updatedTrainList = onlineTrainsData.success ? await Promise.all(
|
||||
onlineTrainsData.message
|
||||
.filter(train => train.region === this.state.region.id)
|
||||
.map(async train => {
|
||||
const locoType = train.dataCon.split(";") ? train.dataCon.split(";")[0] : train.dataCon;
|
||||
|
||||
return {
|
||||
trainNo: train.trainNo,
|
||||
mass: train.dataMass,
|
||||
length: train.dataLength,
|
||||
speed: train.dataSpeed,
|
||||
distance: train.dataDistance,
|
||||
signal: train.dataSignal,
|
||||
online: train.isOnline,
|
||||
driverId: train.driverId,
|
||||
driverName: train.driverName,
|
||||
currentStationName: train.station.stationName,
|
||||
currentStationHash: train.station.stationHash,
|
||||
connectedTrack: train.dataSceneryConnection,
|
||||
locoType,
|
||||
locoURL: getLocoURL(locoType),
|
||||
cars: train.dataCon.split(";").filter((train, i) => i > 0) || [],
|
||||
};
|
||||
})
|
||||
) : [];
|
||||
|
||||
// Pass reduced lists to mutations
|
||||
commit(MUTATIONS.UPDATE_STATIONS, updatedStationList);
|
||||
commit(MUTATIONS.UPDATE_TRAINS, updatedTrainList);
|
||||
|
||||
// Statuses
|
||||
commit(MUTATIONS.SET_DATA_CONNECTION_STATUS, DataStatus.Loaded);
|
||||
|
||||
// commit(MUTATIONS.SET_TIMETABLE_DATA_STATUS, DataStatus.Loading);
|
||||
dispatch(ACTIONS.fetchTimetableData);
|
||||
})
|
||||
.catch(() => {
|
||||
commit(MUTATIONS.SET_DATA_CONNECTION_STATUS, DataStatus.Error);
|
||||
});
|
||||
if (!sceneryData)
|
||||
commit(MUTATIONS.SET_SCENERY_DATA_STATUS, DataStatus.Error);
|
||||
else
|
||||
commit(MUTATIONS.SET_SCENERY_DATA, sceneryData);
|
||||
},
|
||||
|
||||
async fetchTimetableData({ commit }) {
|
||||
let warnings = 0;
|
||||
async fetchOnlineData({ commit }) {
|
||||
// Pobierz dane o pociągach i rozkładach jazdy z API Stacjownika
|
||||
const trainsAPIData: { response: TrainAPIData[], errorMessage?: string } = (await axios.get(`${URLs.stacjownikAPI}/api/getActiveTrainList`)).data;
|
||||
|
||||
const timetableList = this.state.trainList.reduce(async (acc: Promise<Timetable[]>, train: Train) => {
|
||||
const data: { success: boolean; message: TimetableAPIData } = await (await axios.get(URLs.getTimetableURL(train.trainNo, this.state.region.id))).data;
|
||||
// Pobierz dane o sceneriach online i o dyżurnych
|
||||
const dispatchersAPIData: { success: boolean, message: string[][] } = await (await axios.get(URLs.dispatchers)).data;
|
||||
const stationsAPIData: { success: boolean, message: StationAPIData[] } = await (await axios.get(URLs.stations)).data;
|
||||
|
||||
if (!data.success) {
|
||||
warnings++;
|
||||
if (!stationsAPIData || !stationsAPIData.success) {
|
||||
commit(MUTATIONS.SET_SCENERY_DATA_STATUS, DataStatus.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
(await acc).push({
|
||||
trainNo: train.trainNo,
|
||||
success: false
|
||||
commit(MUTATIONS.SET_SCENERY_DATA_STATUS, DataStatus.Loaded);
|
||||
|
||||
if (!dispatchersAPIData || !dispatchersAPIData.success)
|
||||
commit(MUTATIONS.SET_DISPATCHER_DATA_STATUS, DataStatus.Warning)
|
||||
|
||||
if (!trainsAPIData || !trainsAPIData.response)
|
||||
commit(MUTATIONS.SET_TRAINS_DATA_STATUS, DataStatus.Warning);
|
||||
|
||||
|
||||
// Zaktualizuj listę pociągów
|
||||
const updatedTrainList: Train[] =
|
||||
trainsAPIData?.response
|
||||
.filter(train => train.region === this.state.region.id && train.online)
|
||||
.map(train => {
|
||||
const stock = train.stockString.split(";");
|
||||
const locoType = stock ? stock[0] : train.stockString;
|
||||
|
||||
const timetable = train.timetable;
|
||||
|
||||
return {
|
||||
trainNo: train.trainNo,
|
||||
mass: train.mass,
|
||||
length: train.length,
|
||||
speed: train.speed,
|
||||
region: train.region,
|
||||
|
||||
distance: train.distance,
|
||||
signal: train.signal,
|
||||
online: train.online,
|
||||
driverId: train.driverId,
|
||||
driverName: train.driverName,
|
||||
currentStationName: train.currentStationName,
|
||||
currentStationHash: train.currentStationHash,
|
||||
connectedTrack: train.connectedTrack,
|
||||
locoType,
|
||||
locoURL: getLocoURL(locoType),
|
||||
cars: stock.slice(1),
|
||||
|
||||
timetableData: timetable ? {
|
||||
timetableId: timetable.timetableId,
|
||||
SKR: timetable.SKR,
|
||||
TWR: timetable.TWR,
|
||||
route: timetable.route,
|
||||
category: timetable.category,
|
||||
followingStops: timetable.stopList,
|
||||
routeDistance: timetable.stopList[timetable.stopList.length - 1].stopDistance,
|
||||
sceneries: timetable.sceneries
|
||||
} : undefined
|
||||
};
|
||||
}) || []
|
||||
|
||||
const onlineStationNames: string[] = [];
|
||||
|
||||
stationsAPIData.message.forEach((stationAPI) => {
|
||||
if (stationAPI.region !== this.state.region.id || !stationAPI.isOnline) return;
|
||||
|
||||
onlineStationNames.push(stationAPI.stationName);
|
||||
|
||||
const stationName = stationAPI.stationName.toLowerCase();
|
||||
const station = this.state.stationList.find(s => s.name == stationAPI.stationName);
|
||||
|
||||
const stationStatus = dispatchersAPIData.success ? dispatchersAPIData.message.find((status: string[]) => status[0] == stationAPI.stationHash && status[1] == this.state.region.id) : -1;
|
||||
const statusTimestamp = getStatusTimestamp(stationStatus);
|
||||
const statusID = getStatusID(stationStatus);
|
||||
|
||||
const stationTrains = trainsAPIData.response
|
||||
.filter(train => train.region === this.state.region.id && train.online && train.currentStationName === stationAPI.stationName)
|
||||
.map(train => ({ driverName: train.driverName, trainNo: train.trainNo }));
|
||||
|
||||
station?.generalInfo?.checkpoints.forEach(cp => cp.scheduledTrains.length = 0);
|
||||
|
||||
const scheduledTrains: ScheduledTrain[] = updatedTrainList.reduce((acc: ScheduledTrain[], train) => {
|
||||
if (!train.timetableData) return acc;
|
||||
|
||||
const timetable = train.timetableData;
|
||||
if (!timetable.sceneries.includes(stationAPI.stationHash)) return acc;
|
||||
|
||||
const stopInfoIndex = timetable.followingStops.findIndex(stop => {
|
||||
const stopName = stop.stopNameRAW.toLowerCase();
|
||||
|
||||
// if (stop.stopName == "ARKADIA ZDRÓJ" && station.name == "Arkadia Zdrój 2019" && stop.pointId != "1583014379097") return false;
|
||||
// if (stop.stopName == "ARKADIA ZDRÓJ" && station.name == "Arkadia Zdrój 2012" && stop.pointId != "1519258642187") return false;
|
||||
|
||||
if (stationName === stopName) return true;
|
||||
if (stopName.includes(stationName) && !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 (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;
|
||||
});
|
||||
|
||||
return acc;
|
||||
}
|
||||
if (stopInfoIndex == -1) return acc;
|
||||
|
||||
const timetable = data.message;
|
||||
const trainInfo = timetable.trainInfo;
|
||||
const trainStop = timetable.followingStops[stopInfoIndex];
|
||||
const scheduledStopTrain = getScheduledTrain(train, trainStop, stationAPI.stationName);
|
||||
|
||||
if (!timetable || !trainInfo) return acc;
|
||||
if (station && station.generalInfo?.checkpoints && station.generalInfo.checkpoints.length > 0) {
|
||||
for (const checkpoint of station.generalInfo.checkpoints) {
|
||||
timetable.followingStops
|
||||
.filter(trainStop => trainStop.stopNameRAW.toLowerCase() === checkpoint.checkpointName.toLowerCase())
|
||||
.forEach(trainCheckpointStop => {
|
||||
const scheduledCheckpointTrain = getScheduledTrain(train, trainCheckpointStop, stationAPI.stationName);
|
||||
|
||||
let lastArrivalLine = "";
|
||||
|
||||
const followingStops: TrainStop[] = timetable.stopPoints.reduce((stopsAcc: TrainStop[], point) => {
|
||||
if (point.pointNameRAW.toLowerCase().includes("sbl")) {
|
||||
if (point.arrivalLine && !point.arrivalLine.toLocaleLowerCase().includes("sbl"))
|
||||
lastArrivalLine = point.arrivalLine;
|
||||
|
||||
if (point.departureLine && !point.departureLine.toLocaleLowerCase().includes("sbl")) {
|
||||
stopsAcc[stopsAcc.length - 1].departureLine = point.departureLine
|
||||
checkpoint.scheduledTrains.push(scheduledCheckpointTrain);
|
||||
});
|
||||
}
|
||||
|
||||
return stopsAcc;
|
||||
}
|
||||
|
||||
const arrivalTimestamp = getTimestamp(point.arrivalTime);
|
||||
const arrivalRealTimestamp = getTimestamp(point.arrivalRealTime);
|
||||
|
||||
const departureTimestamp = getTimestamp(point.departureTime);
|
||||
const departureRealTimestamp = getTimestamp(point.departureRealTime);
|
||||
|
||||
let arrivalLine = lastArrivalLine || point.arrivalLine;
|
||||
|
||||
if (lastArrivalLine != "")
|
||||
lastArrivalLine = "";
|
||||
|
||||
stopsAcc.push({
|
||||
stopName: point.pointName,
|
||||
stopNameRAW: point.pointNameRAW,
|
||||
stopType: point.pointStopType,
|
||||
stopDistance: point.pointDistance,
|
||||
pointId: point.pointId,
|
||||
|
||||
comments: point.comments,
|
||||
|
||||
mainStop: point.pointName.includes("strong"),
|
||||
|
||||
arrivalLine,
|
||||
arrivalTimeString: timestampToString(arrivalTimestamp),
|
||||
arrivalTimestamp: arrivalTimestamp,
|
||||
arrivalRealTimeString: timestampToString(arrivalRealTimestamp),
|
||||
arrivalRealTimestamp: arrivalRealTimestamp,
|
||||
arrivalDelay: point.arrivalDelay,
|
||||
|
||||
departureLine: point.departureLine,
|
||||
departureTimeString: timestampToString(departureTimestamp),
|
||||
departureTimestamp: departureTimestamp,
|
||||
departureRealTimeString: timestampToString(departureRealTimestamp),
|
||||
departureRealTimestamp: departureRealTimestamp,
|
||||
departureDelay: point.departureDelay,
|
||||
|
||||
beginsHere: arrivalTimestamp == 0,
|
||||
terminatesHere: departureTimestamp == 0,
|
||||
|
||||
confirmed: point.confirmed,
|
||||
stopped: point.isStopped,
|
||||
stopTime: point.pointStopTime
|
||||
});
|
||||
|
||||
return stopsAcc;
|
||||
acc.push(scheduledStopTrain);
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
(await acc).push({
|
||||
data: {
|
||||
trainNo: train.trainNo,
|
||||
driverName: train.driverName,
|
||||
driverId: train.driverId,
|
||||
currentStationName: train.currentStationName,
|
||||
currentStationHash: train.currentStationHash,
|
||||
timetableId: trainInfo.timetableId,
|
||||
category: trainInfo.trainCategoryCode,
|
||||
route: trainInfo.route,
|
||||
TWR: trainInfo.twr,
|
||||
SKR: trainInfo.skr,
|
||||
routeDistance: timetable.stopPoints[timetable.stopPoints.length - 1].pointDistance,
|
||||
followingStops,
|
||||
followingSceneries: trainInfo.sceneries
|
||||
},
|
||||
const onlineInfo = {
|
||||
name: stationAPI.stationName,
|
||||
hash: stationAPI.stationHash,
|
||||
maxUsers: stationAPI.maxUsers,
|
||||
currentUsers: stationAPI.currentUsers,
|
||||
spawns: parseSpawns(stationAPI.spawnString),
|
||||
dispatcherName: stationAPI.dispatcherName,
|
||||
dispatcherRate: stationAPI.dispatcherRate,
|
||||
dispatcherId: stationAPI.dispatcherId,
|
||||
dispatcherExp: stationAPI.dispatcherExp,
|
||||
dispatcherIsSupporter: stationAPI.dispatcherIsSupporter,
|
||||
stationTrains,
|
||||
statusTimestamp,
|
||||
statusID,
|
||||
scheduledTrains,
|
||||
// statusTimeString: timestampToString(statusTimestamp),
|
||||
}
|
||||
|
||||
trainNo: train.trainNo,
|
||||
success: true
|
||||
if (!station) {
|
||||
this.state.stationList.push({
|
||||
name: stationAPI.stationName,
|
||||
onlineInfo
|
||||
})
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
station.onlineInfo = { ...onlineInfo };
|
||||
|
||||
});
|
||||
|
||||
this.state.stationList
|
||||
.filter(station => !onlineStationNames.includes(station.name) && station.onlineInfo)
|
||||
.forEach(offlineStation => {
|
||||
offlineStation.onlineInfo = undefined;
|
||||
});
|
||||
|
||||
return acc;
|
||||
}, Promise.resolve([]));
|
||||
|
||||
commit(MUTATIONS.UPDATE_TIMETABLES, (await timetableList));
|
||||
commit(MUTATIONS.SET_TIMETABLE_DATA_STATUS, warnings == 0 ? DataStatus.Loaded : DataStatus.Warning);
|
||||
}
|
||||
|
||||
this.state.trainList = updatedTrainList;
|
||||
},
|
||||
},
|
||||
|
||||
mutations: {
|
||||
SET_SCENERY_DATA(state, data: StationJSONData[]) {
|
||||
|
||||
state.stationList = data.map(stationData => ({
|
||||
name: stationData.name,
|
||||
|
||||
@@ -349,7 +313,7 @@ export const store = createStore<State>({
|
||||
routes: stationData.routes?.split(";").filter(routeString => routeString).reduce((acc, routeString) => {
|
||||
const specs1 = routeString.split("_")[0];
|
||||
const isInternal = specs1.startsWith('!');
|
||||
const name = isInternal ? specs1.replace("!", "") : specs1;
|
||||
const name = isInternal ? specs1.replace("!", "") : specs1;
|
||||
|
||||
const specs2 = routeString.split("_")[1].split("");
|
||||
const twoWay = specs2[0] == "2";
|
||||
@@ -366,7 +330,7 @@ export const store = createStore<State>({
|
||||
: 'oneWayNoCatenaryRouteNames';
|
||||
|
||||
acc[twoWay ? 'twoWay' : 'oneWay'].push({ name, SBL, TWB, catenary, isInternal, tracks: twoWay ? 2 : 1 });
|
||||
if(!isInternal) acc[propName].push(name);
|
||||
if (!isInternal) acc[propName].push(name);
|
||||
|
||||
if (SBL) acc['sblRouteNames'].push(name);
|
||||
|
||||
@@ -383,21 +347,13 @@ export const store = createStore<State>({
|
||||
checkpoints: stationData.checkpoints ? stationData.checkpoints.split(";").map(sub => ({ checkpointName: sub, scheduledTrains: [] })) : [],
|
||||
}
|
||||
}));
|
||||
},
|
||||
|
||||
|
||||
SET_DATA_CONNECTION_STATUS(state, status: DataStatus) {
|
||||
state.dataConnectionStatus = status;
|
||||
},
|
||||
|
||||
SET_SCENERY_DATA_STATUS(state, status: DataStatus) {
|
||||
state.sceneryDataStatus = status;
|
||||
},
|
||||
|
||||
SET_TIMETABLE_DATA_STATUS(state, status: DataStatus) {
|
||||
state.timetableDataStatus = status;
|
||||
},
|
||||
|
||||
SET_DISPATCHER_DATA_STATUS(state, status: DataStatus) {
|
||||
state.dispatcherDataStatus = status;
|
||||
},
|
||||
@@ -406,187 +362,10 @@ export const store = createStore<State>({
|
||||
state.trainsDataStatus = status;
|
||||
},
|
||||
|
||||
|
||||
SET_REGION(state, region: { id: string; value: string }) {
|
||||
state.region = region;
|
||||
},
|
||||
|
||||
UPDATE_STATIONS(state, updatedStationList: Station['onlineInfo'][]) {
|
||||
|
||||
state.stationList = state.stationList.reduce((acc: Station[], station) => {
|
||||
const onlineStationData = updatedStationList.find(updatedStation => updatedStation?.name === station.name);
|
||||
const listedStationData = state.stationList.find(data => data.name === station.name);
|
||||
|
||||
if (onlineStationData)
|
||||
acc.push({
|
||||
name: station.name,
|
||||
generalInfo: station.generalInfo,
|
||||
onlineInfo: {
|
||||
...onlineStationData,
|
||||
scheduledTrains: station.onlineInfo?.scheduledTrains || []
|
||||
},
|
||||
});
|
||||
else if (listedStationData)
|
||||
acc.push({
|
||||
...station,
|
||||
onlineInfo: undefined
|
||||
});
|
||||
|
||||
return acc;
|
||||
}, [] as Station[]);
|
||||
|
||||
updatedStationList
|
||||
.filter(uStation => !state.stationList.some(station => uStation?.name === station.name))
|
||||
.forEach(uStation => {
|
||||
if (!uStation) return;
|
||||
|
||||
state.stationList.push({
|
||||
name: uStation.name,
|
||||
|
||||
onlineInfo: {
|
||||
...uStation,
|
||||
scheduledTrains: [],
|
||||
stationTrains: uStation.stationTrains || []
|
||||
},
|
||||
generalInfo: undefined
|
||||
});
|
||||
});
|
||||
|
||||
state.stationCount = state.stationList.filter(station => station.onlineInfo).length;
|
||||
state.dataConnectionStatus = DataStatus.Loaded;
|
||||
},
|
||||
|
||||
UPDATE_TRAINS(state, updatedTrainList: any[]) {
|
||||
state.trainList = updatedTrainList.reduce((acc, updatedTrain) => {
|
||||
const trainData = state.trainList.find(train => train.trainNo === updatedTrain.trainNo);
|
||||
|
||||
if (trainData) acc.push({ ...trainData, ...updatedTrain });
|
||||
else acc.push({ ...updatedTrain });
|
||||
|
||||
return acc;
|
||||
}, [] as Train[]);
|
||||
|
||||
state.trainCount = state.trainList.length;
|
||||
|
||||
state.dataConnectionStatus = DataStatus.Loaded;
|
||||
},
|
||||
|
||||
UPDATE_TIMETABLES(state, timetableList: Timetable[]) {
|
||||
state.stationList = state.stationList.map(station => {
|
||||
const stationName = station.name.toLowerCase();
|
||||
|
||||
const scheduledTrains: ScheduledTrain[] = timetableList.reduce((acc: ScheduledTrain[], timetable: Timetable) => {
|
||||
if (!timetable.data)
|
||||
return acc;
|
||||
|
||||
if (!timetable.data.followingSceneries.includes(station.onlineInfo?.hash || "")) return acc;
|
||||
|
||||
const stopInfoIndex = timetable.data.followingStops.findIndex(stop => {
|
||||
const stopName = stop.stopNameRAW.toLowerCase();
|
||||
|
||||
// if (stop.stopName == "ARKADIA ZDRÓJ" && station.name == "Arkadia Zdrój 2019" && stop.pointId != "1583014379097") return false;
|
||||
// if (stop.stopName == "ARKADIA ZDRÓJ" && station.name == "Arkadia Zdrój 2012" && stop.pointId != "1519258642187") return false;
|
||||
|
||||
if (stationName === stopName) return true;
|
||||
if (stopName.includes(stationName) && !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 (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;
|
||||
});
|
||||
|
||||
if (stopInfoIndex == -1) return acc;
|
||||
|
||||
const trainStop = timetable.data.followingStops[stopInfoIndex];
|
||||
const trainStopStatus = getTrainStopStatus(trainStop, timetable.data.currentStationName, station);
|
||||
|
||||
acc.push({
|
||||
trainNo: timetable.data.trainNo,
|
||||
driverName: timetable.data.driverName,
|
||||
driverId: timetable.data.driverId,
|
||||
currentStationName: timetable.data.currentStationName,
|
||||
currentStationHash: timetable.data.currentStationHash,
|
||||
category: timetable.data.category,
|
||||
beginsAt: timetable.data.followingStops[0].stopNameRAW,
|
||||
terminatesAt: timetable.data.followingStops[timetable.data.followingStops.length - 1].stopNameRAW,
|
||||
nearestStop: "",
|
||||
stopInfo: trainStop,
|
||||
stopLabel: trainStopStatus.stopLabel,
|
||||
stopStatus: trainStopStatus.stopStatus,
|
||||
stopStatusID: trainStopStatus.stopStatusID
|
||||
});
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
if (station.generalInfo && station.generalInfo.checkpoints.length > 0) {
|
||||
station.generalInfo.checkpoints.forEach(cp => (cp.scheduledTrains.length = 0));
|
||||
|
||||
for (const checkpoint of station.generalInfo.checkpoints) {
|
||||
timetableList.forEach(timetable => {
|
||||
if (!timetable.data) return;
|
||||
if (!timetable.data.followingSceneries.includes(station.onlineInfo?.hash || "")) return;
|
||||
|
||||
const timetableData = timetable.data;
|
||||
|
||||
timetableData.followingStops
|
||||
.filter(trainStop => trainStop.stopNameRAW.toLowerCase() === checkpoint.checkpointName.toLowerCase())
|
||||
.forEach(trainStop => {
|
||||
const trainStopStatus = getTrainStopStatus(trainStop, timetableData.currentStationName, station);
|
||||
|
||||
checkpoint.scheduledTrains.push({
|
||||
trainNo: timetable.trainNo,
|
||||
driverName: timetableData.driverName,
|
||||
driverId: timetableData.driverId,
|
||||
currentStationName: timetableData.currentStationName,
|
||||
currentStationHash: timetableData.currentStationHash,
|
||||
category: timetableData.category,
|
||||
beginsAt: timetableData.followingStops[0].stopNameRAW,
|
||||
terminatesAt: timetableData.followingStops[timetableData.followingStops.length - 1].stopNameRAW,
|
||||
nearestStop: "",
|
||||
stopInfo: trainStop,
|
||||
stopLabel: trainStopStatus.stopLabel,
|
||||
stopStatus: trainStopStatus.stopStatus,
|
||||
stopStatusID: trainStopStatus.stopStatusID
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
...station,
|
||||
onlineInfo: station.onlineInfo ? {
|
||||
...station.onlineInfo,
|
||||
scheduledTrains
|
||||
} : undefined
|
||||
};
|
||||
});
|
||||
|
||||
state.trainList = state.trainList.reduce((acc, train) => {
|
||||
const timetable = timetableList.find(tt => tt.data && tt.trainNo === train.trainNo && tt.data.driverId === train.driverId);
|
||||
|
||||
if (!train.online && !timetable) return acc;;
|
||||
|
||||
const trainStopData = state.stationList
|
||||
.find(station => station.name === train.currentStationName)
|
||||
?.onlineInfo?.scheduledTrains?.find(stationTrain => stationTrain.trainNo === train.trainNo);
|
||||
|
||||
acc.push({ ...train, timetableData: timetable?.data, stopStatus: trainStopData?.stopStatus || "", stopLabel: trainStopData?.stopLabel || "" });
|
||||
|
||||
return acc;
|
||||
}, [] as Train[]);
|
||||
|
||||
state.timetableDataStatus = DataStatus.Loaded;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
+13
-13
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="scenery-view">
|
||||
<div class="scenery-offline" v-if="!stationInfo && isDataLoaded && isComponentVisible">
|
||||
<div class="scenery-offline" v-if="!stationInfo && isComponentVisible">
|
||||
<div>{{ $t('scenery.no-scenery') }}</div>
|
||||
|
||||
<action-button>
|
||||
@@ -77,8 +77,8 @@ export default defineComponent({
|
||||
|
||||
viewMode: 'info',
|
||||
|
||||
stationInfo: {} as (Station | undefined),
|
||||
onlineFrom: -1
|
||||
stationInfo: {} as Station | undefined,
|
||||
onlineFrom: -1,
|
||||
}),
|
||||
|
||||
setup() {
|
||||
@@ -91,12 +91,11 @@ export default defineComponent({
|
||||
|
||||
const isComponentVisible = computed(() => route.path === '/scenery');
|
||||
|
||||
const isDataLoaded = computed(() => data.value.dataConnectionStatus === DataStatus.Loaded);
|
||||
|
||||
const stationInfo = computed(() => {
|
||||
return data.value.stationList.find((station) => station.name === route.query.station?.toString().replace(/_/g, ' '))
|
||||
})
|
||||
|
||||
const stationInfo = computed(() => {
|
||||
return data.value.stationList.find(
|
||||
(station) => station.name === route.query.station?.toString().replace(/_/g, ' ')
|
||||
);
|
||||
});
|
||||
|
||||
// const onlineFrom = computed(async () => {
|
||||
// return await (await axios.get(`${URLs.stacjownikAPI}?name=${route.query.station}&historyCount=0`)).data;
|
||||
@@ -107,8 +106,7 @@ export default defineComponent({
|
||||
currentRegion: computed(() => store.getters[GETTERS.currentRegion]),
|
||||
timetableOnly,
|
||||
isComponentVisible,
|
||||
isDataLoaded,
|
||||
stationInfo
|
||||
stationInfo,
|
||||
};
|
||||
},
|
||||
|
||||
@@ -126,10 +124,12 @@ export default defineComponent({
|
||||
// this.stationInfo = (this.$store.getters[GETTERS.allData] as StoreData).stationList.find((station) => station.name === this.$route.query.station?.toString().replace(/_/g, ' '))
|
||||
},
|
||||
|
||||
async activated() {
|
||||
async activated() {
|
||||
if (this.currentRegion.id != 'eu' && this.viewMode == 'history') this.viewMode = 'info';
|
||||
|
||||
const onlineFrom = await (await axios.get(`${URLs.stacjownikAPI}/api/getSceneryHistory?name=${this.$route.query.station}&historyCount=0`)).data;
|
||||
const onlineFrom = await (
|
||||
await axios.get(`${URLs.stacjownikAPI}/api/getSceneryHistory?name=${this.$route.query.station}&historyCount=0`)
|
||||
).data;
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -90,18 +90,6 @@ export default defineComponent({
|
||||
return filterManager.getFilteredStationList(store.getters[GETTERS.stationList]);
|
||||
});
|
||||
|
||||
const getStatusClass = computed(() => {
|
||||
if (data.value.dataConnectionStatus == DataStatus.Loading) return 'loading';
|
||||
if (data.value.dataConnectionStatus == DataStatus.Error) return 'error';
|
||||
return 'success';
|
||||
});
|
||||
|
||||
const timetableDataStatusClass = computed(() => {
|
||||
if (data.value.timetableDataStatus == DataStatus.Loading) return 'loading';
|
||||
if (data.value.timetableDataStatus == DataStatus.Error) return 'error';
|
||||
return 'success';
|
||||
});
|
||||
|
||||
const focusedStationInfo = computed(() =>
|
||||
computedStations.value.find((station) => station.name === focusedStationName)
|
||||
);
|
||||
@@ -110,8 +98,6 @@ export default defineComponent({
|
||||
data,
|
||||
computedStations,
|
||||
filterManager,
|
||||
getStatusClass,
|
||||
timetableDataStatusClass,
|
||||
focusedStationName,
|
||||
focusedStationInfo,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user