This commit is contained in:
+16
-3
@@ -4,7 +4,8 @@ import StatsBlock from '@/components/StatsBlock.vue';
|
|||||||
import { specialCars } from '@/data/specials.ts';
|
import { specialCars } from '@/data/specials.ts';
|
||||||
import { type, useTramStore } from '@/stores/tram.ts';
|
import { type, useTramStore } from '@/stores/tram.ts';
|
||||||
import { groupBy } from '@/utils/array.ts';
|
import { groupBy } from '@/utils/array.ts';
|
||||||
import { idsOf } from '@/utils/typeGroup.ts';
|
import { idsOf, missingOf } from '@/utils/typeGroup.ts';
|
||||||
|
import { ref } from 'vue';
|
||||||
import {
|
import {
|
||||||
useModal,
|
useModal,
|
||||||
useToast,
|
useToast,
|
||||||
@@ -12,6 +13,7 @@ import {
|
|||||||
VaCard,
|
VaCard,
|
||||||
VaCardContent,
|
VaCardContent,
|
||||||
VaCardTitle,
|
VaCardTitle,
|
||||||
|
VaCheckbox,
|
||||||
type VaFile,
|
type VaFile,
|
||||||
VaFileUpload
|
VaFileUpload
|
||||||
} from 'vuestic-ui';
|
} from 'vuestic-ui';
|
||||||
@@ -21,6 +23,8 @@ const { init } = useToast();
|
|||||||
const { confirm } = useModal();
|
const { confirm } = useModal();
|
||||||
const tramStore = useTramStore();
|
const tramStore = useTramStore();
|
||||||
|
|
||||||
|
const showMissing = ref(false);
|
||||||
|
|
||||||
function download() {
|
function download() {
|
||||||
const fileType = 'application/json';
|
const fileType = 'application/json';
|
||||||
const blob = new Blob([tramStore.exportData()], { type: fileType });
|
const blob = new Blob([tramStore.exportData()], { type: fileType });
|
||||||
@@ -85,7 +89,10 @@ async function reset() {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<article class="p-4">
|
<article class="p-4">
|
||||||
<h1 class="mb-4 text-3xl">Statistiken</h1>
|
<div class="mb-4 flex flex-row items-center">
|
||||||
|
<h1 class="text-3xl">Statistiken</h1>
|
||||||
|
<VaCheckbox v-model="showMissing" label="Fehlende anzeigen?" left-label class="ml-auto" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
||||||
<VaCard stripe-color="success" stripe>
|
<VaCard stripe-color="success" stripe>
|
||||||
@@ -93,7 +100,13 @@ async function reset() {
|
|||||||
<VaCardContent>
|
<VaCardContent>
|
||||||
<div class="flex flex-col justify-around gap-4">
|
<div class="flex flex-col justify-around gap-4">
|
||||||
<div v-for="(group, i) in groupBy(type, (t) => t[3])" :key="i">
|
<div v-for="(group, i) in groupBy(type, (t) => t[3])" :key="i">
|
||||||
<p>{{ idsOf(group.elements) }}:</p>
|
<p>
|
||||||
|
{{
|
||||||
|
showMissing
|
||||||
|
? missingOf(group.elements, tramStore.trams.bsag)
|
||||||
|
: idsOf(group.elements)
|
||||||
|
}}:
|
||||||
|
</p>
|
||||||
<StatsBlock
|
<StatsBlock
|
||||||
:total="group.elements.reduce((acc, t) => acc + (t[1] - t[0]) + 1, 0)"
|
:total="group.elements.reduce((acc, t) => acc + (t[1] - t[0]) + 1, 0)"
|
||||||
:found="
|
:found="
|
||||||
|
|||||||
@@ -7,3 +7,23 @@ export function idsOf(elements: CarType[]): string {
|
|||||||
|
|
||||||
return elements.map((t) => (t[0] === t[1] ? t[0] : `${t[0]}-${t[1]}`)).join(', ');
|
return elements.map((t) => (t[0] === t[1] ? t[0] : `${t[0]}-${t[1]}`)).join(', ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function missingOf(elements: CarType[], found: number[]): string {
|
||||||
|
if (elements.length <= 0) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
const cars = elements.flatMap((t) =>
|
||||||
|
t[0] === t[1] ? t[0] : new Array(t[1] - t[0] + 1).fill(t[0]).map((o, i) => Number(o + i))
|
||||||
|
);
|
||||||
|
const missingElements = cars.filter((e) => !found.includes(e));
|
||||||
|
|
||||||
|
if (missingElements.length > 8) {
|
||||||
|
return 'Es fehlen mehr als 8';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (missingElements.length <= 0) {
|
||||||
|
return 'Alle gefunden';
|
||||||
|
}
|
||||||
|
|
||||||
|
return missingElements.join(', ');
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user