refactored new system interface logic

This commit is contained in:
gabryon99 2020-03-23 11:03:40 +01:00
parent c0f30310f7
commit 84254e69a4
24 changed files with 115 additions and 69 deletions

View file

@ -248,27 +248,14 @@ end
-- ##############################################
function sendHTTPContentTypeHeader(content_type, content_disposition, charset, view_mode)
-- Check if the current request page belongs to iface/system view
if (content_type == "text/html") then
local really_view_mode = view_mode or getIfaceViewFlag()
if (isSystemView() and really_view_mode == getIfaceViewFlag()) then
setSystemView(false)
elseif (not isSystemView() and view_mode == getSystemViewFlag()) then
setSystemView(true)
elseif (really_view_mode == getBothViewFlag()) then
-- do nothing because the view is shared between iface view and system view
end
end
function sendHTTPContentTypeHeader(content_type, content_disposition, charset)
local charset = charset or "utf-8"
local mime = content_type.."; charset="..charset
sendHTTPHeader(mime, content_disposition)
end
-- ##############################################
function printGETParameters(get)
@ -3491,37 +3478,6 @@ function areFlowdevTimeseriesEnabled(ifid, device)
return(ntop.getPref("ntopng.prefs.flow_device_port_rrd_creation") == "1")
end
-- ##############################################
function isSystemView()
return ((ntop.getPref("ntopng.prefs.system_mode_enabled") == "1") and isAdministrator())
end
-- ##############################################
function getSystemViewFlag()
return "system"
end
-- ##############################################
function getBothViewFlag()
return "both"
end
-- ##############################################
function getIfaceViewFlag()
return "iface"
end
-- ##############################################
function setSystemView(toggle)
local t = (toggle and "1" or "0")
ntop.setPref("ntopng.prefs.system_mode_enabled", t)
end
-- ###########################################
--