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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user