feat: add automation features (auto-update, auto-start, scheduled updates)
This commit is contained in:
@@ -26,6 +26,10 @@ export default function Settings() {
|
||||
const [difficulty, setDifficulty] = useState('')
|
||||
const [activeConfig, setActiveConfig] = useState('')
|
||||
const [activeModlist, setActiveModlist] = useState('')
|
||||
const [autoUpdateOnStartup, setAutoUpdateOnStartup] = useState(false)
|
||||
const [autoStartOnStartup, setAutoStartOnStartup] = useState(false)
|
||||
const [autoUpdateModsOnStartup, setAutoUpdateModsOnStartup] = useState(false)
|
||||
const [scheduledUpdate, setScheduledUpdate] = useState('')
|
||||
|
||||
useEffect(() => {
|
||||
if (settings) {
|
||||
@@ -39,6 +43,10 @@ export default function Settings() {
|
||||
setDifficulty(settings.difficulty_presets)
|
||||
setActiveConfig(settings.active_config)
|
||||
setActiveModlist(settings.active_modlist)
|
||||
setAutoUpdateOnStartup(settings.auto_update_on_startup)
|
||||
setAutoStartOnStartup(settings.auto_start_on_startup)
|
||||
setAutoUpdateModsOnStartup(settings.auto_update_mods_on_startup)
|
||||
setScheduledUpdate(settings.scheduled_update)
|
||||
}
|
||||
}, [settings])
|
||||
|
||||
@@ -54,6 +62,10 @@ export default function Settings() {
|
||||
difficulty_presets: difficulty,
|
||||
active_config: activeConfig,
|
||||
active_modlist: activeModlist,
|
||||
auto_update_on_startup: autoUpdateOnStartup,
|
||||
auto_start_on_startup: autoStartOnStartup,
|
||||
auto_update_mods_on_startup: autoUpdateModsOnStartup,
|
||||
scheduled_update: scheduledUpdate,
|
||||
}),
|
||||
onSuccess: () => { qc.invalidateQueries({ queryKey: ['settings'] }); setDirty(false) },
|
||||
})
|
||||
@@ -220,6 +232,45 @@ export default function Settings() {
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<hr className="border-neutral-800 my-6" />
|
||||
|
||||
<div>
|
||||
<h3 className="text-lg font-medium mb-3">Automation</h3>
|
||||
<div className="space-y-3">
|
||||
<label className="flex items-center gap-3 cursor-pointer">
|
||||
<input type="checkbox" checked={autoUpdateOnStartup} onChange={e => { setAutoUpdateOnStartup(e.target.checked); setDirty(true) }} className="accent-amber-600 w-4 h-4" />
|
||||
<div>
|
||||
<div className="text-sm">Auto-update server on startup</div>
|
||||
<div className="text-xs text-neutral-500">Run gameserver update when the web service starts</div>
|
||||
</div>
|
||||
</label>
|
||||
<label className="flex items-center gap-3 cursor-pointer">
|
||||
<input type="checkbox" checked={autoUpdateModsOnStartup} onChange={e => { setAutoUpdateModsOnStartup(e.target.checked); setDirty(true) }} className="accent-amber-600 w-4 h-4" />
|
||||
<div>
|
||||
<div className="text-sm">Auto-update mods on startup</div>
|
||||
<div className="text-xs text-neutral-500">Download workshop updates for the active modlist when the web service starts</div>
|
||||
</div>
|
||||
</label>
|
||||
<label className="flex items-center gap-3 cursor-pointer">
|
||||
<input type="checkbox" checked={autoStartOnStartup} onChange={e => { setAutoStartOnStartup(e.target.checked); setDirty(true) }} className="accent-amber-600 w-4 h-4" />
|
||||
<div>
|
||||
<div className="text-sm">Auto-start server on startup</div>
|
||||
<div className="text-xs text-neutral-500">Restart the server if it was running before the web service stopped</div>
|
||||
</div>
|
||||
</label>
|
||||
<div>
|
||||
<label className="text-xs text-neutral-500 block mb-1">Scheduled update (cron)</label>
|
||||
<input
|
||||
value={scheduledUpdate}
|
||||
onChange={e => { setScheduledUpdate(e.target.value); setDirty(true) }}
|
||||
placeholder='e.g. "0 4 * * *" for daily at 4 AM'
|
||||
className="w-full bg-neutral-800 border border-neutral-700 rounded px-3 py-2 text-sm font-mono"
|
||||
/>
|
||||
<div className="text-xs text-neutral-500 mt-1">Empty = disabled. Runs game + mod updates at the specified schedule.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{showSteamCMD && (
|
||||
<div className="mt-4">
|
||||
<div className="flex items-center justify-between mb-2">
|
||||
|
||||
@@ -9,6 +9,11 @@ export interface ServerSettings {
|
||||
difficulty_presets: string
|
||||
active_config: string
|
||||
active_modlist: string
|
||||
auto_update_on_startup: boolean
|
||||
auto_start_on_startup: boolean
|
||||
auto_update_mods_on_startup: boolean
|
||||
was_running: boolean
|
||||
scheduled_update: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user