Skip to content

Commit

Permalink
Improve alert time format
Browse files Browse the repository at this point in the history
  • Loading branch information
emanuele-f committed Dec 20, 2018
1 parent 19052bc commit 46b950b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scripts/lua/get_alerts_data.lua
Expand Up @@ -9,6 +9,7 @@ require "lua_utils"
require "alert_utils"
require "flow_utils"

local format_utils = require "format_utils"
local json = require "dkjson"

sendHTTPContentTypeHeader('text/html')
Expand Down Expand Up @@ -88,8 +89,10 @@ for _key,_value in ipairs(alerts) do
alert_entity_val = ""
end

if(tdiff < 60) then
column_date = secondsToTime(tdiff).." ago"
if(tdiff <= 600) then
column_date = secondsToTime(tdiff).. " " ..i18n("details.ago")
else
column_date = format_utils.formatPastEpochShort(_value["alert_tstamp"])
end

if engaged == true then
Expand Down
4 changes: 4 additions & 0 deletions scripts/lua/modules/format_utils.lua
Expand Up @@ -218,4 +218,8 @@ function format_utils.formatEpochShort(epoch_begin, epoch_end, epoch)
return format_utils.formatEpoch(epoch)
end

function format_utils.formatPastEpochShort(epoch)
return format_utils.formatEpochShort(epoch, os.time(), epoch)
end

return format_utils

0 comments on commit 46b950b

Please sign in to comment.