Refactor alert ajax to try to save some space and make things more readable
<div class="panel panel-danger collapse" id="show-{{ key|slugify }}">
{% endif %}
<table class="table table-bordered table-condensed">
- <tr>
- <th>Starts</th>
- <th>Labels</th>
- <th>Annotations</th>
- </tr>
{% for alert in alerts %}
<tr>
<td><a href="{{ alert.generatorURL }}">{{ alert.startsAt|timezone:TIMEZONE }}</a></td>
<td>
+ <dl class="dl-horizontal">
+ <dt>labels</dt>
+ <dd>
{% for label, value in alert.labels.items|dictsort:0 %}
<a
class="label label-warning"
style="display: inline-block;"
>{{label}}: {{ value }}</a>
{% endfor %}
- </td>
- <td>
- {% if alert.annotations.summary %}
- <p>Summary: {{ alert.annotations.summary }}</p>
- {% endif %}
- {% if alert.annotations.description %}
- <p>Description: {{ alert.annotations.description }}</p>
- {% endif %}
- {% if alert.annotations.grafana %}
- <a href="{{ alert.annotations.grafana }}">Grafana</a>
+ </dd>
+ {% for label, value in alert.annotations.items|dictsort:0 %}
+ <dt>{{ label }}</dt>
+ <dd>
+ {% if 'http' in value %}
+ <a href="{{value}}">{{value|truncatechars:64}}</a>
+ {% else %}
+ {{label}}: {{value}}
{% endif %}
+ </dd>
+ {% endfor %}
+ </dl>
</td>
</tr>
{% endfor %}
