mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-01 00:42:49 +08:00
Add "Virtuellen Server editieren" dialog
Wires up tsclientlib's typed Server::edit() builder (name, welcome message, password, host message/banner/button settings, nickname, phonetic name, codec encryption mode) through a new "serveredit" stdin command. Frontend dialog has Host and Verschiedenes tabs fully implemented, with Übertragung/Anti-Flood/Sicherheit/Protokoll shown as not-yet-implemented placeholders (their fields have no typed setter in tsclientlib's generated bindings, would need hand-built raw commands). Entry point is a new link in the server info panel, next to the connection-info one added earlier. Every field is optional in the payload - blank means "leave unchanged" - except the password field, which has an explicit "remove password" checkbox for the clear case. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
330ecccadb
commit
181b0fc43b
7 files changed
+493
-3
No files matched your search
+258
@@ -492,6 +492,7 @@ function InfoPanel({
|
||||
channels,
|
||||
clients,
|
||||
onShowServerConnectionInfo,
|
||||
onEditServer,
|
||||
}: {
|
||||
selected: SelectedItem | null;
|
||||
host: string;
|
||||
@@ -503,6 +504,7 @@ function InfoPanel({
|
||||
channels: ChannelInfo[];
|
||||
clients: ClientInfo[];
|
||||
onShowServerConnectionInfo: () => void;
|
||||
onEditServer: () => void;
|
||||
}) {
|
||||
const t = useT();
|
||||
if (!selected || selected.type === "server") {
|
||||
@@ -534,6 +536,9 @@ function InfoPanel({
|
||||
<button className="ts-info-connection-link" onClick={onShowServerConnectionInfo}>
|
||||
🔌 {t("connectionInfo.serverTitle")}
|
||||
</button>
|
||||
<button className="ts-info-connection-link" onClick={onEditServer}>
|
||||
✏️ {t("serverEdit.title")}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -2354,6 +2359,242 @@ function OptionsDialog({
|
||||
);
|
||||
}
|
||||
|
||||
const SERVER_EDIT_TABS = ["host", "misc", "transmission", "antiflood", "security", "log"] as const;
|
||||
|
||||
interface ServerEditPayload {
|
||||
name?: string;
|
||||
welcomeMessage?: string;
|
||||
password?: string;
|
||||
maxClients?: number;
|
||||
hostmessage?: string;
|
||||
hostmessageMode?: string;
|
||||
hostbannerUrl?: string;
|
||||
hostbannerGfxUrl?: string;
|
||||
hostbannerGfxIntervalSecs?: number;
|
||||
hostbannerMode?: string;
|
||||
hostbuttonTooltip?: string;
|
||||
hostbuttonUrl?: string;
|
||||
hostbuttonGfxUrl?: string;
|
||||
nickname?: string;
|
||||
phoneticName?: string;
|
||||
codecEncryptionMode?: string;
|
||||
}
|
||||
|
||||
function ServerEditDialog({
|
||||
serverName,
|
||||
welcomeMessage,
|
||||
hostbannerGfxUrl,
|
||||
onSave,
|
||||
onClose,
|
||||
}: {
|
||||
serverName: string;
|
||||
welcomeMessage: string;
|
||||
hostbannerGfxUrl: string;
|
||||
onSave: (payload: ServerEditPayload) => void;
|
||||
onClose: () => void;
|
||||
}) {
|
||||
const t = useT();
|
||||
const backdrop = useBackdropDismiss(onClose);
|
||||
const [tab, setTab] = useState<(typeof SERVER_EDIT_TABS)[number]>("host");
|
||||
|
||||
const [name, setName] = useState(serverName);
|
||||
const [welcome, setWelcome] = useState(welcomeMessage);
|
||||
const [clearPassword, setClearPassword] = useState(false);
|
||||
const [password, setPassword] = useState("");
|
||||
const [hostmessage, setHostmessage] = useState("");
|
||||
const [hostmessageMode, setHostmessageMode] = useState("");
|
||||
const [hostbannerUrl, setHostbannerUrl] = useState("");
|
||||
const [bannerGfxUrl, setBannerGfxUrl] = useState(hostbannerGfxUrl);
|
||||
const [hostbannerGfxInterval, setHostbannerGfxInterval] = useState("");
|
||||
const [hostbannerMode, setHostbannerMode] = useState("");
|
||||
const [hostbuttonTooltip, setHostbuttonTooltip] = useState("");
|
||||
const [hostbuttonUrl, setHostbuttonUrl] = useState("");
|
||||
const [hostbuttonGfxUrl, setHostbuttonGfxUrl] = useState("");
|
||||
const [maxClients, setMaxClients] = useState("");
|
||||
const [nickname, setNickname] = useState("");
|
||||
const [phoneticName, setPhoneticName] = useState("");
|
||||
const [codecEncryptionMode, setCodecEncryptionMode] = useState("");
|
||||
|
||||
const handleSave = () => {
|
||||
const payload: ServerEditPayload = {};
|
||||
if (name.trim() && name !== serverName) payload.name = name.trim();
|
||||
if (welcome !== welcomeMessage) payload.welcomeMessage = welcome;
|
||||
if (clearPassword) payload.password = "";
|
||||
else if (password) payload.password = password;
|
||||
if (hostmessage) payload.hostmessage = hostmessage;
|
||||
if (hostmessageMode) payload.hostmessageMode = hostmessageMode;
|
||||
if (hostbannerUrl) payload.hostbannerUrl = hostbannerUrl;
|
||||
if (bannerGfxUrl !== hostbannerGfxUrl) payload.hostbannerGfxUrl = bannerGfxUrl;
|
||||
if (hostbannerGfxInterval) payload.hostbannerGfxIntervalSecs = Number(hostbannerGfxInterval) || 0;
|
||||
if (hostbannerMode) payload.hostbannerMode = hostbannerMode;
|
||||
if (hostbuttonTooltip) payload.hostbuttonTooltip = hostbuttonTooltip;
|
||||
if (hostbuttonUrl) payload.hostbuttonUrl = hostbuttonUrl;
|
||||
if (hostbuttonGfxUrl) payload.hostbuttonGfxUrl = hostbuttonGfxUrl;
|
||||
if (maxClients) payload.maxClients = Number(maxClients) || 0;
|
||||
if (nickname) payload.nickname = nickname;
|
||||
if (phoneticName) payload.phoneticName = phoneticName;
|
||||
if (codecEncryptionMode) payload.codecEncryptionMode = codecEncryptionMode;
|
||||
onSave(payload);
|
||||
onClose();
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="ts-dialog-backdrop" {...backdrop}>
|
||||
<div className="ts-dialog ts-options-dialog" onClick={(e) => e.stopPropagation()}>
|
||||
<div className="ts-dialog-titlebar">
|
||||
<span>{t("serverEdit.title")}</span>
|
||||
<button onClick={onClose} title={t("dialog.close")}>
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
<div className="ts-options-body">
|
||||
<div className="ts-options-sidebar">
|
||||
{SERVER_EDIT_TABS.map((id) => (
|
||||
<button
|
||||
key={id}
|
||||
className={`ts-options-sidebar-item${id === tab ? " ts-options-sidebar-item-active" : ""}`}
|
||||
onClick={() => setTab(id)}
|
||||
>
|
||||
<span>{t(`serverEdit.tab.${id}`)}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<div className="ts-options-content">
|
||||
{tab === "host" && (
|
||||
<>
|
||||
<label className="ts-dialog-field">
|
||||
{t("serverEdit.name")}
|
||||
<input value={name} onChange={(e) => setName(e.target.value)} />
|
||||
</label>
|
||||
<label className="ts-dialog-field">
|
||||
{t("serverEdit.welcomeMessage")}
|
||||
<textarea rows={3} value={welcome} onChange={(e) => setWelcome(e.target.value)} />
|
||||
</label>
|
||||
<label className="ts-dialog-field">
|
||||
<span>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={clearPassword}
|
||||
onChange={(e) => setClearPassword(e.target.checked)}
|
||||
/>{" "}
|
||||
{t("serverEdit.clearPassword")}
|
||||
</span>
|
||||
</label>
|
||||
<label className="ts-dialog-field">
|
||||
{t("serverEdit.newPassword")}
|
||||
<input
|
||||
type="password"
|
||||
disabled={clearPassword}
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<label className="ts-dialog-field">
|
||||
{t("serverEdit.hostmessage")}
|
||||
<input value={hostmessage} onChange={(e) => setHostmessage(e.target.value)} />
|
||||
</label>
|
||||
<label className="ts-dialog-field">
|
||||
{t("serverEdit.hostmessageMode")}
|
||||
<select value={hostmessageMode} onChange={(e) => setHostmessageMode(e.target.value)}>
|
||||
<option value="">{t("serverEdit.unchanged")}</option>
|
||||
<option value="none">{t("serverEdit.hostmessageMode.none")}</option>
|
||||
<option value="log">{t("serverEdit.hostmessageMode.log")}</option>
|
||||
<option value="modal">{t("serverEdit.hostmessageMode.modal")}</option>
|
||||
<option value="modalquit">{t("serverEdit.hostmessageMode.modalquit")}</option>
|
||||
</select>
|
||||
</label>
|
||||
<label className="ts-dialog-field">
|
||||
{t("serverEdit.hostbannerUrl")}
|
||||
<input value={hostbannerUrl} onChange={(e) => setHostbannerUrl(e.target.value)} />
|
||||
</label>
|
||||
<label className="ts-dialog-field">
|
||||
{t("serverEdit.hostbannerGfxUrl")}
|
||||
<input value={bannerGfxUrl} onChange={(e) => setBannerGfxUrl(e.target.value)} />
|
||||
</label>
|
||||
<label className="ts-dialog-field">
|
||||
{t("serverEdit.hostbannerGfxInterval")}
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
value={hostbannerGfxInterval}
|
||||
onChange={(e) => setHostbannerGfxInterval(e.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<label className="ts-dialog-field">
|
||||
{t("serverEdit.hostbannerMode")}
|
||||
<select value={hostbannerMode} onChange={(e) => setHostbannerMode(e.target.value)}>
|
||||
<option value="">{t("serverEdit.unchanged")}</option>
|
||||
<option value="noadjust">{t("serverEdit.hostbannerMode.noadjust")}</option>
|
||||
<option value="adjustignoreaspect">{t("serverEdit.hostbannerMode.adjustignoreaspect")}</option>
|
||||
<option value="adjustkeepaspect">{t("serverEdit.hostbannerMode.adjustkeepaspect")}</option>
|
||||
</select>
|
||||
</label>
|
||||
<label className="ts-dialog-field">
|
||||
{t("serverEdit.hostbuttonTooltip")}
|
||||
<input value={hostbuttonTooltip} onChange={(e) => setHostbuttonTooltip(e.target.value)} />
|
||||
</label>
|
||||
<label className="ts-dialog-field">
|
||||
{t("serverEdit.hostbuttonUrl")}
|
||||
<input value={hostbuttonUrl} onChange={(e) => setHostbuttonUrl(e.target.value)} />
|
||||
</label>
|
||||
<label className="ts-dialog-field">
|
||||
{t("serverEdit.hostbuttonGfxUrl")}
|
||||
<input value={hostbuttonGfxUrl} onChange={(e) => setHostbuttonGfxUrl(e.target.value)} />
|
||||
</label>
|
||||
</>
|
||||
)}
|
||||
{tab === "misc" && (
|
||||
<>
|
||||
<label className="ts-dialog-field">
|
||||
{t("serverEdit.maxClients")}
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
value={maxClients}
|
||||
onChange={(e) => setMaxClients(e.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<label className="ts-dialog-field">
|
||||
{t("serverEdit.nickname")}
|
||||
<input value={nickname} onChange={(e) => setNickname(e.target.value)} />
|
||||
</label>
|
||||
<label className="ts-dialog-field">
|
||||
{t("serverEdit.phoneticName")}
|
||||
<input value={phoneticName} onChange={(e) => setPhoneticName(e.target.value)} />
|
||||
</label>
|
||||
<label className="ts-dialog-field">
|
||||
{t("serverEdit.codecEncryptionMode")}
|
||||
<select
|
||||
value={codecEncryptionMode}
|
||||
onChange={(e) => setCodecEncryptionMode(e.target.value)}
|
||||
>
|
||||
<option value="">{t("serverEdit.unchanged")}</option>
|
||||
<option value="perchannel">{t("serverEdit.codecEncryptionMode.perchannel")}</option>
|
||||
<option value="forcedoff">{t("serverEdit.codecEncryptionMode.forcedoff")}</option>
|
||||
<option value="forcedon">{t("serverEdit.codecEncryptionMode.forcedon")}</option>
|
||||
</select>
|
||||
</label>
|
||||
</>
|
||||
)}
|
||||
{(tab === "transmission" || tab === "antiflood" || tab === "security" || tab === "log") && (
|
||||
<>
|
||||
<h3>{t(`serverEdit.tab.${tab}`)}</h3>
|
||||
<p className="ts-options-placeholder">{t("options.notImplemented")}</p>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="ts-dialog-buttons">
|
||||
<div className="ts-dialog-buttons-right">
|
||||
<button onClick={handleSave}>{t("serverEdit.save")}</button>
|
||||
<button onClick={onClose}>{t("serverEdit.cancel")}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function AppInner() {
|
||||
const [host, setHost] = useState(() => localStorage.getItem(LAST_HOST_KEY) ?? (DEMO_MODE ? DEMO_HOST : "localhost"));
|
||||
const [nickname, setNickname] = useState(
|
||||
@@ -2375,6 +2616,8 @@ function AppInner() {
|
||||
const [serverVersion, setServerVersion] = useState("");
|
||||
const [serverLicense, setServerLicense] = useState("");
|
||||
const [serverBannerUrl, setServerBannerUrl] = useState("");
|
||||
const [serverWelcomeMessage, setServerWelcomeMessage] = useState("");
|
||||
const [serverEditOpen, setServerEditOpen] = useState(false);
|
||||
const [treeWidth, setTreeWidth] = useState(260);
|
||||
const [upperHeight, setUpperHeight] = useState(340);
|
||||
const [selected, setSelected] = useState<SelectedItem | null>(null);
|
||||
@@ -2768,6 +3011,7 @@ function AppInner() {
|
||||
setServerVersion(data.serverVersion);
|
||||
setServerLicense(data.serverLicense);
|
||||
setServerBannerUrl(data.serverBannerUrl);
|
||||
setServerWelcomeMessage(data.welcomeMessage);
|
||||
setSelected({ type: "server" });
|
||||
setServerChat((prev) => [...prev, { from: "Server", message: data.welcomeMessage }]);
|
||||
previousClientsRef.current = null;
|
||||
@@ -4204,6 +4448,19 @@ function AppInner() {
|
||||
/>
|
||||
)}
|
||||
|
||||
{serverEditOpen && (
|
||||
<ServerEditDialog
|
||||
serverName={serverName}
|
||||
welcomeMessage={serverWelcomeMessage}
|
||||
hostbannerGfxUrl={serverBannerUrl}
|
||||
onSave={(payload) => {
|
||||
socketRef.current?.send(JSON.stringify({ type: "editServer", payload }));
|
||||
logClient("info", "Moderation", "Edited server settings");
|
||||
}}
|
||||
onClose={() => setServerEditOpen(false)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{contactsOpen && (
|
||||
<ContactsDialog
|
||||
contacts={contacts}
|
||||
@@ -4561,6 +4818,7 @@ function AppInner() {
|
||||
channels={channels}
|
||||
clients={clients}
|
||||
onShowServerConnectionInfo={handleShowServerConnectionInfo}
|
||||
onEditServer={() => setServerEditOpen(true)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -318,6 +318,44 @@ const translations: Record<Lang, Record<string, string>> = {
|
||||
"ban.confirm": "Bannen",
|
||||
"ban.cancel": "Abbrechen",
|
||||
|
||||
"serverEdit.title": "Virtuellen Server editieren",
|
||||
"serverEdit.tab.host": "Host",
|
||||
"serverEdit.tab.misc": "Verschiedenes",
|
||||
"serverEdit.tab.transmission": "Übertragung",
|
||||
"serverEdit.tab.antiflood": "Anti-Flood",
|
||||
"serverEdit.tab.security": "Sicherheit",
|
||||
"serverEdit.tab.log": "Protokoll",
|
||||
"serverEdit.name": "Servername:",
|
||||
"serverEdit.welcomeMessage": "Willkommensnachricht:",
|
||||
"serverEdit.clearPassword": "Serverpasswort entfernen",
|
||||
"serverEdit.newPassword": "Neues Serverpasswort:",
|
||||
"serverEdit.hostmessage": "Hostnachricht:",
|
||||
"serverEdit.hostmessageMode": "Anzeigemodus:",
|
||||
"serverEdit.hostmessageMode.none": "Nicht anzeigen",
|
||||
"serverEdit.hostmessageMode.log": "Im Protokoll anzeigen",
|
||||
"serverEdit.hostmessageMode.modal": "Als Dialog anzeigen",
|
||||
"serverEdit.hostmessageMode.modalquit": "Als Dialog anzeigen und trennen",
|
||||
"serverEdit.hostbannerUrl": "Host-Banner URL:",
|
||||
"serverEdit.hostbannerGfxUrl": "Host-Banner Bild-URL:",
|
||||
"serverEdit.hostbannerGfxInterval": "Banner-Aktualisierung (Sekunden):",
|
||||
"serverEdit.hostbannerMode": "Banner-Anpassung:",
|
||||
"serverEdit.hostbannerMode.noadjust": "Nicht anpassen",
|
||||
"serverEdit.hostbannerMode.adjustignoreaspect": "Anpassen (Seitenverhältnis ignorieren)",
|
||||
"serverEdit.hostbannerMode.adjustkeepaspect": "Anpassen (Seitenverhältnis beibehalten)",
|
||||
"serverEdit.hostbuttonTooltip": "Host-Button Tooltip:",
|
||||
"serverEdit.hostbuttonUrl": "Host-Button URL:",
|
||||
"serverEdit.hostbuttonGfxUrl": "Host-Button Bild-URL:",
|
||||
"serverEdit.maxClients": "Maximale Clientanzahl:",
|
||||
"serverEdit.nickname": "Server-Nickname:",
|
||||
"serverEdit.phoneticName": "Phonetischer Name:",
|
||||
"serverEdit.codecEncryptionMode": "Sprachverschlüsselung:",
|
||||
"serverEdit.codecEncryptionMode.perchannel": "Pro Channel konfigurierbar",
|
||||
"serverEdit.codecEncryptionMode.forcedoff": "Global deaktiviert",
|
||||
"serverEdit.codecEncryptionMode.forcedon": "Global aktiviert",
|
||||
"serverEdit.unchanged": "Unverändert lassen",
|
||||
"serverEdit.save": "Speichern",
|
||||
"serverEdit.cancel": "Abbrechen",
|
||||
|
||||
"clientContext.privateChat": "Privater Chat",
|
||||
"clientContext.poke": "Anstupsen",
|
||||
"clientContext.copyName": "Namen kopieren",
|
||||
@@ -673,6 +711,44 @@ const translations: Record<Lang, Record<string, string>> = {
|
||||
"ban.confirm": "Ban",
|
||||
"ban.cancel": "Cancel",
|
||||
|
||||
"serverEdit.title": "Edit Virtual Server",
|
||||
"serverEdit.tab.host": "Host",
|
||||
"serverEdit.tab.misc": "Misc",
|
||||
"serverEdit.tab.transmission": "Transmission",
|
||||
"serverEdit.tab.antiflood": "Anti-Flood",
|
||||
"serverEdit.tab.security": "Security",
|
||||
"serverEdit.tab.log": "Log",
|
||||
"serverEdit.name": "Server name:",
|
||||
"serverEdit.welcomeMessage": "Welcome message:",
|
||||
"serverEdit.clearPassword": "Remove server password",
|
||||
"serverEdit.newPassword": "New server password:",
|
||||
"serverEdit.hostmessage": "Host message:",
|
||||
"serverEdit.hostmessageMode": "Display mode:",
|
||||
"serverEdit.hostmessageMode.none": "Don't display",
|
||||
"serverEdit.hostmessageMode.log": "Display in log",
|
||||
"serverEdit.hostmessageMode.modal": "Display as dialog",
|
||||
"serverEdit.hostmessageMode.modalquit": "Display as dialog and disconnect",
|
||||
"serverEdit.hostbannerUrl": "Host banner URL:",
|
||||
"serverEdit.hostbannerGfxUrl": "Host banner image URL:",
|
||||
"serverEdit.hostbannerGfxInterval": "Banner refresh (seconds):",
|
||||
"serverEdit.hostbannerMode": "Banner scaling:",
|
||||
"serverEdit.hostbannerMode.noadjust": "Don't adjust",
|
||||
"serverEdit.hostbannerMode.adjustignoreaspect": "Adjust (ignore aspect ratio)",
|
||||
"serverEdit.hostbannerMode.adjustkeepaspect": "Adjust (keep aspect ratio)",
|
||||
"serverEdit.hostbuttonTooltip": "Host button tooltip:",
|
||||
"serverEdit.hostbuttonUrl": "Host button URL:",
|
||||
"serverEdit.hostbuttonGfxUrl": "Host button image URL:",
|
||||
"serverEdit.maxClients": "Max clients:",
|
||||
"serverEdit.nickname": "Server nickname:",
|
||||
"serverEdit.phoneticName": "Phonetic name:",
|
||||
"serverEdit.codecEncryptionMode": "Voice encryption:",
|
||||
"serverEdit.codecEncryptionMode.perchannel": "Configurable per channel",
|
||||
"serverEdit.codecEncryptionMode.forcedoff": "Globally disabled",
|
||||
"serverEdit.codecEncryptionMode.forcedon": "Globally enabled",
|
||||
"serverEdit.unchanged": "Leave unchanged",
|
||||
"serverEdit.save": "Save",
|
||||
"serverEdit.cancel": "Cancel",
|
||||
|
||||
"clientContext.privateChat": "Private chat",
|
||||
"clientContext.poke": "Poke",
|
||||
"clientContext.copyName": "Copy name",
|
||||
|
||||
Reference in new issue
Block a user