Implements configurable UI displayed string length

Implements #1159
This commit is contained in:
Simone Mainardi 2017-07-21 13:00:44 +02:00
parent 85da10af61
commit fcd007a5e9
10 changed files with 32 additions and 23 deletions

View file

@ -21,8 +21,12 @@ end
-- ##############################################
function shortenString(name, max_len)
max_len = max_len or 24
if(string.len(name) < max_len) then
if max_len == nil then
max_len = ntop.getPref("ntopng.prefs.max_ui_strlen")
max_len = tonumber(max_len)
end
if(string.len(name) < max_len) then
return(name)
else
return(string.sub(name, 1, max_len).."...")
@ -419,8 +423,9 @@ function shortHostName(name)
if(#chunks == 4) then
return(name)
else
max_len = 24
local max_len = ntop.getPref("ntopng.prefs.max_ui_strlen")
max_len = tonumber(max_len)
chunks = {name:match("%w+:%w+:%w+:%w+:%w+:%w+")}
--io.write(#chunks.."\n")
if(#chunks == 1) then