mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
Rework statystyk RJ
This commit is contained in:
@@ -48,44 +48,15 @@ import { URLs } from '../../scripts/utils/apiURLs';
|
||||
import { useStore } from '../../store/store';
|
||||
|
||||
export default defineComponent({
|
||||
emits: ['closeCard'],
|
||||
|
||||
setup() {
|
||||
const store = useStore();
|
||||
return {
|
||||
store,
|
||||
driverStatsName: computed(() => store.driverStatsName),
|
||||
};
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
test: Math.random(),
|
||||
lastDispatcherName: '',
|
||||
store: useStore(),
|
||||
|
||||
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>
|
||||
|
||||
|
||||
@@ -89,7 +89,9 @@ import { defineComponent, inject, PropType } from 'vue';
|
||||
import imageMixin from '../../mixins/imageMixin';
|
||||
import keyMixin from '../../mixins/keyMixin';
|
||||
import { DataStatus } from '../../scripts/enums/DataStatus';
|
||||
import { DriverStatsAPIData } from '../../scripts/interfaces/api/DriverStatsAPIData';
|
||||
import { URLs } from '../../scripts/utils/apiURLs';
|
||||
import { useStore } from '../../store/store';
|
||||
import { JournalTimetableFilter } from '../../types/Journal/JournalTimetablesTypes';
|
||||
import ActionButton from '../Global/ActionButton.vue';
|
||||
import SelectBox from '../Global/SelectBox.vue';
|
||||
@@ -124,6 +126,7 @@ export default defineComponent({
|
||||
dispatcherSuggestions: [] as string[],
|
||||
|
||||
searchTimeout: 0,
|
||||
store: useStore(),
|
||||
|
||||
DataStatus,
|
||||
};
|
||||
@@ -138,6 +141,10 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
computed: {
|
||||
driverStatsName() {
|
||||
return this.store.driverStatsName;
|
||||
},
|
||||
|
||||
translatedSorterOptions() {
|
||||
return this.$props.sorterOptionIds.map((id) => ({
|
||||
id,
|
||||
@@ -147,6 +154,11 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
watch: {
|
||||
async driverStatsName(value: string) {
|
||||
await this.fetchDispatcherStats();
|
||||
this.store.currentStatsTab = value ? 'driver' : 'daily';
|
||||
},
|
||||
|
||||
async 'searchersValues.search-driver'(value: string | undefined) {
|
||||
clearTimeout(this.searchTimeout);
|
||||
|
||||
@@ -192,6 +204,18 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
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
|
||||
onKeyDownFunction() {
|
||||
this.showOptions = !this.showOptions;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<template>
|
||||
<section class="journal-timetables">
|
||||
<div class="journal_wrapper">
|
||||
<TimetablesStats />
|
||||
|
||||
<JournalOptions
|
||||
@on-search-confirm="searchHistory"
|
||||
@on-options-reset="resetOptions"
|
||||
@@ -9,7 +11,7 @@
|
||||
:data-status="dataStatus"
|
||||
/>
|
||||
|
||||
<DriverStats />
|
||||
<!-- <DriverStats /> -->
|
||||
<!-- <button @click="statsCardOpen = true">Stats</button> -->
|
||||
|
||||
<div class="list_wrapper" @scroll="handleScroll">
|
||||
@@ -66,11 +68,12 @@ import modalTrainMixin from '../../mixins/modalTrainMixin';
|
||||
import imageMixin from '../../mixins/imageMixin';
|
||||
import JournalTimetablesList from './JournalTimetablesList.vue';
|
||||
import { journalTimetableFilters } from '../../constants/Journal/JournalTimetablesConsts';
|
||||
import TimetablesStats from './TimetablesStats.vue';
|
||||
|
||||
const TIMETABLES_API_URL = `${URLs.stacjownikAPI}/api/getTimetables`;
|
||||
|
||||
export default defineComponent({
|
||||
components: { DriverStats, Loading, JournalOptions, JournalTimetablesList },
|
||||
components: { DriverStats, Loading, JournalOptions, JournalTimetablesList, TimetablesStats },
|
||||
mixins: [dateMixin, routerMixin, modalTrainMixin, imageMixin],
|
||||
|
||||
name: 'JournalTimetables',
|
||||
|
||||
Reference in New Issue
Block a user