Skip to content

Commit e7d0811

Browse files
committed
device detail template: optimize log level objects
1 parent 9ed6fd3 commit e7d0811

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

app/templates/devices/detail.html

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,28 @@ <h3 class="mt-4 mb-4">{% trans "Log" %}</h3>
9393
<ul class="list-group mb-3">
9494
{% for log in device_logs %}
9595
<li class="list-group-item">
96-
<div class="d-flex w-100 justify-content-between">
96+
<div class="d-flex w-100 justify-content-start">
9797
<small class="text-muted">{{ log.timestamp|naturaltime }}</small>
9898
<!-- Display log level with badge using the mapping -->
9999
{% with badge_class=level_badge_map|get:log.level %}
100100
{% if badge_class %}
101-
<span class="badge {{ badge_class }}">{{ level_map|get:log.level }}</span>
101+
<span class="badge {{ badge_class }} ms-2">
102+
{% if log.level == 0 %}
103+
<i class="bi bi-info-circle"></i> {{ level_map|get:log.level|capfirst }}
104+
{% elif log.level == 1 %}
105+
<i class="bi bi-info-circle"></i> {{ level_map|get:log.level|capfirst }}
106+
{% elif log.level == 2 %}
107+
<i class="bi bi-exclamation-triangle"></i> {{ level_map|get:log.level|capfirst }}
108+
{% elif log.level == 3 %}
109+
<i class="bi bi-exclamation-octagon"></i> {{ level_map|get:log.level|capfirst }}
110+
{% elif log.level == 4 %}
111+
<i class="bi bi-x-octagon"></i> {{ level_map|get:log.level|capfirst }}
112+
{% else %}
113+
{{ level_map|get:log.level|default:_("unknown") }}
114+
{% endif %}
115+
</span>
102116
{% else %}
103-
<span class="badge {{ badge_class }}">{{ level_map|get:log.level }}</span>
117+
<span class="badge bg-light text-dark">{{ level_map|get:log.level|capfirst }}</span>
104118
{% endif %}
105119
{% endwith %}
106120
</div>

0 commit comments

Comments
 (0)