xrforge-v2/src/page/admin/index.lua

28 lines
716 B
Lua
Raw Normal View History

2026-07-22 18:36:02 +02:00
local util = require("util")
local data = util.merge({notification=''},{ opts = app.opts })
if GetMethod() == 'POST' then
local params = GetParams()
local saveconfig = false
foreach(params, function(k,v)
if v[1]:match("^opts.") then
app.opts[ v[1]:gsub("^opts.","") ] = v[2] -- update
saveconfig = true
end
end)
if saveconfig then
app.set('app.opts', app.opts )
data.notification = '<div class="notification">updated</div>'
else
data.notification = '<div class="notification">no changes detected</div>'
end
end
local html = util.template( LoadAsset("page/admin/index.html"),data)
SetStatus(200)
SetHeader('Content-Type', 'text/html; charset=utf-8')
Write( html )