chore: added station filters (scenery types); pwa adjustments

This commit is contained in:
2024-05-16 19:59:43 +02:00
parent e0036bf969
commit e117f62fcb
12 changed files with 104 additions and 68 deletions
+16 -9
View File
@@ -8,9 +8,12 @@
<img
class="traction-only"
:src="`https://rj.td2.info.pl/dist/img/thumbnails/${computedStockList[0].split(':')[0]}${
/^EN/.test(computedStockList[0]) ? 'rb' : ''
}.png`"
:src="
getVehicleThumbnailURL(
computedStockList[0].split(':')[0],
/^EN/.test(computedStockList[0]) ? 'rb' : ''
)
"
@error="onImageError($event, computedStockList[0])"
width="300"
height="60"
@@ -29,9 +32,9 @@
:data-mouseover="stockName"
data-tooltip-type="VehiclePreviewTooltip"
:data-tooltip-content="stockName.split(':')[0]"
:src="`https://rj.td2.info.pl/dist/img/thumbnails/${stockName.split(':')[0]}${
/^EN/.test(stockName) ? 'rb' : ''
}.png`"
:src="
getVehicleThumbnailURL(stockName.split(':')[0], /^EN/.test(stockName) ? 'rb' : '')
"
@error="onImageError($event, stockName)"
@click.stop="() => {}"
width="400"
@@ -44,7 +47,7 @@
data-tooltip-type="VehiclePreviewTooltip"
:data-tooltip-content="stockName.split(':')[0]"
v-if="/^(EN|2EN)/.test(stockName)"
:src="`https://rj.td2.info.pl/dist/img/thumbnails/${stockName.split(':')[0]}s.png`"
:src="getVehicleThumbnailURL(stockName, 's')"
@error="
(event) => ((event.target as HTMLImageElement).src = '/images/icon-loco-ezt-s.png')
"
@@ -56,7 +59,7 @@
data-tooltip-type="VehiclePreviewTooltip"
:data-tooltip-content="stockName.split(':')[0]"
v-if="/^EN71/.test(stockName)"
:src="`https://rj.td2.info.pl/dist/img/thumbnails/${stockName.split(':')[0]}s.png`"
:src="getVehicleThumbnailURL(stockName, 's')"
@error="
(event) => ((event.target as HTMLImageElement).src = '/images/icon-loco-ezt-s.png')
"
@@ -68,7 +71,7 @@
data-tooltip-type="VehiclePreviewTooltip"
:data-tooltip-content="stockName.split(':')[0]"
v-if="/^(EN|2EN)/.test(stockName)"
:src="`https://rj.td2.info.pl/dist/img/thumbnails/${stockName.split(':')[0]}ra.png`"
:src="getVehicleThumbnailURL(stockName, 'ra')"
@error="
(event) => ((event.target as HTMLImageElement).src = '/images/icon-loco-ezt-ra.png')
"
@@ -110,6 +113,10 @@ export default defineComponent({
},
methods: {
getVehicleThumbnailURL(locoType: string, suffix?: string) {
return `https://static.spythere.eu/thumbnails/${locoType}${suffix}.png`;
},
onImageError(event: Event, stockName: string) {
let fallbackName = '';
+36 -15
View File
@@ -4,7 +4,6 @@
<div class="stats-row">
<div>
&bull;
<span
>{{ $t('station-stats.u-factor') }}
<a
@@ -29,19 +28,21 @@
<div>
&bull;
{{ $t('station-stats.single-track-count') }}
<b>{{ trackCount.oneWayElectric }}</b> {{ $t('station-stats.electrified') }} /
<b>{{ trackCount.oneWayOther }}</b> {{ $t('station-stats.not-electrified') }}
<b>{{ trackCount.oneWay }}</b> (<b>{{ trackCount.oneWayElectric }} </b>)
</div>
<div>
&bull;
{{ $t('station-stats.double-track-count') }}
<b>{{ trackCount.twoWayElectric }}</b> {{ $t('station-stats.electrified') }} /
<b>{{ trackCount.twoWayOther }}</b>
{{ $t('station-stats.not-electrified') }}
<b>{{ trackCount.twoWay }}</b>
(<b>{{ trackCount.twoWayElectric }} </b>)
</div>
<div>&bull; {{ $t('station-stats.cross-sceneries') }} <b>test</b></div>
<div>
&bull; {{ $t('station-stats.cross-sceneries') }} <b>{{ trackCount.crossTrack }}</b> (<b
>{{ trackCount.crossTrackElectric }} </b
>)
</div>
<div>
&bull;
@@ -101,15 +102,14 @@ export default defineComponent({
if (scheduledTrainsArr.length == 0) return 0;
let v1 = scheduledTrainsArr[scheduledTrainsArr.length / 2];
if (scheduledTrainsArr.length % 2 == 0) {
let v1 = scheduledTrainsArr[scheduledTrainsArr.length / 2];
let v2 = scheduledTrainsArr[scheduledTrainsArr.length / 2 - 1];
return (v1 + v2) / 2;
}
return v1;
return scheduledTrainsArr[~~(scheduledTrainsArr.length / 2)];
},
trackCount() {
@@ -122,17 +122,38 @@ export default defineComponent({
)
.reduce(
(acc, st) => {
[...st.generalInfo!.routes.single, ...st.generalInfo!.routes.double].forEach((r) => {
const { routes } = st.generalInfo!;
if (
routes.single.filter((r) => !r.isInternal).length > 0 &&
routes.double.filter((r) => !r.isInternal).length > 0
) {
acc.crossTrack++;
if (
routes.single.some((r) => r.isElectric) &&
routes.double.some((r) => r.isElectric)
)
acc.crossTrackElectric++;
}
[...routes.single, ...routes.double].forEach((r) => {
if (r.isInternal) return;
const keyName: keyof typeof acc = `${r.routeTracks == 2 ? 'twoWay' : 'oneWay'}${r.isElectric ? 'Electric' : 'Other'}`;
acc[keyName] += 1;
acc[r.routeTracks == 2 ? 'twoWay' : 'oneWay'] += 1;
if (r.isElectric) acc[r.routeTracks == 2 ? 'twoWayElectric' : 'oneWayElectric'] += 1;
});
return acc;
},
{ oneWayElectric: 0, oneWayOther: 0, twoWayElectric: 0, twoWayOther: 0 }
{
oneWay: 0,
oneWayElectric: 0,
twoWay: 0,
twoWayElectric: 0,
crossTrack: 0,
crossTrackElectric: 0
}
);
},
+2
View File
@@ -55,4 +55,6 @@ export interface Filter {
onlineFromHours: number;
withActiveTimetables: boolean;
withoutActiveTimetables: boolean;
junction: boolean;
nonJunction: boolean;
}
+15
View File
@@ -4,6 +4,7 @@
"timetables",
"reality",
"package-access",
"station-type",
"access",
"control",
"blockades",
@@ -61,6 +62,20 @@
"value": false,
"defaultValue": false
},
{
"id": "junction",
"name": "junction",
"section": "station-type",
"value": true,
"defaultValue": true
},
{
"id": "nonJunction",
"name": "nonJunction",
"section": "station-type",
"value": true,
"defaultValue": true
},
{
"id": "SPK",
"name": "SPK",
+4 -2
View File
@@ -174,6 +174,7 @@
"sections": {
"quick": "QUICK FILTERS",
"station-type": "STATION TYPE",
"reality": "SCENERY REALITY",
"package-access": "IN-GAME AVAILABILITY",
"access": "GENERAL AVAILABILITY",
@@ -233,6 +234,9 @@
"withActiveTimetables": "ACTIVE",
"withoutActiveTimetables": "NO ACTIVE",
"junction": "JUNCTIONS",
"nonJunction": "OTHER",
"sliders": {
"min-lvl": "MIN. REQUIRED DISPATCHER LEVEL",
"max-lvl": "MAX. REQUIRED DISPATCHER LEVEL",
@@ -303,8 +307,6 @@
"single-track-count": "Single track routes:",
"double-track-count": "Double track routes:",
"cross-sceneries": "Cross-track sceneries (1-track <-> 2-track)",
"electrified": "(electrified)",
"not-electrified": "(not electr.)",
"open-spawns": "Open spawns:"
},
"trains": {
+4 -2
View File
@@ -171,6 +171,7 @@
"sections": {
"quick": "SZYBKIE FILTRY",
"station-type": "RODZAJ STACJI",
"reality": "FIKCYJNOŚĆ SCENERII",
"package-access": "DOSTĘPNOŚĆ W PACZCE",
"access": "DOSTĘPNOŚĆ OGÓLNA",
@@ -229,6 +230,9 @@
"withActiveTimetables": "AKTYWNE",
"withoutActiveTimetables": "BEZ AKTYWNYCH",
"junction": "WĘZŁOWE",
"nonJunction": "INNE",
"sliders": {
"min-lvl": "MIN. WYMAGANY POZIOM DYŻURNEGO",
"max-lvl": "MAKS. WYMAGANY POZIOM DYŻURNEGO",
@@ -296,8 +300,6 @@
"single-track-count": "Szlaki jednotorowe:",
"double-track-count": "Szlaki dwutorowe:",
"cross-sceneries": "Scenerie przejściowe (1-tor <-> 2-tor):",
"electrified": "(zelektr.)",
"not-electrified": "(niezelektr.)",
"open-spawns": "Otwarte spawny:"
},
"trains": {
+7 -2
View File
@@ -5,10 +5,15 @@ import router from './router';
import i18n from './i18n';
import { createPinia } from 'pinia';
import useCustomSW from './mixins/useCustomSW';
import { registerSW } from 'virtual:pwa-register';
// Service worker
useCustomSW();
registerSW({
immediate: true,
onNeedRefresh() {
console.log('Needs refresh!');
}
});
const clickOutsideDirective: Directive = {
mounted(el, binding) {
-13
View File
@@ -1,13 +0,0 @@
import { useRegisterSW } from 'virtual:pwa-register/vue';
export default () => {
const { needRefresh, updateServiceWorker, offlineReady } = useRegisterSW({
immediate: true
});
return {
needRefresh,
updateServiceWorker,
offlineReady
};
};
+7
View File
@@ -229,6 +229,13 @@ export const filterStations = (station: Station, filters: Filter) => {
!authors?.map((a) => a.toLocaleLowerCase()).includes(filters['authors'].toLocaleLowerCase())
)
return false;
const singleTracks = routes.single.filter((r) => !r.isInternal);
const doubleTracks = routes.double.filter((r) => !r.isInternal);
let isJunction = singleTracks.length > 0 && doubleTracks.length > 0;
if (filters['junction'] && isJunction) return false;
if (filters['nonJunction'] && !isJunction) return false;
}
return true;
+11 -7
View File
@@ -30,12 +30,6 @@ const filterInitStates: Filter = {
mieszana: false,
SBL: false,
PBL: false,
minLevel: 0,
maxLevel: 20,
minOneWayCatenary: 0,
minOneWay: 0,
minTwoWayCatenary: 0,
minTwoWay: 0,
'include-selected': false,
'no-1track': false,
'no-2track': false,
@@ -52,10 +46,20 @@ const filterInitStates: Filter = {
unsignedStatus: false,
withActiveTimetables: false,
withoutActiveTimetables: false,
junction: false,
nonJunction: false,
maxVmax: 200,
minVmax: 0,
authors: '',
onlineFromHours: 0
onlineFromHours: 0,
minLevel: 0,
maxLevel: 20,
minOneWayCatenary: 0,
minOneWay: 0,
minTwoWayCatenary: 0,
minTwoWay: 0
};
export const useStationFiltersStore = defineStore('stationFiltersStore', {
-6
View File
@@ -9,12 +9,6 @@ import {
ScenerySpawnType
} from '../typings/common';
export function getLocoURL(locoType: string): string {
return `https://rj.td2.info.pl/dist/img/thumbnails/${
locoType.includes('EN') ? locoType + 'rb' : locoType
}.png`;
}
export function getStatusTimestamp(stationStatus: any): number {
if (!stationStatus) return -2;