diff --git a/app/portal/__init__.py b/app/portal/__init__.py index 3cbb73f..75803b1 100644 --- a/app/portal/__init__.py +++ b/app/portal/__init__.py @@ -65,10 +65,13 @@ def search(): @portal.route('/alarms') def view_alarms(): - three_days_ago = datetime.now(timezone.utc) - timedelta(days=3) - alarms = Alarm.query.filter(Alarm.last_updated >= three_days_ago).order_by( - Alarm.alarm_state, desc(Alarm.state_changed)).all() - return render_template("alarms.html.j2", section="alarm", alarms=alarms) + one_day_ago = datetime.now(timezone.utc) - timedelta(days=1) + alarms = Alarm.query.filter(Alarm.last_updated >= one_day_ago).order_by( + desc(Alarm.alarm_state), desc(Alarm.state_changed)).all() + return render_template("list.html.j2", + section="alarm", + title="Alarms", + items=alarms) @portal.route('/lists') diff --git a/app/portal/templates/alarms.html.j2 b/app/portal/templates/alarms.html.j2 deleted file mode 100644 index 50fe8fb..0000000 --- a/app/portal/templates/alarms.html.j2 +++ /dev/null @@ -1,37 +0,0 @@ -{% extends "base.html.j2" %} -{% from 'bootstrap5/form.html' import render_form %} - -{% block content %} -

Alarms

- -
- - - - - - - - - - - - {% for alarm in alarms %} - - {% if alarm.target == "proxy" %} - - {% elif alarm.target == "origin" %} - - {% elif alarm.target == "service/cloudfront" %} - - {% endif %} - - - - - - {% endfor %} - -
ResourceTypeStateMessageLast Update
Proxy: {{ alarm.proxy.url }}
({{ alarm.proxy.origin.domain_name }})
Origin: {{ alarm.origin.domain_name }}AWS CloudFront{{ alarm.alarm_type }}{{ alarm.alarm_state.name }}{{ alarm.text }}{{ alarm.last_updated | format_datetime }}
-
-{% endblock %} diff --git a/app/portal/templates/list.html.j2 b/app/portal/templates/list.html.j2 index 9d80e57..cd2284e 100644 --- a/app/portal/templates/list.html.j2 +++ b/app/portal/templates/list.html.j2 @@ -1,14 +1,15 @@ {% extends "base.html.j2" %} -{% from "tables.html.j2" import automations_table, bridgeconfs_table, bridges_table, - groups_table, mirrorlists_table, origins_table, origin_onion_table, - onions_table, proxies_table %} +{% from "tables.html.j2" import alarms_table, automations_table, bridgeconfs_table, bridges_table, + groups_table, mirrorlists_table, origins_table, origin_onion_table, onions_table, proxies_table %} {% block content %}

{{ title }}

{% if new_link %} Create new {{ item }} {% endif %} - {% if item == "automation" %} + {% if section == "alarm" %} + {{ alarms_table(items) }} + {% elif item == "automation" %} {{ automations_table(items) }} {% elif item == "bridge configuration" %} {{ bridgeconfs_table(items) }} diff --git a/app/portal/templates/tables.html.j2 b/app/portal/templates/tables.html.j2 index 9c9939f..fd7cd3e 100644 --- a/app/portal/templates/tables.html.j2 +++ b/app/portal/templates/tables.html.j2 @@ -22,6 +22,39 @@ {% endmacro %} +{% macro alarms_table(alarms) %} +
+ + + + + + + + + + + + {% for alarm in alarms %} + + {% if alarm.target == "proxy" %} + + {% elif alarm.target == "origin" %} + + {% elif alarm.target == "service/cloudfront" %} + + {% endif %} + + + + + + {% endfor %} + +
ResourceTypeStateMessageLast Update
Proxy: {{ alarm.proxy.url }}
({{ alarm.proxy.origin.domain_name }})
Origin: {{ alarm.origin.domain_name }}AWS CloudFront{{ alarm.alarm_type }}{{ alarm.alarm_state.name }}{{ alarm.text }}{{ alarm.last_updated | format_datetime }}
+
+{% endmacro %} + {% macro eotk_table(eotks) %}
Not implemented yet.
{% endmacro %}