Host Pools UI changes

- Do now show the "Not Assigned" group in user pool dropdown
- Show an alert message when creating a Captive Portal user and no pools are defined
- Improve unique member validator to account missing network prefixes
- Prevent deleting an Host Group when a captive portal user is defined on it
This commit is contained in:
emanuele-f 2017-01-20 13:28:24 +01:00
parent 1bd0d01658
commit 0db8abd83e
11 changed files with 120 additions and 39 deletions

View file

@ -7,7 +7,7 @@ package.path = dirs.installdir .. "/scripts/lua/modules/?/init.lua;" .. package.
local host_pools_utils = {}
host_pools_utils.DEFAULT_POOL_ID = "0"
host_pools_utils.DEFAULT_POOL_NAME = "Default"
host_pools_utils.DEFAULT_POOL_NAME = "Not Assigned"
host_pools_utils.MAX_NUM_POOLS = 16
host_pools_utils.MAX_MEMBERS_NUM = 32
@ -23,6 +23,10 @@ local function get_pool_details_key(ifid, pool_id)
return "ntopng.prefs." .. ifid .. ".host_pools.details." .. pool_id
end
local function get_user_pool_id_key(username)
return "ntopng.user." .. username .. ".host_pool_id"
end
local function get_pool_detail(ifid, pool_id, detail)
local details_key = get_pool_details_key(ifid, pool_id)
@ -106,4 +110,19 @@ function host_pools_utils.initPools()
end
end
function host_pools_utils.getUndeletablePools()
-- TODO fix interface-local pools VS global users inconsistence
local key = get_user_pool_id_key("*")
local pools = {}
for user_key,_ in pairs(ntop.getKeysCache(key) or {}) do
local pool_id = ntop.getCache(user_key)
if tonumber(pool_id) ~= nil then
pools[pool_id] = true
end
end
return pools
end
return host_pools_utils