mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-01 00:42:49 +08:00
Add Server Protokoll dialog
Adds the first StreamItem::MessageEvent handler in the connector's event loop (previously dropped by a catch-all) - needed because log lines aren't part of the bookkeeping data model, unlike client/server connection info, so they only ever arrive as a raw notifyserverlog reply rather than a book-state update. This unblocks the same pattern for Bannliste/Beschwerdeliste next. Sends "logview" via tsclientlib's typed Server::log_view() builder, requesting the last 200 lines. Verified end-to-end against the real server (though a permission-gated account got no reply at all there - the frontend dialog now falls back to a "no response" message after a timeout instead of loading forever, matching the connection-info dialogs' existing behavior). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
181b0fc43b
commit
4318ce359f
7 files changed
+157
-5
No files matched your search
@@ -1054,6 +1054,17 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.ts-server-protocol-log-dialog {
|
||||
width: 640px;
|
||||
}
|
||||
|
||||
.ts-server-protocol-log-line {
|
||||
padding: 0.15rem 0.4rem;
|
||||
border-bottom: 1px solid var(--border-soft);
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.ts-log-time {
|
||||
color: var(--text-muted);
|
||||
flex-shrink: 0;
|
||||
|
||||
+85
-1
@@ -1198,6 +1198,62 @@ function ClientLogDialog({ entries, onClose }: { entries: ClientLogEntry[]; onCl
|
||||
);
|
||||
}
|
||||
|
||||
function ServerProtocolLogDialog({
|
||||
lines,
|
||||
onClose,
|
||||
}: {
|
||||
lines: string[] | null;
|
||||
onClose: () => void;
|
||||
}) {
|
||||
const t = useT();
|
||||
const backdrop = useBackdropDismiss(onClose);
|
||||
// The server may silently decline (e.g. missing b_virtualserver_log_view
|
||||
// permission) without ever replying - fall back to an error instead of
|
||||
// spinning forever.
|
||||
const [timedOut, setTimedOut] = useState(false);
|
||||
useEffect(() => {
|
||||
setTimedOut(false);
|
||||
if (lines) return;
|
||||
const id = window.setTimeout(() => setTimedOut(true), 6000);
|
||||
return () => window.clearTimeout(id);
|
||||
}, [lines]);
|
||||
|
||||
return (
|
||||
<div className="ts-dialog-backdrop" {...backdrop}>
|
||||
<div className="ts-dialog ts-server-protocol-log-dialog" onClick={(e) => e.stopPropagation()}>
|
||||
<div className="ts-dialog-titlebar">
|
||||
<span>{t("serverProtocolLog.title")}</span>
|
||||
<button onClick={onClose} title={t("dialog.close")}>
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
<div className="ts-dialog-body">
|
||||
{!lines ? (
|
||||
<div className="ts-connection-info-loading">
|
||||
{timedOut ? t("connectionInfo.unavailable") : t("connectionInfo.loading")}
|
||||
</div>
|
||||
) : lines.length === 0 ? (
|
||||
<div className="ts-connection-info-loading">{t("serverProtocolLog.empty")}</div>
|
||||
) : (
|
||||
<div className="ts-log-list">
|
||||
{lines.map((line, i) => (
|
||||
<div key={i} className="ts-server-protocol-log-line">
|
||||
{line}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="ts-dialog-buttons">
|
||||
<div className="ts-dialog-buttons-right">
|
||||
<button onClick={onClose}>{t("dialog.close")}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function WhisperHistoryDialog({
|
||||
serverName,
|
||||
entries,
|
||||
@@ -2618,6 +2674,8 @@ function AppInner() {
|
||||
const [serverBannerUrl, setServerBannerUrl] = useState("");
|
||||
const [serverWelcomeMessage, setServerWelcomeMessage] = useState("");
|
||||
const [serverEditOpen, setServerEditOpen] = useState(false);
|
||||
const [serverProtocolLogOpen, setServerProtocolLogOpen] = useState(false);
|
||||
const [serverProtocolLog, setServerProtocolLog] = useState<string[] | null>(null);
|
||||
const [treeWidth, setTreeWidth] = useState(260);
|
||||
const [upperHeight, setUpperHeight] = useState(340);
|
||||
const [selected, setSelected] = useState<SelectedItem | null>(null);
|
||||
@@ -3179,6 +3237,9 @@ function AppInner() {
|
||||
bandwidthReceivedLastSecond: data.bandwidthReceivedLastSecond,
|
||||
});
|
||||
break;
|
||||
case "serverProtocolLog":
|
||||
setServerProtocolLog(data.lines);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3749,6 +3810,12 @@ function AppInner() {
|
||||
socketRef.current?.send(JSON.stringify({ type: "getServerConnectionInfo" }));
|
||||
};
|
||||
|
||||
const handleShowServerProtocolLog = () => {
|
||||
setServerProtocolLogOpen(true);
|
||||
setServerProtocolLog(null);
|
||||
socketRef.current?.send(JSON.stringify({ type: "getServerLog" }));
|
||||
};
|
||||
|
||||
const handleClientContextMenu = (
|
||||
e: React.MouseEvent,
|
||||
clientId: number,
|
||||
@@ -4111,7 +4178,6 @@ function AppInner() {
|
||||
{ icon: "🚫", label: t("menu.extras.banList"), shortcut: "Strg+Umschalt+B" },
|
||||
{ icon: "⚠️", label: t("menu.extras.complaintList"), shortcut: "Strg+Umschalt+C" },
|
||||
{ icon: "🔑", label: t("menu.extras.serverQueryLogin") },
|
||||
{ icon: "📄", label: t("menu.extras.serverLog"), shortcut: "Strg+Umschalt+L" },
|
||||
].map((item) => (
|
||||
<button key={item.label} className="ts-menu-item" disabled>
|
||||
<span className="ts-menu-item-icon">{item.icon}</span>
|
||||
@@ -4119,6 +4185,17 @@ function AppInner() {
|
||||
{item.shortcut && <span className="ts-menu-item-shortcut">{item.shortcut}</span>}
|
||||
</button>
|
||||
))}
|
||||
<button
|
||||
className="ts-menu-item"
|
||||
onClick={() => {
|
||||
handleShowServerProtocolLog();
|
||||
setExtrasMenuOpen(false);
|
||||
}}
|
||||
>
|
||||
<span className="ts-menu-item-icon">📄</span>
|
||||
<span className="ts-menu-item-label">{t("menu.extras.serverLog")}</span>
|
||||
<span className="ts-menu-item-shortcut">Strg+Umschalt+L</span>
|
||||
</button>
|
||||
<div className="ts-menu-separator" />
|
||||
<button
|
||||
className="ts-menu-item"
|
||||
@@ -4461,6 +4538,13 @@ function AppInner() {
|
||||
/>
|
||||
)}
|
||||
|
||||
{serverProtocolLogOpen && (
|
||||
<ServerProtocolLogDialog
|
||||
lines={serverProtocolLog}
|
||||
onClose={() => setServerProtocolLogOpen(false)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{contactsOpen && (
|
||||
<ContactsDialog
|
||||
contacts={contacts}
|
||||
|
||||
@@ -201,6 +201,20 @@ export class DemoSocket {
|
||||
);
|
||||
break;
|
||||
}
|
||||
case "getServerLog": {
|
||||
this.after(400, () =>
|
||||
this.emit({
|
||||
type: "serverProtocolLog",
|
||||
lines: [
|
||||
"2026-08-05 10:12:03.421128|INFO |VirtualServerBase|1 |connect to server successful, connection accepted",
|
||||
"2026-08-05 10:12:04.001912|INFO |VirtualServerBase|1 |client 'Guest'(id:101) connected",
|
||||
"2026-08-05 10:14:19.552031|INFO |VirtualServerBase|1 |client 'Sam'(id:103) connected",
|
||||
"2026-08-05 10:15:02.884120|INFO |VirtualServerBase|1 |client 'Jordan'(id:104) switched channel",
|
||||
],
|
||||
})
|
||||
);
|
||||
break;
|
||||
}
|
||||
// "disconnect" is intentionally unhandled here: handleDisconnect() in
|
||||
// App.tsx always calls socket.close() right after sending it, and
|
||||
// close() already emits the "disconnected" event below.
|
||||
|
||||
@@ -356,6 +356,9 @@ const translations: Record<Lang, Record<string, string>> = {
|
||||
"serverEdit.save": "Speichern",
|
||||
"serverEdit.cancel": "Abbrechen",
|
||||
|
||||
"serverProtocolLog.title": "Server Protokoll",
|
||||
"serverProtocolLog.empty": "Keine Protokolleinträge vorhanden.",
|
||||
|
||||
"clientContext.privateChat": "Privater Chat",
|
||||
"clientContext.poke": "Anstupsen",
|
||||
"clientContext.copyName": "Namen kopieren",
|
||||
@@ -749,6 +752,9 @@ const translations: Record<Lang, Record<string, string>> = {
|
||||
"serverEdit.save": "Save",
|
||||
"serverEdit.cancel": "Cancel",
|
||||
|
||||
"serverProtocolLog.title": "Server Log",
|
||||
"serverProtocolLog.empty": "No log entries.",
|
||||
|
||||
"clientContext.privateChat": "Private chat",
|
||||
"clientContext.poke": "Poke",
|
||||
"clientContext.copyName": "Copy name",
|
||||
|
||||
Reference in new issue
Block a user