Implements script values factory reset

Implements #4297
This commit is contained in:
Simone Mainardi 2020-08-31 17:51:54 +02:00
parent 20bf30946e
commit 77d458c632
2 changed files with 46 additions and 2 deletions

View file

@ -13,7 +13,7 @@ local alert_consts = require("alert_consts")
sendHTTPContentTypeHeader('application/json')
local subdir = _GET["script_subdir"] or "host"
local confset_id = tonumber(_GET["confset_id"] or user_scripts.DEFAULT_CONFIGSET_ID)
local confset_id = tonumber(_GET["confset_id"])
local script_key = _GET["script_key"]
local script_type = user_scripts.getScriptType(subdir)
@ -28,7 +28,14 @@ if(script_key == nil) then
return
end
local config_set = user_scripts.getConfigsets()[confset_id]
local config_set
if confset_id then
-- If confset_id has been submitted, the user-configuration is returned
config_set = user_scripts.getConfigsets()[confset_id]
else
-- If no confset_id has been submitted, the factory configuration is returned
config_set = user_scripts.getFactoryConfig()
end
if(config_set == nil) then
traceError(TRACE_ERROR, TRACE_CONSOLE, "Unknown configset ID: " .. confset_id)