Host alerts migration to new api

This commit is contained in:
emanuele-f 2019-07-09 12:35:32 +02:00
parent ad5113cee0
commit ecdf88b8a0
8 changed files with 879 additions and 532 deletions

View file

@ -26,6 +26,8 @@ if _GET["ifid"] ~= nil then
interface.select(_GET["ifid"])
end
local ifid = interface.getId()
if(tonumber(_GET["currentPage"]) == nil) then _GET["currentPage"] = 1 end
if(tonumber(_GET["perPage"]) == nil) then _GET["perPage"] = getDefaultTableSize() end
@ -64,14 +66,23 @@ local function formatAlertRecord(alert_entity, record)
column_msg = formatRawUserActivity(record, record["alert_json"])
else
local alert_obj = alerts_api.parseAlert(record)
local msg = record["alert_json"]
if(alert_obj.formatter ~= nil) then
local msg = record["alert_json"]
if(string.sub(msg, 1, 1) == "{") then
if(string.sub(msg, 1, 1) == "{") then
msg = json.decode(msg)
end
if(alert_obj.formatter ~= nil) then
column_msg = alert_obj.formatter(msg, record)
else
local description = alertTypeDescription(record.alert_type)
if(type(description) == "string") then
-- localization string
column_msg = i18n(description, msg)
elseif(type(description) == "function") then
column_msg = description(ifid, record, msg)
end
end
end