mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5c4c486643 | |||
| 755c729a9b | |||
| 3ac8d60c5c | |||
| dcff3b088f | |||
| 90b2099955 | |||
| fc0c04ec9d | |||
| 41b335555a | |||
| 60f7b3bbb5 | |||
| eaefe955a7 | |||
| edaa4f2684 | |||
| 30fce3787b |
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "stacjownik",
|
||||
"version": "1.20.4",
|
||||
"version": "1.21.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
+3
-47
@@ -47,8 +47,6 @@ import TrainModal from './components/TrainsView/TrainModal.vue';
|
||||
import StorageManager from './managers/storageManager';
|
||||
import { useApiStore } from './store/apiStore';
|
||||
import { Status } from './typings/common';
|
||||
import { Websocket } from './typings/api';
|
||||
import socket from './websocket';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
@@ -88,39 +86,7 @@ export default defineComponent({
|
||||
this.setReleaseURL();
|
||||
this.setupOfflineHandling();
|
||||
|
||||
this.apiStore.setupStaticAPIData();
|
||||
this.connectToWebsocket();
|
||||
},
|
||||
|
||||
async connectToWebsocket() {
|
||||
this.apiStore.dataStatuses.connection = Status.Data.Loading;
|
||||
|
||||
console.log('ws connecting');
|
||||
|
||||
socket.on('connect_error', (err) => {
|
||||
console.error(`WS connection error: ${err.message}`);
|
||||
|
||||
this.apiStore.dataStatuses.connection = Status.Data.Error;
|
||||
this.apiStore.websocketData = undefined;
|
||||
});
|
||||
|
||||
let timeFrom = Date.now();
|
||||
socket.on('connect', () => {
|
||||
socket.emit('CONNECTION', { version: packageInfo.version }, () => {
|
||||
console.log(`Connection time: ${Date.now() - timeFrom}ms`);
|
||||
});
|
||||
|
||||
console.log('ws connected');
|
||||
});
|
||||
|
||||
socket.on('UPDATE', (data: Websocket.Payload) => {
|
||||
console.log('ws update');
|
||||
|
||||
this.apiStore.websocketData = data;
|
||||
this.apiStore.dataStatuses.connection = Status.Data.Loaded;
|
||||
});
|
||||
|
||||
this.fetchWebsocketData();
|
||||
this.apiStore.setupAPIData();
|
||||
},
|
||||
|
||||
setupOfflineHandling() {
|
||||
@@ -135,24 +101,14 @@ export default defineComponent({
|
||||
handleOfflineMode() {
|
||||
this.store.isOffline = true;
|
||||
|
||||
this.apiStore.websocketData = undefined;
|
||||
this.apiStore.activeData = undefined;
|
||||
this.apiStore.dataStatuses.connection = Status.Data.Offline;
|
||||
},
|
||||
|
||||
handleOnlineMode() {
|
||||
this.store.isOffline = false;
|
||||
|
||||
this.apiStore.setupStaticAPIData();
|
||||
this.connectToWebsocket();
|
||||
},
|
||||
|
||||
fetchWebsocketData() {
|
||||
socket.emit('FETCH_DATA', (data: Websocket.Payload) => {
|
||||
console.log('ws fetch data');
|
||||
|
||||
this.apiStore.websocketData = data;
|
||||
this.apiStore.dataStatuses.connection = Status.Data.Loaded;
|
||||
});
|
||||
this.apiStore.setupAPIData();
|
||||
},
|
||||
|
||||
changeLang(lang: string) {
|
||||
|
||||
@@ -100,8 +100,8 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
onlineDispatchersCount() {
|
||||
return this.store.onlineSceneryList.filter(
|
||||
(scenery) => scenery.region == this.store.region.id
|
||||
return this.store.activeSceneryList.filter(
|
||||
(scenery) => scenery.region == this.store.region.id && scenery.dispatcherId != -1
|
||||
).length;
|
||||
},
|
||||
|
||||
|
||||
@@ -36,11 +36,11 @@
|
||||
<circle id="Ellipse 18" cx="15" cy="17" r="7" fill="#393838" />
|
||||
</g>
|
||||
|
||||
<g v-if="greenLight" filter="url(#filter0_d_843_28)">
|
||||
<g v-if="indicator.lights.greenLight" filter="url(#filter0_d_843_28)">
|
||||
<circle cx="15" cy="17" r="7" fill="#00FF0A" />
|
||||
</g>
|
||||
|
||||
<g v-if="greenBlinkLight" filter="url(#filter0_d_843_28)">
|
||||
<g v-if="indicator.lights.greenBlinkLight" filter="url(#filter0_d_843_28)">
|
||||
<circle cx="15" cy="17" r="7" fill="#00FF0A" />
|
||||
|
||||
<animate
|
||||
@@ -52,14 +52,14 @@
|
||||
/>
|
||||
</g>
|
||||
|
||||
<g v-if="redTopLight" filter="url(#filter1_d_843_28)">
|
||||
<g v-if="indicator.lights.redTopLight" filter="url(#filter1_d_843_28)">
|
||||
<circle cx="15" cy="36" r="7" fill="#F40000" />
|
||||
</g>
|
||||
|
||||
<g v-if="orangeLight" filter="url(#filter2_d_843_28)">
|
||||
<g v-if="indicator.lights.orangeLight" filter="url(#filter2_d_843_28)">
|
||||
<circle cx="15" cy="55" r="7" fill="#FFB800" />
|
||||
</g>
|
||||
<g v-if="redBottomLight" filter="url(#filter3_d_843_28)">
|
||||
<g v-if="indicator.lights.redBottomLight" filter="url(#filter3_d_843_28)">
|
||||
<circle cx="15" cy="74" r="7" fill="#F40000" />
|
||||
|
||||
<animate
|
||||
@@ -186,7 +186,11 @@
|
||||
</svg>
|
||||
|
||||
<transition name="tooltip-anim">
|
||||
<div v-html="$t(indicator.message)" class="indicator-tooltip" v-if="tooltipActive"></div>
|
||||
<div
|
||||
v-html="$t('data-status.' + indicator.message)"
|
||||
class="indicator-tooltip"
|
||||
v-if="tooltipActive"
|
||||
></div>
|
||||
</transition>
|
||||
</div>
|
||||
</div>
|
||||
@@ -194,125 +198,112 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { useMainStore } from '../../store/mainStore';
|
||||
import { Status } from '../../typings/common';
|
||||
import { useApiStore } from '../../store/apiStore';
|
||||
import { APIDataStatus } from '../../typings/api';
|
||||
|
||||
interface Indicator {
|
||||
// status: Status.Data;
|
||||
message: string;
|
||||
|
||||
lights: {
|
||||
greenLight: boolean;
|
||||
greenBlinkLight: boolean;
|
||||
redTopLight: boolean;
|
||||
orangeLight: boolean;
|
||||
redBottomLight: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
data() {
|
||||
return {
|
||||
tooltipActive: false,
|
||||
indicator: {
|
||||
offline: false,
|
||||
status: Status.Data.Loading,
|
||||
message: 'data-status.S3'
|
||||
},
|
||||
|
||||
greenLight: false,
|
||||
greenBlinkLight: false,
|
||||
redTopLight: false,
|
||||
orangeLight: false,
|
||||
redBottomLight: false
|
||||
apiStore: useApiStore()
|
||||
};
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.setSignalStatus(Status.Data.Loading);
|
||||
},
|
||||
|
||||
setup() {
|
||||
const store = useMainStore();
|
||||
const apiStore = useApiStore();
|
||||
|
||||
return {
|
||||
dataStatus: apiStore.dataStatuses,
|
||||
store
|
||||
};
|
||||
},
|
||||
|
||||
watch: {
|
||||
dataStatus: {
|
||||
deep: true,
|
||||
|
||||
handler(statuses: any) {
|
||||
const connectionStatus = statuses.connection;
|
||||
const sceneryDataStatus = statuses.sceneries;
|
||||
const trainsDataStatus = statuses.trains;
|
||||
const dispatcherDataStatus = statuses.dispatchers;
|
||||
|
||||
if (connectionStatus == Status.Data.Offline) {
|
||||
this.setSignalStatus(Status.Data.Offline);
|
||||
this.indicator.status = Status.Data.Offline;
|
||||
this.indicator.message = 'data-status.S1-offline';
|
||||
return;
|
||||
}
|
||||
|
||||
if (connectionStatus == Status.Data.Error) {
|
||||
this.setSignalStatus(connectionStatus);
|
||||
this.indicator.status = connectionStatus;
|
||||
this.indicator.message = 'data-status.S1a-connection';
|
||||
return;
|
||||
}
|
||||
|
||||
if (sceneryDataStatus == Status.Data.Error) {
|
||||
this.setSignalStatus(sceneryDataStatus);
|
||||
this.indicator.status = sceneryDataStatus;
|
||||
this.indicator.message = 'data-status.S1a-sceneries';
|
||||
return;
|
||||
}
|
||||
|
||||
if (trainsDataStatus == Status.Data.Warning) {
|
||||
this.setSignalStatus(trainsDataStatus);
|
||||
this.indicator.status = trainsDataStatus;
|
||||
this.indicator.message = 'data-status.S5-trains';
|
||||
return;
|
||||
}
|
||||
|
||||
if (dispatcherDataStatus == Status.Data.Warning) {
|
||||
this.setSignalStatus(dispatcherDataStatus);
|
||||
this.indicator.status = dispatcherDataStatus;
|
||||
this.indicator.message = 'data-status.S5-dispatchers';
|
||||
return;
|
||||
}
|
||||
|
||||
if (sceneryDataStatus == Status.Data.Loaded) {
|
||||
this.setSignalStatus(Status.Data.Loaded);
|
||||
|
||||
this.indicator.status = Status.Data.Loaded;
|
||||
this.indicator.message = 'data-status.S2';
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
setSignalStatus(status: Status.Data) {
|
||||
this.greenLight = false;
|
||||
this.greenBlinkLight = false;
|
||||
this.redTopLight = false;
|
||||
this.orangeLight = false;
|
||||
this.redBottomLight = false;
|
||||
setLights(message: string) {
|
||||
let lights = {
|
||||
greenBlinkLight: false,
|
||||
greenLight: false,
|
||||
orangeLight: false,
|
||||
redBottomLight: false,
|
||||
redTopLight: false
|
||||
};
|
||||
|
||||
if (status == Status.Data.Initialized || status == Status.Data.Offline) {
|
||||
this.redTopLight = true;
|
||||
switch (message) {
|
||||
case 'S3':
|
||||
lights.greenBlinkLight = true;
|
||||
break;
|
||||
|
||||
case 'S2':
|
||||
lights.greenLight = true;
|
||||
break;
|
||||
|
||||
case 'S1-offline':
|
||||
lights.redTopLight = true;
|
||||
break;
|
||||
|
||||
case 'S1a-connection':
|
||||
case 'S1a-sceneries':
|
||||
lights.redTopLight = true;
|
||||
lights.redBottomLight = true;
|
||||
break;
|
||||
|
||||
case 'S5-dispatchers':
|
||||
case 'S5-trains':
|
||||
lights.orangeLight = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (status == Status.Data.Loaded) {
|
||||
this.greenLight = true;
|
||||
return lights;
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
indicator(): Indicator {
|
||||
const dataStatuses = this.apiStore.dataStatuses;
|
||||
const swdrStatuses = this.apiStore.activeData?.apiStatuses;
|
||||
|
||||
let message = 'S3';
|
||||
|
||||
switch (dataStatuses.connection) {
|
||||
case Status.Data.Loading:
|
||||
message = 'S3';
|
||||
break;
|
||||
case Status.Data.Loaded:
|
||||
message = 'S2';
|
||||
break;
|
||||
case Status.Data.Offline:
|
||||
message = 'S1-offline';
|
||||
break;
|
||||
case Status.Data.Error:
|
||||
message = 'S1a-connection';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (status == Status.Data.Warning) {
|
||||
this.orangeLight = true;
|
||||
if (swdrStatuses?.dispatchersAPI == APIDataStatus.WARNING) {
|
||||
message = 'S5-dispatchers';
|
||||
}
|
||||
|
||||
if (status == Status.Data.Error) {
|
||||
this.redTopLight = true;
|
||||
this.redBottomLight = true;
|
||||
if (swdrStatuses?.trainsAPI == APIDataStatus.WARNING) {
|
||||
message = 'S5-trains';
|
||||
}
|
||||
|
||||
if (status == Status.Data.Loading) {
|
||||
this.greenBlinkLight = true;
|
||||
if (swdrStatuses?.stationsAPI == APIDataStatus.WARNING) {
|
||||
message = 'S1a-sceneries';
|
||||
}
|
||||
|
||||
return {
|
||||
lights: this.setLights(message),
|
||||
message
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -85,7 +85,7 @@ export default defineComponent({
|
||||
|
||||
regionList() {
|
||||
return regionsJSON.map((region) => {
|
||||
const regionStationCount = this.store.onlineSceneryList.filter(
|
||||
const regionStationCount = this.store.activeSceneryList.filter(
|
||||
(scenery) => scenery.region == region.id
|
||||
).length;
|
||||
|
||||
|
||||
@@ -61,6 +61,9 @@ export default defineComponent({
|
||||
case Status.ActiveDispatcher.UNKNOWN:
|
||||
return 'unknown';
|
||||
|
||||
case Status.ActiveDispatcher.FREE:
|
||||
return 'free';
|
||||
|
||||
default:
|
||||
if (this.dispatcherTimestamp != null && this.dispatcherStatus >= Date.now() + 25500000)
|
||||
return 'no-limit';
|
||||
|
||||
@@ -76,7 +76,7 @@ import Station from '../../scripts/interfaces/Station';
|
||||
import Loading from '../Global/Loading.vue';
|
||||
import styleMixin from '../../mixins/styleMixin';
|
||||
import listObserverMixin from '../../mixins/listObserverMixin';
|
||||
import { OnlineScenery } from '../../store/typings';
|
||||
import { ActiveScenery } from '../../store/typings';
|
||||
import { API } from '../../typings/api';
|
||||
import { Status } from '../../typings/common';
|
||||
import http from '../../http';
|
||||
@@ -90,7 +90,7 @@ export default defineComponent({
|
||||
type: Object as PropType<Station>
|
||||
},
|
||||
onlineScenery: {
|
||||
type: Object as PropType<OnlineScenery>
|
||||
type: Object as PropType<ActiveScenery>
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<script lang="ts">
|
||||
import { PropType, defineComponent } from 'vue';
|
||||
import Station from '../../scripts/interfaces/Station';
|
||||
import { OnlineScenery } from '../../store/typings';
|
||||
import { ActiveScenery } from '../../store/typings';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
@@ -29,7 +29,7 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
onlineScenery: {
|
||||
type: Object as PropType<OnlineScenery>
|
||||
type: Object as PropType<ActiveScenery>
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -90,7 +90,7 @@ import SceneryInfoUserList from './SceneryInfo/SceneryInfoUserList.vue';
|
||||
import SceneryInfoSpawnList from './SceneryInfo/SceneryInfoSpawnList.vue';
|
||||
import SceneryInfoRoutes from './SceneryInfo/SceneryInfoRoutes.vue';
|
||||
import Station from '../../scripts/interfaces/Station';
|
||||
import { OnlineScenery } from '../../store/typings';
|
||||
import { ActiveScenery } from '../../store/typings';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
@@ -106,7 +106,7 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
onlineScenery: {
|
||||
type: Object as PropType<OnlineScenery>
|
||||
type: Object as PropType<ActiveScenery>
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<section class="info-dispatcher">
|
||||
<div class="dispatcher" v-if="onlineScenery">
|
||||
<div class="dispatcher" v-if="onlineScenery && onlineScenery.dispatcherExp != -1">
|
||||
<span
|
||||
class="dispatcher_level"
|
||||
:style="calculateExpStyle(onlineScenery.dispatcherExp, onlineScenery.dispatcherIsSupporter)"
|
||||
@@ -42,14 +42,14 @@ import dateMixin from '../../../mixins/dateMixin';
|
||||
import routerMixin from '../../../mixins/routerMixin';
|
||||
import styleMixin from '../../../mixins/styleMixin';
|
||||
import StationStatusBadge from '../../Global/StationStatusBadge.vue';
|
||||
import { OnlineScenery } from '../../../store/typings';
|
||||
import { ActiveScenery } from '../../../store/typings';
|
||||
import donatorMixin from '../../../mixins/donatorMixin';
|
||||
|
||||
export default defineComponent({
|
||||
mixins: [styleMixin, dateMixin, routerMixin, donatorMixin],
|
||||
props: {
|
||||
onlineScenery: {
|
||||
type: Object as PropType<OnlineScenery>,
|
||||
type: Object as PropType<ActiveScenery>,
|
||||
required: false
|
||||
}
|
||||
},
|
||||
|
||||
@@ -30,12 +30,12 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { PropType, defineComponent } from 'vue';
|
||||
import { OnlineScenery } from '../../../store/typings';
|
||||
import { ActiveScenery } from '../../../store/typings';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
onlineScenery: {
|
||||
type: Object as PropType<OnlineScenery>,
|
||||
type: Object as PropType<ActiveScenery>,
|
||||
required: false
|
||||
}
|
||||
},
|
||||
|
||||
@@ -32,14 +32,14 @@
|
||||
import { PropType, defineComponent } from 'vue';
|
||||
import modalTrainMixin from '../../../mixins/modalTrainMixin';
|
||||
import routerMixin from '../../../mixins/routerMixin';
|
||||
import { OnlineScenery } from '../../../store/typings';
|
||||
import { ActiveScenery } from '../../../store/typings';
|
||||
|
||||
export default defineComponent({
|
||||
mixins: [routerMixin, modalTrainMixin],
|
||||
|
||||
props: {
|
||||
onlineScenery: {
|
||||
type: Object as PropType<OnlineScenery>,
|
||||
type: Object as PropType<ActiveScenery>,
|
||||
required: false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
<span>{{ $t('scenery.timetables') }}</span>
|
||||
|
||||
<span>
|
||||
<span class="text--primary">{{ onlineScenery?.scheduledTrainCount.all || 0 }}</span>
|
||||
<span class="text--primary">{{ onlineScenery?.scheduledTrainCount.all ?? 0 }}</span>
|
||||
<span> / </span>
|
||||
<span class="text--grayed">
|
||||
{{ onlineScenery?.scheduledTrainCount.confirmed || '0' }}
|
||||
{{ onlineScenery?.scheduledTrainCount.confirmed ?? 0 }}
|
||||
</span>
|
||||
</span>
|
||||
|
||||
@@ -33,12 +33,12 @@
|
||||
{{ (i > 0 && '•') || '' }}
|
||||
|
||||
<button
|
||||
:key="cp.checkpointName"
|
||||
:key="cp"
|
||||
class="checkpoint_item"
|
||||
:class="{ current: chosenCheckpoint === cp.checkpointName }"
|
||||
:class="{ current: chosenCheckpoint === cp }"
|
||||
@click="setCheckpoint(cp)"
|
||||
>
|
||||
{{ cp.checkpointName }}
|
||||
{{ cp }}
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
@@ -190,7 +190,7 @@ import Station from '../../scripts/interfaces/Station';
|
||||
import { useMainStore } from '../../store/mainStore';
|
||||
import modalTrainMixin from '../../mixins/modalTrainMixin';
|
||||
import ScheduledTrainStatus from './ScheduledTrainStatus.vue';
|
||||
import { OnlineScenery } from '../../store/typings';
|
||||
import { ActiveScenery } from '../../store/typings';
|
||||
import { useApiStore } from '../../store/apiStore';
|
||||
|
||||
export default defineComponent({
|
||||
@@ -205,7 +205,7 @@ export default defineComponent({
|
||||
type: Object as PropType<Station>
|
||||
},
|
||||
onlineScenery: {
|
||||
type: Object as PropType<OnlineScenery>
|
||||
type: Object as PropType<ActiveScenery>
|
||||
}
|
||||
},
|
||||
|
||||
@@ -231,7 +231,7 @@ export default defineComponent({
|
||||
const chosenCheckpoint = ref(
|
||||
props.station?.generalInfo?.checkpoints?.length == 0
|
||||
? ''
|
||||
: props.station?.generalInfo?.checkpoints[0].checkpointName || null
|
||||
: props.station?.generalInfo?.checkpoints[0] ?? null
|
||||
);
|
||||
|
||||
return {
|
||||
@@ -278,12 +278,11 @@ export default defineComponent({
|
||||
loadSelectedOption() {
|
||||
if (!this.station) return;
|
||||
|
||||
this.chosenCheckpoint =
|
||||
this.station.generalInfo?.checkpoints[0]?.checkpointName || this.station.name;
|
||||
this.chosenCheckpoint = this.station.generalInfo?.checkpoints[0] ?? this.station.name;
|
||||
},
|
||||
|
||||
setCheckpoint(cp: { checkpointName: string }) {
|
||||
this.chosenCheckpoint = cp.checkpointName;
|
||||
setCheckpoint(cp: string) {
|
||||
this.chosenCheckpoint = cp;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -74,7 +74,7 @@ import dateMixin from '../../mixins/dateMixin';
|
||||
import Station from '../../scripts/interfaces/Station';
|
||||
import Loading from '../Global/Loading.vue';
|
||||
import listObserverMixin from '../../mixins/listObserverMixin';
|
||||
import { OnlineScenery } from '../../store/typings';
|
||||
import { ActiveScenery } from '../../store/typings';
|
||||
import { API } from '../../typings/api';
|
||||
import { Status } from '../../typings/common';
|
||||
import http from '../../http';
|
||||
@@ -87,7 +87,7 @@ export default defineComponent({
|
||||
type: Object as PropType<Station>
|
||||
},
|
||||
onlineScenery: {
|
||||
type: Object as PropType<OnlineScenery>
|
||||
type: Object as PropType<ActiveScenery>
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@
|
||||
|
||||
<td class="station_dispatcher-exp">
|
||||
<span
|
||||
v-if="station.onlineInfo"
|
||||
v-if="station.onlineInfo && station.onlineInfo?.dispatcherExp != -1"
|
||||
:style="
|
||||
calculateExpStyle(
|
||||
station.onlineInfo.dispatcherExp,
|
||||
|
||||
@@ -42,14 +42,13 @@ export interface Filter {
|
||||
nonPublic: boolean;
|
||||
unavailable: boolean;
|
||||
abandoned: boolean;
|
||||
|
||||
endingStatus: boolean;
|
||||
afkStatus: boolean;
|
||||
noSpaceStatus: boolean;
|
||||
unavailableStatus: boolean;
|
||||
unsignedStatus: boolean;
|
||||
|
||||
authors: string;
|
||||
|
||||
onlineFromHours: number;
|
||||
withActiveTimetables: boolean;
|
||||
withoutActiveTimetables: boolean;
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ export default defineComponent({
|
||||
isSBL: /sbl/gi.test(stop.stopName),
|
||||
position: stop.beginsHere ? 'begin' : stop.terminatesHere ? 'end' : 'en-route',
|
||||
sceneryHash: '',
|
||||
sceneryName: this.timetableSceneryNames[currentSceneryIndex],
|
||||
sceneryName: this.train.timetableData!.sceneryNames[currentSceneryIndex],
|
||||
status: stop.confirmed ? 'confirmed' : stop.stopped ? 'stopped' : 'unconfirmed'
|
||||
};
|
||||
}) ?? []
|
||||
@@ -216,19 +216,6 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
return activeMinorStopList;
|
||||
},
|
||||
|
||||
timetableSceneryNames() {
|
||||
if (!this.train.timetableData?.sceneries) return [];
|
||||
|
||||
return this.train.timetableData?.sceneries
|
||||
.map(
|
||||
(sceneryHash) =>
|
||||
this.store.onlineSceneryList.find((st) => st.hash === sceneryHash)?.name ??
|
||||
this.apiStore.sceneryData.find((sd) => sd.hash === sceneryHash)?.name ??
|
||||
sceneryHash
|
||||
)
|
||||
.reverse();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
+16
-1
@@ -7,7 +7,8 @@
|
||||
"addons",
|
||||
"blockades",
|
||||
"signals",
|
||||
"status"
|
||||
"status",
|
||||
"timetables"
|
||||
],
|
||||
|
||||
"options": [
|
||||
@@ -228,6 +229,20 @@
|
||||
"section": "status",
|
||||
"value": true,
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"id": "withActiveTimetables",
|
||||
"name": "withActiveTimetables",
|
||||
"section": "timetables",
|
||||
"value": true,
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"id": "withoutActiveTimetables",
|
||||
"name": "withoutActiveTimetables",
|
||||
"section": "timetables",
|
||||
"value": true,
|
||||
"defaultValue": true
|
||||
}
|
||||
],
|
||||
"sliders": [
|
||||
|
||||
+6
-1
@@ -176,7 +176,8 @@
|
||||
"signals": "SIGNALLING",
|
||||
"addons": "ADDITIONAL PROGRAMS",
|
||||
"blockades": "BLOCK SIGNALLING",
|
||||
"status": "ONLINE STATUS"
|
||||
"status": "ONLINE STATUS",
|
||||
"timetables": "ACTIVE TIMETABLES"
|
||||
},
|
||||
|
||||
"all-available": "ALL AVAILABLE",
|
||||
@@ -219,6 +220,10 @@
|
||||
"historical": "HISTORICAL",
|
||||
"free": "FREE",
|
||||
"occupied": "OCCUPIED",
|
||||
|
||||
"withActiveTimetables": "ACTIVE",
|
||||
"withoutActiveTimetables": "NO ACTIVE",
|
||||
|
||||
"sliders": {
|
||||
"min-lvl": "MIN. REQUIRED DISPATCHER LEVEL",
|
||||
"max-lvl": "MAX. REQUIRED DISPATCHER LEVEL",
|
||||
|
||||
+5
-1
@@ -165,7 +165,8 @@
|
||||
"signals": "TYP SYGNALIZACJI",
|
||||
"addons": "DODATKOWE PROGRAMY",
|
||||
"blockades": "BLOKADY LINIOWE",
|
||||
"status": "STATUS ONLINE"
|
||||
"status": "STATUS ONLINE",
|
||||
"timetables": "AKTYWNE ROZKŁADY JAZDY"
|
||||
},
|
||||
|
||||
"all-available": "WSZYSTKIE DOSTĘPNE",
|
||||
@@ -209,6 +210,9 @@
|
||||
"free": "WOLNA",
|
||||
"occupied": "ZAJĘTA",
|
||||
|
||||
"withActiveTimetables": "AKTYWNE RJ",
|
||||
"withoutActiveTimetables": "BEZ AKTYWNYCH RJ",
|
||||
|
||||
"sliders": {
|
||||
"min-lvl": "MIN. WYMAGANY POZIOM DYŻURNEGO",
|
||||
"max-lvl": "MAKS. WYMAGANY POZIOM DYŻURNEGO",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Availability, OnlineScenery, ScheduledTrain } from '../../store/typings';
|
||||
import { Availability, ActiveScenery, ScheduledTrain } from '../../store/typings';
|
||||
import { StationRoutes } from './StationRoutes';
|
||||
|
||||
export default interface Station {
|
||||
@@ -8,6 +8,7 @@ export default interface Station {
|
||||
name: string;
|
||||
url: string;
|
||||
abbr: string;
|
||||
hash?: string;
|
||||
|
||||
reqLevel: number;
|
||||
// supportersOnly: boolean;
|
||||
@@ -25,11 +26,8 @@ export default interface Station {
|
||||
availability: Availability;
|
||||
routes: StationRoutes;
|
||||
|
||||
checkpoints: {
|
||||
checkpointName: string;
|
||||
scheduledTrains: ScheduledTrain[];
|
||||
}[];
|
||||
checkpoints: string[];
|
||||
};
|
||||
|
||||
onlineInfo?: OnlineScenery;
|
||||
onlineInfo?: ActiveScenery;
|
||||
}
|
||||
|
||||
@@ -33,5 +33,6 @@ export default interface Train {
|
||||
SKR: boolean;
|
||||
routeDistance: number;
|
||||
sceneries: string[];
|
||||
sceneryNames: string[];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -93,26 +93,41 @@ export const sortStations = (
|
||||
};
|
||||
|
||||
export const filterStations = (station: Station, filters: Filter) => {
|
||||
if (!station.onlineInfo && filters['free']) return false;
|
||||
if (filters['free'] && (!station.onlineInfo || station.onlineInfo.dispatcherId == -1))
|
||||
return false;
|
||||
|
||||
if (station.onlineInfo) {
|
||||
const { dispatcherStatus } = station.onlineInfo;
|
||||
|
||||
const isEnding = dispatcherStatus == Status.ActiveDispatcher.ENDING && filters['endingStatus'];
|
||||
const excludeEnding =
|
||||
dispatcherStatus == Status.ActiveDispatcher.ENDING && filters['endingStatus'];
|
||||
|
||||
const isNotSigned =
|
||||
const excludeNotSigned =
|
||||
(dispatcherStatus == Status.ActiveDispatcher.NOT_LOGGED_IN ||
|
||||
dispatcherStatus == Status.ActiveDispatcher.UNAVAILABLE) &&
|
||||
filters['unavailableStatus'];
|
||||
|
||||
const isAFK = dispatcherStatus == Status.ActiveDispatcher.AFK && filters['afkStatus'];
|
||||
const excludeAFK = dispatcherStatus == Status.ActiveDispatcher.AFK && filters['afkStatus'];
|
||||
|
||||
const isNoSpace =
|
||||
const excludeNoSpace =
|
||||
dispatcherStatus == Status.ActiveDispatcher.NO_SPACE && filters['noSpaceStatus'];
|
||||
|
||||
const isOccupied = station.onlineInfo && filters['occupied'];
|
||||
const excludeOccupied = filters['occupied'] && dispatcherStatus != Status.ActiveDispatcher.FREE;
|
||||
|
||||
if (isEnding || isNotSigned || isAFK || isNoSpace || isOccupied) return false;
|
||||
const excludeActiveTTs =
|
||||
(dispatcherStatus == Status.ActiveDispatcher.FREE ||
|
||||
station.onlineInfo.scheduledTrainCount.all != 0) &&
|
||||
filters['withActiveTimetables'];
|
||||
|
||||
if (
|
||||
excludeEnding ||
|
||||
excludeAFK ||
|
||||
excludeNoSpace ||
|
||||
excludeNotSigned ||
|
||||
excludeOccupied ||
|
||||
excludeActiveTTs
|
||||
)
|
||||
return false;
|
||||
|
||||
if (
|
||||
filters['onlineFromHours'] > 0 &&
|
||||
@@ -121,6 +136,12 @@ export const filterStations = (station: Station, filters: Filter) => {
|
||||
return false;
|
||||
}
|
||||
|
||||
const excludeNoActiveTTs =
|
||||
filters['withoutActiveTimetables'] &&
|
||||
(!station.onlineInfo || station.onlineInfo.scheduledTrainCount.all == 0);
|
||||
|
||||
if (excludeNoActiveTTs) return false;
|
||||
|
||||
if (
|
||||
(station.generalInfo?.availability == 'nonPublic' || !station.generalInfo) &&
|
||||
filters['nonPublic']
|
||||
|
||||
+37
-9
@@ -1,18 +1,18 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import http from '../http';
|
||||
import { API, Websocket } from '../typings/api';
|
||||
import { API } from '../typings/api';
|
||||
import axios from 'axios';
|
||||
import { Status } from '../typings/common';
|
||||
import { StationJSONData } from './typings';
|
||||
|
||||
// Update seconds cron for active data scheduler
|
||||
const UPDATE_SECONDS = [3, 23, 43];
|
||||
|
||||
export const useApiStore = defineStore('apiStore', {
|
||||
state: () => ({
|
||||
dataStatuses: {
|
||||
connection: Status.Data.Loading,
|
||||
sceneries: Status.Data.Loading,
|
||||
timetables: Status.Data.Loading,
|
||||
dispatchers: Status.Data.Loading,
|
||||
trains: Status.Data.Loading
|
||||
sceneries: Status.Data.Loading
|
||||
},
|
||||
|
||||
activeData: undefined as API.ActiveData.Response | undefined,
|
||||
@@ -20,17 +20,45 @@ export const useApiStore = defineStore('apiStore', {
|
||||
donatorsData: [] as API.Donators.Response,
|
||||
sceneryData: [] as StationJSONData[],
|
||||
|
||||
websocketData: undefined as Websocket.Payload | undefined
|
||||
|
||||
// activeDataTimeout: undefined as number | undefined
|
||||
activeDataScheduler: undefined as number | undefined
|
||||
}),
|
||||
|
||||
actions: {
|
||||
async setupStaticAPIData() {
|
||||
async setupAPIData() {
|
||||
// Static data
|
||||
this.fetchStockInfoData();
|
||||
this.fetchDonatorsData();
|
||||
this.fetchStationsGeneralInfo();
|
||||
|
||||
// Active data schedueler
|
||||
this.fetchActiveData();
|
||||
this.setupActiveDataFetcher();
|
||||
},
|
||||
|
||||
async setupActiveDataFetcher() {
|
||||
if (this.activeDataScheduler) return;
|
||||
|
||||
this.dataStatuses.connection = Status.Data.Loading;
|
||||
|
||||
this.activeDataScheduler = window.setInterval(() => {
|
||||
if (UPDATE_SECONDS.includes(new Date().getSeconds())) {
|
||||
this.fetchActiveData();
|
||||
}
|
||||
}, 1000);
|
||||
},
|
||||
|
||||
async fetchActiveData() {
|
||||
try {
|
||||
const response = await http.get<API.ActiveData.Response>('api/getActiveData');
|
||||
|
||||
this.activeData = response.data;
|
||||
this.dataStatuses.connection = Status.Data.Loaded;
|
||||
|
||||
console.log('Fetching active data at ' + new Date().toLocaleTimeString('pl-PL'));
|
||||
} catch (error) {
|
||||
this.dataStatuses.connection = Status.Data.Error;
|
||||
console.error('Ups! Wystąpił błąd podczas pobierania danych online:', error);
|
||||
}
|
||||
},
|
||||
|
||||
async fetchDonatorsData() {
|
||||
|
||||
+107
-38
@@ -2,12 +2,11 @@ import { defineStore } from 'pinia';
|
||||
import Train from '../scripts/interfaces/Train';
|
||||
import { parseSpawns, getScheduledTrains, getStationTrains } from './utils';
|
||||
|
||||
import { OnlineScenery, ScheduledTrain, StoreState } from './typings';
|
||||
import { ActiveScenery, ScheduledTrain, StoreState } from './typings';
|
||||
|
||||
import { Status } from '../typings/common';
|
||||
import Station from '../scripts/interfaces/Station';
|
||||
import { useApiStore } from './apiStore';
|
||||
import { API } from '../typings/api';
|
||||
import { StationRoutes } from '../scripts/interfaces/StationRoutes';
|
||||
|
||||
export const useMainStore = defineStore('store', {
|
||||
@@ -34,7 +33,7 @@ export const useMainStore = defineStore('store', {
|
||||
trainList(): Train[] {
|
||||
const apiStore = useApiStore();
|
||||
|
||||
return (apiStore.websocketData?.activeTrains ?? [])
|
||||
return (apiStore.activeData?.trains ?? [])
|
||||
.filter((train) => train.timetable || train.online)
|
||||
.map((train) => {
|
||||
const stock = train.stockString.split(';');
|
||||
@@ -42,6 +41,14 @@ export const useMainStore = defineStore('store', {
|
||||
|
||||
const timetable = train.timetable;
|
||||
|
||||
const sceneryNames =
|
||||
train.timetable?.sceneries?.map(
|
||||
(sceneryHash) =>
|
||||
this.activeSceneryList.find((st) => st.hash === sceneryHash)?.name ??
|
||||
apiStore.sceneryData.find((sd) => sd.hash === sceneryHash)?.name ??
|
||||
sceneryHash
|
||||
) ?? [];
|
||||
|
||||
return {
|
||||
trainId: train.driverName + train.trainNo.toString(),
|
||||
|
||||
@@ -77,43 +84,67 @@ export const useMainStore = defineStore('store', {
|
||||
category: timetable.category,
|
||||
followingStops: timetable.stopList,
|
||||
routeDistance: timetable.stopList[timetable.stopList.length - 1].stopDistance,
|
||||
sceneries: timetable.sceneries
|
||||
sceneries: timetable.sceneries,
|
||||
sceneryNames: sceneryNames.reverse()
|
||||
}
|
||||
: undefined
|
||||
} as Train;
|
||||
});
|
||||
},
|
||||
|
||||
onlineSceneryList(state): OnlineScenery[] {
|
||||
activeSceneryList(state): ActiveScenery[] {
|
||||
const apiStore = useApiStore();
|
||||
|
||||
if (state.isOffline) return [];
|
||||
if (!apiStore.websocketData?.activeSceneries) return [];
|
||||
|
||||
return apiStore.websocketData?.activeSceneries.reduce((list, scenery) => {
|
||||
if (!apiStore.activeData?.activeSceneries) return [];
|
||||
|
||||
const offlineActiveSceneries = this.trainList.reduce((acc, train) => {
|
||||
if (!train.timetableData) return acc;
|
||||
|
||||
train.timetableData.sceneryNames.forEach((name) => {
|
||||
if (
|
||||
acc.findIndex((v) => v.name == name && v.region == train.region) != -1 ||
|
||||
apiStore.activeData?.activeSceneries?.findIndex(
|
||||
(sc) => sc.stationName === name && sc.region == train.region
|
||||
) != -1
|
||||
)
|
||||
return acc;
|
||||
|
||||
acc.push({
|
||||
name: name,
|
||||
hash: '',
|
||||
region: train.region,
|
||||
maxUsers: 0,
|
||||
currentUsers: 0,
|
||||
spawns: [],
|
||||
dispatcherName: '',
|
||||
dispatcherRate: 0,
|
||||
dispatcherId: -1,
|
||||
dispatcherExp: -1,
|
||||
dispatcherIsSupporter: false,
|
||||
scheduledTrains: [],
|
||||
stationTrains: [],
|
||||
dispatcherStatus: Status.ActiveDispatcher.FREE,
|
||||
dispatcherTimestamp: -1,
|
||||
|
||||
isOnline: false,
|
||||
|
||||
scheduledTrainCount: {
|
||||
all: 0,
|
||||
confirmed: 0,
|
||||
unconfirmed: 0
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return acc;
|
||||
}, [] as ActiveScenery[]);
|
||||
|
||||
const onlineActiveSceneries = apiStore.activeData?.activeSceneries.reduce((list, scenery) => {
|
||||
if (scenery.isOnline !== 1 && Date.now() - scenery.lastSeen > 1000 * 60 * 2) return list;
|
||||
if (scenery.dispatcherStatus == Status.ActiveDispatcher.UNKNOWN) return list;
|
||||
|
||||
const station = this.stationList.find((s) => s.name === scenery.stationName);
|
||||
|
||||
const scheduledTrains = getScheduledTrains(this.trainList, scenery, station?.generalInfo);
|
||||
|
||||
const stationTrains = getStationTrains(
|
||||
this.trainList,
|
||||
scheduledTrains,
|
||||
this.region.id,
|
||||
scenery
|
||||
);
|
||||
|
||||
// Remove checkpoint duplicates
|
||||
const uniqueScheduledTrains = scheduledTrains.reduce(
|
||||
(uniqueList, sTrain) =>
|
||||
uniqueList.find((v) => v.trainId === sTrain.trainId)
|
||||
? uniqueList
|
||||
: [...uniqueList, sTrain],
|
||||
[] as ScheduledTrain[]
|
||||
);
|
||||
|
||||
const dispatcherTimestamp =
|
||||
scenery.dispatcherStatus == Status.ActiveDispatcher.NO_LIMIT
|
||||
? Date.now() + 25500000
|
||||
@@ -133,22 +164,64 @@ export const useMainStore = defineStore('store', {
|
||||
dispatcherId: scenery.dispatcherId,
|
||||
dispatcherExp: scenery.dispatcherExp,
|
||||
dispatcherIsSupporter: scenery.dispatcherIsSupporter,
|
||||
scheduledTrains: scheduledTrains,
|
||||
stationTrains: stationTrains,
|
||||
dispatcherStatus: scenery.dispatcherStatus,
|
||||
dispatcherTimestamp: dispatcherTimestamp,
|
||||
|
||||
isOnline: scenery.isOnline == 1,
|
||||
|
||||
scheduledTrains: [],
|
||||
stationTrains: [],
|
||||
scheduledTrainCount: {
|
||||
all: uniqueScheduledTrains.length,
|
||||
confirmed: uniqueScheduledTrains.filter((train) => train.stopInfo.confirmed).length,
|
||||
unconfirmed: uniqueScheduledTrains.filter((train) => !train.stopInfo.confirmed).length
|
||||
all: 0,
|
||||
confirmed: 0,
|
||||
unconfirmed: 0
|
||||
}
|
||||
});
|
||||
|
||||
return list;
|
||||
}, [] as OnlineScenery[]);
|
||||
}, [] as ActiveScenery[]);
|
||||
|
||||
const allActiveSceneries = [...onlineActiveSceneries, ...offlineActiveSceneries];
|
||||
|
||||
for (let i = 0, n = allActiveSceneries.length; i < n; i++) {
|
||||
const scenery = allActiveSceneries[i];
|
||||
|
||||
const station = this.stationList.find((s) => s.name === scenery.name);
|
||||
|
||||
const scheduledTrains = getScheduledTrains(
|
||||
this.trainList,
|
||||
station?.generalInfo,
|
||||
scenery.name,
|
||||
scenery.region
|
||||
);
|
||||
|
||||
const stationTrains = getStationTrains(
|
||||
this.trainList,
|
||||
scheduledTrains,
|
||||
this.region.id,
|
||||
scenery.name
|
||||
);
|
||||
|
||||
// Remove checkpoint duplicates
|
||||
const uniqueScheduledTrains = scheduledTrains.reduce(
|
||||
(uniqueList, sTrain) =>
|
||||
uniqueList.find((v) => v.trainId === sTrain.trainId)
|
||||
? uniqueList
|
||||
: [...uniqueList, sTrain],
|
||||
[] as ScheduledTrain[]
|
||||
);
|
||||
|
||||
scenery.scheduledTrains = scheduledTrains;
|
||||
scenery.stationTrains = stationTrains;
|
||||
|
||||
scenery.scheduledTrainCount = {
|
||||
all: uniqueScheduledTrains.length,
|
||||
confirmed: uniqueScheduledTrains.filter((train) => train.stopInfo.confirmed).length,
|
||||
unconfirmed: uniqueScheduledTrains.filter((train) => !train.stopInfo.confirmed).length
|
||||
};
|
||||
}
|
||||
|
||||
return allActiveSceneries;
|
||||
},
|
||||
|
||||
stationList(): Station[] {
|
||||
@@ -188,11 +261,7 @@ export const useMainStore = defineStore('store', {
|
||||
...scenery,
|
||||
authors: scenery.authors?.split(',').map((a) => a.trim()),
|
||||
routes: routes,
|
||||
checkpoints: scenery.checkpoints
|
||||
? scenery.checkpoints
|
||||
.split(';')
|
||||
.map((sub) => ({ checkpointName: sub, scheduledTrains: [] }))
|
||||
: []
|
||||
checkpoints: scenery.checkpoints?.split(';') ?? []
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
@@ -48,6 +48,8 @@ const filterInitStates: Filter = {
|
||||
noSpaceStatus: false,
|
||||
unavailableStatus: false,
|
||||
unsignedStatus: false,
|
||||
withActiveTimetables: false,
|
||||
withoutActiveTimetables: false,
|
||||
|
||||
authors: '',
|
||||
|
||||
@@ -73,7 +75,7 @@ export const useStationFiltersStore = defineStore('stationFiltersStore', {
|
||||
const store = useMainStore();
|
||||
const savedStationNames = store.stationList.map((s) => s.name);
|
||||
|
||||
const onlineUnsavedStations = store.onlineSceneryList
|
||||
const onlineUnsavedStations = store.activeSceneryList
|
||||
.filter((os) => !savedStationNames.includes(os.name) && os.region == store.region.id)
|
||||
.map((os) => ({
|
||||
name: os.name,
|
||||
@@ -85,7 +87,8 @@ export const useStationFiltersStore = defineStore('stationFiltersStore', {
|
||||
...onlineUnsavedStations,
|
||||
...store.stationList.map((station) => ({
|
||||
...station,
|
||||
onlineInfo: store.onlineSceneryList.find(
|
||||
// append to 'onlineInfo' object for filtering legacy reasons - to optimize later (hopefully)
|
||||
onlineInfo: store.activeSceneryList.find(
|
||||
(os) => os.name == station.name && os.region == store.region.id
|
||||
)
|
||||
}))
|
||||
|
||||
@@ -63,7 +63,7 @@ export interface StationJSONData {
|
||||
availability: Availability;
|
||||
}
|
||||
|
||||
export interface OnlineScenery {
|
||||
export interface ActiveScenery {
|
||||
name: string;
|
||||
hash: string;
|
||||
region: string;
|
||||
|
||||
+37
-84
@@ -1,6 +1,5 @@
|
||||
import Station from '../scripts/interfaces/Station';
|
||||
import Train from '../scripts/interfaces/Train';
|
||||
import { API } from '../typings/api';
|
||||
import { ScheduledTrain, StationTrain, StopStatus, TrainStop } from './typings';
|
||||
|
||||
export function getLocoURL(locoType: string): string {
|
||||
@@ -102,51 +101,33 @@ export function getCheckpointTrain(
|
||||
let prevStationName = '',
|
||||
nextStationName = '';
|
||||
|
||||
let prevDepartureLine: string | null = null,
|
||||
nextArrivalLine: string | null = null;
|
||||
|
||||
for (let i = trainStopIndex - 1; i >= 0; i--) {
|
||||
if (/strong|podg/g.test(followingStops[i].stopName)) {
|
||||
prevStationName = followingStops[i].stopNameRAW.replace(/,.*/g, '');
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = trainStopIndex + 1; i < followingStops.length; i++) {
|
||||
if (/strong|podg/g.test(followingStops[i].stopName)) {
|
||||
nextStationName = followingStops[i].stopNameRAW.replace(/,.*/g, '');
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let departureLine: string | null = null;
|
||||
let arrivingLine: string | null = null;
|
||||
|
||||
for (let i = trainStopIndex; i < followingStops.length; i++) {
|
||||
const currentStop = followingStops[i];
|
||||
let prevDepartureLine: string | null = null,
|
||||
nextArrivalLine: string | null = null;
|
||||
|
||||
if (currentStop.departureLine == null) continue;
|
||||
for (let i = trainStopIndex; i >= 0; i--) {
|
||||
const stop = followingStops[i];
|
||||
|
||||
if (!/-|_|it|sbl/gi.test(currentStop.departureLine)) {
|
||||
departureLine = currentStop.departureLine;
|
||||
nextArrivalLine = followingStops[i + 1]?.arrivalLine || null;
|
||||
if (/strong|podg\.|pe\./g.test(stop.stopName) && !prevStationName && i <= trainStopIndex - 1)
|
||||
prevStationName = stop.stopNameRAW.replace(/,.*/g, '');
|
||||
|
||||
break;
|
||||
if (stop.arrivalLine != null && !arrivingLine && !/-|_|it|sbl/gi.test(stop.arrivalLine)) {
|
||||
arrivingLine = stop.arrivalLine;
|
||||
prevDepartureLine = followingStops[i - 1]?.departureLine || null;
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = trainStopIndex; i >= 0; i--) {
|
||||
const currentStop = followingStops[i];
|
||||
for (let i = trainStopIndex; i < followingStops.length; i++) {
|
||||
const stop = followingStops[i];
|
||||
|
||||
if (currentStop.arrivalLine == null) continue;
|
||||
if (/strong|podg\.|pe\./g.test(stop.stopName) && !nextStationName && i > trainStopIndex)
|
||||
nextStationName = stop.stopNameRAW.replace(/,.*/g, '');
|
||||
|
||||
if (!/-|_|it|sbl/gi.test(currentStop.arrivalLine)) {
|
||||
arrivingLine = currentStop.arrivalLine;
|
||||
prevDepartureLine = followingStops[i - 1]?.departureLine || null;
|
||||
|
||||
break;
|
||||
if (stop.departureLine && !departureLine && !/-|_|it|sbl/gi.test(stop.departureLine)) {
|
||||
departureLine = stop.departureLine;
|
||||
nextArrivalLine = followingStops[i + 1]?.arrivalLine || null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,8 +158,8 @@ export function getCheckpointTrain(
|
||||
|
||||
region: train.region,
|
||||
|
||||
arrivingLine,
|
||||
departureLine,
|
||||
arrivingLine: arrivingLine,
|
||||
departureLine: departureLine,
|
||||
|
||||
nextArrivalLine,
|
||||
prevDepartureLine
|
||||
@@ -187,59 +168,33 @@ export function getCheckpointTrain(
|
||||
|
||||
export function getScheduledTrains(
|
||||
trainList: Train[],
|
||||
sceneryData: API.ActiveSceneries.Data,
|
||||
stationGeneralInfo: Station['generalInfo']
|
||||
stationGeneralInfo: Station['generalInfo'],
|
||||
stationName: string,
|
||||
region: string
|
||||
// sceneryData: API.ActiveSceneries.Data,
|
||||
): ScheduledTrain[] {
|
||||
const stationNameLower = sceneryData.stationName.toLocaleLowerCase();
|
||||
|
||||
stationGeneralInfo?.checkpoints.forEach((cp) => (cp.scheduledTrains.length = 0));
|
||||
// stationGeneralInfo?.checkpoints.forEach((cp) => (cp.scheduledTrains.length = 0));
|
||||
|
||||
return trainList.reduce((acc: ScheduledTrain[], train) => {
|
||||
if (!train.timetableData) return acc;
|
||||
if (train.region != sceneryData.region) return acc;
|
||||
if (train.region != region) return acc;
|
||||
|
||||
const timetable = train.timetableData;
|
||||
if (!timetable.sceneries.includes(sceneryData.stationHash)) return acc;
|
||||
if (!timetable.sceneryNames.includes(stationName)) return acc;
|
||||
|
||||
const stopInfoIndex = timetable.followingStops.findIndex((stop) => {
|
||||
const stopNameLower = stop.stopNameRAW.toLocaleLowerCase();
|
||||
|
||||
return (
|
||||
stationNameLower == stopNameLower ||
|
||||
(!/(po\.|podg\.)/.test(stopNameLower) && stopNameLower.includes(stationNameLower)) ||
|
||||
(!/(po\.|podg\.)/.test(stationNameLower) && stationNameLower.includes(stopNameLower)) ||
|
||||
(stopNameLower.split(', podg.')[0] !== undefined &&
|
||||
stationNameLower.startsWith(stopNameLower.split(', podg.')[0]))
|
||||
);
|
||||
});
|
||||
const checkpoints = [stationName];
|
||||
if (stationGeneralInfo?.checkpoints) checkpoints.push(...stationGeneralInfo.checkpoints);
|
||||
|
||||
const checkpointScheduledTrains: ScheduledTrain[] = [];
|
||||
|
||||
if (stopInfoIndex != -1) {
|
||||
checkpointScheduledTrains.push(
|
||||
getCheckpointTrain(train, stopInfoIndex, sceneryData.stationName)
|
||||
);
|
||||
}
|
||||
|
||||
stationGeneralInfo?.checkpoints?.forEach((checkpoint) => {
|
||||
// if (checkpoint.checkpointName.toLocaleLowerCase() == stationNameLower) return;
|
||||
|
||||
for (let i = 0; i < timetable.followingStops.length; i++) {
|
||||
if (
|
||||
checkpointScheduledTrains.findIndex(
|
||||
(cpTrain) =>
|
||||
cpTrain.checkpointName.toLocaleLowerCase() ==
|
||||
checkpoint.checkpointName.toLocaleLowerCase()
|
||||
) != -1
|
||||
)
|
||||
return;
|
||||
|
||||
const index = timetable.followingStops.findIndex(
|
||||
(stop) => stop.stopNameRAW.toLowerCase() == checkpoint.checkpointName.toLowerCase()
|
||||
);
|
||||
|
||||
if (index > -1)
|
||||
checkpointScheduledTrains.push(getCheckpointTrain(train, index, sceneryData.stationName));
|
||||
});
|
||||
new RegExp(`^(${checkpoints.join('|')})$`, 'i').test(
|
||||
timetable.followingStops[i].stopNameRAW
|
||||
)
|
||||
) {
|
||||
checkpointScheduledTrains.push(getCheckpointTrain(train, i, stationName));
|
||||
}
|
||||
}
|
||||
|
||||
acc.push(...checkpointScheduledTrains);
|
||||
return acc;
|
||||
@@ -250,14 +205,12 @@ export function getStationTrains(
|
||||
trainList: Train[],
|
||||
scheduledTrainList: ScheduledTrain[],
|
||||
region: string,
|
||||
sceneryData: API.ActiveSceneries.Data
|
||||
stationName: string
|
||||
): StationTrain[] {
|
||||
return trainList
|
||||
.filter(
|
||||
(train) =>
|
||||
train?.region === region &&
|
||||
train.online &&
|
||||
train.currentStationName === sceneryData.stationName
|
||||
train?.region === region && train.online && train.currentStationName === stationName
|
||||
)
|
||||
.map((train) => ({
|
||||
driverName: train.driverName,
|
||||
|
||||
@@ -1,10 +1,22 @@
|
||||
import { Status } from './common';
|
||||
|
||||
export enum APIDataStatus {
|
||||
OK = 'OK',
|
||||
WARNING = 'WARNING'
|
||||
}
|
||||
export namespace API {
|
||||
export namespace ActiveData {
|
||||
export interface APIStatuses {
|
||||
stationsAPI: APIDataStatus;
|
||||
trainsAPI: APIDataStatus;
|
||||
dispatchersAPI: APIDataStatus;
|
||||
sceneryRequirementsAPI: APIDataStatus;
|
||||
}
|
||||
|
||||
export interface Response {
|
||||
activeSceneries?: API.ActiveSceneries.Response;
|
||||
trains?: API.ActiveTrains.Response;
|
||||
apiStatuses?: APIStatuses;
|
||||
}
|
||||
}
|
||||
export namespace DispatcherHistory {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export namespace Status {
|
||||
export enum ActiveDispatcher {
|
||||
FREE = -3,
|
||||
INVALID = -2,
|
||||
UNKNOWN = -1,
|
||||
NO_LIMIT = 0,
|
||||
|
||||
@@ -147,7 +147,7 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
onlineSceneryInfo() {
|
||||
return this.store.onlineSceneryList.find(
|
||||
return this.store.activeSceneryList.find(
|
||||
(scenery) =>
|
||||
scenery.name === this.station?.toString().replace(/_/g, ' ') &&
|
||||
scenery.region == this.store.region.id
|
||||
@@ -169,11 +169,7 @@ export default defineComponent({
|
||||
loadSelectedCheckpoint() {
|
||||
if (!this.stationInfo?.generalInfo?.checkpoints) return;
|
||||
if (this.stationInfo.generalInfo.checkpoints.length == 0) return;
|
||||
this.selectedCheckpoint = this.stationInfo.generalInfo.checkpoints[0].checkpointName;
|
||||
},
|
||||
|
||||
selectCheckpoint(cp: { checkpointName: string }) {
|
||||
this.selectedCheckpoint = cp.checkpointName;
|
||||
this.selectedCheckpoint = this.stationInfo.generalInfo.checkpoints[0];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import { io } from 'socket.io-client';
|
||||
|
||||
const URL =
|
||||
import.meta.env.VITE_WS_MODE === 'development'
|
||||
? 'http://localhost:3001'
|
||||
: 'https://stacjownik.spythere.eu';
|
||||
|
||||
const socket = io(URL, {
|
||||
transports: ['websocket', 'polling'],
|
||||
rememberUpgrade: true,
|
||||
reconnection: true
|
||||
});
|
||||
|
||||
export default socket;
|
||||
Reference in New Issue
Block a user