mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-04 22:08:12 +00:00
Przystosowanie pod update API
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
<template #count>
|
<template #count>
|
||||||
<b class="text--primary">
|
<b class="text--primary">
|
||||||
{{ data.stats.totalTimetables }}
|
{{ data.stats.totalTimetables }}
|
||||||
{{ $t('journal.timetable-count', data.stats.dispatcherTimetablesCount) }}
|
{{ $t('journal.timetable-count', data.stats.totalTimetables) }}
|
||||||
</b>
|
</b>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -38,19 +38,44 @@
|
|||||||
</template>
|
</template>
|
||||||
</i18n-t>
|
</i18n-t>
|
||||||
|
|
||||||
<i18n-t keypath="journal.timetable-stats-most-active" tag="p">
|
<p v-if="firstPlaceDispatchers.length == 1">
|
||||||
<template #dispatcher>
|
<i18n-t keypath="journal.timetable-stats-most-active">
|
||||||
<router-link :to="`/journal/dispatchers?dispatcherName=${data.stats.dispatcherName}`">
|
<template #dispatcher>
|
||||||
<b>{{ data.stats.dispatcherName }}</b>
|
<router-link :to="`/journal/dispatchers?dispatcherName=${firstPlaceDispatchers[0].name}`">
|
||||||
</router-link>
|
<b>{{ firstPlaceDispatchers[0].name }}</b>
|
||||||
</template>
|
</router-link>
|
||||||
<template #count>
|
</template>
|
||||||
<b class="text--primary">
|
<template #count>
|
||||||
{{ data.stats.dispatcherTimetablesCount }}
|
<b class="text--primary">
|
||||||
{{ $t('journal.timetable-count', data.stats.dispatcherTimetablesCount) }}
|
{{ firstPlaceDispatchers[0].count }}
|
||||||
</b>
|
{{ $t('journal.timetable-count', firstPlaceDispatchers[0].count) }}
|
||||||
</template>
|
</b>
|
||||||
</i18n-t>
|
</template>
|
||||||
|
</i18n-t>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p v-if="firstPlaceDispatchers.length > 1">
|
||||||
|
<i18n-t keypath="journal.timetable-stats-most-active-many">
|
||||||
|
<template #dispatchers>
|
||||||
|
<span v-for="(disp, i) in firstPlaceDispatchers">
|
||||||
|
<span v-if="i == firstPlaceDispatchers.length - 1"> {{ $t('general.and') }} </span>
|
||||||
|
|
||||||
|
<router-link :to="`/journal/dispatchers?dispatcherName=${disp.name}`">
|
||||||
|
<b>{{ disp.name }}</b>
|
||||||
|
</router-link>
|
||||||
|
|
||||||
|
<span v-if="i < firstPlaceDispatchers.length - 2">, </span>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #count>
|
||||||
|
<b class="text--primary">
|
||||||
|
{{ firstPlaceDispatchers[0].count }}
|
||||||
|
{{ $t('journal.timetable-count', firstPlaceDispatchers[0].count) }}
|
||||||
|
</b>
|
||||||
|
</template>
|
||||||
|
</i18n-t>
|
||||||
|
</p>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</section>
|
</section>
|
||||||
@@ -58,7 +83,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { reactive, ref } from 'vue';
|
import { computed, reactive, ref } from 'vue';
|
||||||
import { DataStatus } from '../../scripts/enums/DataStatus';
|
import { DataStatus } from '../../scripts/enums/DataStatus';
|
||||||
import { ITimetablesDailyStats, ITimetablesDailyStatsResponse } from '../../scripts/interfaces/api/StatsAPIData';
|
import { ITimetablesDailyStats, ITimetablesDailyStatsResponse } from '../../scripts/interfaces/api/StatsAPIData';
|
||||||
import { URLs } from '../../scripts/utils/apiURLs';
|
import { URLs } from '../../scripts/utils/apiURLs';
|
||||||
@@ -76,11 +101,18 @@ const data = reactive({
|
|||||||
timetableDriver: '',
|
timetableDriver: '',
|
||||||
timetableId: 0,
|
timetableId: 0,
|
||||||
timetableRouteDistance: 0,
|
timetableRouteDistance: 0,
|
||||||
dispatcherName: '',
|
|
||||||
dispatcherTimetablesCount: 0,
|
mostActiveDispatchers: [],
|
||||||
} as ITimetablesDailyStats,
|
} as ITimetablesDailyStats,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const firstPlaceDispatchers = computed(() => {
|
||||||
|
if (data.stats.mostActiveDispatchers.length == 0) return [];
|
||||||
|
const maxCount = data.stats.mostActiveDispatchers[0].count;
|
||||||
|
|
||||||
|
return data.stats.mostActiveDispatchers.filter((disp) => disp.count === maxCount);
|
||||||
|
});
|
||||||
|
|
||||||
async function fetchDailyTimetableStats() {
|
async function fetchDailyTimetableStats() {
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
@@ -88,7 +120,7 @@ async function fetchDailyTimetableStats() {
|
|||||||
distanceSum,
|
distanceSum,
|
||||||
maxTimetable,
|
maxTimetable,
|
||||||
totalTimetables,
|
totalTimetables,
|
||||||
mostActiveDispatcher,
|
mostActiveDispatchers,
|
||||||
}: ITimetablesDailyStatsResponse = await (
|
}: ITimetablesDailyStatsResponse = await (
|
||||||
await axios.get(`${URLs.stacjownikAPI}/api/getDailyTimetableStats`)
|
await axios.get(`${URLs.stacjownikAPI}/api/getDailyTimetableStats`)
|
||||||
).data;
|
).data;
|
||||||
@@ -101,8 +133,8 @@ async function fetchDailyTimetableStats() {
|
|||||||
timetableDriver: maxTimetable?.driverName || '',
|
timetableDriver: maxTimetable?.driverName || '',
|
||||||
timetableId: maxTimetable?.timetableId || 0,
|
timetableId: maxTimetable?.timetableId || 0,
|
||||||
timetableRouteDistance: maxTimetable?.routeDistance || 0,
|
timetableRouteDistance: maxTimetable?.routeDistance || 0,
|
||||||
dispatcherName: mostActiveDispatcher?.name || '',
|
|
||||||
dispatcherTimetablesCount: mostActiveDispatcher?.count || 0,
|
mostActiveDispatchers,
|
||||||
};
|
};
|
||||||
|
|
||||||
data.statsStatus = DataStatus.Loaded;
|
data.statsStatus = DataStatus.Loaded;
|
||||||
|
|||||||
+5
-1
@@ -1,4 +1,7 @@
|
|||||||
{
|
{
|
||||||
|
"general": {
|
||||||
|
"and": " and "
|
||||||
|
},
|
||||||
"app": {
|
"app": {
|
||||||
"sceneries": "SCENERIES",
|
"sceneries": "SCENERIES",
|
||||||
"trains": "TRAINS",
|
"trains": "TRAINS",
|
||||||
@@ -266,7 +269,8 @@
|
|||||||
|
|
||||||
"timetable-stats-total": "Today, dispatchers made so far {count} with total distance of {distance}",
|
"timetable-stats-total": "Today, dispatchers made so far {count} with total distance of {distance}",
|
||||||
"timetable-stats-longest": "The longest timetable today is #{id} made by {author} for {driver} - {distance}",
|
"timetable-stats-longest": "The longest timetable today is #{id} made by {author} for {driver} - {distance}",
|
||||||
"timetable-stats-most-active": "The most active dispatcher is {dispatcher} who created {count}",
|
"timetable-stats-most-active": "The most active dispatcher today is {dispatcher} who created {count}",
|
||||||
|
"timetable-stats-most-active-many": "The most active dispatchers today are {dispatchers} who created {count} each",
|
||||||
|
|
||||||
"timetable-count": "timetable | timetables",
|
"timetable-count": "timetable | timetables",
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
{
|
{
|
||||||
|
"general": {
|
||||||
|
"and": " oraz "
|
||||||
|
},
|
||||||
"app": {
|
"app": {
|
||||||
"sceneries": "SCENERIE",
|
"sceneries": "SCENERIE",
|
||||||
"trains": "POCIĄGI",
|
"trains": "POCIĄGI",
|
||||||
@@ -271,6 +274,7 @@
|
|||||||
"timetable-stats-total": "Dyżurni stworzyli dziś {count} o łącznym dystansie {distance}",
|
"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-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-stats-most-active": "Dzisiejszym najaktywniejszym dyżurnym jest {dispatcher}, który stworzył {count}",
|
||||||
|
"timetable-stats-most-active-many": "Dzisiejszymi najaktywniejszymi dyżurnymi są {dispatchers}, którzy stworzyli po {count}",
|
||||||
|
|
||||||
"timetable-count": "rozkład jazdy | rozkładów jazdy",
|
"timetable-count": "rozkład jazdy | rozkładów jazdy",
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ export interface ITimetablesDailyStats {
|
|||||||
timetableDriver: string;
|
timetableDriver: string;
|
||||||
timetableRouteDistance: number;
|
timetableRouteDistance: number;
|
||||||
|
|
||||||
dispatcherName: string;
|
mostActiveDispatchers: {
|
||||||
dispatcherTimetablesCount: number;
|
name: string;
|
||||||
|
count: number;
|
||||||
|
}[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ITimetablesDailyStatsResponse {
|
export interface ITimetablesDailyStatsResponse {
|
||||||
@@ -19,8 +21,10 @@ export interface ITimetablesDailyStatsResponse {
|
|||||||
distanceSum: number;
|
distanceSum: number;
|
||||||
distanceAvg: number;
|
distanceAvg: number;
|
||||||
maxTimetable: TimetableHistory | null;
|
maxTimetable: TimetableHistory | null;
|
||||||
mostActiveDispatcher: {
|
|
||||||
|
mostActiveDispatchers: {
|
||||||
name: string;
|
name: string;
|
||||||
count: number;
|
count: number;
|
||||||
} | null;
|
}[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user