Bulk-Move für Objects
Mehrfachauswahl in der Objekttabelle (Checkboxen + Alle-auswählen), neues Popup zum Verschieben in einen anderen Bucket, Move via Copy+Delete gegen die bestehende S3-Schnittstelle. sigv4 kann jetzt zusätzliche Header signieren (x-amz-copy-source), sonst nix am Backend angefasst wie gewünscht.
This commit is contained in:
@@ -3,6 +3,16 @@
|
||||
<table v-if="loading || objects.length" class="w-full border-collapse text-sm">
|
||||
<thead class="sticky top-0 bg-bg">
|
||||
<tr class="border-b border-border text-left text-xs tracking-[0.08em] text-muted">
|
||||
<th class="w-10 px-4 py-2.5 font-medium">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="size-4 cursor-pointer accent-accent"
|
||||
:checked="allSelected"
|
||||
:indeterminate="someSelected"
|
||||
@click.stop
|
||||
@change="$emit('toggle-all')"
|
||||
>
|
||||
</th>
|
||||
<th class="px-4 py-2.5 font-medium">
|
||||
<SortHeader :active="sortKey === 'key' ? sortDir : null" @click="toggleSort('key')">KEY</SortHeader>
|
||||
</th>
|
||||
@@ -17,7 +27,7 @@
|
||||
<tbody>
|
||||
<template v-if="loading">
|
||||
<tr v-for="n in 5" :key="n" class="border-b border-border/60">
|
||||
<td class="px-4 py-3" colspan="3">
|
||||
<td class="px-4 py-3" colspan="4">
|
||||
<div class="h-4 w-2/3 animate-pulse rounded bg-surface-raised" />
|
||||
</td>
|
||||
</tr>
|
||||
@@ -27,8 +37,17 @@
|
||||
v-else
|
||||
:key="object.key"
|
||||
class="cursor-pointer border-b border-border/60 transition-colors hover:bg-surface-raised/35"
|
||||
:class="{ 'bg-accent-dim/40': selectedKeys.has(object.key) }"
|
||||
@click="$emit('select', object)"
|
||||
>
|
||||
<td class="px-4 py-[5px]" @click.stop>
|
||||
<input
|
||||
type="checkbox"
|
||||
class="size-4 cursor-pointer accent-accent"
|
||||
:checked="selectedKeys.has(object.key)"
|
||||
@change="$emit('toggle', object.key)"
|
||||
>
|
||||
</td>
|
||||
<td class="px-4 py-[5px]">
|
||||
<div class="flex items-center gap-2.5">
|
||||
<FileTypeBadge :filename="object.key" />
|
||||
@@ -96,8 +115,18 @@ const props = defineProps<{
|
||||
hasSearch: boolean
|
||||
searchTerm: string
|
||||
error?: string | null
|
||||
selectedKeys: Set<string>
|
||||
}>()
|
||||
defineEmits<{ select: [object: S3Object]; upload: []; retry: [] }>()
|
||||
defineEmits<{
|
||||
select: [object: S3Object]
|
||||
upload: []
|
||||
retry: []
|
||||
toggle: [key: string]
|
||||
'toggle-all': []
|
||||
}>()
|
||||
|
||||
const allSelected = computed(() => props.objects.length > 0 && props.objects.every((object) => props.selectedKeys.has(object.key)))
|
||||
const someSelected = computed(() => !allSelected.value && props.objects.some((object) => props.selectedKeys.has(object.key)))
|
||||
|
||||
type SortKey = 'key' | 'size' | 'lastModified'
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
<template>
|
||||
<div class="space-y-5">
|
||||
<div>
|
||||
<FieldLabel>Objekte</FieldLabel>
|
||||
<p class="mt-1 text-sm text-text">
|
||||
{{ payload.keys.length }} Objekt{{ payload.keys.length === 1 ? '' : 'e' }} aus
|
||||
<span class="font-mono">{{ payload.sourceBucket }}</span>
|
||||
</p>
|
||||
<ul class="mt-2 max-h-32 space-y-1 overflow-y-auto rounded-md border border-border bg-bg px-3 py-2">
|
||||
<li v-for="key in payload.keys" :key="key" class="truncate font-mono text-xs text-muted">
|
||||
{{ key }}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<FieldLabel>Zielbucket</FieldLabel>
|
||||
<select
|
||||
v-model="targetBucket"
|
||||
class="mt-1 w-full rounded-md border border-border bg-bg px-3 py-2 text-sm text-text focus:outline-none"
|
||||
>
|
||||
<option value="" disabled>Bucket auswählen…</option>
|
||||
<option v-for="bucket in destinationBuckets" :key="bucket.name" :value="bucket.name">
|
||||
{{ bucket.name }}
|
||||
</option>
|
||||
</select>
|
||||
<p v-if="!destinationBuckets.length" class="mt-1.5 text-xs text-muted">
|
||||
Kein anderer Bucket verfügbar.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<p v-if="error" class="text-sm text-red-500">{{ error }}</p>
|
||||
|
||||
<div class="flex justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-md border border-border px-3 py-2 text-sm font-medium text-text transition-colors hover:bg-surface-raised"
|
||||
@click="usePopup().close()"
|
||||
>
|
||||
Abbrechen
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="flex items-center gap-2 rounded-md bg-accent px-4 py-2 text-sm font-medium text-white transition-opacity hover:opacity-90 disabled:cursor-wait disabled:opacity-70"
|
||||
:disabled="loading || !targetBucket"
|
||||
@click="confirm"
|
||||
>
|
||||
<span class="material-symbols-outlined !text-[18px]" :class="{ 'animate-spin': loading }">
|
||||
{{ loading ? 'progress_activity' : 'drive_file_move' }}
|
||||
</span>
|
||||
Verschieben
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import type { S3Bucket } from '~/utils/s3xml'
|
||||
|
||||
export interface MoveObjectsPayload {
|
||||
sourceBucket: string
|
||||
keys: string[]
|
||||
buckets: S3Bucket[]
|
||||
}
|
||||
|
||||
const payload = usePopup().require<MoveObjectsPayload>().payload!
|
||||
const { moveObjects } = useS3Client()
|
||||
|
||||
const targetBucket = ref('')
|
||||
const loading = ref(false)
|
||||
const error = ref<string | null>(null)
|
||||
|
||||
const destinationBuckets = computed(() => payload.buckets.filter((bucket) => bucket.name !== payload.sourceBucket))
|
||||
|
||||
async function confirm() {
|
||||
if (!targetBucket.value) {
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const failures = await moveObjects(payload.sourceBucket, payload.keys, targetBucket.value)
|
||||
if (failures.length) {
|
||||
error.value = failures.length === payload.keys.length
|
||||
? 'Das hat nicht geklappt. Versuch es nochmal.'
|
||||
: `${failures.length} von ${payload.keys.length} Objekten konnten nicht verschoben werden.`
|
||||
if (failures.length < payload.keys.length) {
|
||||
usePopup().callback(payload.keys.filter((key) => !failures.some((failure) => failure.key === key)))
|
||||
}
|
||||
return
|
||||
}
|
||||
usePopup().callback(payload.keys)
|
||||
usePopup().close()
|
||||
}
|
||||
catch {
|
||||
error.value = 'Das hat nicht geklappt. Versuch es nochmal.'
|
||||
}
|
||||
finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user