diff --git a/src/components/JournalView/DailyStats.vue b/src/components/JournalView/DailyStats.vue new file mode 100644 index 0000000..230ed9a --- /dev/null +++ b/src/components/JournalView/DailyStats.vue @@ -0,0 +1,111 @@ + + + + + + diff --git a/src/components/JournalView/DriverStats.vue b/src/components/JournalView/DriverStats.vue deleted file mode 100644 index e547b85..0000000 --- a/src/components/JournalView/DriverStats.vue +++ /dev/null @@ -1,65 +0,0 @@ - - - - - diff --git a/src/components/JournalView/JournalDriverStats.vue b/src/components/JournalView/JournalDriverStats.vue new file mode 100644 index 0000000..b9018d3 --- /dev/null +++ b/src/components/JournalView/JournalDriverStats.vue @@ -0,0 +1,67 @@ + + + + + diff --git a/src/components/JournalView/JournalOptions.vue b/src/components/JournalView/JournalOptions.vue index 76aa189..304c2ce 100644 --- a/src/components/JournalView/JournalOptions.vue +++ b/src/components/JournalView/JournalOptions.vue @@ -155,7 +155,7 @@ export default defineComponent({ watch: { async driverStatsName(value: string) { - await this.fetchDispatcherStats(); + await this.fetchDriverStats(); this.store.currentStatsTab = value ? 'driver' : 'daily'; }, @@ -204,16 +204,27 @@ export default defineComponent({ }, methods: { - async fetchDispatcherStats() { + async fetchDriverStats() { this.store.driverStatsData = undefined; - if (!this.store.driverStatsName) return; + if (!this.store.driverStatsName) { + this.store.driverStatsStatus = DataStatus.Initialized; + return; + } - const statsData: DriverStatsAPIData = await ( - await axios.get(`${URLs.stacjownikAPI}/api/getDriverInfo?name=${this.store.driverStatsName}`) - ).data; + try { + this.store.driverStatsStatus = DataStatus.Loading; - this.store.driverStatsData = statsData; + const statsData: DriverStatsAPIData = await ( + await axios.get(`${URLs.stacjownikAPI}/api/getDriverInfo?name=${this.store.driverStatsName}`) + ).data; + + this.store.driverStatsData = statsData; + this.store.driverStatsStatus = DataStatus.Loaded; + } catch (error) { + this.store.driverStatsStatus = DataStatus.Error; + console.error('Ups! Wystąpił błąd przy próbie pobrania statystyk maszynisty! :/'); + } }, // Override keyMixin function diff --git a/src/components/JournalView/JournalStats.vue b/src/components/JournalView/JournalStats.vue new file mode 100644 index 0000000..93fb471 --- /dev/null +++ b/src/components/JournalView/JournalStats.vue @@ -0,0 +1,113 @@ + + + + + + diff --git a/src/components/JournalView/TimetablesStats.vue b/src/components/JournalView/TimetablesStats.vue deleted file mode 100644 index 3c4c74b..0000000 --- a/src/components/JournalView/TimetablesStats.vue +++ /dev/null @@ -1,168 +0,0 @@ - - - - - - diff --git a/src/locales/en.json b/src/locales/en.json index b8ae3bc..a3d222a 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -264,9 +264,19 @@ "stats-distance": "DISTANCE", "stats-stations": "STATIONS", - "timetables-stats-total": "Today, dispatchers made so far {count} timetables with total distance of {distance}km.", - "timetable-stats-longest": "Today's the longest timetable is #{id} made by {author} for {driver} - {distance}km!", - "timetable-stats-most-active": "The most active dispatcher is {dispatcher} who created {count} timetables." + "timetable-stats-total": "Today, dispatchers made so far {count} with total distance of {distance}", + "timetable-stats-longest": "Today's the longest timetable is #{id} made by {author} for {driver} - {distance}", + "timetable-stats-most-active": "The most active dispatcher is {dispatcher} who created {count}", + + "timetable-count": "timetable | timetables", + + "daily-stats-title": "DAILY STATS", + "driver-stats-title": "DRIVER STATS", + + "driver-stats-info": "Enter a proper nickname into filters [F] to see user's driving statistics!", + + "stats-loading": "Fetching statistics...", + "stats-error": "Oops! An unexpected error occurred while trying to fetch statistics! :/" }, "scenery": { "users": "PLAYERS ONLINE", diff --git a/src/locales/pl.json b/src/locales/pl.json index 67fdf71..a1097be 100644 --- a/src/locales/pl.json +++ b/src/locales/pl.json @@ -268,9 +268,18 @@ "stats-distance": "DYSTANS", "stats-stations": "STACJE", - "timetables-stats-total": "Dyżurni stworzyli dziś {count} rozkładów jazdy o łącznym dystansie {distance}km.", - "timetable-stats-longest": "Najdłuższym rozkładem jazdy jest dzisiaj #{id} stworzony przez dyżurnego {author} dla maszynisty {driver} - {distance}km!", - "timetable-stats-most-active": "Dzisiejszym najaktywniejszym dyżurnym jest {dispatcher}, który stworzył {count} RJ." + "timetable-stats-total": "Dyżurni stworzyli dziś {count} o łącznym dystansie {distance}", + "timetable-stats-longest": "Najdłuższym rozkładem jazdy jest dzisiaj #{id} stworzony przez dyżurnego {author} dla maszynisty {driver} - {distance}", + "timetable-stats-most-active": "Dzisiejszym najaktywniejszym dyżurnym jest {dispatcher}, który stworzył {count}", + + "timetable-count": "rozkład jazdy | rozkładów jazdy", + + "daily-stats-title": "STATYSTYKI DNIA", + "driver-stats-title": "STATYSTYKI GRACZA", + "driver-stats-info": "Wpisz nazwę użytkownika w filtrach [F], aby zobaczyć jego statystyki maszynisty!", + + "stats-loading": "Pobieranie statystyk...", + "stats-error": "Ups! Wystąpił błąd podczas próby pobrania statystyk! :/" }, "scenery": { "users": "GRACZE ONLINE", diff --git a/src/store/store.ts b/src/store/store.ts index 831f25b..5b8062a 100644 --- a/src/store/store.ts +++ b/src/store/store.ts @@ -41,6 +41,7 @@ export const useStore = defineStore('store', { driverStatsName: '', driverStatsData: undefined, + driverStatsStatus: DataStatus.Initialized, chosenModalTrainId: undefined, diff --git a/src/store/storeTypes.ts b/src/store/storeTypes.ts index e20bed2..417127b 100644 --- a/src/store/storeTypes.ts +++ b/src/store/storeTypes.ts @@ -29,6 +29,7 @@ export interface StoreState { driverStatsName: string; driverStatsData?: DriverStatsAPIData; + driverStatsStatus: DataStatus; chosenModalTrainId?: string; diff --git a/src/styles/JournalStats.scss b/src/styles/JournalStats.scss index ce95ccc..45df00f 100644 --- a/src/styles/JournalStats.scss +++ b/src/styles/JournalStats.scss @@ -1,7 +1,7 @@ @import 'variables.scss'; @import 'responsive.scss'; -.journal-stats { +.stats-tab { background-color: #1a1a1a; padding: 1em; margin-bottom: 1em; diff --git a/src/views/JournalTimetables.vue b/src/views/JournalTimetables.vue index a0e5fb6..f2b83fa 100644 --- a/src/views/JournalTimetables.vue +++ b/src/views/JournalTimetables.vue @@ -3,7 +3,7 @@
- +