mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-19 19:25:56 +00:00
Settings: full searchable list of every documented world-server setting (575), edited in place with a snapshot before each save
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8f2b585641
commit
9444434734
13 files changed
+557
No files matched your search
@@ -54,6 +54,8 @@ export {};
|
||||
if(cmd==="realmlist_save"){const w=window as any;const rl=w.__rl;if(args.profileId){const p=rl.profiles.find((x: any)=>x.id===args.profileId);p.name=args.name;p.data=args.data;return p;}if(rl.profiles.some((x: any)=>x.name.toLowerCase()===String(args.name).toLowerCase()))throw {human:{code:"unknown",title:"",message:"",actions:[]},technical:"A realmlist with that name already exists."};const p={id:String(args.name).toLowerCase().replace(/[^a-z0-9]+/g,"-"),name:args.name,data:(/\s/.test(args.data.trim())?args.data.trim():"set realmlist "+args.data.trim())+"\r\n"};rl.profiles.push(p);return p;}
|
||||
if(cmd==="realmlist_delete"){const rl=(window as any).__rl;rl.profiles=rl.profiles.filter((x: any)=>x.id!==args.profileId);return null;}
|
||||
if(cmd==="modules_list") return [];
|
||||
if(cmd==="all_settings") return [{key:"Rate.Drop.Item.Epic",value:"3",default:"1",doc:"Description: Drop rates for money and items based on quality. Default: 1",changed:true},{key:"Instance.ResetTimeHour",value:"4",default:"4",doc:"Description: Hour of the day when the global instance reset occurs. Range: 0-23 Default: 4 - (04:00 AM)",changed:false},{key:"PlayerLimit",value:"1000",default:"1000",doc:"Description: Maximum number of players in the world.",changed:false}];
|
||||
if(cmd==="all_settings_save") return Object.keys(args&&args.changes||{});
|
||||
if(cmd==="module_set_enabled"){const m=(window as any).__mods.find((x: any)=>x.id===args.module);m.enabled=args.enabled;return null;}
|
||||
if(cmd==="module_settings") return [{key:"WarGames.Enable",value:"1",default:"1",doc:"Turns War Games on."},{key:"WarGames.ChallengeSeconds",value:"60",default:"60",doc:"How long a challenge stays open."}];
|
||||
if(cmd==="module_save_settings") return Object.keys(args.changes);
|
||||
|
||||
@@ -724,6 +724,17 @@ const de: Partial<Record<keyof typeof en, string>> = {
|
||||
|
||||
// Modules page: nothing yet
|
||||
"mod.empty": "Hier ist noch nichts. Optionale Module erscheinen auf dieser Seite, sobald sie hinzugefügt werden.",
|
||||
// Settings page: the full searchable list
|
||||
"all.title": "Alle Servereinstellungen",
|
||||
"all.intro": "Jede dokumentierte Einstellung des Weltservers mit Erklärung. Ändere nur, was du verstehst: Ein falscher Wert kann den Server beschädigen. Die bisherige Konfiguration wird vorher gesichert und kann wiederhergestellt werden.",
|
||||
"all.search": "Nach Name oder Beschreibung suchen…",
|
||||
"all.onlyChanged": "Nur geänderte",
|
||||
"all.count": "{shown} von {total} werden angezeigt. Suche, um die Liste einzugrenzen.",
|
||||
"all.none": "Keine Einstellungen gefunden.",
|
||||
"all.changed": "geändert",
|
||||
"all.useDefault": "Standardwert verwenden ({v})",
|
||||
"all.save": "{n} Änderung(en) speichern",
|
||||
"all.saved": "Gespeichert. Starte den Server neu, um die Änderungen zu übernehmen.",
|
||||
};
|
||||
|
||||
export default de;
|
||||
@@ -724,6 +724,17 @@ const en = {
|
||||
|
||||
// Modules page: nothing yet
|
||||
"mod.empty": "There is nothing here yet. Optional modules will appear on this page as they are added.",
|
||||
// Settings page: the full searchable list
|
||||
"all.title": "All server settings",
|
||||
"all.intro": "Every documented setting of the world server, with its explanation. Change only what you understand: a wrong value can break the server. The previous configuration is saved first and can be restored.",
|
||||
"all.search": "Search by name or description…",
|
||||
"all.onlyChanged": "Only changed",
|
||||
"all.count": "Showing {shown} of {total}. Search to narrow it down.",
|
||||
"all.none": "No settings match.",
|
||||
"all.changed": "changed",
|
||||
"all.useDefault": "Use the default ({v})",
|
||||
"all.save": "Save {n} change(s)",
|
||||
"all.saved": "Saved. Restart the server to apply the changes.",
|
||||
} as const;
|
||||
|
||||
export default en;
|
||||
@@ -724,6 +724,17 @@ const es: Partial<Record<keyof typeof en, string>> = {
|
||||
|
||||
// Modules page: nothing yet
|
||||
"mod.empty": "Aquí todavía no hay nada. Los módulos opcionales aparecerán en esta página a medida que se añadan.",
|
||||
// Settings page: the full searchable list
|
||||
"all.title": "Todos los ajustes del servidor",
|
||||
"all.intro": "Cada ajuste documentado del servidor del mundo, con su explicación. Cambia solo lo que entiendas: un valor incorrecto puede romper el servidor. La configuración anterior se guarda antes y se puede restaurar.",
|
||||
"all.search": "Buscar por nombre o descripción…",
|
||||
"all.onlyChanged": "Solo los cambiados",
|
||||
"all.count": "Mostrando {shown} de {total}. Usa la búsqueda para acotar.",
|
||||
"all.none": "Ningún ajuste coincide.",
|
||||
"all.changed": "cambiado",
|
||||
"all.useDefault": "Usar el valor predeterminado ({v})",
|
||||
"all.save": "Guardar {n} cambio(s)",
|
||||
"all.saved": "Guardado. Reinicia el servidor para aplicar los cambios.",
|
||||
};
|
||||
|
||||
export default es;
|
||||
@@ -724,6 +724,17 @@ const fr: Partial<Record<keyof typeof en, string>> = {
|
||||
|
||||
// Modules page: nothing yet
|
||||
"mod.empty": "Il n’y a encore rien ici. Les modules optionnels apparaîtront sur cette page au fur et à mesure de leur ajout.",
|
||||
// Settings page: the full searchable list
|
||||
"all.title": "Tous les réglages du serveur",
|
||||
"all.intro": "Chaque réglage documenté du serveur de monde, avec son explication. Ne modifiez que ce que vous comprenez : une mauvaise valeur peut casser le serveur. La configuration précédente est sauvegardée d'abord et peut être restaurée.",
|
||||
"all.search": "Rechercher par nom ou description…",
|
||||
"all.onlyChanged": "Seulement les modifiés",
|
||||
"all.count": "{shown} sur {total} affichés. Utilisez la recherche pour affiner.",
|
||||
"all.none": "Aucun réglage ne correspond.",
|
||||
"all.changed": "modifié",
|
||||
"all.useDefault": "Utiliser la valeur par défaut ({v})",
|
||||
"all.save": "Enregistrer {n} modification(s)",
|
||||
"all.saved": "Enregistré. Redémarrez le serveur pour appliquer les changements.",
|
||||
};
|
||||
|
||||
export default fr;
|
||||
@@ -724,6 +724,17 @@ const ru: Partial<Record<keyof typeof en, string>> = {
|
||||
|
||||
// Modules page: nothing yet
|
||||
"mod.empty": "Здесь пока пусто. Дополнительные модули появятся на этой странице по мере добавления.",
|
||||
// Settings page: the full searchable list
|
||||
"all.title": "Все настройки сервера",
|
||||
"all.intro": "Все документированные настройки мирового сервера с пояснениями. Меняйте только то, что понимаете: неверное значение может сломать сервер. Прежняя конфигурация сохраняется заранее, её можно восстановить.",
|
||||
"all.search": "Поиск по названию или описанию…",
|
||||
"all.onlyChanged": "Только изменённые",
|
||||
"all.count": "Показано {shown} из {total}. Используйте поиск, чтобы сузить список.",
|
||||
"all.none": "Ничего не найдено.",
|
||||
"all.changed": "изменено",
|
||||
"all.useDefault": "Вернуть значение по умолчанию ({v})",
|
||||
"all.save": "Сохранить изменения: {n}",
|
||||
"all.saved": "Сохранено. Перезапустите сервер, чтобы изменения вступили в силу.",
|
||||
};
|
||||
|
||||
export default ru;
|
||||
@@ -190,6 +190,15 @@ export interface ModuleSetting {
|
||||
doc: string;
|
||||
}
|
||||
|
||||
export interface AllSetting {
|
||||
key: string;
|
||||
value: string;
|
||||
default: string;
|
||||
doc: string;
|
||||
/** the configuration sets it to something other than the documented default */
|
||||
changed: boolean;
|
||||
}
|
||||
|
||||
export interface ReportContext {
|
||||
manager_version: string;
|
||||
windows: string;
|
||||
@@ -367,6 +376,8 @@ export const api = {
|
||||
moduleSetEnabled: (id: string, module: string, enabled: boolean) => invoke<void>("module_set_enabled", { id, module, enabled }),
|
||||
moduleSettings: (id: string, module: string) => invoke<ModuleSetting[]>("module_settings", { id, module }),
|
||||
moduleSaveSettings: (id: string, module: string, changes: Record<string, string>) => invoke<string[]>("module_save_settings", { id, module, changes }),
|
||||
allSettings: (id: string) => invoke<AllSetting[]>("all_settings", { id }),
|
||||
allSettingsSave: (id: string, changes: Record<string, string>) => invoke<string[]>("all_settings_save", { id, changes }),
|
||||
reportContext: (id: string) => invoke<ReportContext>("report_context", { id }),
|
||||
listAccounts: (id: string) => invoke<AccountInfo[]>("list_accounts", { id }),
|
||||
accountSetPassword: (id: string, name: string, password: string) => invoke<void>("account_set_password", { id, name, password }),
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { ChevronDown, ChevronRight, Loader2, Search } from "lucide-react";
|
||||
import { api, asUiError, type AllSetting, type UiError } from "@/lib/api";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card } from "@/components/ui/card";
|
||||
import { useHuman, useT } from "@/i18n";
|
||||
|
||||
/** How many matches are drawn at once; the rest is reached by searching. */
|
||||
const SHOWN = 40;
|
||||
|
||||
/** Every documented setting of the world server, searchable. For people who want more than the curated list above. */
|
||||
export function AllSettingsCard({ serverId }: { serverId: string }) {
|
||||
const t = useT();
|
||||
const human = useHuman();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [items, setItems] = useState<AllSetting[] | null>(null);
|
||||
const [query, setQuery] = useState("");
|
||||
const [onlyChanged, setOnlyChanged] = useState(false);
|
||||
const [edits, setEdits] = useState<Record<string, string>>({});
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<UiError | null>(null);
|
||||
const [note, setNote] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open || items) return;
|
||||
void api.allSettings(serverId).then(setItems).catch((e) => setError(asUiError(e)));
|
||||
}, [open, items, serverId]);
|
||||
|
||||
const matches = useMemo(() => {
|
||||
const q = query.trim().toLowerCase();
|
||||
return (items ?? []).filter((s) => (!onlyChanged || s.changed) && (!q || s.key.toLowerCase().includes(q) || s.doc.toLowerCase().includes(q)));
|
||||
}, [items, query, onlyChanged]);
|
||||
|
||||
const dirty = Object.keys(edits);
|
||||
|
||||
async function save() {
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
setNote(null);
|
||||
try {
|
||||
const done = await api.allSettingsSave(serverId, edits);
|
||||
setEdits({});
|
||||
setItems(await api.allSettings(serverId));
|
||||
setNote(done.length ? t("all.saved") : t("set.nothingChanged"));
|
||||
} catch (e) {
|
||||
setError(asUiError(e));
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Card className="mt-8 p-5">
|
||||
<button onClick={() => setOpen((v) => !v)} aria-expanded={open} className="flex w-full cursor-pointer items-center gap-2 text-left">
|
||||
{open ? <ChevronDown className="h-4 w-4" aria-hidden /> : <ChevronRight className="h-4 w-4" aria-hidden />}
|
||||
<span className="font-semibold">{t("all.title")}</span>
|
||||
</button>
|
||||
<p className="mt-2 text-sm text-muted">{t("all.intro")}</p>
|
||||
|
||||
{open && (
|
||||
<div className="mt-4">
|
||||
{items === null && !error && <Loader2 className="h-4 w-4 animate-spin text-muted" aria-hidden />}
|
||||
{items && (
|
||||
<>
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<label className="relative block min-w-[16rem] flex-1">
|
||||
<Search className="pointer-events-none absolute left-2.5 top-2.5 h-4 w-4 text-muted" aria-hidden />
|
||||
<input
|
||||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
placeholder={t("all.search")}
|
||||
aria-label={t("all.search")}
|
||||
className="selectable w-full rounded-md border border-line bg-bg py-2 pl-8 pr-3 text-sm outline-none focus:border-gold"
|
||||
/>
|
||||
</label>
|
||||
<label className="flex cursor-pointer items-center gap-2 text-sm">
|
||||
<input type="checkbox" checked={onlyChanged} onChange={(e) => setOnlyChanged(e.target.checked)} />
|
||||
{t("all.onlyChanged")}
|
||||
</label>
|
||||
</div>
|
||||
<p className="mt-2 text-xs text-muted">{t("all.count", { shown: Math.min(matches.length, SHOWN), total: matches.length })}</p>
|
||||
|
||||
{matches.length === 0 && <p className="mt-4 text-sm text-muted">{t("all.none")}</p>}
|
||||
<ul className="mt-2 divide-y divide-line">
|
||||
{matches.slice(0, SHOWN).map((s) => {
|
||||
const value = edits[s.key] ?? s.value;
|
||||
return (
|
||||
<li key={s.key} className="py-3">
|
||||
<div className="flex flex-wrap items-center justify-between gap-3">
|
||||
<label htmlFor={`all-${s.key}`} className="selectable text-sm font-medium">
|
||||
{s.key}
|
||||
{s.changed && <span className="ml-2 rounded bg-gold/15 px-1.5 py-0.5 text-xs text-gold">{t("all.changed")}</span>}
|
||||
</label>
|
||||
<input
|
||||
id={`all-${s.key}`}
|
||||
value={value}
|
||||
onChange={(e) => {
|
||||
const v = e.target.value;
|
||||
setEdits((x) => {
|
||||
const n = { ...x };
|
||||
if (v === s.value) delete n[s.key];
|
||||
else n[s.key] = v;
|
||||
return n;
|
||||
});
|
||||
}}
|
||||
className="selectable w-56 rounded-md border border-line bg-bg px-2.5 py-1.5 text-sm outline-none focus:border-gold"
|
||||
/>
|
||||
</div>
|
||||
<p className="selectable mt-1 text-xs text-muted">{s.doc}</p>
|
||||
{value !== s.default && (
|
||||
<button
|
||||
className="mt-1 cursor-pointer text-xs text-muted underline hover:text-ink"
|
||||
onClick={() =>
|
||||
setEdits((x) => {
|
||||
const n = { ...x };
|
||||
if (s.default === s.value) delete n[s.key];
|
||||
else n[s.key] = s.default;
|
||||
return n;
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("all.useDefault", { v: s.default })}
|
||||
</button>
|
||||
)}
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
|
||||
<div className="mt-4 flex items-center gap-3">
|
||||
<Button size="sm" variant="primary" disabled={dirty.length === 0 || busy} onClick={() => void save()}>
|
||||
{busy && <Loader2 className="h-4 w-4 animate-spin" aria-hidden />}
|
||||
{t("all.save", { n: dirty.length })}
|
||||
</Button>
|
||||
{dirty.length > 0 && (
|
||||
<Button size="sm" variant="ghost" onClick={() => setEdits({})}>
|
||||
{t("set.discard")}
|
||||
</Button>
|
||||
)}
|
||||
{note && <span className="text-sm text-ok" role="status">{note}</span>}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{error && <p className="mt-3 text-sm text-bad" role="alert">{error.human.code === "unknown" ? error.technical : human(error.human).message}</p>}
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card } from "@/components/ui/card";
|
||||
import { AllSettingsCard } from "@/screens/AllSettingsCard";
|
||||
import { CompanionsCard } from "@/screens/CompanionsCard";
|
||||
import { useHuman, useI18n, useSchemaText, useT, type Key } from "@/i18n";
|
||||
|
||||
@@ -427,6 +428,8 @@ export function SettingsPage(props: { serverId: string; scope: Scope; title: str
|
||||
<p className="mt-6 text-xs text-muted">{t("set.unknownKept", { n: view.unknown_keys })}</p>
|
||||
)}
|
||||
|
||||
{scope === "server" && <AllSettingsCard serverId={serverId} />}
|
||||
|
||||
{dirtyKeys.length > 0 && (
|
||||
<div className="fixed bottom-0 left-60 right-0 flex items-center justify-between border-t border-line bg-[#0b0c0e]/95 px-10 py-3">
|
||||
<span className="text-sm text-muted">{tn("set.unsaved", dirtyKeys.length)}</span>
|
||||
|
||||
Reference in new issue
Block a user