1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-09 03:36:48 +00:00
webvirtcloud/admin/templates/admin/logs.html
catborise b4c999a22f feat(admin): the Logs page searches every row, shows failures and downloads them
The search box filtered only the 100 rows on screen, in the browser: an
older row seemed not to exist. The page now searches on the server, in
every row's user, host, VM, VM UUID, message and IP, as plain text, and
can show the failed rows only; its pages keep the search.

Failed rows are marked red, dates carry the year and the time zone, and
a VM's rows link to the VM while it is in the panel. Excel downloads the
rows the search chooses, all pages of them, with the VM report's
workbook (text stays text).
2026-10-25 23:08:42 +03:00

68 lines
3.4 KiB
HTML

{% extends "base.html" %}
{% load i18n %}
{% load django_bootstrap5 %}
{% load bootstrap_icons %}
{% block title %}{% trans "Logs" %}{% endblock %}
{% block page_heading %}{% trans "Logs" %}{% endblock page_heading %}
{% block page_heading_extra %}
{# the search runs on the server over every row; the download takes the same rows #}
<form method="get" class="float-end d-flex flex-wrap gap-2 align-items-center" role="search">
<input name="q" value="{{ q }}" class="form-control w-auto" type="search" placeholder="{% trans 'Search' %}"
aria-label="{% trans 'Search the logs' %}">
<div class="form-check mb-0">
<input id="logs-failed" class="form-check-input" type="checkbox" name="failed" value="1"{% if failed %} checked{% endif %}>
<label class="form-check-label" for="logs-failed">{% trans "Failed only" %}</label>
</div>
<button type="submit" class="btn btn-primary">{% trans "Search" %}</button>
<a class="btn btn-outline-primary" href="{% url 'admin:logs_export' %}{% if query %}?{{ query }}{% endif %}"
title="{% trans 'Download these rows as an Excel file' %}">{% bs_icon 'download' %} {% trans "Excel" %}</a>
</form>
{% endblock page_heading_extra %}
{% block content %}
<div class="row">
<div class="col-lg-12">
{% if not logs %}
<div class="alert alert-warning shadow-sm">
{% bs_icon 'exclamation-triangle'%}
{% if q or failed %}{% trans "No log rows match." %}{% else %}{% trans "There are no log rows yet." %}{% endif %}
</div>
{% else %}
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">{% blocktrans %}Date ({{ time_zone }}){% endblocktrans %}</th>
<th scope="col">{% trans "User" %}</th>
<th scope="col">{% trans "Host" %}</th>
<th scope="col">{% trans "Instance" %}</th>
<th scope="col">{% trans "Message" %}</th>
<th scope="col">{% trans "Result" %}</th>
<th scope="col">{% trans "IP" %}</th>
</tr>
</thead>
<tbody>
{% for log in logs %}
<tr{% if log.success is False %} class="table-danger"{% endif %}>
<td>{{ log.id }}</td>
<td class="text-nowrap">{{ log.date|date:"Y-m-d H:i:s" }}</td>
<td>{{ log.user }}</td>
<td>{{ log.host }}</td>
<td>{% if log.vm_pk %}<a href="{% url 'instances:instance' log.vm_pk %}">{{ log.instance }}</a>{% else %}{{ log.instance }}{% endif %}</td>
<td>{{ log.message }}</td>
<td>{% if log.success is None %}{% trans "Unknown" %}{% elif log.success %}{% trans "Done" %}{% else %}{% trans "Failed" %}{% endif %}</td>
<td>{{ log.ip|default:"" }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% bootstrap_pagination logs extra=query %}
{% endif %}
</div>
</div>
{% endblock %}