mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-22 11:25:56 +00:00
MySQL options of the owner kept across starts (#103)
Settings, Service edits Settings/mysql-custom.ini. Every start adds its name = value lines (outside a section or in [mysqld]) to the rendered my.ini, after the defaults so they win; the port, addresses, data and log paths, sockets and !include stay managed. Nothing changes for a server without the file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f08ae1c76b
commit
20657df203
13 files changed
+211
-2
No files matched your search
@@ -0,0 +1,48 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { api, asUiError, type CustomMysql } from "@/lib/api";
|
||||
import { Card } from "@/components/ui/card";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useT } from "@/i18n";
|
||||
|
||||
/** The owner's own MySQL options (#103): kept in Settings/mysql-custom.ini and added to my.ini at every start. */
|
||||
export function MySqlSettings({ serverId }: { serverId: string }) {
|
||||
const t = useT();
|
||||
const [saved, setSaved] = useState<CustomMysql | null>(null);
|
||||
const [draft, setDraft] = useState("");
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [done, setDone] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
void api.mysqlCustom(serverId).then(v => { if (alive) { setSaved(v); setDraft(v.text); } }).catch(e => { if (alive) setError(asUiError(e).technical); });
|
||||
return () => { alive = false; };
|
||||
}, [serverId]);
|
||||
|
||||
async function save() {
|
||||
setBusy(true); setError(null); setDone(false);
|
||||
try { const v = await api.mysqlCustomSave(serverId, draft); setSaved(v); setDraft(v.text); setDone(true); }
|
||||
catch (e) { setError(asUiError(e).technical); }
|
||||
finally { setBusy(false); }
|
||||
}
|
||||
|
||||
const applied = saved?.applied.trim() ? saved.applied.trim().split("\n").length : 0;
|
||||
return <Card className="mt-6 p-6" aria-busy={busy}>
|
||||
<h2 className="font-semibold">{t("mysql.title")}</h2>
|
||||
<p className="mt-1 text-sm text-muted">{t("mysql.hint")}</p>
|
||||
<textarea
|
||||
className="selectable mt-3 h-36 w-full rounded border border-line bg-bg p-3 font-mono text-xs text-ink outline-none focus:border-gold"
|
||||
spellCheck={false}
|
||||
placeholder={"innodb_buffer_pool_size = 1G\nmax_connections = 300"}
|
||||
aria-label={t("mysql.title")}
|
||||
value={draft}
|
||||
disabled={busy || !saved}
|
||||
onChange={e => { setDraft(e.target.value); setDone(false); }}
|
||||
/>
|
||||
<div className="mt-3 flex flex-wrap items-center gap-3">
|
||||
<Button size="sm" disabled={busy || !saved || draft === saved.text} onClick={() => void save()}>{t("mysql.save")}</Button>
|
||||
<span className="text-xs text-muted">{t("mysql.applied", { count: applied })}{done ? ` · ${t("mysql.saved")}` : ""}</span>
|
||||
</div>
|
||||
{error && <p className="mt-3 text-sm text-bad" role="alert">{error}</p>}
|
||||
</Card>;
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import { ClientCard } from "./ClientCard";
|
||||
import { GameDataCard } from "./GameDataCard";
|
||||
import { RealmStartupSettings } from "./RealmStartupSettings";
|
||||
import { RealmNameSettings } from "./RealmNameSettings";
|
||||
import { MySqlSettings } from "./MySqlSettings";
|
||||
import { AutoRestartSettings } from "./AutoRestartSettings";
|
||||
import { DiagnosticsCard } from "./DiagnosticsCard";
|
||||
import { RepairCard } from "./RepairCard";
|
||||
@@ -53,7 +54,7 @@ export function SettingsHome({ serverId, path, onForget }: { serverId: string; s
|
||||
</div>
|
||||
<div hidden={section !== "startup"} className="max-w-3xl"><RealmNameSettings serverId={serverId} /><RealmStartupSettings serverId={serverId} /><AutoRestartSettings serverId={serverId} /></div>
|
||||
<div hidden={section !== "client"} className="max-w-3xl"><ClientCard serverId={serverId} /><GameDataCard serverId={serverId} /></div>
|
||||
<div hidden={section !== "service"} className="max-w-3xl"><ServerLoggingSettings serverId={serverId} /><DiagnosticsCard serverId={serverId} /><RepairCard serverId={serverId} /><RemoveServerCard serverId={serverId} path={path} onForget={onForget} /></div>
|
||||
<div hidden={section !== "service"} className="max-w-3xl"><ServerLoggingSettings serverId={serverId} /><MySqlSettings serverId={serverId} /><DiagnosticsCard serverId={serverId} /><RepairCard serverId={serverId} /><RemoveServerCard serverId={serverId} path={path} onForget={onForget} /></div>
|
||||
<div hidden={section !== "interface"} className="max-w-3xl"><Card className="mt-6 p-6"><h2 className="font-semibold">{t("settings.language")}</h2><p className="mt-1 text-sm text-muted">{t("settings.languageHint")}</p><LanguagePicker className="mt-4" /></Card><WindowSettings /><PublicServerSettings /></div>
|
||||
</div>;
|
||||
}
|
||||
Reference in new issue
Block a user