portal: use list template for alarms

This commit is contained in:
Iain Learmonth 2022-05-11 14:26:14 +01:00
parent ad63a9ff41
commit 36b20f392a
4 changed files with 45 additions and 45 deletions

View file

@ -1,37 +0,0 @@
{% extends "base.html.j2" %}
{% from 'bootstrap5/form.html' import render_form %}
{% block content %}
<h1 class="h2 mt-3">Alarms</h1>
<div class="table-responsive">
<table class="table table-sm">
<thead>
<tr>
<th scope="col">Resource</th>
<th scope="col">Type</th>
<th scope="col">State</th>
<th scope="col">Message</th>
<th scope="col">Last Update</th>
</tr>
</thead>
<tbody>
{% for alarm in alarms %}
<tr class="bg-{% if alarm.alarm_state.name == "OK" %}success{% elif alarm.alarm_state.name == "UNKNOWN" %}dark{% else %}danger{% endif %} text-light">
{% if alarm.target == "proxy" %}
<td>Proxy: {{ alarm.proxy.url }}<br />({{ alarm.proxy.origin.domain_name }})</td>
{% elif alarm.target == "origin" %}
<td>Origin: {{ alarm.origin.domain_name }}</td>
{% elif alarm.target == "service/cloudfront" %}
<td>AWS CloudFront</td>
{% endif %}
<td>{{ alarm.alarm_type }}</td>
<td>{{ alarm.alarm_state.name }}</td>
<td>{{ alarm.text }}</td>
<td>{{ alarm.last_updated | format_datetime }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}

View file

@ -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 %}
<h1 class="h2 mt-3">{{ title }}</h1>
{% if new_link %}
<a href="{{ new_link }}" class="btn btn-success">Create new {{ item }}</a>
{% endif %}
{% if item == "automation" %}
{% if section == "alarm" %}
{{ alarms_table(items) }}
{% elif item == "automation" %}
{{ automations_table(items) }}
{% elif item == "bridge configuration" %}
{{ bridgeconfs_table(items) }}

View file

@ -22,6 +22,39 @@
</svg>
{% endmacro %}
{% macro alarms_table(alarms) %}
<div class="table-responsive">
<table class="table table-sm">
<thead>
<tr>
<th scope="col">Resource</th>
<th scope="col">Type</th>
<th scope="col">State</th>
<th scope="col">Message</th>
<th scope="col">Last Update</th>
</tr>
</thead>
<tbody>
{% for alarm in alarms %}
<tr class="bg-{% if alarm.alarm_state.name == "OK" %}success{% elif alarm.alarm_state.name == "UNKNOWN" %}dark{% elif alarm.alarm_state.name == "WARNING" %}warning{% else %}danger{% endif %} text-{% if alarm.alarm_state.name == "WARNING" %}dark{% else %}light{% endif %}">
{% if alarm.target == "proxy" %}
<td>Proxy: {{ alarm.proxy.url }}<br />({{ alarm.proxy.origin.domain_name }})</td>
{% elif alarm.target == "origin" %}
<td>Origin: {{ alarm.origin.domain_name }}</td>
{% elif alarm.target == "service/cloudfront" %}
<td>AWS CloudFront</td>
{% endif %}
<td>{{ alarm.alarm_type }}</td>
<td>{{ alarm.alarm_state.name }}</td>
<td>{{ alarm.text }}</td>
<td>{{ alarm.last_updated | format_datetime }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endmacro %}
{% macro eotk_table(eotks) %}
<div class="alert alert-danger">Not implemented yet.</div>
{% endmacro %}