From 0f8932b53cfeccd1411beb45f0df8fa7a52f8177 Mon Sep 17 00:00:00 2001 From: Spythere Date: Sun, 8 Feb 2026 22:00:15 +0100 Subject: [PATCH] refactor(journal): removed seperate driver & dispatcher stats dropdowns; added button leading to player profile view --- .../JournalDispatcherStats.vue | 85 -------------- src/components/JournalView/JournalStats.vue | 87 ++++++--------- .../JournalTimetables/JournalDriverStats.vue | 105 ------------------ src/components/JournalView/typings.ts | 13 --- src/locales/pl.json | 1 + src/store/mainStore.ts | 10 +- src/store/typings.ts | 5 - src/views/JournalDispatchers.vue | 64 ++--------- src/views/JournalTimetables.vue | 73 ++---------- 9 files changed, 57 insertions(+), 386 deletions(-) delete mode 100644 src/components/JournalView/JournalDispatchers/JournalDispatcherStats.vue delete mode 100644 src/components/JournalView/JournalTimetables/JournalDriverStats.vue diff --git a/src/components/JournalView/JournalDispatchers/JournalDispatcherStats.vue b/src/components/JournalView/JournalDispatchers/JournalDispatcherStats.vue deleted file mode 100644 index 4923d4b..0000000 --- a/src/components/JournalView/JournalDispatchers/JournalDispatcherStats.vue +++ /dev/null @@ -1,85 +0,0 @@ - - - - - diff --git a/src/components/JournalView/JournalStats.vue b/src/components/JournalView/JournalStats.vue index 6c71d0b..7458294 100644 --- a/src/components/JournalView/JournalStats.vue +++ b/src/components/JournalView/JournalStats.vue @@ -2,87 +2,70 @@
@@ -50,15 +50,6 @@ import JournalHeader from '../components/JournalView/JournalHeader.vue'; import JournalStats from '../components/JournalView/JournalStats.vue'; import { useApiStore } from '../store/apiStore'; -const statsButtons: Journal.StatsButton[] = [ - { - tab: Journal.StatsTab.DISPATCHER_STATS, - localeKey: 'journal.dispatcher-stats.button', - iconName: 'user', - disabled: true - } -]; - interface DispatchersQueryParams { dispatcherName?: string; stationName?: string; @@ -105,18 +96,15 @@ export default defineComponent({ }, data: () => ({ - statsButtons, - dataRefreshedAt: null as Date | null, currentQueryParams: {} as DispatchersQueryParams, scrollDataLoaded: true, scrollNoMoreData: false, - showReturnButton: false, - statsCardOpen: false, - currentOptionsActive: false, + chosenPlayerId: -1, + currentOptionsActive: false, dataStatus: Status.Data.Loading, historyList: [] as API.DispatcherHistory.Response @@ -158,15 +146,6 @@ export default defineComponent({ queryParams[k as keyof DispatchersQueryParams] != defaultQueryParams[k as keyof DispatchersQueryParams] ); - }, - - 'mainStore.dispatcherStatsData'(stats) { - this.statsButtons.find((sb) => sb.tab == Journal.StatsTab.DISPATCHER_STATS)!.disabled = - stats === undefined; - }, - - async 'mainStore.dispatcherStatsName'() { - this.fetchDispatcherStats(); } }, @@ -215,29 +194,6 @@ export default defineComponent({ this.setOptions(query as any); }, - async fetchDispatcherStats() { - if (!this.mainStore.dispatcherStatsName) { - this.mainStore.dispatcherStatsData = undefined; - return; - } - - try { - const statsData: API.DispatcherStats.Response = await ( - await this.apiStore.client!.get('api/getDispatcherStats', { - params: { - name: this.mainStore.dispatcherStatsName - } - }) - ).data; - - this.mainStore.dispatcherStatsData = statsData; - } catch (error) { - this.mainStore.dispatcherStatsData = undefined; - - console.error('Ups! Wystąpił błąd przy próbie pobrania statystyk dyżurnego! :/'); - } - }, - setOptions(options: { [key: string]: string }) { this.searchersValues['search-date-from'] = options['search-date-from'] ?? ''; this.searchersValues['search-date-to'] = options['search-date-to'] ?? ''; @@ -320,24 +276,24 @@ export default defineComponent({ if (!responseData) { this.dataStatus = Status.Data.Error; + this.chosenPlayerId = -1; + return; } - if (!responseData) return; - // Response data exists this.historyList = responseData; - // Stats display - this.mainStore.dispatcherStatsName = - this.historyList.length > 0 && this.searchersValues['search-dispatcher'].trim() - ? this.historyList[0].dispatcherName - : ''; + this.chosenPlayerId = + this.historyList.length > 0 && this.searchersValues['search-dispatcher'].trim() != '' + ? this.historyList[0].dispatcherId + : -1; this.dataRefreshedAt = new Date(); this.dataStatus = Status.Data.Loaded; } catch (error) { this.dataStatus = Status.Data.Error; + this.chosenPlayerId = -1; } this.scrollNoMoreData = false; diff --git a/src/views/JournalTimetables.vue b/src/views/JournalTimetables.vue index 978d0bd..1c414d9 100644 --- a/src/views/JournalTimetables.vue +++ b/src/views/JournalTimetables.vue @@ -14,7 +14,7 @@ optionsType="timetables" /> - +
@@ -170,35 +170,19 @@ export default defineComponent({ mainStore: useMainStore(), apiStore: useApiStore(), - statsButtons: [ - { - tab: Journal.StatsTab.DAILY_STATS, - localeKey: 'journal.daily-stats.button', - iconName: 'stats', - disabled: false - }, - { - tab: Journal.StatsTab.DRIVER_STATS, - localeKey: 'journal.driver-stats.button', - iconName: 'train', - disabled: true - } - ], - currentQueryParams: {} as TimetablesQueryParams, dataRefreshedAt: null as Date | null, scrollDataLoaded: true, scrollNoMoreData: false, - showReturnButton: false, - statsCardOpen: false, + chosenPlayerId: -1, + currentOptionsActive: false, timetableHistory: [] as API.TimetableHistory.Response, - dataStatus: Status.Data.Loading, - dataErrorMessage: '' + dataStatus: Status.Data.Loading }), setup() { @@ -248,15 +232,6 @@ export default defineComponent({ watch: { currentQueryParams(q: TimetablesQueryParams) { this.currentOptionsActive = Object.values(q).some((v) => v !== undefined); - }, - - 'mainStore.driverStatsData'(driverStats) { - this.statsButtons.find((sb) => sb.tab == Journal.StatsTab.DRIVER_STATS)!.disabled = - driverStats === undefined; - }, - - async 'mainStore.driverStatsName'() { - this.fetchDriverStats(); } }, @@ -287,31 +262,6 @@ export default defineComponent({ this.setOptions(query as any); }, - async fetchDriverStats() { - if (!this.mainStore.driverStatsName) { - this.mainStore.driverStatsData = undefined; - this.mainStore.driverStatsStatus = Status.Data.Initialized; - return; - } - - try { - this.mainStore.driverStatsStatus = Status.Data.Loading; - - const statsData: API.DriverStats.Response = await ( - await this.apiStore.client!.get( - `api/getDriverInfo?name=${this.mainStore.driverStatsName}` - ) - ).data; - - this.mainStore.driverStatsData = statsData; - this.mainStore.driverStatsStatus = Status.Data.Loaded; - } catch (error) { - this.mainStore.driverStatsData = undefined; - this.mainStore.driverStatsStatus = Status.Data.Error; - console.error('Ups! Wystąpił błąd przy próbie pobrania statystyk maszynisty! :/'); - } - }, - setOptions(options: { [key: string]: string }) { Object.keys(this.searchersValues).forEach((v) => { this.searchersValues[v as Journal.TimetableSearchKey] = options[v] ?? ''; @@ -464,26 +414,23 @@ export default defineComponent({ if (!responseData) { this.dataStatus = Status.Data.Error; - this.dataErrorMessage = 'Brak danych!'; + this.chosenPlayerId = -1; return; } - if (!responseData) return; - // Response data exists this.timetableHistory = responseData; - // Stats display - this.mainStore.driverStatsName = - this.timetableHistory.length > 0 && this.searchersValues['search-driver'].trim() - ? this.timetableHistory[0].driverName - : ''; + this.chosenPlayerId = + this.timetableHistory.length > 0 && this.searchersValues['search-driver'].trim() != '' + ? this.timetableHistory[0].driverId + : -1; this.dataStatus = Status.Data.Loaded; this.dataRefreshedAt = new Date(); } catch (error) { this.dataStatus = Status.Data.Error; - this.dataErrorMessage = 'Ups! Coś poszło nie tak!'; + this.chosenPlayerId = -1; } this.scrollNoMoreData = false;