feat(manager): notification bell, sign-in/venue/print settings, log download (platform-v2 2.6f)

- Bell in the header: /api/platform/notifications with unread count, live via
  the new LiveProvider (one createLiveClient connection) on platform_notification
  and reconnect; mark read / all; warning+critical pop a toast.
- Settings: Sign-in card (manager/waiter/device modes, require username, one
  session per manager/waiter, username autofill) replaces the dead v1
  security.login_method card; new "Venue & language" tab (language, time zone);
  print alert threshold in Printing. Tab labels are i18n keys.
- Technical > Log files: list + download of the daily logs (owner-level).
  Backend: GET /api/system/logs, /api/system/logs/{date} (core.settings.manage),
  error system.log_not_found.
- Setup wizard asks staff language and time zone (setup/init stores them).
- @xenia/ui theme helpers (applyTheme, getStoredTheme); the manager stays light
  until phase 6 converts the older pages (owner decision 2026-11-14).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-14 09:01:26 +02:00
co-authored by Claude Opus 5.5
parent 92bc1b0113
commit 2426ffddad
36 changed files with 995 additions and 92 deletions
@@ -2,6 +2,9 @@ import { useState } from 'react'
import { TabBar } from '../../ui/Tabs'
import PrinterHistory from './operations/PrinterHistory'
import PrinterHealthLog from './operations/PrinterHealthLog'
import LogsPanel from './operations/LogsPanel'
import { useCan } from '@xenia/access'
import { useTranslation } from '@xenia/i18n'
const TABS = [
{ id: 'printer-history', label: 'Ιστορικό Εκτυπωτή', Component: PrinterHistory },
@@ -9,13 +12,16 @@ const TABS = [
]
export default function TechnicalPage() {
const { t } = useTranslation('manager')
const canLogs = useCan('core.settings.manage') // the files carry names and IPs: owner-level
const tabs = canLogs ? [...TABS, { id: 'logs', label: t('logs.tab'), Component: LogsPanel }] : TABS
const [active, setActive] = useState('printer-history')
const tab = TABS.find(t => t.id === active) || TABS[0]
const tab = tabs.find(x => x.id === active) || tabs[0]
const { Component } = tab
return (
<div className="flex flex-col h-full min-h-0">
<TabBar tabs={TABS} active={active} onChange={setActive} />
<TabBar tabs={tabs} active={active} onChange={setActive} />
<div className="flex-1 min-h-0 flex flex-col">
<Component key={active} />
</div>
@@ -0,0 +1,76 @@
// Log download (plan step 2.6f, APPS_PLATFORM §10): the backend's daily log files
// (UTC days, kept 30 days) to send to support. GET /api/system/logs → [{date, name, size}],
// GET /api/system/logs/{date} → the file (core.settings.manage). Fetched through the API
// client (it carries the session), then saved with a temporary link.
import { useCallback, useEffect, useState } from 'react'
import { Download, FileText } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import { useTranslation, useFormat } from '@xenia/i18n'
import { Button, EmptyState, Spinner } from '@xenia/ui'
import client from '../../../api/client'
export default function LogsPanel() {
const { t } = useTranslation('manager')
const f = useFormat()
const [rows, setRows] = useState(null)
const [error, setError] = useState(null)
const [busy, setBusy] = useState(null)
const load = useCallback(async () => {
try {
setRows((await client.get('/api/system/logs')).data)
setError(null)
} catch (err) {
setError(errorMessage(err, t))
}
}, [t])
useEffect(() => { load() }, [load])
async function download(row) {
setBusy(row.date)
try {
const r = await client.get(`/api/system/logs/${row.date}`, { responseType: 'blob' })
const url = URL.createObjectURL(r.data)
const a = document.createElement('a')
a.href = url
a.download = row.name
document.body.appendChild(a)
a.click()
a.remove()
setTimeout(() => URL.revokeObjectURL(url), 10_000)
} catch (err) {
setError(errorMessage(err, t))
} finally {
setBusy(null)
}
}
if (error && !rows) return <div className="p-8"><EmptyState title={error} action={<Button variant="secondary" onClick={load}>{t('common:actions.retry')}</Button>} /></div>
if (!rows) return <div className="p-8 flex justify-center"><Spinner /></div>
return (
<div className="p-6 max-w-3xl grid gap-4 overflow-y-auto">
<p className="text-body text-ink-2">{t('logs.intro')}</p>
{error && <p className="text-label text-danger-ink" role="alert">{error}</p>}
{rows.length === 0
? <EmptyState icon={<FileText />} title={t('logs.empty')} />
: (
<div className="bg-surface border border-line rounded-card shadow-raised divide-y divide-line" data-testid="logs-list">
{rows.map(row => (
<div key={row.date} className="flex items-center gap-4 px-4 py-3" data-testid={`log-${row.date}`}>
<div className="flex-1 min-w-0">
<div className="text-body font-medium text-ink">
{f.formatDate(row.date, 'dateLong')}{row.date === new Date().toISOString().slice(0, 10) && <span className="ml-2 text-caption text-ink-3">{t('logs.current')}</span>}
</div>
<div className="text-caption text-ink-3">{row.name} · {t('logs.size', { size: f.formatNumber(Math.max(1, Math.round(row.size / 1024))) })}</div>
</div>
<Button size="sm" variant="secondary" icon={<Download size={14} />} loading={busy === row.date} onClick={() => download(row)}>
{t('logs.download')}
</Button>
</div>
))}
</div>
)}
</div>
)
}