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.
104 lines
3.3 KiB
Vue
104 lines
3.3 KiB
Vue
<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>
|