feature: vmax szlaków

This commit is contained in:
2023-02-11 03:08:24 +01:00
parent 3f818069cd
commit 8bedc4dfc6
7 changed files with 207 additions and 199 deletions
@@ -1,114 +1,106 @@
<template> <template>
<section class="info-routes" v-if="station.generalInfo"> <section class="info-routes" v-if="station.generalInfo">
<div class="routes one-way" v-if="station.generalInfo.routes.oneWay.length > 0"> <div class="routes one-way" v-if="station.generalInfo.routes.oneWay.length > 0">
<b>{{ $t('scenery.one-way-routes') }}</b> <b>{{ $t('scenery.one-way-routes') }}</b>
<ul class="routes-list"> <ul class="routes-list">
<li <li v-for="route in station.generalInfo.routes.oneWay">
v-for="route in station.generalInfo.routes.oneWay" <span :class="{ 'no-catenary': !route.catenary, internal: route.isInternal }"> {{ route.name }}</span>
:class="{ 'no-catenary': !route.catenary, internal: route.isInternal }" <span v-if="route.speed" class="speed">{{ route.speed }}</span>
> <span v-if="route.SBL" class="sbl">SBL</span>
{{ route.name }} </li>
<b v-if="route.SBL">SBL</b> </ul>
</li> </div>
</ul>
</div> <div class="routes two-way" v-if="station.generalInfo.routes.twoWay.length > 0">
<b>{{ $t('scenery.two-way-routes') }}</b>
<div class="routes two-way" v-if="station.generalInfo.routes.twoWay.length > 0">
<b>{{ $t('scenery.two-way-routes') }}</b> <ul class="routes-list">
<li v-for="route in station.generalInfo.routes.twoWay">
<ul class="routes-list"> <span :class="{ 'no-catenary': !route.catenary, internal: route.isInternal }">{{ route.name }}</span>
<li <span v-if="route.speed" class="speed">{{ route.speed }}</span>
v-for="route in station.generalInfo.routes.twoWay" <span v-if="route.SBL" class="sbl">SBL</span>
:class="{ 'no-catenary': !route.catenary, internal: route.isInternal }" </li>
> </ul>
{{ route.name }} <b v-if="route.SBL">SBL</b> </div>
</li> </section>
</ul> </template>
</div>
<script lang="ts">
<!-- <div import { defineComponent } from 'vue';
class="route-info" import Station from '../../../scripts/interfaces/Station';
:class="{ 'no-catenary': !route.catenary, internal: route.isInternal }"
v-for="route in [...station.generalInfo.routes.oneWay, ...station.generalInfo.routes.twoWay].filter( export default defineComponent({
(route) => route.name != '-' props: {
)" station: {
:key="route.name" type: Object as () => Station,
:title="`Szlak ${route.name}: ${route.isInternal ? 'wewnętrzny' : 'zewnętrzny'}, ${ default: {},
route.tracks == 2 ? 'dwutorowy' : 'jednotorowy' },
}, ${route.catenary ? 'zelektryfikowany' : 'niezelektryfikowany'} z ${route.SBL ? 'SBL' : 'PBL'} ${ },
route.TWB ? 'i blokadą dwukierunkową' : '' });
}`" </script>
> -->
<!-- <span class="track-name"> <style lang="scss" scoped>
<b>{{ route.name }}</b> .info-routes {
</span> --> display: flex;
<!-- justify-content: center;
<span class="track-specs"> flex-wrap: wrap;
{{ route.tracks }}tor
<img v-if="route.catenary" :src="icons.trackCatenary" alt="icon track catenary" /> margin: 1em 0;
<img v-else :src="icons.trackNoCatenary" alt="icon track no catenary" /> }
<img v-if="route.TWB" :src="icons.trackTWB" alt="icon track twb" /> .routes {
<img v-if="route.SBL" :src="icons.trackSBL" alt="icon track sbl" /> display: flex;
</span> --> justify-content: center;
<!-- </div> --> align-items: center;
</section> flex-wrap: wrap;
</template>
padding: 0.25em;
<script lang="ts"> }
import { defineComponent } from 'vue';
import Station from '../../../scripts/interfaces/Station'; ul.routes-list {
margin: 0.45em 0.25em;
export default defineComponent({ display: flex;
props: {
station: { li {
type: Object as () => Station, margin: 0.2em 0.25em;
default: {},
}, span {
}, padding: 0.2em 0.25em;
}); background-color: #007599;
</script> font-weight: bold;
<style lang="scss" scoped> &.no-catenary {
.info-routes { background-color: #686868;
display: flex; }
justify-content: center;
flex-wrap: wrap; &.internal {
text-decoration: underline;
margin: 1em 0; }
}
&.speed {
.routes { background-color: #404040;
display: flex; color: #cfcfcf;
justify-content: center; }
align-items: center;
flex-wrap: wrap; &.sbl {
color: var(--clr-primary);
padding: 0.25em; background-color: #404040;
} }
ul.routes-list { &:last-child {
margin: 0.45em 0.25em; border-radius: 0 0.5em 0.5em 0;
display: flex; }
li { &:first-child {
background-color: #007599; border-radius: 0.5em 0 0 0.5em;
}
padding: 0.2em 0.25em;
margin-left: 0.25em; &:only-child {
border-radius: 0.5em;
&.no-catenary {
background-color: #686868; }
} }
}
&.internal { }
text-decoration: underline; </style>
}
b {
color: var(--clr-primary);
}
}
}
</style>
@@ -89,6 +89,7 @@ import dateMixin from '../../mixins/dateMixin';
import imageMixin from '../../mixins/imageMixin'; import imageMixin from '../../mixins/imageMixin';
import Train from '../../scripts/interfaces/Train'; import Train from '../../scripts/interfaces/Train';
import TrainStop from '../../scripts/interfaces/TrainStop'; import TrainStop from '../../scripts/interfaces/TrainStop';
import { useStore } from '../../store/store';
import StopDate from '../Global/StopDate.vue'; import StopDate from '../Global/StopDate.vue';
export default defineComponent({ export default defineComponent({
@@ -106,6 +107,8 @@ export default defineComponent({
setup(props) { setup(props) {
return { return {
store: useStore(),
lastConfirmed: computed(() => { lastConfirmed: computed(() => {
return props.train.timetableData!.followingStops.findIndex( return props.train.timetableData!.followingStops.findIndex(
(stop, i, stops) => stop.confirmed && !stops[i + 1]?.confirmed && !stops[i + 1]?.stopped (stop, i, stops) => stop.confirmed && !stops[i + 1]?.confirmed && !stops[i + 1]?.stopped
@@ -424,3 +427,4 @@ ul.stop_list > li.stop {
} }
} }
</style> </style>
+30 -27
View File
@@ -1,27 +1,30 @@
export default interface StationRoutes { export default interface StationRoutes {
oneWay: oneWay: {
{ name: string;
name: string; catenary: boolean;
catenary: boolean; SBL: boolean;
SBL: boolean; TWB: boolean;
TWB: boolean; isInternal: boolean;
isInternal: boolean; tracks: number;
tracks: number; speed: number;
}[]; length: number;
}[];
twoWay: {
name: string; twoWay: {
catenary: boolean; name: string;
SBL: boolean; catenary: boolean;
TWB: boolean; SBL: boolean;
isInternal: boolean; TWB: boolean;
tracks: number; isInternal: boolean;
}[]; tracks: number;
speed: number;
/* [catenary, noCatenary] */ length: number;
oneWayCatenaryRouteNames: string[]; }[];
oneWayNoCatenaryRouteNames: string[];
twoWayCatenaryRouteNames: string[]; /* [catenary, noCatenary] */
twoWayNoCatenaryRouteNames: string[]; oneWayCatenaryRouteNames: string[];
sblRouteNames: string[]; oneWayNoCatenaryRouteNames: string[];
} twoWayCatenaryRouteNames: string[];
twoWayNoCatenaryRouteNames: string[];
sblRouteNames: string[];
}
+1 -1
View File
@@ -12,7 +12,7 @@ export default interface Train {
driverId: number; driverId: number;
trainNo: number; trainNo: number;
driverName: string; driverName: string;
driverLevel: number; driverLevel?: number;
currentStationName: string; currentStationName: string;
currentStationHash: string; currentStationHash: string;
locoURL: string; locoURL: string;
+1 -1
View File
@@ -1,4 +1,4 @@
export default interface TrainStop { export default interface TrainStop {
stopName: string; stopName: string;
stopNameRAW: string; stopNameRAW: string;
stopType: string; stopType: string;
+63 -55
View File
@@ -24,6 +24,7 @@ export const useStore = defineStore('store', {
stationList: [], stationList: [],
trainList: [], trainList: [],
routesList: [],
sceneryData: [], sceneryData: [],
lastDispatcherStatuses: [], lastDispatcherStatuses: [],
@@ -115,8 +116,8 @@ export const useStore = defineStore('store', {
sceneries: timetable.sceneries, sceneries: timetable.sceneries,
} }
: undefined, : undefined,
}; } as Train;
}) as Train[]; });
}, },
getDispatcherStatus(onlineStationData: StationAPIData) { getDispatcherStatus(onlineStationData: StationAPIData) {
@@ -294,65 +295,72 @@ export const useStore = defineStore('store', {
return; return;
} }
this.stationList = sceneryData.map((scenery) => ({ this.stationList = sceneryData.map((scenery) => {
name: scenery.name, return {
name: scenery.name,
generalInfo: { generalInfo: {
...scenery, ...scenery,
authors: scenery.authors?.split(',').map((a) => a.trim()), authors: scenery.authors?.split(',').map((a) => a.trim()),
routes: routes:
scenery.routes scenery.routes
?.split(';') ?.split(';')
.filter((routeString) => routeString) .filter((routeString) => routeString)
.reduce( .reduce(
(acc, routeString) => { (acc, routeString) => {
const specs1 = routeString.split('_')[0]; const specs1 = routeString.split('_')[0];
const isInternal = specs1.startsWith('!'); const isInternal = specs1.startsWith('!');
const name = isInternal ? specs1.replace('!', '') : specs1; const name = isInternal ? specs1.replace('!', '') : specs1;
const specs2 = routeString.split('_')[1].split(''); const specs2 = routeString.split('_')[1].split('');
const twoWay = specs2[0] == '2'; const twoWay = specs2[0] == '2';
const catenary = specs2[1] == 'E'; const catenary = specs2[1] == 'E';
const SBL = specs2[2] == 'S'; const SBL = specs2[2] == 'S';
const TWB = specs2[3] ? true : false; const TWB = specs2[3] ? true : false;
const speed = Number(routeString.split(':')[1]) || 0;
const length = Number(routeString.split(':')[2]) || 0;
const propName = twoWay
? catenary
? 'twoWayCatenaryRouteNames'
: 'twoWayNoCatenaryRouteNames'
: catenary
? 'oneWayCatenaryRouteNames'
: 'oneWayNoCatenaryRouteNames';
acc[twoWay ? 'twoWay' : 'oneWay'].push({ const propName = twoWay
name, ? catenary
SBL, ? 'twoWayCatenaryRouteNames'
TWB, : 'twoWayNoCatenaryRouteNames'
catenary, : catenary
isInternal, ? 'oneWayCatenaryRouteNames'
tracks: twoWay ? 2 : 1, : 'oneWayNoCatenaryRouteNames';
});
if (!isInternal) acc[propName].push(name);
if (SBL) acc['sblRouteNames'].push(name); acc[twoWay ? 'twoWay' : 'oneWay'].push({
name,
SBL,
TWB,
catenary,
isInternal,
tracks: twoWay ? 2 : 1,
length,
speed,
});
if (!isInternal) acc[propName].push(name);
return acc; if (SBL) acc['sblRouteNames'].push(name);
},
{ return acc;
oneWay: [], },
twoWay: [], {
sblRouteNames: [], oneWay: [],
oneWayCatenaryRouteNames: [], twoWay: [],
oneWayNoCatenaryRouteNames: [], sblRouteNames: [],
twoWayCatenaryRouteNames: [], oneWayCatenaryRouteNames: [],
twoWayNoCatenaryRouteNames: [], oneWayNoCatenaryRouteNames: [],
} as StationRoutes twoWayCatenaryRouteNames: [],
) || {}, twoWayNoCatenaryRouteNames: [],
checkpoints: scenery.checkpoints } as StationRoutes
? scenery.checkpoints.split(';').map((sub) => ({ checkpointName: sub, scheduledTrains: [] })) ) || {},
: [], checkpoints: scenery.checkpoints
}, ? scenery.checkpoints.split(';').map((sub) => ({ checkpointName: sub, scheduledTrains: [] }))
})); : [],
},
};
});
}, },
connectToWebsocket() { connectToWebsocket() {
+2 -1
View File
@@ -69,8 +69,9 @@ export interface StationJSONData {
SUP: boolean; SUP: boolean;
routes: string; routes: string;
checkpoints: string | null; checkpoints: string | null;
authors?: string; authors?: string;
availability: Availability; availability: Availability;
} }