Migrates alerts to an object-oriented implementation

This commit is contained in:
Matteo Biscosi 2020-12-23 10:55:53 +01:00
parent f412783c12
commit 101c53336e
30 changed files with 970 additions and 910 deletions

View file

@ -2,24 +2,45 @@
-- (C) 2019-20 - ntop.org
--
-- ##############################################
local alert_keys = require "alert_keys"
local alert_creators = require "alert_creators"
-- Import the classes library.
local classes = require "classes"
-- Make sure to import the Superclass!
local alert = require "alert"
-- ##############################################
local alert_host_pool_connection = classes.class(alert)
-- ##############################################
alert_host_pool_connection.meta = {
alert_key = alert_keys.ntopng.alert_host_pool_connection,
i18n_title = "alerts_dashboard.host_pool_connection",
icon = "fas fa-sign-in",
}
-- ##############################################
function alert_host_pool_connection:init(pool)
-- Call the paren constructor
self.super:init()
self.alert_type_params = alert_creators.createPoolConnectionDisconnection(pool)
end
-- #######################################################
local function poolConnectionFormat(ifid, alert, info)
function alert_host_pool_connection.format(ifid, alert, alert_type_params)
return(i18n("alert_messages.host_pool_has_connected", {
pool = info.pool,
pool = alert_type_params.pool,
url = getHostPoolUrl(alert.alert_entity_val),
}))
end
-- #######################################################
return {
alert_key = alert_keys.ntopng.alert_host_pool_connection,
i18n_title = "alerts_dashboard.host_pool_connection",
i18n_description = poolConnectionFormat,
icon = "fas fa-sign-in",
creator = alert_creators.createPoolConnectionDisconnection,
}
return alert_host_pool_connection