Summaries are not coming to the desktop app, and the customer is chosen in the web UI after the upload: - drop the Anthropic key (Service::Anthropic, Settings field) and delete a leftover keyring entry best-effort at startup - drop the Summary model, the store's summary accessors and the "Zusammenfassung" tab; the transcript is the detail's only content - drop the mocked customer accounts, list_accounts/set_account and the "Kunde" dropdown; calls.account_id and summaries stay in the schema Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
390 lines
10 KiB
Svelte
390 lines
10 KiB
Svelte
<script lang="ts">
|
||
import { onMount } from 'svelte'
|
||
import {
|
||
errorText,
|
||
getSettings,
|
||
hasApiKey,
|
||
listDevices,
|
||
meterFill,
|
||
saveSettings,
|
||
setApiKey,
|
||
testDevices,
|
||
type DeviceInfo,
|
||
type DeviceLevels,
|
||
type Devices,
|
||
type Service,
|
||
type Settings,
|
||
} from '../lib/api'
|
||
|
||
const services: { id: Service; name: string }[] = [
|
||
{ id: 'deepscript', name: 'DeepScript' },
|
||
]
|
||
|
||
let settings = $state<Settings | null>(null)
|
||
let devices = $state<Devices>({ inputs: [], outputs: [] })
|
||
let keySaved = $state<Record<Service, boolean>>({ deepscript: false })
|
||
let keyInput = $state<Record<Service, string>>({ deepscript: '' })
|
||
let newApp = $state('')
|
||
let testing = $state(false)
|
||
let testResult = $state<DeviceLevels | null>(null)
|
||
let message = $state('')
|
||
let error = $state('')
|
||
|
||
onMount(load)
|
||
|
||
async function load() {
|
||
try {
|
||
settings = await getSettings()
|
||
for (const { id } of services) keySaved[id] = await hasApiKey(id)
|
||
devices = await listDevices()
|
||
} catch (err) {
|
||
error = errorText(err)
|
||
}
|
||
}
|
||
|
||
/** The device list plus the saved device if it is currently unavailable. */
|
||
function withSaved(list: DeviceInfo[], saved: string | null): DeviceInfo[] {
|
||
if (saved === null || list.some((d) => d.id === saved)) return list
|
||
return [...list, { id: saved, name: `${saved} (nicht verfügbar)` }]
|
||
}
|
||
|
||
async function run(action: () => Promise<void>, done = '') {
|
||
message = ''
|
||
error = ''
|
||
try {
|
||
await action()
|
||
message = done
|
||
} catch (err) {
|
||
error = errorText(err)
|
||
}
|
||
}
|
||
|
||
function storeKey(service: Service, key: string) {
|
||
return run(async () => {
|
||
await setApiKey(service, key)
|
||
keySaved[service] = await hasApiKey(service)
|
||
keyInput[service] = ''
|
||
}, key ? 'Schlüssel gespeichert' : 'Schlüssel entfernt')
|
||
}
|
||
|
||
function addApp() {
|
||
const name = newApp.trim().toLowerCase()
|
||
if (settings && name && !settings.allowlist.includes(name)) {
|
||
settings.allowlist = [...settings.allowlist, name]
|
||
}
|
||
newApp = ''
|
||
}
|
||
|
||
function removeApp(name: string) {
|
||
if (settings) settings.allowlist = settings.allowlist.filter((a) => a !== name)
|
||
}
|
||
|
||
/** Inline message for a delay in whole seconds outside `min`–`max`. */
|
||
function delayError(value: number | null, min: number, max: number, label: string): string {
|
||
if (value !== null && Number.isInteger(value) && value >= min && value <= max) return ''
|
||
return `${label}: ${min}–${max} Sekunden`
|
||
}
|
||
|
||
let startError = $derived(
|
||
settings ? delayError(settings.start_after_secs, 1, 30, 'Start nach') : '',
|
||
)
|
||
let endError = $derived(settings ? delayError(settings.end_after_secs, 3, 120, 'Ende nach') : '')
|
||
|
||
async function persist() {
|
||
if (!settings) return
|
||
if (startError || endError) throw startError || endError
|
||
if (!Number.isInteger(settings.retention_days) || settings.retention_days < 1) {
|
||
throw 'Aufbewahrung: bitte eine ganze Zahl ab 1 eingeben'
|
||
}
|
||
await saveSettings($state.snapshot(settings))
|
||
}
|
||
|
||
async function runTest() {
|
||
testing = true
|
||
testResult = null
|
||
await run(async () => {
|
||
await persist()
|
||
testResult = await testDevices()
|
||
})
|
||
testing = false
|
||
}
|
||
</script>
|
||
|
||
<main class="page">
|
||
<header class="page-header">
|
||
<h1>Einstellungen</h1>
|
||
<a class="btn" href="#/">← Zurück</a>
|
||
</header>
|
||
|
||
{#if settings}
|
||
<section class="card">
|
||
<h2>API-Schlüssel</h2>
|
||
{#each services as { id, name } (id)}
|
||
<div class="key-row">
|
||
<span class="key-name">{name}</span>
|
||
{#if keySaved[id]}
|
||
<span class="pill ok">gespeichert ✓</span>
|
||
{:else}
|
||
<span class="pill missing">fehlt</span>
|
||
{/if}
|
||
<input
|
||
type="password"
|
||
placeholder={keySaved[id] ? 'Neuen Schlüssel eingeben' : 'Schlüssel eingeben'}
|
||
autocomplete="off"
|
||
bind:value={keyInput[id]}
|
||
/>
|
||
<button
|
||
class="btn small"
|
||
disabled={!keyInput[id].trim()}
|
||
onclick={() => storeKey(id, keyInput[id])}>Speichern</button
|
||
>
|
||
{#if keySaved[id]}
|
||
<button class="btn small danger" onclick={() => storeKey(id, '')}>Entfernen</button>
|
||
{/if}
|
||
</div>
|
||
{/each}
|
||
</section>
|
||
|
||
<section class="card">
|
||
<h2>Audio</h2>
|
||
<div class="grid">
|
||
<label for="mic">Mikrofon</label>
|
||
<select id="mic" bind:value={settings.mic_device}>
|
||
<option value={null}>Standardgerät</option>
|
||
{#each withSaved(devices.inputs, settings.mic_device) as d (d.id)}
|
||
<option value={d.id}>{d.name}</option>
|
||
{/each}
|
||
</select>
|
||
<label for="out">Lautsprecher</label>
|
||
<select id="out" bind:value={settings.output_device}>
|
||
<option value={null}>Standardgerät</option>
|
||
{#each withSaved(devices.outputs, settings.output_device) as d (d.id)}
|
||
<option value={d.id}>{d.name}</option>
|
||
{/each}
|
||
</select>
|
||
</div>
|
||
<p class="hint">
|
||
Bitte mit Headset telefonieren – sonst landet die Gegenseite auch auf der Mikrofonspur.
|
||
</p>
|
||
<div class="test">
|
||
<button class="btn" disabled={testing} onclick={runTest}>
|
||
{testing ? 'Test läuft …' : 'Test'}
|
||
</button>
|
||
<span class="muted">
|
||
{testing
|
||
? 'Bitte 5 Sekunden sprechen und etwas abspielen.'
|
||
: 'Nimmt 5 Sekunden auf und zeigt den Pegel beider Spuren.'}
|
||
</span>
|
||
</div>
|
||
{#if testResult}
|
||
<div class="levels">
|
||
<span>Mikrofon</span>
|
||
<div class="meter"><div style:width="{meterFill(testResult.mic) * 100}%"></div></div>
|
||
<span>Lautsprecher</span>
|
||
<div class="meter"><div style:width="{meterFill(testResult.out) * 100}%"></div></div>
|
||
</div>
|
||
{/if}
|
||
</section>
|
||
|
||
<section class="card">
|
||
<h2>Gesprächserkennung</h2>
|
||
<p class="muted">Programme, deren Mikrofonnutzung als Gespräch zählt:</p>
|
||
<ul class="allowlist">
|
||
{#each settings.allowlist as name (name)}
|
||
<li>
|
||
<span>{name}</span>
|
||
<button class="remove" title="Entfernen" onclick={() => removeApp(name)}>✕</button>
|
||
</li>
|
||
{/each}
|
||
</ul>
|
||
<form
|
||
class="add"
|
||
onsubmit={(e) => {
|
||
e.preventDefault()
|
||
addApp()
|
||
}}
|
||
>
|
||
<input placeholder="z. B. zoom.exe" bind:value={newApp} />
|
||
<button class="btn small" type="submit" disabled={!newApp.trim()}>Hinzufügen</button>
|
||
</form>
|
||
</section>
|
||
|
||
<section class="card">
|
||
<h2>Anrufe erkennen</h2>
|
||
<div class="grid">
|
||
<label for="start-after">Start nach</label>
|
||
<span>
|
||
<input
|
||
id="start-after"
|
||
type="number"
|
||
min="1"
|
||
max="30"
|
||
step="1"
|
||
aria-invalid={!!startError}
|
||
bind:value={settings.start_after_secs}
|
||
/> s
|
||
</span>
|
||
{#if startError}
|
||
<span></span><span class="error">{startError}</span>
|
||
{/if}
|
||
<label for="end-after">Ende nach</label>
|
||
<span>
|
||
<input
|
||
id="end-after"
|
||
type="number"
|
||
min="3"
|
||
max="120"
|
||
step="1"
|
||
aria-invalid={!!endError}
|
||
bind:value={settings.end_after_secs}
|
||
/> s
|
||
</span>
|
||
<span></span>
|
||
<span class="muted">Zu kurz kann ein Gespräch aufteilen, z. B. beim Headset-Wechsel.</span>
|
||
{#if endError}
|
||
<span></span><span class="error">{endError}</span>
|
||
{/if}
|
||
</div>
|
||
</section>
|
||
|
||
<section class="card">
|
||
<h2>Allgemein</h2>
|
||
<div class="grid">
|
||
<label for="language">Sprache der Gespräche</label>
|
||
<select id="language" bind:value={settings.language}>
|
||
<option value="de">Deutsch</option>
|
||
<option value="en">Englisch</option>
|
||
</select>
|
||
<label for="retention">Aufbewahrung der Audiodateien</label>
|
||
<span><input id="retention" type="number" min="1" bind:value={settings.retention_days} /> Tage</span>
|
||
<label for="autostart">Beim Anmelden starten</label>
|
||
<input id="autostart" type="checkbox" bind:checked={settings.autostart} />
|
||
</div>
|
||
</section>
|
||
|
||
<div class="footer">
|
||
<button class="btn primary" onclick={() => run(persist, 'Einstellungen gespeichert ✓')}>
|
||
Speichern
|
||
</button>
|
||
{#if message}<span class="saved">{message}</span>{/if}
|
||
{#if error}<span class="error">{error}</span>{/if}
|
||
</div>
|
||
{:else if error}
|
||
<p class="error">{error}</p>
|
||
{/if}
|
||
</main>
|
||
|
||
<style>
|
||
.key-row {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 8px;
|
||
margin-bottom: 8px;
|
||
}
|
||
|
||
.key-name {
|
||
width: 150px;
|
||
font-weight: 600;
|
||
}
|
||
|
||
.key-row input {
|
||
flex: 1;
|
||
min-width: 0;
|
||
}
|
||
|
||
.grid {
|
||
display: grid;
|
||
grid-template-columns: 220px 1fr;
|
||
align-items: center;
|
||
gap: 8px 12px;
|
||
}
|
||
|
||
.grid select {
|
||
max-width: 380px;
|
||
}
|
||
|
||
.grid input[type='number'] {
|
||
width: 70px;
|
||
}
|
||
|
||
.grid input[aria-invalid='true'] {
|
||
border-color: var(--rec);
|
||
}
|
||
|
||
.grid input[type='checkbox'] {
|
||
justify-self: start;
|
||
}
|
||
|
||
.hint {
|
||
margin: 12px 0;
|
||
padding: 8px 10px;
|
||
border-radius: 6px;
|
||
background: #fff4d6;
|
||
color: #8a6100;
|
||
font-size: 12px;
|
||
}
|
||
|
||
.test {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 10px;
|
||
}
|
||
|
||
.levels {
|
||
display: grid;
|
||
grid-template-columns: 100px 1fr;
|
||
align-items: center;
|
||
gap: 6px 10px;
|
||
margin-top: 10px;
|
||
max-width: 420px;
|
||
font-size: 12px;
|
||
}
|
||
|
||
.allowlist {
|
||
list-style: none;
|
||
margin: 8px 0;
|
||
padding: 0;
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
gap: 6px;
|
||
}
|
||
|
||
.allowlist li {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
gap: 4px;
|
||
padding: 2px 4px 2px 10px;
|
||
border-radius: 999px;
|
||
background: var(--primary-soft);
|
||
font-size: 12px;
|
||
}
|
||
|
||
.remove {
|
||
border: none;
|
||
background: none;
|
||
color: var(--muted);
|
||
cursor: pointer;
|
||
font-size: 11px;
|
||
}
|
||
|
||
.remove:hover {
|
||
color: var(--rec);
|
||
}
|
||
|
||
.add {
|
||
display: flex;
|
||
gap: 8px;
|
||
}
|
||
|
||
.footer {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 12px;
|
||
}
|
||
|
||
.saved {
|
||
color: var(--ok);
|
||
font-size: 12px;
|
||
}
|
||
</style>
|