mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 21:38:13 +00:00
refactor(journal): removed seperate driver & dispatcher stats dropdowns; added button leading to player profile view
This commit is contained in:
@@ -1,85 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="journal-stats dispatcher" v-if="dispatcherName && stats">
|
|
||||||
<span class="loading" v-if="!stats.issuedTimetables && !stats.services">
|
|
||||||
{{ $t('journal.dispatcher-stats.empty') }}
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<span v-else>
|
|
||||||
<h3>
|
|
||||||
<i18n-t keypath="journal.dispatcher-stats.title">
|
|
||||||
<template #name>
|
|
||||||
<span class="text--primary">{{ dispatcherName.toUpperCase() }}</span>
|
|
||||||
</template>
|
|
||||||
</i18n-t>
|
|
||||||
</h3>
|
|
||||||
|
|
||||||
<hr class="header-separator" />
|
|
||||||
|
|
||||||
<div class="info-stats">
|
|
||||||
<span class="badge stat-badge" v-if="stats.services">
|
|
||||||
<span>{{ $t('journal.dispatcher-stats.services-count') }}</span>
|
|
||||||
<span>{{ stats.services.count }}</span>
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<span class="badge stat-badge" v-if="stats.services">
|
|
||||||
<span>{{ $t('journal.dispatcher-stats.service-max') }}</span>
|
|
||||||
<span>{{ calculateDuration(stats.services.durationMax) }}</span>
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<span class="badge stat-badge" v-if="stats.services">
|
|
||||||
<span>{{ $t('journal.dispatcher-stats.service-avg') }}</span>
|
|
||||||
<span>{{ calculateDuration(stats.services.durationAvg) }}</span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<hr class="section-separator" v-if="stats.issuedTimetables" />
|
|
||||||
|
|
||||||
<div class="info-stats" v-if="stats.issuedTimetables">
|
|
||||||
<span class="badge stat-badge">
|
|
||||||
<span>{{ $t('journal.dispatcher-stats.timetables-count') }}</span>
|
|
||||||
<span>{{ stats.issuedTimetables.count }}</span>
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<span class="badge stat-badge">
|
|
||||||
<span>{{ $t('journal.dispatcher-stats.timetables-sum') }}</span>
|
|
||||||
<span>{{ stats.issuedTimetables.distanceSum.toFixed(2) }}km</span>
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<span class="badge stat-badge">
|
|
||||||
<span>{{ $t('journal.dispatcher-stats.timetables-max') }}</span>
|
|
||||||
<span>{{ stats.issuedTimetables.distanceMax.toFixed(2) }}km</span>
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<span class="badge stat-badge">
|
|
||||||
<span>{{ $t('journal.dispatcher-stats.timetables-avg') }}</span>
|
|
||||||
<span>{{ stats.issuedTimetables.distanceAvg.toFixed(2) }}km</span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts">
|
|
||||||
import { defineComponent } from 'vue';
|
|
||||||
import dateMixin from '../../../mixins/dateMixin';
|
|
||||||
import { useMainStore } from '../../../store/mainStore';
|
|
||||||
|
|
||||||
export default defineComponent({
|
|
||||||
name: 'journal-dispatcher-stats',
|
|
||||||
|
|
||||||
mixins: [dateMixin],
|
|
||||||
|
|
||||||
setup() {
|
|
||||||
const store = useMainStore();
|
|
||||||
|
|
||||||
return {
|
|
||||||
stats: store.dispatcherStatsData,
|
|
||||||
dispatcherName: store.dispatcherStatsName
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
@use '../../../styles/journal-stats';
|
|
||||||
</style>
|
|
||||||
@@ -2,87 +2,70 @@
|
|||||||
<div
|
<div
|
||||||
class="journal-stats dropdown"
|
class="journal-stats dropdown"
|
||||||
v-if="!mainStore.isOffline"
|
v-if="!mainStore.isOffline"
|
||||||
@keydown.esc="currentStatsTab = null"
|
@keydown.esc="isDropdownOpen = false"
|
||||||
>
|
>
|
||||||
<div
|
<div class="dropdown_background" v-if="isDropdownOpen" @click="isDropdownOpen = false"></div>
|
||||||
class="dropdown_background"
|
|
||||||
v-if="currentStatsTab !== null"
|
|
||||||
@click="currentStatsTab = null"
|
|
||||||
></div>
|
|
||||||
|
|
||||||
<div class="actions-bar">
|
<div class="actions-bar">
|
||||||
|
<button class="btn--filled btn--image" @click="toggleDropdown">
|
||||||
|
<img :src="`/images/icon-stats.svg`" alt="stats icon" />
|
||||||
|
{{ $t('journal.daily-stats.button') }}
|
||||||
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
v-for="button in statsButtons"
|
|
||||||
:key="button.tab"
|
|
||||||
class="btn--filled btn--image"
|
class="btn--filled btn--image"
|
||||||
:data-selected="button.tab == currentStatsTab"
|
:data-disabled="chosenPlayerId == -1"
|
||||||
:data-disabled="button.disabled"
|
@click="navigateToProfile"
|
||||||
:disabled="button.disabled"
|
|
||||||
@click="onTabButtonClick(button.tab)"
|
|
||||||
>
|
>
|
||||||
<img
|
<img :src="`/images/icon-user.svg`" alt="user icon" />
|
||||||
v-if="button.iconName"
|
{{ $t('profile.journal-button') }}
|
||||||
:src="`/images/icon-${button.iconName}.svg`"
|
|
||||||
:alt="button.iconName"
|
|
||||||
/>
|
|
||||||
{{ $t(button.localeKey) }}
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<transition name="dropdown-anim">
|
<transition name="dropdown-anim">
|
||||||
<div
|
<div class="dropdown_wrapper" v-if="isDropdownOpen">
|
||||||
class="dropdown_wrapper"
|
|
||||||
:class="{ 'dropdown-align-right': true }"
|
|
||||||
v-if="currentStatsTab !== null"
|
|
||||||
>
|
|
||||||
<keep-alive>
|
<keep-alive>
|
||||||
<component :is="currentStatsTab" :key="currentStatsTab"></component>
|
<JournalDailyStats />
|
||||||
</keep-alive>
|
</keep-alive>
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</transition>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent, PropType } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { useMainStore } from '../../store/mainStore';
|
import { useMainStore } from '../../store/mainStore';
|
||||||
import StorageManager from '../../managers/storageManager';
|
|
||||||
import { Journal } from './typings';
|
|
||||||
import JournalDailyStats from './JournalDailyStats.vue';
|
import JournalDailyStats from './JournalDailyStats.vue';
|
||||||
import JournalDispatcherStats from '../JournalView/JournalDispatchers/JournalDispatcherStats.vue';
|
import { useRouter } from 'vue-router';
|
||||||
import JournalDriverStats from '../JournalView/JournalTimetables/JournalDriverStats.vue';
|
|
||||||
|
|
||||||
export default defineComponent({
|
const router = useRouter();
|
||||||
components: { JournalDailyStats, JournalDriverStats, JournalDispatcherStats },
|
|
||||||
props: {
|
|
||||||
statsButtons: {
|
|
||||||
type: Array as PropType<Journal.StatsButton[]>,
|
|
||||||
required: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
Journal,
|
|
||||||
mainStore: useMainStore(),
|
|
||||||
currentStatsTab: null as Journal.StatsTab | null
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
const props = defineProps({
|
||||||
onTabButtonClick(tab: Journal.StatsTab) {
|
chosenPlayerId: {
|
||||||
this.currentStatsTab = tab == this.currentStatsTab ? null : tab;
|
type: Number,
|
||||||
|
required: true
|
||||||
StorageManager.setStringValue('journalStatsTab', this.currentStatsTab ?? '');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const mainStore = useMainStore();
|
||||||
|
const isDropdownOpen = ref(false);
|
||||||
|
|
||||||
|
function toggleDropdown() {
|
||||||
|
isDropdownOpen.value = !isDropdownOpen.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function navigateToProfile() {
|
||||||
|
if (props.chosenPlayerId == -1) return;
|
||||||
|
|
||||||
|
router.push(`/profile?playerId=${props.chosenPlayerId}`);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@use '../../styles/dropdown';
|
@use '../../styles/dropdown';
|
||||||
@use '../../styles/dropdown-filters';
|
@use '../../styles/dropdown-filters';
|
||||||
|
|
||||||
.dropdown_wrapper.dropdown-align-right {
|
.dropdown_wrapper {
|
||||||
left: auto;
|
left: auto;
|
||||||
right: 0;
|
right: 0;
|
||||||
max-width: 700px;
|
max-width: 700px;
|
||||||
|
|||||||
@@ -1,105 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="journal-stats driver" v-if="store.driverStatsData">
|
|
||||||
<span>
|
|
||||||
<h3>
|
|
||||||
<i18n-t keypath="journal.driver-stats.title">
|
|
||||||
<template #name>
|
|
||||||
<span class="text--primary">{{ store.driverStatsName.toUpperCase() }}</span>
|
|
||||||
</template>
|
|
||||||
</i18n-t>
|
|
||||||
</h3>
|
|
||||||
|
|
||||||
<hr class="header-separator" />
|
|
||||||
|
|
||||||
<div class="info-stats">
|
|
||||||
<span class="badge stat-badge">
|
|
||||||
<span>{{ $t('journal.driver-stats.longest-timetable') }}</span>
|
|
||||||
<span> {{ store.driverStatsData._max.routeDistance.toFixed(2) }}km </span>
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<span class="badge stat-badge">
|
|
||||||
<span>{{ $t('journal.driver-stats.avg-timetable') }}</span>
|
|
||||||
<span> {{ store.driverStatsData._avg.routeDistance.toFixed(2) }}km </span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<hr class="section-separator" />
|
|
||||||
|
|
||||||
<div class="info-stats">
|
|
||||||
<span class="badge stat-badge">
|
|
||||||
<span>{{ $t('journal.driver-stats.timetables') }}</span>
|
|
||||||
<span>
|
|
||||||
{{ store.driverStatsData._count.fulfilled }} /
|
|
||||||
{{ store.driverStatsData._count._all }}
|
|
||||||
|
|
||||||
<template v-if="store.driverStatsData._count._all > 0">
|
|
||||||
({{
|
|
||||||
(
|
|
||||||
(store.driverStatsData._count.fulfilled / store.driverStatsData._count._all) *
|
|
||||||
100
|
|
||||||
).toFixed(2)
|
|
||||||
}}%)
|
|
||||||
</template>
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<span class="badge stat-badge">
|
|
||||||
<span>{{ $t('journal.driver-stats.distance') }}</span>
|
|
||||||
<span>
|
|
||||||
{{ store.driverStatsData._sum.currentDistance.toFixed(2) }} /
|
|
||||||
{{ store.driverStatsData._sum.routeDistance.toFixed(2) }}km
|
|
||||||
|
|
||||||
<template v-if="store.driverStatsData._sum.routeDistance > 0">
|
|
||||||
({{
|
|
||||||
(
|
|
||||||
(store.driverStatsData._sum.currentDistance /
|
|
||||||
store.driverStatsData._sum.routeDistance) *
|
|
||||||
100
|
|
||||||
).toFixed(2)
|
|
||||||
}}%)
|
|
||||||
</template>
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<span class="badge stat-badge">
|
|
||||||
<span>{{ $t('journal.driver-stats.stations') }}</span>
|
|
||||||
<span>
|
|
||||||
{{ store.driverStatsData._sum.confirmedStopsCount }} /
|
|
||||||
{{ store.driverStatsData._sum.allStopsCount }}
|
|
||||||
|
|
||||||
<template v-if="store.driverStatsData._sum.allStopsCount > 0">
|
|
||||||
({{
|
|
||||||
(
|
|
||||||
(store.driverStatsData._sum.confirmedStopsCount /
|
|
||||||
store.driverStatsData._sum.allStopsCount) *
|
|
||||||
100
|
|
||||||
).toFixed(2)
|
|
||||||
}}%)
|
|
||||||
</template>
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts">
|
|
||||||
import { defineComponent } from 'vue';
|
|
||||||
import { useMainStore } from '../../../store/mainStore';
|
|
||||||
import { Status } from '../../../typings/common';
|
|
||||||
|
|
||||||
export default defineComponent({
|
|
||||||
name: 'journal-driver-stats',
|
|
||||||
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
store: useMainStore(),
|
|
||||||
Status: Status
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
@use '../../../styles/journal-stats';
|
|
||||||
</style>
|
|
||||||
@@ -62,19 +62,6 @@ export namespace Journal {
|
|||||||
default: boolean;
|
default: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum StatsTab {
|
|
||||||
DRIVER_STATS = 'journal-driver-stats',
|
|
||||||
DISPATCHER_STATS = 'journal-dispatcher-stats',
|
|
||||||
DAILY_STATS = 'journal-daily-stats'
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface StatsButton {
|
|
||||||
tab: StatsTab;
|
|
||||||
localeKey: string;
|
|
||||||
iconName: string;
|
|
||||||
disabled: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TimetableStopDetails {
|
export interface TimetableStopDetails {
|
||||||
stopName: string;
|
stopName: string;
|
||||||
arrivalTimestamp: number;
|
arrivalTimestamp: number;
|
||||||
|
|||||||
@@ -605,6 +605,7 @@
|
|||||||
"desc-terminated": "Pociąg zakończył bieg"
|
"desc-terminated": "Pociąg zakończył bieg"
|
||||||
},
|
},
|
||||||
"profile": {
|
"profile": {
|
||||||
|
"journal-button": "PROFIL GRACZA",
|
||||||
"filters": {
|
"filters": {
|
||||||
"Timetable": "ROZKŁADY JAZDY",
|
"Timetable": "ROZKŁADY JAZDY",
|
||||||
"Dispatcher": "SŁUŻBY DYŻURNEGO",
|
"Dispatcher": "SŁUŻBY DYŻURNEGO",
|
||||||
|
|||||||
@@ -26,20 +26,12 @@ export const useMainStore = defineStore('mainStore', {
|
|||||||
isOffline: false,
|
isOffline: false,
|
||||||
appUpdate: null,
|
appUpdate: null,
|
||||||
|
|
||||||
dispatcherStatsName: '',
|
|
||||||
dispatcherStatsStatus: Status.Data.Initialized,
|
|
||||||
|
|
||||||
driverStatsName: '',
|
|
||||||
driverStatsData: undefined,
|
|
||||||
driverStatsStatus: Status.Data.Initialized,
|
|
||||||
|
|
||||||
chosenModalTrainId: undefined,
|
chosenModalTrainId: undefined,
|
||||||
|
|
||||||
modalLastClickedTarget: null,
|
modalLastClickedTarget: null,
|
||||||
currentLocale: 'pl',
|
currentLocale: 'pl',
|
||||||
|
|
||||||
isMigrateInfoCardOpen: false,
|
isMigrateInfoCardOpen: false
|
||||||
pinnedStationNames: []
|
|
||||||
}) as MainStoreState,
|
}) as MainStoreState,
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
|||||||
@@ -5,11 +5,6 @@ export interface MainStoreState {
|
|||||||
region: { id: string; value: string; name: string };
|
region: { id: string; value: string; name: string };
|
||||||
isOffline: boolean;
|
isOffline: boolean;
|
||||||
appUpdate: { version: string; changelog: string; releaseURL: string } | null;
|
appUpdate: { version: string; changelog: string; releaseURL: string } | null;
|
||||||
dispatcherStatsName: string;
|
|
||||||
dispatcherStatsData?: API.DispatcherStats.Response;
|
|
||||||
driverStatsName: string;
|
|
||||||
driverStatsData?: API.DriverStats.Response;
|
|
||||||
driverStatsStatus: Status.Data;
|
|
||||||
chosenModalTrainId?: string;
|
chosenModalTrainId?: string;
|
||||||
modalLastClickedTarget: EventTarget | null;
|
modalLastClickedTarget: EventTarget | null;
|
||||||
currentLocale: string;
|
currentLocale: string;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
optionsType="dispatchers"
|
optionsType="dispatchers"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<JournalStats :statsButtons="statsButtons" />
|
<JournalStats :chosen-player-id="chosenPlayerId" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="journal_refreshed-date">
|
<div class="journal_refreshed-date">
|
||||||
@@ -50,15 +50,6 @@ import JournalHeader from '../components/JournalView/JournalHeader.vue';
|
|||||||
import JournalStats from '../components/JournalView/JournalStats.vue';
|
import JournalStats from '../components/JournalView/JournalStats.vue';
|
||||||
import { useApiStore } from '../store/apiStore';
|
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 {
|
interface DispatchersQueryParams {
|
||||||
dispatcherName?: string;
|
dispatcherName?: string;
|
||||||
stationName?: string;
|
stationName?: string;
|
||||||
@@ -105,18 +96,15 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
data: () => ({
|
data: () => ({
|
||||||
statsButtons,
|
|
||||||
|
|
||||||
dataRefreshedAt: null as Date | null,
|
dataRefreshedAt: null as Date | null,
|
||||||
currentQueryParams: {} as DispatchersQueryParams,
|
currentQueryParams: {} as DispatchersQueryParams,
|
||||||
|
|
||||||
scrollDataLoaded: true,
|
scrollDataLoaded: true,
|
||||||
scrollNoMoreData: false,
|
scrollNoMoreData: false,
|
||||||
|
|
||||||
showReturnButton: false,
|
chosenPlayerId: -1,
|
||||||
statsCardOpen: false,
|
|
||||||
currentOptionsActive: false,
|
|
||||||
|
|
||||||
|
currentOptionsActive: false,
|
||||||
dataStatus: Status.Data.Loading,
|
dataStatus: Status.Data.Loading,
|
||||||
|
|
||||||
historyList: [] as API.DispatcherHistory.Response
|
historyList: [] as API.DispatcherHistory.Response
|
||||||
@@ -158,15 +146,6 @@ export default defineComponent({
|
|||||||
queryParams[k as keyof DispatchersQueryParams] !=
|
queryParams[k as keyof DispatchersQueryParams] !=
|
||||||
defaultQueryParams[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);
|
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 }) {
|
setOptions(options: { [key: string]: string }) {
|
||||||
this.searchersValues['search-date-from'] = options['search-date-from'] ?? '';
|
this.searchersValues['search-date-from'] = options['search-date-from'] ?? '';
|
||||||
this.searchersValues['search-date-to'] = options['search-date-to'] ?? '';
|
this.searchersValues['search-date-to'] = options['search-date-to'] ?? '';
|
||||||
@@ -320,24 +276,24 @@ export default defineComponent({
|
|||||||
|
|
||||||
if (!responseData) {
|
if (!responseData) {
|
||||||
this.dataStatus = Status.Data.Error;
|
this.dataStatus = Status.Data.Error;
|
||||||
|
this.chosenPlayerId = -1;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!responseData) return;
|
|
||||||
|
|
||||||
// Response data exists
|
// Response data exists
|
||||||
this.historyList = responseData;
|
this.historyList = responseData;
|
||||||
|
|
||||||
// Stats display
|
this.chosenPlayerId =
|
||||||
this.mainStore.dispatcherStatsName =
|
this.historyList.length > 0 && this.searchersValues['search-dispatcher'].trim() != ''
|
||||||
this.historyList.length > 0 && this.searchersValues['search-dispatcher'].trim()
|
? this.historyList[0].dispatcherId
|
||||||
? this.historyList[0].dispatcherName
|
: -1;
|
||||||
: '';
|
|
||||||
|
|
||||||
this.dataRefreshedAt = new Date();
|
this.dataRefreshedAt = new Date();
|
||||||
this.dataStatus = Status.Data.Loaded;
|
this.dataStatus = Status.Data.Loaded;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.dataStatus = Status.Data.Error;
|
this.dataStatus = Status.Data.Error;
|
||||||
|
this.chosenPlayerId = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.scrollNoMoreData = false;
|
this.scrollNoMoreData = false;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
optionsType="timetables"
|
optionsType="timetables"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<JournalStats :statsButtons="statsButtons" />
|
<JournalStats :chosen-player-id="chosenPlayerId" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="journal_refreshed-date">
|
<div class="journal_refreshed-date">
|
||||||
@@ -170,35 +170,19 @@ export default defineComponent({
|
|||||||
mainStore: useMainStore(),
|
mainStore: useMainStore(),
|
||||||
apiStore: useApiStore(),
|
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,
|
currentQueryParams: {} as TimetablesQueryParams,
|
||||||
dataRefreshedAt: null as Date | null,
|
dataRefreshedAt: null as Date | null,
|
||||||
|
|
||||||
scrollDataLoaded: true,
|
scrollDataLoaded: true,
|
||||||
scrollNoMoreData: false,
|
scrollNoMoreData: false,
|
||||||
|
|
||||||
showReturnButton: false,
|
chosenPlayerId: -1,
|
||||||
statsCardOpen: false,
|
|
||||||
currentOptionsActive: false,
|
currentOptionsActive: false,
|
||||||
|
|
||||||
timetableHistory: [] as API.TimetableHistory.Response,
|
timetableHistory: [] as API.TimetableHistory.Response,
|
||||||
|
|
||||||
dataStatus: Status.Data.Loading,
|
dataStatus: Status.Data.Loading
|
||||||
dataErrorMessage: ''
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
@@ -248,15 +232,6 @@ export default defineComponent({
|
|||||||
watch: {
|
watch: {
|
||||||
currentQueryParams(q: TimetablesQueryParams) {
|
currentQueryParams(q: TimetablesQueryParams) {
|
||||||
this.currentOptionsActive = Object.values(q).some((v) => v !== undefined);
|
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);
|
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 }) {
|
setOptions(options: { [key: string]: string }) {
|
||||||
Object.keys(this.searchersValues).forEach((v) => {
|
Object.keys(this.searchersValues).forEach((v) => {
|
||||||
this.searchersValues[v as Journal.TimetableSearchKey] = options[v] ?? '';
|
this.searchersValues[v as Journal.TimetableSearchKey] = options[v] ?? '';
|
||||||
@@ -464,26 +414,23 @@ export default defineComponent({
|
|||||||
|
|
||||||
if (!responseData) {
|
if (!responseData) {
|
||||||
this.dataStatus = Status.Data.Error;
|
this.dataStatus = Status.Data.Error;
|
||||||
this.dataErrorMessage = 'Brak danych!';
|
this.chosenPlayerId = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!responseData) return;
|
|
||||||
|
|
||||||
// Response data exists
|
// Response data exists
|
||||||
this.timetableHistory = responseData;
|
this.timetableHistory = responseData;
|
||||||
|
|
||||||
// Stats display
|
this.chosenPlayerId =
|
||||||
this.mainStore.driverStatsName =
|
this.timetableHistory.length > 0 && this.searchersValues['search-driver'].trim() != ''
|
||||||
this.timetableHistory.length > 0 && this.searchersValues['search-driver'].trim()
|
? this.timetableHistory[0].driverId
|
||||||
? this.timetableHistory[0].driverName
|
: -1;
|
||||||
: '';
|
|
||||||
|
|
||||||
this.dataStatus = Status.Data.Loaded;
|
this.dataStatus = Status.Data.Loaded;
|
||||||
this.dataRefreshedAt = new Date();
|
this.dataRefreshedAt = new Date();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.dataStatus = Status.Data.Error;
|
this.dataStatus = Status.Data.Error;
|
||||||
this.dataErrorMessage = 'Ups! Coś poszło nie tak!';
|
this.chosenPlayerId = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.scrollNoMoreData = false;
|
this.scrollNoMoreData = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user