Hochladen per Dateiauswahl, Drag & Drop und Einfügen mit Fortschritt und Abbrechen, Aufbewahrung wählbar. Datei-Karten mit Bildvorschau, Größe, Ablauf und Download; Speicheranzeige im Konto. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
80 lines
1.8 KiB
Vue
80 lines
1.8 KiB
Vue
<script setup lang="ts">
|
|
import { useUploadsStore } from '@/stores/uploads'
|
|
import { formatBytes } from '@/utils/format'
|
|
|
|
const uploads = useUploadsStore()
|
|
|
|
function percent(loaded: number, size: number): number {
|
|
return size > 0 ? Math.min(100, Math.round((loaded / size) * 100)) : 0
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<ul v-if="uploads.items.length > 0" class="uploads" aria-label="Uploads">
|
|
<li v-for="upload in uploads.items" :key="upload.id" class="upload" :class="upload.status">
|
|
<div class="line">
|
|
<span class="name">{{ upload.name }}</span>
|
|
<span class="muted small">
|
|
<template v-if="upload.status === 'uploading'">
|
|
{{ percent(upload.loaded, upload.size) }} % von {{ formatBytes(upload.size) }}
|
|
</template>
|
|
<template v-else-if="upload.status === 'waiting'">wartet</template>
|
|
</span>
|
|
<button
|
|
type="button"
|
|
class="small"
|
|
:class="{ danger: upload.status !== 'failed' }"
|
|
@click="uploads.dismiss(upload.id)"
|
|
>
|
|
{{ upload.status === 'failed' ? 'OK' : 'Abbrechen' }}
|
|
</button>
|
|
</div>
|
|
<progress
|
|
v-if="upload.status !== 'failed'"
|
|
:value="upload.loaded"
|
|
:max="upload.size"
|
|
:aria-label="`Fortschritt ${upload.name}`"
|
|
></progress>
|
|
<p v-else class="error small" role="alert">{{ upload.error }}</p>
|
|
</li>
|
|
</ul>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.uploads {
|
|
display: grid;
|
|
gap: 0.5rem;
|
|
margin: 0;
|
|
padding: 0;
|
|
list-style: none;
|
|
}
|
|
|
|
.line {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
}
|
|
|
|
.name {
|
|
flex: 1;
|
|
min-width: 0;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.small {
|
|
font-size: 0.85rem;
|
|
}
|
|
|
|
progress {
|
|
width: 100%;
|
|
height: 0.4rem;
|
|
accent-color: var(--accent);
|
|
}
|
|
|
|
.error {
|
|
margin: 0.25rem 0 0;
|
|
}
|
|
</style>
|