Author SHA1 Message Date
Stefan Krüger 8d2e60126e docs: Doc.md mit Projektüberblick ergänzen
Setup, Struktur, Kommandos und SigV4-Kram kurz dokumentiert, damit
nicht jeder wieder von vorne den Code durchwühlen muss.
2026-09-11 23:08:10 +02:00
5 changed files with 127 additions and 47 deletions
+115
View File
@@ -0,0 +1,115 @@
# r9t Frontend
Web-UI für unseren S3-kompatiblen Object Storage (r9t). Rein clientseitiges Nuxt/Vue-Frontend, das Buckets und Objekte auflistet, Objekte anzeigt/hochlädt/löscht und dafür Requests direkt per AWS SigV4 signiert.
## Tech-Stack
- [Nuxt 4](https://nuxt.com/) (Vue 3, TypeScript)
- [Tailwind CSS 4](https://tailwindcss.com/) (via `@tailwindcss/vite`)
- Kein State-Management-Framework, kein Backend-Code hier — nur UI + ein schlanker S3-Client
## Setup
Voraussetzung: Node.js (siehe `Dockerfile`, dort läuft `node:22.9.0-alpine`).
```bash
npm install
```
`.env` aus der Vorlage anlegen:
```bash
cp .env.example .env
```
Relevante Variablen (siehe `nuxt.config.ts` → `runtimeConfig.public`):
| Variable | Zweck | Default (Beispiel) |
|-------------------------------|---------------------------------------------|---------------------|
| `NUXT_PUBLIC_S3_ACCESS_KEY` | Access Key für SigV4-Signierung der Requests | `devkey` |
| `NUXT_PUBLIC_S3_SECRET_KEY` | Secret Key für SigV4-Signierung | `devsecret` |
Wichtig: Diese Keys landen im Public Runtime Config, sind also im Client-Bundle sichtbar. Für den Dev-Betrieb gegen einen lokalen/Test-Storage okay, für produktive Zugangsdaten nicht geeignet — das müsste über einen Backend-Proxy laufen, der Requests serverseitig signiert.
## Entwicklung
```bash
npm run dev
```
Läuft auf `http://localhost:3000`. Requests an `/api/*` werden per Vite-Dev-Proxy (siehe `nuxt.config.ts`) an `http://localhost:8080` weitergeleitet und dort landet der eigentliche S3-Server. Heißt: Für lokale Entwicklung muss der Storage-Server separat auf Port 8080 laufen.
## Build & Produktion
```bash
npm run build # Produktions-Build (.output/)
npm run preview # lokal den Produktions-Build testen
npm run generate # statischer Export, falls mal gebraucht
```
### Docker
```bash
docker build --build-arg VERSION=<version> -t r9t-frontend .
docker run -p 3000:3000 r9t-frontend
```
Das Dockerfile baut mit `npx nuxi build` und startet den Nitro-Server via `node .output/server/index.mjs`.
### CI/CD
`Jenkinsfile` baut das Image, pusht es nach `harbor.dinauer.dev/r9t/frontend:<BUILD_NUMBER>` und räumt danach den lokalen Build-Agent wieder auf. Kein automatischer Deploy-Schritt enthalten — Image landet nur in der Registry.
## Projektstruktur
```
app/
├── app.vue # Root-Komponente, App-Layout, State-Orchestrierung
├── assets/css/main.css # Tailwind-Einstieg
├── components/
│ ├── BucketList.vue # Sidebar mit Bucket-Auswahl
│ ├── ObjectTable.vue # Objektliste im gewählten Bucket
│ ├── ObjectDetail.vue # Detail-/Aktions-Panel für ein Objekt
│ ├── PathBreadcrumb.vue
│ ├── SortHeader.vue
│ ├── ChunkBar.vue
│ ├── CopyField.vue
│ ├── FieldLabel.vue
│ ├── FileTypeBadge.vue
│ ├── AppToast.vue # Toast-Benachrichtigungen
│ └── popup/
│ ├── PopupSlot.vue # Rendert die aktuell offene Popup-Instanz
│ ├── ConfirmPopup.vue
│ ├── UploadPopup.vue
│ └── TextPreviewPopup.vue
├── composables/
│ ├── useS3Client.ts # High-Level S3-Operationen (list/get/put/delete)
│ └── usePopup.ts # Globaler Popup-Store
└── utils/
├── sigv4.ts # AWS SigV4 Request-Signierung (browserseitig, WebCrypto)
├── s3xml.ts # Parsen der S3 List-XML-Responses
├── popup.ts # Popup-Klasse/Config-Typen
└── format.ts # Formatierungs-Helper (Größen, Daten, o.ä.)
```
Sonstige relevante Dateien:
- `nuxt.config.ts` — Runtime-Config, Tailwind-Plugin, Dev-Proxy nach `/api`
- `Dockerfile` — Produktions-Image
- `Jenkinsfile` — Build-Pipeline (Image bauen + nach Harbor pushen)
- `.env.example` — Vorlage für lokale Env-Variablen
## Funktionsweise (Kurzfassung)
1. `app.vue` lädt beim Mount die Bucket-Liste (`useS3Client().listBuckets()`).
2. Bei Bucket-Auswahl werden die Objekte geladen (`listObjects`), gefiltert per Suchfeld (Client-seitig, kein Server-Filter).
3. Jeder Request wird vorher in `sigv4.ts` per AWS4-HMAC-SHA256 signiert (Access/Secret Key aus der Runtime-Config) und läuft über den `/api`-Proxy zum eigentlichen S3-Server.
4. Objekt-Aktionen (Download, Upload, Löschen, Text-Vorschau) laufen über Popups (`usePopup`/`PopupSlot`), die dynamisch eine Vue-Komponente rendern.
5. Bucket-Erstellung ist aktuell nur gemockt (`mockAction` in `app.vue`) — das UI unterstützt bislang keinen echten Bucket-Create/Delete.
## Bekannte Einschränkungen
- Keine Authentifizierung im UI selbst — Access/Secret Key liegen statisch in der Config.
- Kein serverseitiger Proxy für die Signierung, SigV4 läuft komplett im Browser.
- Bucket-Erstellung ist nicht implementiert, nur ein Platzhalter-Toast.
- Kein automatisierter Test-Runner im Repo vorhanden (kein `test`-Script in `package.json`).
+4 -30
View File
@@ -7,20 +7,9 @@
<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">
<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 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>
</header>
@@ -92,7 +81,6 @@
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' })
@@ -100,7 +88,7 @@ useHead({ title: 'r9t · Object Storage' })
const config = useRuntimeConfig()
const accessKey = config.public.s3AccessKey
const { listBuckets, listObjects, downloadAuditLogs } = useS3Client()
const { listBuckets, listObjects } = useS3Client()
const buckets = ref<S3Bucket[]>([])
const objects = ref<S3Object[]>([])
@@ -111,7 +99,6 @@ 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) {
@@ -154,19 +141,6 @@ 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 {
+7 -2
View File
@@ -84,7 +84,6 @@
<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'
@@ -131,7 +130,13 @@ async function download() {
}
downloading.value = true
try {
saveBlob(await downloadObject(props.bucket, props.object.key), baseName(props.object.key))
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)
}
catch {
emit('error', `${baseName(props.object.key)} konnte nicht heruntergeladen werden.`)
+1 -7
View File
@@ -23,12 +23,6 @@ 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}`)
}
@@ -49,5 +43,5 @@ export function useS3Client() {
await $fetch(`/api${encodeCanonicalPath(path)}`, { method: 'DELETE', headers })
}
return { listBuckets, listObjects, downloadObject, downloadAuditLogs, getObjectText, uploadObject, deleteObject }
return { listBuckets, listObjects, downloadObject, getObjectText, uploadObject, deleteObject }
}
-8
View File
@@ -1,8 +0,0 @@
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)
}