Interface disaggregation gui improvements

This commit is contained in:
emanuele-f 2018-04-11 11:33:50 +02:00
parent 0438ec5f70
commit d1b77ade45
3 changed files with 20 additions and 22 deletions

View file

@ -2316,12 +2316,28 @@ function setCustomnDPIProtoCategory(if_name, app_id, new_cat_id)
ntop.setHashCache(key, tostring(app_id), tostring(new_cat_id));
end
-- "Some Very Long String" -> "Some Ver...g String"
function shortenCollapse(s, max_len)
if max_len == nil then
max_len = ntop.getPref("ntopng.prefs.max_ui_strlen")
max_len = tonumber(max_len)
if(max_len == nil) then max_len = 24 end
end
if string.len(s) > max_len then
local half = math.floor(max_len / 2)
return string.sub(s, 1, half) .. "..." .. string.sub(s, half+1)
end
return s
end
function getHumanReadableInterfaceName(interface_name)
local key = 'ntopng.prefs.'..interface_name..'.name'
local custom_name = ntop.getCache(key)
if not isEmptyString(custom_name) then
return(shortenString(custom_name))
return(shortenCollapse(custom_name))
else
interface.select(interface_name)
local _ifstats = interface.getStats()
@ -2332,7 +2348,7 @@ function getHumanReadableInterfaceName(interface_name)
end
-- print(interface_name.."=".._ifstats.name)
return(shortenString(nm or ''))
return(shortenCollapse(nm or ''))
end
end