✨ Add audit log CSV download

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-03 19:12:27 +02:00
co-authored by Claude Opus 5.5
parent 02e5b1f4e4
commit 2bbda8d24e
4 changed files with 47 additions and 12 deletions
+30 -4
View File
@@ -7,9 +7,20 @@
<span class="material-symbols-outlined text-accent">storage</span>
<span class="text-sm font-semibold tracking-[0.04em]">r9t</span>
</div>
<div class="flex items-center gap-2 rounded-full border border-border bg-surface-raised px-3 py-1 text-xs text-muted">
<span class="material-symbols-outlined !text-[15px]">vpn_key</span>
<span class="font-mono">{{ accessKey }}</span>
<div class="flex items-center gap-2">
<button
type="button"
class="flex items-center gap-1.5 rounded-md border border-border bg-surface-raised px-3 py-1.5 text-xs text-muted transition-colors hover:text-text disabled:opacity-60"
:disabled="downloadingAuditLogs"
@click="downloadAuditLogCsv"
>
<span class="material-symbols-outlined !text-[16px]" :class="{ 'animate-spin': downloadingAuditLogs }">{{ downloadingAuditLogs ? 'progress_activity' : 'download' }}</span>
Audit Logs (CSV)
</button>
<div class="flex items-center gap-2 rounded-full border border-border bg-surface-raised px-3 py-1 text-xs text-muted">
<span class="material-symbols-outlined !text-[15px]">vpn_key</span>
<span class="font-mono">{{ accessKey }}</span>
</div>
</div>
</header>
@@ -81,6 +92,7 @@
import { ref, computed, watch, onMounted } from 'vue'
import { Popup, PopupSize } from '~/utils/popup'
import UploadPopup from '~/components/popup/UploadPopup.vue'
import { saveBlob } from '~/utils/download'
import type { S3Bucket, S3Object } from '~/utils/s3xml'
useHead({ title: 'r9t · Object Storage' })
@@ -88,7 +100,7 @@ useHead({ title: 'r9t · Object Storage' })
const config = useRuntimeConfig()
const accessKey = config.public.s3AccessKey
const { listBuckets, listObjects } = useS3Client()
const { listBuckets, listObjects, downloadAuditLogs } = useS3Client()
const buckets = ref<S3Bucket[]>([])
const objects = ref<S3Object[]>([])
@@ -99,6 +111,7 @@ const loadingObjects = ref(false)
const errorMessage = ref<string | null>(null)
const objectsError = ref<string | null>(null)
const toastMessage = ref<string | null>(null)
const downloadingAuditLogs = ref(false)
const filteredObjects = computed(() => {
if (!search.value) {
@@ -141,6 +154,19 @@ function openUploadPopup() {
)
}
async function downloadAuditLogCsv() {
downloadingAuditLogs.value = true
try {
saveBlob(await downloadAuditLogs(), 'audit-logs.csv')
}
catch {
notify('Audit Logs konnten nicht heruntergeladen werden.')
}
finally {
downloadingAuditLogs.value = false
}
}
async function loadBuckets() {
errorMessage.value = null
try {
+2 -7
View File
@@ -84,6 +84,7 @@
<script setup lang="ts">
import { ref, computed } from 'vue'
import { partCount, formatBytes, formatDateTime, baseName } from '~/utils/format'
import { saveBlob } from '~/utils/download'
import { Popup, PopupSize } from '~/utils/popup'
import TextPreviewPopup from '~/components/popup/TextPreviewPopup.vue'
import ConfirmPopup, { type ConfirmPayload } from '~/components/popup/ConfirmPopup.vue'
@@ -130,13 +131,7 @@ async function download() {
}
downloading.value = true
try {
const blob = await downloadObject(props.bucket, props.object.key)
const url = URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = baseName(props.object.key)
link.click()
URL.revokeObjectURL(url)
saveBlob(await downloadObject(props.bucket, props.object.key), baseName(props.object.key))
}
catch {
emit('error', `${baseName(props.object.key)} konnte nicht heruntergeladen werden.`)
+7 -1
View File
@@ -23,6 +23,12 @@ export function useS3Client() {
return $fetch<Blob>(`/api${encodeCanonicalPath(path)}`, { headers, responseType: 'blob' })
}
async function downloadAuditLogs(): Promise<Blob> {
const path = '/_audit-logs/csv'
const headers = await signS3Get(path, config.public.s3AccessKey, config.public.s3SecretKey)
return $fetch<Blob>(`/api${path}`, { headers, responseType: 'blob' })
}
async function getObjectText(bucket: string, key: string): Promise<string> {
return get(`/${bucket}/${key}`)
}
@@ -43,5 +49,5 @@ export function useS3Client() {
await $fetch(`/api${encodeCanonicalPath(path)}`, { method: 'DELETE', headers })
}
return { listBuckets, listObjects, downloadObject, getObjectText, uploadObject, deleteObject }
return { listBuckets, listObjects, downloadObject, downloadAuditLogs, getObjectText, uploadObject, deleteObject }
}
+8
View File
@@ -0,0 +1,8 @@
export function saveBlob(blob: Blob, fileName: string) {
const url = URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = fileName
link.click()
URL.revokeObjectURL(url)
}