From 5d822684c006d69b70cf9490f2db83df5efe109b Mon Sep 17 00:00:00 2001 From: Spythere Date: Sun, 14 May 2023 15:05:51 +0200 Subject: [PATCH] feature: rozszerzone filtry RJ --- src/assets/icon-timetableAll.svg | 3 + src/assets/icon-timetableConfirmed.svg | 3 + src/assets/icon-timetableUnconfirmed.svg | 3 + src/components/StationsView/StationTable.vue | 58 ++++++++++++++------ src/locales/en.json | 8 ++- src/locales/pl.json | 8 ++- src/scripts/data/stationHeaderNames.ts | 2 +- src/store/utils/filterUtils.ts | 44 ++++++++------- 8 files changed, 86 insertions(+), 43 deletions(-) create mode 100644 src/assets/icon-timetableAll.svg create mode 100644 src/assets/icon-timetableConfirmed.svg create mode 100644 src/assets/icon-timetableUnconfirmed.svg diff --git a/src/assets/icon-timetableAll.svg b/src/assets/icon-timetableAll.svg new file mode 100644 index 0000000..f7565e0 --- /dev/null +++ b/src/assets/icon-timetableAll.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/assets/icon-timetableConfirmed.svg b/src/assets/icon-timetableConfirmed.svg new file mode 100644 index 0000000..59aeb55 --- /dev/null +++ b/src/assets/icon-timetableConfirmed.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/assets/icon-timetableUnconfirmed.svg b/src/assets/icon-timetableUnconfirmed.svg new file mode 100644 index 0000000..51483ba --- /dev/null +++ b/src/assets/icon-timetableUnconfirmed.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/components/StationsView/StationTable.vue b/src/components/StationsView/StationTable.vue index c7bf08d..d7384fb 100644 --- a/src/components/StationsView/StationTable.vue +++ b/src/components/StationsView/StationTable.vue @@ -8,7 +8,12 @@ - - - + +
+
@@ -21,9 +26,14 @@
+ - + - {{ station.onlineInfo?.currentUsers || '0' }} + {{ station.onlineInfo?.currentUsers || 0 }} / - {{ station.onlineInfo?.maxUsers || '0' }} + {{ station.onlineInfo?.maxUsers || 0 }} - {{ station.onlineInfo?.spawns.length || '0' }} + {{ station.onlineInfo?.spawns.length || 0 }} - - - {{ station.onlineInfo?.scheduledTrains?.length || '0' }} - - / - - {{ station.onlineInfo?.scheduledTrains?.filter((train) => train.stopInfo.confirmed).length || '0' }} - + + + {{ station.onlineInfo?.scheduledTrains?.length || 0 }} + + / + + {{ station.onlineInfo?.scheduledTrains?.filter((train) => train.stopInfo.confirmed).length || 0 }} + + / + + {{ station.onlineInfo?.scheduledTrains?.filter((train) => !train.stopInfo.confirmed).length || 0 }}
@@ -352,9 +370,15 @@ table { position: sticky; top: 0; - min-width: 80px; + &.header-text { + min-width: 140px; + } - padding: 0.5em; + &.header-image { + min-width: 60px; + } + + padding: 0.5em 0.25em; background-color: $bgCol; white-space: pre-wrap; diff --git a/src/locales/en.json b/src/locales/en.json index 6f975e4..4a07119 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -211,9 +211,11 @@ "dispatcher-lvl": "Dispatcher\nlevel", "routes": "Routes\ndouble / single", "general": "General info", - "users": "Drivers online", - "spawns": "Spawns online", - "timetables": "Active timetables", + "user": "Drivers online", + "spawn": "Spawns online", + "timetableAll": "Active timetables", + "timetableConfirmed": "Confirmed timetables", + "timetableUnconfirmed": "Unconfirmed timetables", "no-stations": "No stations to show here!", "scenery-search": "Search for scenery..." }, diff --git a/src/locales/pl.json b/src/locales/pl.json index ee93fcc..c756ad5 100644 --- a/src/locales/pl.json +++ b/src/locales/pl.json @@ -215,9 +215,11 @@ "dispatcher-lvl": "Poziom\ndyżurnego", "routes": "Szlaki\n2tor / 1tor", "general": "Informacje\nogólne", - "users": "Maszyniści online", - "spawns": "Otwarte spawny", - "timetables": "Aktywne rozkłady jazdy", + "user": "Maszyniści online", + "spawn": "Otwarte spawny", + "timetableAll": "Aktywne rozkłady jazdy", + "timetableConfirmed": "Zatwierdzone rozkłady jazdy", + "timetableUnconfirmed": "Niezatwierdzone rozkłady jazdy", "no-stations": "Brak stacji do wyświetlenia!", "scenery-search": "Wyszukaj scenerię..." }, diff --git a/src/scripts/data/stationHeaderNames.ts b/src/scripts/data/stationHeaderNames.ts index 4e82dc2..70b1b75 100644 --- a/src/scripts/data/stationHeaderNames.ts +++ b/src/scripts/data/stationHeaderNames.ts @@ -8,6 +8,6 @@ export const headIds = [ 'general', ] as const; -export const headIconsIds = ['user', 'spawn', 'timetable'] as const; +export const headIconsIds = ['user', 'spawn', 'timetableAll', 'timetableConfirmed', 'timetableUnconfirmed'] as const; export type HeadIdsTypes = typeof headIds[number] | typeof headIconsIds[number]; diff --git a/src/store/utils/filterUtils.ts b/src/store/utils/filterUtils.ts index ff7f5ad..eaa3f88 100644 --- a/src/store/utils/filterUtils.ts +++ b/src/store/utils/filterUtils.ts @@ -3,18 +3,18 @@ import Filter from '../../scripts/interfaces/Filter'; import Station from '../../scripts/interfaces/Station'; export const sortStations = (a: Station, b: Station, sorter: { headerName: HeadIdsTypes; dir: number }) => { + let diff = 0; + switch (sorter.headerName) { case 'station': return sorter.dir == 1 ? a.name.localeCompare(b.name) : b.name.localeCompare(a.name); case 'min-lvl': - if ((a.generalInfo?.reqLevel || 0) > (b.generalInfo?.reqLevel || 0)) return sorter.dir; - if ((a.generalInfo?.reqLevel || 0) < (b.generalInfo?.reqLevel || 0)) return -sorter.dir; + diff = (a.generalInfo?.reqLevel || 0) - (b.generalInfo?.reqLevel || 0); break; case 'status': - if ((a.onlineInfo?.statusTimestamp || 0) > (b.onlineInfo?.statusTimestamp || 0)) return sorter.dir; - if ((a.onlineInfo?.statusTimestamp || 0) < (b.onlineInfo?.statusTimestamp || 0)) return -sorter.dir; + diff = (a.onlineInfo?.statusTimestamp || 0) - (b.onlineInfo?.statusTimestamp || 0); break; case 'dispatcher': @@ -25,34 +25,40 @@ export const sortStations = (a: Station, b: Station, sorter: { headerName: HeadI break; case 'dispatcher-lvl': - if ((a.onlineInfo?.dispatcherExp || 0) > (b.onlineInfo?.dispatcherExp || 0)) return sorter.dir; - if ((a.onlineInfo?.dispatcherExp || 0) < (b.onlineInfo?.dispatcherExp || 0)) return -sorter.dir; + diff = (a.onlineInfo?.dispatcherExp || 0) - (b.onlineInfo?.dispatcherExp || 0); break; case 'user': - if ((a.onlineInfo?.currentUsers || 0) > (b.onlineInfo?.currentUsers || 0)) return sorter.dir; - if ((a.onlineInfo?.currentUsers || 0) < (b.onlineInfo?.currentUsers || 0)) return -sorter.dir; - - if ((a.onlineInfo?.maxUsers || 0) > (b.onlineInfo?.maxUsers || 0)) return sorter.dir; - if ((a.onlineInfo?.maxUsers || 0) < (b.onlineInfo?.maxUsers || 0)) return -sorter.dir; + diff = + (a.onlineInfo?.currentUsers || a.onlineInfo?.maxUsers || 0) - + (b.onlineInfo?.currentUsers || b.onlineInfo?.maxUsers || 0); break; case 'spawn': - if ((a.onlineInfo?.spawns.length || 0) > (b.onlineInfo?.spawns.length || 0)) return sorter.dir; - if ((a.onlineInfo?.spawns.length || 0) < (b.onlineInfo?.spawns.length || 0)) return -sorter.dir; - + diff = (a.onlineInfo?.spawns.length || 0) - (b.onlineInfo?.spawns.length || 0); break; - case 'timetable': - if ((a.onlineInfo?.scheduledTrains?.length || 0) > (b.onlineInfo?.scheduledTrains?.length || 0)) - return sorter.dir; - if ((a.onlineInfo?.scheduledTrains?.length || 0) < (b.onlineInfo?.scheduledTrains?.length || 0)) - return -sorter.dir; + case 'timetableConfirmed': + diff = + (a.onlineInfo?.scheduledTrains?.filter((train) => train.stopInfo.confirmed).length || 0) - + (b.onlineInfo?.scheduledTrains?.filter((train) => train.stopInfo.confirmed).length || 0); + break; + + case 'timetableUnconfirmed': + diff = + (a.onlineInfo?.scheduledTrains?.filter((train) => !train.stopInfo.confirmed).length || 0) - + (b.onlineInfo?.scheduledTrains?.filter((train) => !train.stopInfo.confirmed).length || 0); + break; + + case 'timetableAll': + diff = (a.onlineInfo?.scheduledTrains?.length || 0) - (b.onlineInfo?.scheduledTrains?.length || 0); + break; default: break; } + if (diff != 0) return Math.sign(diff) * sorter.dir; return a.name.localeCompare(b.name); };