Fixes alert_periodicity_changed failing to load graph_map_utils

This commit is contained in:
Simone Mainardi 2021-10-07 10:46:18 +02:00
parent 0987014edb
commit 48be233fea

View file

@ -4,7 +4,6 @@
-- ##############################################
local flow_alert_keys = require "flow_alert_keys"
-- Import the classes library.
local classes = require "classes"
@ -52,7 +51,6 @@ function alert_periodicity_changed.format(ifid, alert, alert_type_params)
l7proto = ternary(tonumber(alert["l7_proto"]) ~= 0, alert["l7_proto"], alert["l7_master_proto"]),
vlan_id = alert["vlan_id"]
}
local graph_map_utils = require("graph_map_utils")
if alert.json then
info = json.decode(alert["json"])
@ -63,7 +61,13 @@ function alert_periodicity_changed.format(ifid, alert, alert_type_params)
end
end
href = '<a href="' .. graph_map_utils.getMapUrl(flow_infos, interface.getId(), 'periodicity_map', 'graph') .. '"><i class="fas fa-lg fa-clock"></i></a>'
if ntop.isEnterprise() and ntop.isAdministrator() then
local dirs = ntop.getDirs()
package.path = dirs.installdir .. "/pro/scripts/lua/enterprise/modules/?.lua;" .. package.path
local graph_map_utils = require("graph_map_utils")
href = '<a href="' .. graph_map_utils.getMapUrl(flow_infos, interface.getId(), 'periodicity_map', 'graph') .. '"><i class="fas fa-lg fa-clock"></i></a>'
end
if alert_type_params.is_periodic then
return(i18n("alerts_dashboard.periodicity_is_periodic_descr", { info = info, href = href }))