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