From 4782dba444a725b830c9dd515126bcc541346062 Mon Sep 17 00:00:00 2001 From: Spythere Date: Fri, 3 May 2024 19:02:16 +0200 Subject: [PATCH] feat(app): added min route speed & max route speed station filters --- src/App.vue | 6 ----- .../StationsView/StationFilterCard.vue | 1 + src/components/StationsView/typings.ts | 2 ++ src/data/options.json | 24 +++++++++++++++++++ src/locales/en.json | 2 ++ src/locales/pl.json | 2 ++ src/scripts/interfaces/StationRoutes.ts | 3 +++ src/scripts/utils/stationFilterUtils.ts | 4 +++- src/store/mainStore.ts | 11 ++++++++- src/store/stationFiltersStore.ts | 2 ++ 10 files changed, 49 insertions(+), 8 deletions(-) diff --git a/src/App.vue b/src/App.vue index 23529e0..e2eae3f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -80,12 +80,6 @@ export default defineComponent({ }, async mounted() { - // window.addEventListener('focus', () => { - // if (Date.now() - this.apiStore.lastFetchData.getTime() < 15000) return; - - // this.apiStore.fetchActiveData(); - // }); - window.addEventListener('mousemove', (e: MouseEvent) => this.handlePopUpEvents(e)); }, diff --git a/src/components/StationsView/StationFilterCard.vue b/src/components/StationsView/StationFilterCard.vue index c7baad9..782e47c 100644 --- a/src/components/StationsView/StationFilterCard.vue +++ b/src/components/StationsView/StationFilterCard.vue @@ -108,6 +108,7 @@ :id="slider.id" :min="slider.minRange" :max="slider.maxRange" + :step="slider.step" v-model="slider.value" @change="handleInput" /> diff --git a/src/components/StationsView/typings.ts b/src/components/StationsView/typings.ts index f19cc3f..674ef11 100644 --- a/src/components/StationsView/typings.ts +++ b/src/components/StationsView/typings.ts @@ -36,6 +36,8 @@ export interface Filter { minOneWay: number; minTwoWayCatenary: number; minTwoWay: number; + minVmax: number; + maxVmax: number; 'no-1track': boolean; 'no-2track': boolean; 'include-selected': boolean; diff --git a/src/data/options.json b/src/data/options.json index 4542930..64badce 100644 --- a/src/data/options.json +++ b/src/data/options.json @@ -265,6 +265,7 @@ "name": "minLevel", "minRange": 0, "maxRange": 20, + "step": 1, "value": 0, "defaultValue": 0 }, @@ -273,14 +274,34 @@ "name": "maxLevel", "minRange": 0, "maxRange": 20, + "step": 1, "value": 20, "defaultValue": 20 }, + { + "id": "min-vmax", + "name": "minVmax", + "minRange": 0, + "maxRange": 200, + "step": 10, + "value": 0, + "defaultValue": 0 + }, + { + "id": "max-vmax", + "name": "maxVmax", + "minRange": 0, + "maxRange": 200, + "step": 10, + "value": 200, + "defaultValue": 200 + }, { "id": "routes-1t-cat", "name": "minOneWayCatenary", "minRange": 0, "maxRange": 5, + "step": 1, "value": 0, "defaultValue": 0 }, @@ -289,6 +310,7 @@ "name": "minOneWay", "minRange": 0, "maxRange": 5, + "step": 1, "value": 0, "defaultValue": 0 }, @@ -297,6 +319,7 @@ "name": "minTwoWayCatenary", "minRange": 0, "maxRange": 5, + "step": 1, "value": 0, "defaultValue": 0 }, @@ -305,6 +328,7 @@ "name": "minTwoWay", "minRange": 0, "maxRange": 5, + "step": 1, "value": 0, "defaultValue": 0 } diff --git a/src/locales/en.json b/src/locales/en.json index 9a2b437..cf037bc 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -235,6 +235,8 @@ "sliders": { "min-lvl": "MIN. REQUIRED DISPATCHER LEVEL", "max-lvl": "MAX. REQUIRED DISPATCHER LEVEL", + "min-vmax": "MIN. SCENERY ROUTE SPEED", + "max-vmax": "MAX. SCENERY ROUTE SPEED", "routes-1t-cat": "MIN. CATENARY SINGLE TRACK ROUTES", "routes-1t-other": "MIN. OTHER SINGLE TRACK ROUTES", "routes-2t-cat": "MIN. CATENARY DOUBLE TRACK ROUTES", diff --git a/src/locales/pl.json b/src/locales/pl.json index 5ef5845..106cb86 100644 --- a/src/locales/pl.json +++ b/src/locales/pl.json @@ -232,6 +232,8 @@ "sliders": { "min-lvl": "MIN. WYMAGANY POZIOM DYŻURNEGO", "max-lvl": "MAKS. WYMAGANY POZIOM DYŻURNEGO", + "min-vmax": "MIN. PRĘDKOŚĆ SZLAKOWA", + "max-vmax": "MAKS. PRĘDKOŚĆ SZLAKOWA", "routes-1t-cat": "SZLAKI JEDNOTOROWE ZELEKTR. (MINIMUM)", "routes-1t-other": "SZLAKI JEDNOTOROWE NIEZELEKTR. (MINIMUM)", "routes-2t-cat": "SZLAKI DWUTOROWE ZELEKTR. (MINIMUM)", diff --git a/src/scripts/interfaces/StationRoutes.ts b/src/scripts/interfaces/StationRoutes.ts index f206773..a88dfbb 100644 --- a/src/scripts/interfaces/StationRoutes.ts +++ b/src/scripts/interfaces/StationRoutes.ts @@ -9,4 +9,7 @@ export interface StationRoutes { doubleElectrifiedNames: string[]; doubleOtherNames: string[]; sblNames: string[]; + + minRouteSpeed: number; + maxRouteSpeed: number; } diff --git a/src/scripts/utils/stationFilterUtils.ts b/src/scripts/utils/stationFilterUtils.ts index 141edbe..a8d8912 100644 --- a/src/scripts/utils/stationFilterUtils.ts +++ b/src/scripts/utils/stationFilterUtils.ts @@ -189,9 +189,11 @@ export const filterStations = (station: Station, filters: Filter) => { availability == 'nonPublic' || availability == 'unavailable' || availability == 'abandoned'; if (reqLevel + (otherAvailability ? 1 : 0) < filters['minLevel']) return false; - if (reqLevel + (otherAvailability ? 1 : 0) > filters['maxLevel']) return false; + if (filters['minVmax'] > station.generalInfo.routes.maxRouteSpeed) return false; + if (filters['maxVmax'] < station.generalInfo.routes.minRouteSpeed) return false; + if ( filters['no-1track'] && (routes.singleElectrifiedNames.length != 0 || routes.singleOtherNames.length != 0) diff --git a/src/store/mainStore.ts b/src/store/mainStore.ts index a6e13c8..214a4e4 100644 --- a/src/store/mainStore.ts +++ b/src/store/mainStore.ts @@ -248,6 +248,13 @@ export const useMainStore = defineStore('store', { if (!route.isInternal) acc[routesKey].push(route.routeName); if (route.isRouteSBL) acc['sblNames'].push(route.routeName); + acc.minRouteSpeed = + acc.minRouteSpeed == 0 + ? route.routeSpeed + : Math.min(route.routeSpeed, acc.minRouteSpeed); + + acc.maxRouteSpeed = Math.max(route.routeSpeed, acc.maxRouteSpeed); + acc[tracksKey].push(route); return acc; @@ -259,7 +266,9 @@ export const useMainStore = defineStore('store', { double: [], doubleElectrifiedNames: [], doubleOtherNames: [], - sblNames: [] + sblNames: [], + minRouteSpeed: 0, + maxRouteSpeed: 0 } as StationRoutes ); diff --git a/src/store/stationFiltersStore.ts b/src/store/stationFiltersStore.ts index fbab940..cd6d396 100644 --- a/src/store/stationFiltersStore.ts +++ b/src/store/stationFiltersStore.ts @@ -52,6 +52,8 @@ const filterInitStates: Filter = { unsignedStatus: false, withActiveTimetables: false, withoutActiveTimetables: false, + maxVmax: 200, + minVmax: 0, authors: '',