Rework user script working sets (a single configset is supported now)

This commit is contained in:
Alfredo Cardigliano 2021-03-01 15:37:45 +01:00
parent 03512b963f
commit fa311e3ade
45 changed files with 259 additions and 1077 deletions

View file

@ -2,6 +2,8 @@
-- (C) 2019-21 - ntop.org
--
-- This is deprecated as there is a single configset now
local dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
@ -26,33 +28,15 @@ if(subdir == nil) then
end
local script_type = user_scripts.script_types[subdir]
local config_sets = user_scripts.getConfigsets()
local configset = user_scripts.getConfigset()
local rv = {}
-- Only return the essential information
for _, configset in pairs(config_sets) do
local pools = {}
if(script_type and script_type.default_config_only and (configset.id ~= user_scripts.DEFAULT_CONFIGSET_ID)) then
-- Only return the default
goto continue
end
local configset_pools = user_scripts.getConfigsetPools(subdir, configset.id)
for _, configset_pool in pairs(configset_pools) do
pools[#pools + 1] = {
key = configset_pool["pool_id"],
label = configset_pool["name"]
}
end
rv[#rv + 1] = {
id = configset.id,
name = configset.name,
pools = pools,
}
::continue::
end
rv[#rv + 1] = {
id = configset.id,
name = configset.name,
pools = {},
}
print(json.encode(rv))