mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-02 08:50:12 +00:00
Extends the new api with the format function
This commit is contained in:
parent
7d45d99855
commit
4533806ce8
3 changed files with 29 additions and 7 deletions
|
|
@ -29,6 +29,7 @@ alert_host_new_api_demo.meta = {
|
|||
-- @param another_param The second alert param
|
||||
-- @return A table with the alert built
|
||||
function alert_host_new_api_demo:init(one_param, another_param)
|
||||
-- Call the paren constructor
|
||||
self.super:init()
|
||||
|
||||
self.alert_type_params = {
|
||||
|
|
@ -39,8 +40,21 @@ end
|
|||
|
||||
-- #######################################################
|
||||
|
||||
function alert_host_new_api_demo:format()
|
||||
-- tprint("new format: "..self.def_script.alert_key)
|
||||
-- @brief Format an alert into a human-readable string
|
||||
-- @param ifid The integer interface id of the generated alert
|
||||
-- @param alert The alert description table, including alert data such as the generating entity, timestamp, granularity, type
|
||||
-- @param alert_type_params Table `alert_type_params` as built in the `:init` method
|
||||
-- @return A human-readable string
|
||||
function alert_host_new_api_demo.format(ifid, alert, alert_type_params)
|
||||
local alert_consts = require("alert_consts")
|
||||
local entity = alert_consts.formatAlertEntity(ifid, alert_consts.alertEntityRaw(alert["alert_entity"]), alert["alert_entity_val"])
|
||||
|
||||
return i18n("new_api_demo.alert_host_new_api_demo_description",
|
||||
{
|
||||
host = entity,
|
||||
one_param = alert_type_params.one_param,
|
||||
another_param = alert_type_params.another_param
|
||||
})
|
||||
end
|
||||
|
||||
-- #######################################################
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue