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
+37 -1
View File
@@ -15,6 +15,24 @@ export interface Settings {
autostart: boolean
start_after_secs: number
end_after_secs: number
/** The euvino admin backend, e.g. "https://test.euvinopro.eu". */
backend_url: string
/** Whose backend key is stored; set by the app at login. */
backend_username: string | null
/** When the stored backend key expires (RFC 3339); set by the app. */
backend_key_expires_at: string | null
}
/** Login status for the settings, checked with the backend. */
export interface BackendStatus {
logged_in: boolean
username: string | null
/** RFC 3339. */
expires_at: string | null
/** `false` if the key could not be checked; username and expiry are then the stored ones. */
reachable: boolean
/** Where the admin manages their keys. */
keys_url: string
}
export type Service = 'deepscript'
@@ -67,6 +85,10 @@ export interface CallListItem {
interrupted: boolean
/** The name the user gave the call, if any. */
title: string | null
/** The CRM's id of the transcript, from its last upload. */
crm_transcript_id: string | null
/** When the transcript was last uploaded (RFC 3339). */
uploaded_at: string | null
}
/** A transcript line; `speaker_key` is "me" or "remote:<n>". */
@@ -87,7 +109,7 @@ export interface SpeakerMerge {
}
export interface CallDetail {
call: CallListItem & { error: string | null }
call: CallListItem & { error: string | null; transcribed_at: string | null }
/** The transcript with speaker merges applied. */
segments: SegmentView[]
/** Renamed speakers by key. */
@@ -144,6 +166,14 @@ export const unmergeSpeaker = (id: CallId, fromKey: string) =>
/** `null` or an empty title restores the default heading. */
export const renameCall = (id: CallId, title: string | null) =>
invoke<void>('rename_call', { id, title })
export const backendStatus = () => invoke<BackendStatus>('backend_status')
/** Resolves once the login window created a key; rejects if it was closed or failed. */
export const backendLogin = () => invoke<void>('backend_login')
export const backendLogout = () => invoke<void>('backend_logout')
/** Opens the backend's key management page in the system browser. */
export const openBackendKeysPage = () => invoke<void>('open_backend_keys_page')
/** Logs in first if needed; resolves once the CRM has the transcript. */
export const uploadTranscript = (id: CallId) => invoke<void>('upload_transcript', { id })
export const getUpdate = () => invoke<UpdateInfo | null>('get_update')
/** Resolves only on failure: on success the app restarts. */
export const installUpdate = () => invoke<void>('install_update')
@@ -158,6 +188,12 @@ export const onPromptChanged = (handler: () => void): Promise<UnlistenFn> =>
/** A call's status changed (processing started, done or failed). */
export const onCallUpdated = (handler: (id: CallId) => void): Promise<UnlistenFn> =>
listen<{ id: CallId }>('call-updated', (event) => handler(event.payload.id))
/** The backend login changed (logged in, logged out, key discarded). */
export const onBackendChanged = (handler: () => void): Promise<UnlistenFn> =>
listen<null>('backend-changed', () => handler())
/** Creating the key failed; the login window stays open for another try. */
export const onBackendLoginError = (handler: (message: string) => void): Promise<UnlistenFn> =>
listen<{ message: string }>('backend-login-error', (event) => handler(event.payload.message))
export const onUpdateAvailable = (handler: (info: UpdateInfo) => void): Promise<UnlistenFn> =>
listen<UpdateInfo>('update-available', (event) => handler(event.payload))
export const onUpdateProgress = (
+11
View File
@@ -53,3 +53,14 @@ export function formatOffset(secs: number): string {
const ss = pad(total % 60)
return h > 0 ? `${h}:${mm}:${ss}` : `${mm}:${ss}`
}
/** "06.11.2027". */
export function formatDate(iso: string): string {
const d = new Date(iso)
return `${pad(d.getDate())}.${pad(d.getMonth() + 1)}.${d.getFullYear()}`
}
/** "06.11.2026 14:05". */
export function formatDateTime(iso: string): string {
return `${formatDate(iso)} ${clock(new Date(iso))}`
}
+71 -4
View File
@@ -7,6 +7,7 @@
getRecordingState,
listCalls,
mergeSpeakers,
onBackendLoginError,
onCallEnded,
onCallUpdated,
onPromptChanged,
@@ -18,13 +19,14 @@
startManualRecording,
transcribeCall,
unmergeSpeaker,
uploadTranscript,
type CallDetail,
type CallId,
type CallListItem,
type RecordingState,
} from '../lib/api'
import CallList from '../lib/CallList.svelte'
import { formatDetailTime, formatMinutes } from '../lib/format'
import { formatDateTime, formatDetailTime, formatMinutes } from '../lib/format'
import StatusPill from '../lib/StatusPill.svelte'
import TranscriptView from '../lib/TranscriptView.svelte'
import UpdateBanner from '../lib/UpdateBanner.svelte'
@@ -43,6 +45,12 @@
let actionError = $state('')
let busy = $state(false)
// Uploads run per call and may outlive the selection (the login can
// take a while); their errors are kept per call too.
let uploading = $state<CallId[]>([])
let uploadErrors = $state<Record<CallId, string>>({})
let confirmingUpload = $state(false)
let editingTitle = $state(false)
let titleDraft = $state('')
let savingTitle = $state(false)
@@ -98,6 +106,7 @@
actionError = ''
editingTitle = false
titleError = ''
confirmingUpload = false
refreshDetail()
}
@@ -108,6 +117,7 @@
actionError = ''
editingTitle = false
titleError = ''
confirmingUpload = false
}
onMount(() => {
@@ -117,6 +127,10 @@
if (id === selectedId) refreshDetail()
}),
onCallEnded(refreshList),
// Creating the key failed; the login window stays open for another try.
onBackendLoginError((msg) => {
for (const id of uploading) uploadErrors[id] = msg
}),
onPromptChanged(refreshList),
onRecordingState((state) => {
recordingState = state
@@ -178,6 +192,31 @@
refreshList()
})
/** "Transkript hochladen"; an upload done before asks first. */
function uploadClick() {
if (!detail) return
if (detail.call.uploaded_at) confirmingUpload = true
else upload()
}
/** Uploads the shown call's transcript (logging in first if needed). */
async function upload() {
if (!detail) return
const id = detail.call.id
confirmingUpload = false
if (uploading.includes(id)) return
uploading = [...uploading, id]
delete uploadErrors[id]
try {
await uploadTranscript(id)
delete uploadErrors[id]
} catch (err) {
uploadErrors[id] = errorText(err)
} finally {
uploading = uploading.filter((u) => u !== id)
}
}
async function rename(speakerKey: string, name: string) {
if (!detail) return
await renameSpeaker(detail.call.id, speakerKey, name)
@@ -303,6 +342,11 @@
<p class="error">{titleError}</p>
{/if}
<div class="toolbar">
{#if call.status === 'done' && call.uploaded_at}
<span class="muted uploaded">
Hochgeladen am {formatDateTime(call.uploaded_at)} (ID {call.crm_transcript_id})
</span>
{/if}
<span class="actions">
{#if call.status === 'awaiting_decision'}
<button class="btn primary" disabled={busy} onclick={transcribe}>Transkribieren</button>
@@ -310,16 +354,32 @@
{:else if call.status === 'failed'}
<button class="btn primary" disabled={busy} onclick={retry}>Erneut versuchen</button>
<button class="btn danger" disabled={busy} onclick={discard}>Verwerfen</button>
{:else if call.status === 'done' && confirmingUpload}
<span class="confirm">Dieses Transkript wurde bereits hochgeladen. Nochmal hochladen?</span>
<button class="btn primary" onclick={upload}>Hochladen</button>
<button class="btn" onclick={() => (confirmingUpload = false)}>Abbrechen</button>
{:else if call.status === 'done'}
<span title="Kommt in einer späteren Version">
<button class="btn" disabled>In Kundenakte speichern</button>
</span>
<button
class="btn primary"
disabled={!call.transcribed_at || uploading.includes(call.id)}
title={call.transcribed_at ? 'Transkript ins CRM hochladen' : 'Noch kein Transkript'}
onclick={uploadClick}
>
{uploading.includes(call.id)
? 'wird hochgeladen…'
: call.uploaded_at
? 'Erneut hochladen'
: 'Transkript hochladen'}
</button>
{/if}
</span>
</div>
{#if shownActionError}
<p class="error">{shownActionError}</p>
{/if}
{#if uploadErrors[call.id]}
<p class="error">{uploadErrors[call.id]}</p>
{/if}
</header>
<div class="body">
@@ -496,10 +556,17 @@
.actions {
display: inline-flex;
align-items: center;
flex-wrap: wrap;
gap: 8px;
margin-left: auto;
}
.uploaded,
.confirm {
font-size: 12px;
}
.detail-header .error {
margin: 10px 0 0;
}
+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;