mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 16:09:32 +00:00
Add configsets targets labels
This commit is contained in:
parent
c665bc78d7
commit
fc0206327e
6 changed files with 45 additions and 6 deletions
|
|
@ -8,18 +8,45 @@ package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
|||
require "lua_utils"
|
||||
local json = require("dkjson")
|
||||
local user_scripts = require("user_scripts")
|
||||
local subdir = _GET["script_subdir"]
|
||||
|
||||
sendHTTPContentTypeHeader('application/json')
|
||||
|
||||
if(subdir == nil) then
|
||||
traceError(TRACE_ERROR, TRACE_CONSOLE, "Missing 'script_subdir' parameter")
|
||||
return
|
||||
end
|
||||
|
||||
local target_type = user_scripts.getSubdirTargetType(subdir)
|
||||
|
||||
local config_sets = user_scripts.getConfigsets()
|
||||
local rv = {}
|
||||
|
||||
-- Only return the essential information
|
||||
for _, configset in pairs(config_sets) do
|
||||
local targets = {}
|
||||
|
||||
for _, target in ipairs(configset.targets[subdir] or {}) do
|
||||
local label = target
|
||||
|
||||
if(target_type == "interface") then
|
||||
label = getHumanReadableInterfaceName(getInterfaceName(target))
|
||||
elseif(target_type == "network") then
|
||||
label = getLocalNetworkAlias(target)
|
||||
elseif(target_type == "cidr") then
|
||||
label = getHostAltName(target)
|
||||
end
|
||||
|
||||
targets[#targets + 1] = {
|
||||
key = target,
|
||||
label = label,
|
||||
}
|
||||
end
|
||||
|
||||
rv[#rv + 1] = {
|
||||
id = configset.id,
|
||||
name = configset.name,
|
||||
targets = configset.targets,
|
||||
targets = targets,
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue