fix: add missing age_text and severity_color helpers to alert_live
This commit is contained in:
parent
2c1b749487
commit
08b876b207
1 changed files with 16 additions and 0 deletions
|
|
@ -261,6 +261,22 @@ defmodule ToweropsWeb.AlertLive.Index do
|
|||
end
|
||||
end
|
||||
|
||||
defp age_text(nil), do: "—"
|
||||
defp age_text(dt) do
|
||||
diff = DateTime.diff(DateTime.utc_now(), dt, :second)
|
||||
cond do
|
||||
diff < 60 -> "just now"
|
||||
diff < 3600 -> "#{div(diff, 60)}m ago"
|
||||
diff < 86400 -> "#{div(diff, 3600)}h ago"
|
||||
true -> "#{div(diff, 86400)}d ago"
|
||||
end
|
||||
end
|
||||
|
||||
defp severity_color("critical"), do: "text-red-600 dark:text-red-400"
|
||||
defp severity_color("warning"), do: "text-yellow-600 dark:text-yellow-400"
|
||||
defp severity_color("info"), do: "text-blue-600 dark:text-blue-400"
|
||||
defp severity_color(_), do: "text-gray-600 dark:text-gray-400"
|
||||
|
||||
defp format_number(number) when is_integer(number) do
|
||||
number
|
||||
|> Integer.to_string()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue