-- -- (C) 2013-18 - ntop.org -- local dirs = ntop.getDirs() package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path require "lua_utils" local delete_data_utils = require "delete_data_utils" local template = require "template_utils" local page_utils = require("page_utils") active_page = "admin" local page = _GET["page"] or _POST["page"] local info = ntop.getInfo() local delete_data_utils = require "delete_data_utils" sendHTTPContentTypeHeader('text/html') page_utils.print_header(i18n("manage_data.manage_data")) dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua") if _POST and table.len(_POST) > 0 and isAdministrator() then if _POST["delete_active_if_data"] then -- Data for the active interface can't be hot-deleted. -- a restart of ntopng is required so we just mark the deletion. delete_data_utils.request_delete_active_interface_data(ifname) print('
×'..i18n('delete_data.delete_active_interface_data_ok', {ifname = ifname, product = ntop.getInfo().product})..'
') elseif _POST["delete_inactive_if_data"] then local res = delete_data_utils.delete_inactive_interfaces() local err_msgs = {} for what, what_res in pairs(res) do if what_res["status"] ~= "OK" then err_msgs[#err_msgs + 1] = i18n(delete_data_utils.status_to_i18n(what_res["status"])) end end if #err_msgs == 0 then print('
×'..i18n('delete_data.delete_inactive_interfaces_data_ok')..'
') else print('
×'..i18n('delete_data.delete_inactive_interfaces_data_failed')..' '..table.concat(err_msgs, ' ')..'
') end else -- we're deleting an host local host_info = url2hostinfo(_POST) local parts = split(host_info["host"], "/") local res if (#parts == 2) and (tonumber(parts[2]) ~= nil) then res = delete_data_utils.delete_network(_POST["ifid"], parts[1], parts[2], host_info["vlan"] or 0) else res = delete_data_utils.delete_host(_POST["ifid"], host_info) end local err_msgs = {} for what, what_res in pairs(res) do if what_res["status"] ~= "OK" then err_msgs[#err_msgs + 1] = i18n(delete_data_utils.status_to_i18n(what_res["status"])) end end if #err_msgs == 0 then print('
×'..i18n('delete_data.delete_ok', {host = hostinfo2hostkey(host_info)})..'
') else print('
×'..i18n('delete_data.delete_failed', {host = hostinfo2hostkey(host_info)})..' '..table.concat(err_msgs, ' ')..'
') end end end print( template.gen("modal_confirm_dialog.html", { dialog = { id = "delete_data", action = "delete_data()", title = i18n("manage_data.delete"), message = i18n("delete_data.delete_confirmation", {host = ''}), confirm = i18n("delete"), confirm_button = "btn-danger", } }) ) local delete_active_interface_requested = delete_data_utils.delete_active_interface_data_requested(ifname) if not delete_active_interface_requested then print( template.gen("modal_confirm_dialog.html", { dialog = { id = "delete_active_interface_data", action = "delete_interfaces_data('delete_active_if_data')", title = i18n("manage_data.delete_active_interface"), message = i18n("delete_data.delete_active_interface_confirmation", {ifname = ifname, product = ntop.getInfo().product}), confirm = i18n("delete"), confirm_button = "btn-danger", } }) ) end local inactive_interfaces = delete_data_utils.list_inactive_interfaces() local num_inactive_interfaces = ternary(not ntop.isnEdge(), table.len(inactive_interfaces or {}), 0) if num_inactive_interfaces > 0 then local inactive_list = {} for if_id, if_name in pairs(inactive_interfaces) do inactive_list[#inactive_list + 1] = if_name end if table.len(inactive_list) > 20 then -- too many to use a bullet list, just concat them with a comma inactive_list = '
'..table.concat(inactive_list, ", ")..'
' else inactive_list = '

' end print( template.gen("modal_confirm_dialog.html", { dialog = { id = "delete_inactive_interfaces_data", action = "delete_interfaces_data('delete_inactive_if_data')", title = i18n("manage_data.delete_inactive_interfaces"), message = i18n("delete_data.delete_inactive_interfaces_confirmation", {interfaces_list = inactive_list}), confirm = i18n("delete"), confirm_button = "btn-danger", } }) ) end print[[

]] print(i18n("manage_data.manage_data")) print[[


]] print [[

]] print(i18n("manage_data.export")) print[[

]] print(i18n("manage_data.hosts")) print[[:
]] print(i18n('notes')) print[[ ]] print("
") -- closes
print [[

]] print(i18n("manage_data.delete")) print[[


]] print[[
]] if num_inactive_interfaces > 0 then print[[
]] end if (not ntop.isnEdge()) and (not delete_active_interface_requested) then print[[
]] end print[[

]] print[[ ]] print(i18n('notes')) print[[
  • ]] print(i18n('delete_data.note_persistent_data')) print[[
]] print("
") -- closes
print[[ ]] dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")