feat #14740: link to the euvino admin backend

- Settings section "Backend": backend URL, login status checked live
  (logged in as / until, not logged in, backend unreachable), Anmelden /
  Neu anmelden, Abmelden and the link to the key management page
- login window "backend-login": the backend's own login page in an
  incognito webview without any Tauri capability; after a page load
  behind the login, its cookies create a key (one request, never stored
  or logged), the key goes to the keyring, the window closes; closing it
  cancels; one login at a time, later requests wait for the same result
- call detail: "Transkript hochladen" / "Erneut hochladen" (with a
  confirmation), "wird hochgeladen…", "Hochgeladen am … (ID …)" and
  inline errors; logs in first when there is no usable key
- saving a different backend URL discards the key of the old backend

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
hauke
2026-11-06 14:54:38 +01:00
co-authored by Claude Opus 5.5
parent 58e96a2954
commit f045424e97
10 changed files with 990 additions and 29 deletions
+133 -1
View File
@@ -1,14 +1,22 @@
<script lang="ts">
import { onMount } from 'svelte'
import { formatDate } from '../lib/format'
import {
backendLogin,
backendLogout,
backendStatus,
errorText,
getSettings,
hasApiKey,
listDevices,
meterFill,
onBackendChanged,
onBackendLoginError,
openBackendKeysPage,
saveSettings,
setApiKey,
testDevices,
type BackendStatus,
type DeviceInfo,
type DeviceLevels,
type Devices,
@@ -30,7 +38,70 @@
let message = $state('')
let error = $state('')
onMount(load)
let backend = $state<BackendStatus | null>(null)
let backendBusy = $state(false)
let backendError = $state('')
// Status answers can arrive out of order; only the newest is applied.
let statusRequest = 0
onMount(() => {
load()
refreshBackend()
const unlisten = [
onBackendChanged(refreshBackend),
onBackendLoginError((msg) => (backendError = msg)),
]
return () => unlisten.forEach((u) => u.then((off) => off()))
})
/** Checks the stored key with the backend. */
async function refreshBackend() {
const request = ++statusRequest
try {
const status = await backendStatus()
if (request === statusRequest) backend = status
} catch (err) {
if (request === statusRequest) backendError = errorText(err)
}
}
/** Saves the settings (the login goes to the saved backend URL), then logs in. */
async function login() {
backendBusy = true
backendError = ''
try {
await persist()
await backendLogin()
} catch (err) {
backendError = errorText(err)
} finally {
backendBusy = false
refreshBackend()
}
}
async function logout() {
backendBusy = true
backendError = ''
try {
await backendLogout()
} catch (err) {
backendError = errorText(err)
} finally {
backendBusy = false
refreshBackend()
}
}
async function openKeysPage(event: Event) {
event.preventDefault()
try {
await openBackendKeysPage()
} catch (err) {
backendError = errorText(err)
}
}
async function load() {
try {
@@ -145,6 +216,51 @@
{/each}
</section>
<section class="card">
<h2>Backend</h2>
<div class="grid">
<label for="backend-url">Backend-URL</label>
<input
id="backend-url"
type="url"
placeholder="https://test.euvinopro.eu"
bind:value={settings.backend_url}
/>
<span>Status</span>
<span class="backend-status">
{#if backend === null}
<span class="muted">wird geprüft …</span>
{:else if backend.logged_in}
{backend.username ? `Angemeldet als ${backend.username}` : 'Angemeldet'}{backend.expires_at
? `, gültig bis ${formatDate(backend.expires_at)}`
: ''}
{#if !backend.reachable}
<span class="muted">(Backend nicht erreichbar)</span>
{/if}
{:else}
Nicht angemeldet
{/if}
</span>
</div>
<div class="backend-actions">
<button class="btn small" disabled={backendBusy} onclick={login}>
{backendBusy ? 'Anmeldung läuft …' : backend?.logged_in ? 'Neu anmelden' : 'Anmelden'}
</button>
{#if backend?.logged_in}
<button class="btn small danger" disabled={backendBusy} onclick={logout}>Abmelden</button>
{/if}
</div>
{#if backendError}
<p class="error">{backendError}</p>
{/if}
{#if backend}
<p class="muted keys-hint">
Schlüssel auf dem Server verwalten:
<a href={backend.keys_url} onclick={openKeysPage}>{backend.keys_url}</a>
</p>
{/if}
</section>
<section class="card">
<h2>Audio</h2>
<div class="grid">
@@ -376,6 +492,22 @@
gap: 8px;
}
.grid input[type='url'] {
max-width: 380px;
}
.backend-actions {
display: flex;
gap: 8px;
margin-top: 12px;
}
.keys-hint {
margin: 10px 0 0;
font-size: 12px;
overflow-wrap: anywhere;
}
.footer {
display: flex;
align-items: center;