Rework statystyk RJ

This commit is contained in:
2022-12-17 20:45:53 +01:00
parent 86539cdf23
commit d4fee84603
10 changed files with 49 additions and 39 deletions
+1 -30
View File
@@ -48,44 +48,15 @@ import { URLs } from '../../scripts/utils/apiURLs';
import { useStore } from '../../store/store'; import { useStore } from '../../store/store';
export default defineComponent({ export default defineComponent({
emits: ['closeCard'],
setup() {
const store = useStore();
return {
store,
driverStatsName: computed(() => store.driverStatsName),
};
},
data() { data() {
return { return {
test: Math.random(), test: Math.random(),
lastDispatcherName: '', lastDispatcherName: '',
store: useStore(),
lastTimetables: [] as TimetableHistory[], lastTimetables: [] as TimetableHistory[],
}; };
}, },
watch: {
driverStatsName(value: string) {
this.fetchDispatcherStats();
},
},
methods: {
async fetchDispatcherStats() {
this.store.driverStatsData = undefined;
if (!this.store.driverStatsName) return;
const statsData: DriverStatsAPIData = await (
await axios.get(`${URLs.stacjownikAPI}/api/getDriverInfo?name=${this.store.driverStatsName}`)
).data;
this.store.driverStatsData = statsData;
},
},
}); });
</script> </script>
@@ -89,7 +89,9 @@ import { defineComponent, inject, PropType } from 'vue';
import imageMixin from '../../mixins/imageMixin'; import imageMixin from '../../mixins/imageMixin';
import keyMixin from '../../mixins/keyMixin'; import keyMixin from '../../mixins/keyMixin';
import { DataStatus } from '../../scripts/enums/DataStatus'; import { DataStatus } from '../../scripts/enums/DataStatus';
import { DriverStatsAPIData } from '../../scripts/interfaces/api/DriverStatsAPIData';
import { URLs } from '../../scripts/utils/apiURLs'; import { URLs } from '../../scripts/utils/apiURLs';
import { useStore } from '../../store/store';
import { JournalTimetableFilter } from '../../types/Journal/JournalTimetablesTypes'; import { JournalTimetableFilter } from '../../types/Journal/JournalTimetablesTypes';
import ActionButton from '../Global/ActionButton.vue'; import ActionButton from '../Global/ActionButton.vue';
import SelectBox from '../Global/SelectBox.vue'; import SelectBox from '../Global/SelectBox.vue';
@@ -124,6 +126,7 @@ export default defineComponent({
dispatcherSuggestions: [] as string[], dispatcherSuggestions: [] as string[],
searchTimeout: 0, searchTimeout: 0,
store: useStore(),
DataStatus, DataStatus,
}; };
@@ -138,6 +141,10 @@ export default defineComponent({
}, },
computed: { computed: {
driverStatsName() {
return this.store.driverStatsName;
},
translatedSorterOptions() { translatedSorterOptions() {
return this.$props.sorterOptionIds.map((id) => ({ return this.$props.sorterOptionIds.map((id) => ({
id, id,
@@ -147,6 +154,11 @@ export default defineComponent({
}, },
watch: { watch: {
async driverStatsName(value: string) {
await this.fetchDispatcherStats();
this.store.currentStatsTab = value ? 'driver' : 'daily';
},
async 'searchersValues.search-driver'(value: string | undefined) { async 'searchersValues.search-driver'(value: string | undefined) {
clearTimeout(this.searchTimeout); clearTimeout(this.searchTimeout);
@@ -192,6 +204,18 @@ export default defineComponent({
}, },
methods: { methods: {
async fetchDispatcherStats() {
this.store.driverStatsData = undefined;
if (!this.store.driverStatsName) return;
const statsData: DriverStatsAPIData = await (
await axios.get(`${URLs.stacjownikAPI}/api/getDriverInfo?name=${this.store.driverStatsName}`)
).data;
this.store.driverStatsData = statsData;
},
// Override keyMixin function // Override keyMixin function
onKeyDownFunction() { onKeyDownFunction() {
this.showOptions = !this.showOptions; this.showOptions = !this.showOptions;
@@ -1,6 +1,8 @@
<template> <template>
<section class="journal-timetables"> <section class="journal-timetables">
<div class="journal_wrapper"> <div class="journal_wrapper">
<TimetablesStats />
<JournalOptions <JournalOptions
@on-search-confirm="searchHistory" @on-search-confirm="searchHistory"
@on-options-reset="resetOptions" @on-options-reset="resetOptions"
@@ -9,7 +11,7 @@
:data-status="dataStatus" :data-status="dataStatus"
/> />
<DriverStats /> <!-- <DriverStats /> -->
<!-- <button @click="statsCardOpen = true">Stats</button> --> <!-- <button @click="statsCardOpen = true">Stats</button> -->
<div class="list_wrapper" @scroll="handleScroll"> <div class="list_wrapper" @scroll="handleScroll">
@@ -66,11 +68,12 @@ import modalTrainMixin from '../../mixins/modalTrainMixin';
import imageMixin from '../../mixins/imageMixin'; import imageMixin from '../../mixins/imageMixin';
import JournalTimetablesList from './JournalTimetablesList.vue'; import JournalTimetablesList from './JournalTimetablesList.vue';
import { journalTimetableFilters } from '../../constants/Journal/JournalTimetablesConsts'; import { journalTimetableFilters } from '../../constants/Journal/JournalTimetablesConsts';
import TimetablesStats from './TimetablesStats.vue';
const TIMETABLES_API_URL = `${URLs.stacjownikAPI}/api/getTimetables`; const TIMETABLES_API_URL = `${URLs.stacjownikAPI}/api/getTimetables`;
export default defineComponent({ export default defineComponent({
components: { DriverStats, Loading, JournalOptions, JournalTimetablesList }, components: { DriverStats, Loading, JournalOptions, JournalTimetablesList, TimetablesStats },
mixins: [dateMixin, routerMixin, modalTrainMixin, imageMixin], mixins: [dateMixin, routerMixin, modalTrainMixin, imageMixin],
name: 'JournalTimetables', name: 'JournalTimetables',
+2 -3
View File
@@ -9,7 +9,7 @@
<b>{{ $t('availability.title') }}:</b> {{ $t(`availability.${station.generalInfo.availability}`) }} <b>{{ $t('availability.title') }}:</b> {{ $t(`availability.${station.generalInfo.availability}`) }}
<span v-if="station.generalInfo.reqLevel > -1"> <span v-if="station.generalInfo.reqLevel > -1">
- {{ $tc('scenery.req-level', station.generalInfo.reqLevel, { lvl: station.generalInfo.reqLevel }) }} - {{ $t('scenery.req-level', { lvl: station.generalInfo.reqLevel }, station.generalInfo.reqLevel) }}
</span> </span>
</span> </span>
@@ -33,7 +33,7 @@
<scenery-info-routes :station="station" /> <scenery-info-routes :station="station" />
<div class="scenery-authors" v-if="station.generalInfo.authors && station.generalInfo.authors.length > 0"> <div class="scenery-authors" v-if="station.generalInfo.authors && station.generalInfo.authors.length > 0">
<b> {{ $tc('scenery.authors-title', station.generalInfo.authors.length) }}: </b> <b> {{ $t('scenery.authors-title', { authors: station.generalInfo.authors.length }, station.generalInfo.authors.length) }}: </b>
{{ station.generalInfo.authors.join(', ') }} {{ station.generalInfo.authors.join(', ') }}
</div> </div>
@@ -72,7 +72,6 @@ import SceneryInfoSpawnList from './SceneryInfo/SceneryInfoSpawnList.vue';
import SceneryInfoRoutes from './SceneryInfo/SceneryInfoRoutes.vue'; import SceneryInfoRoutes from './SceneryInfo/SceneryInfoRoutes.vue';
import Station from '../../scripts/interfaces/Station'; import Station from '../../scripts/interfaces/Station';
export default defineComponent({ export default defineComponent({
components: { components: {
SceneryInfoDispatcher, SceneryInfoDispatcher,
+5 -1
View File
@@ -262,7 +262,11 @@
"stats-longest-timetable": "LONGEST TIMETABLE", "stats-longest-timetable": "LONGEST TIMETABLE",
"stats-avg-timetable": "AVERAGE TIMETABLE LENGTH", "stats-avg-timetable": "AVERAGE TIMETABLE LENGTH",
"stats-distance": "DISTANCE", "stats-distance": "DISTANCE",
"stats-stations": "STATIONS" "stats-stations": "STATIONS",
"timetables-stats-total": "Today, dispatchers made so far <b class='text--primary'>{count}</b> timetables with total distance of <b class='text--primary'>{distance}km</b>.",
"timetable-stats-longest": "Today's the longest timetable is <b>#{id}</b> made by <b>{author}</b> for <b>{driver}</b> - <b class='text--primary'>{distance}km</b>!",
"timetable-stats-most-active": "The most active dispatcher is <b>{dispatcher}</b> who created <b class='text--primary'>{count}</b> timetables."
}, },
"scenery": { "scenery": {
"users": "PLAYERS ONLINE", "users": "PLAYERS ONLINE",
+5 -1
View File
@@ -266,7 +266,11 @@
"stats-longest-timetable": "NAJDŁUŻSZY RJ", "stats-longest-timetable": "NAJDŁUŻSZY RJ",
"stats-avg-timetable": "ŚREDNIA DŁUGOŚĆ RJ", "stats-avg-timetable": "ŚREDNIA DŁUGOŚĆ RJ",
"stats-distance": "DYSTANS", "stats-distance": "DYSTANS",
"stats-stations": "STACJE" "stats-stations": "STACJE",
"timetables-stats-total": "Dyżurni stworzyli dziś <b class='text--primary'>{count}</b> rozkładów jazdy o łącznym dystansie <b class='text--primary'>{distance}km</b>.",
"timetable-stats-longest": "Najdłuższym rozkładem jazdy jest dzisiaj <b>#{id}</b> stworzony przez dyżurnego <b>{author}</b> dla maszynisty <b>{driver}</b> - <b class='text--primary'>{distance}km</b>!",
"timetable-stats-most-active": "Dzisiejszym najaktywniejszym dyżurnym jest <b>{dispatcher}</b>, który stworzył <b class='text--primary'>{count}</b> RJ."
}, },
"scenery": { "scenery": {
"users": "GRACZE ONLINE", "users": "GRACZE ONLINE",
+1
View File
@@ -10,6 +10,7 @@ import { createPinia } from 'pinia';
const i18n = createI18n({ const i18n = createI18n({
locale: 'pl', locale: 'pl',
legacy: false,
fallbackLocale: 'pl', fallbackLocale: 'pl',
messages: { messages: {
en: enLang, en: enLang,
+2
View File
@@ -52,6 +52,8 @@ export const useStore = defineStore('store', {
trains: DataStatus.Loading, trains: DataStatus.Loading,
}, },
currentStatsTab: 'daily',
blockScroll: false, blockScroll: false,
listenerLaunched: false, listenerLaunched: false,
+2
View File
@@ -32,6 +32,8 @@ export interface StoreState {
chosenModalTrainId?: string; chosenModalTrainId?: string;
currentStatsTab: 'daily' | 'driver';
dataStatuses: { dataStatuses: {
connection: DataStatus; connection: DataStatus;
sceneries: DataStatus; sceneries: DataStatus;
+1 -1
View File
@@ -210,7 +210,7 @@ button {
} }
button.btn--filled { button.btn--filled {
background-color: #333; background-color: #1a1a1a;
border-radius: 0.25em; border-radius: 0.25em;
&:hover { &:hover {