ntopng/scripts/lua/get_host_pools.lua
emanuele-f 04c72b2038 UI improvements and fixes
- Show confirmation alert when trying to delete some item
- Disable VLAN field for mac addresses in Host Pools and handle accordingly
- Remove Host Pool id column
- Remove Full Name user field minimum length restriction
- Other fixes
2017-01-19 18:33:25 +01:00

38 lines
949 B
Lua

--
-- (C) 2017 - ntop.org
--
dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
require "lua_utils"
local host_pools_utils = require "host_pools_utils"
local json = require "dkjson"
sendHTTPHeader('text/html; charset=iso-8859-1')
local ifid = _GET["ifid"]
local pool_id = _GET["pool"]
local res = {data={}, sort={{"column_", "asc"}}, totalRows=0}
if((ifid ~= nil) and (isAdministrator())) then
if pool_id ~= nil then
for _,member in ipairs(host_pools_utils.getPoolMembers(ifid, pool_id)) do
res.data[#res.data + 1] = {
column_member = member.address,
column_vlan = member.vlan,
}
end
else
for _,pool in ipairs(host_pools_utils.getPoolsList(ifid)) do
res.data[#res.data + 1] = {
column_pool_id = pool.id,
column_pool_name = pool.name,
}
end
end
end
res.totalRows = #res.data
return print(json.encode(res, nil, 1))