engelsystem/resources/views/admin/log.twig

83 lines
3.5 KiB
Twig
Raw Permalink Normal View History

2020-05-01 16:29:28 +02:00
{% extends 'layouts/app.twig' %}
{% import 'macros/base.twig' as m %}
{% import 'macros/form.twig' as f %}
2023-12-07 15:11:05 +01:00
{% block title %}{{ __('log.log') }}{% endblock %}
2020-05-01 16:29:28 +02:00
{% block content %}
<div class="col-md-12">
<h1>{{ block('title') }} <small>({{ entries|length }})</small></h1>
2020-05-01 16:29:28 +02:00
<div class="row">
<div class="col-md-12">
<div class="mb-3">
<form method="post" action="{{ url('/admin/logs') }}" class="form-inline">
2020-05-01 16:29:28 +02:00
{{ csrf() }}
<div class="row">
<div class="col-md-8">
{{ f.input('search', __('form.search'), {
'value': search,
'hide_label': true,
}) }}
</div>
{% if can('logs.all') %}
<div class="col-md-4">
{{ f.select('search_user_id', __('general.user'), users, {
'default_option': __('form.user_select'),
'selected': search_user_id,
}) }}
</div>
{% endif %}
</div>
2020-05-01 16:29:28 +02:00
{{ f.submit(__('form.search'), {'icon_left': 'search'}) }}
2020-05-01 16:29:28 +02:00
</form>
</div>
{% if not can('logs.all') %}
<div class="mb-3">
{{ m.alert(__('log.only_own')) }}
</div>
{% endif %}
2020-05-01 16:29:28 +02:00
<table class="table table-striped">
<tr>
<th>{{ __('log.time') }}</th>
<th>{{ __('log.level') }}</th>
<th>{{ __('general.user') }}</th>
2020-05-01 16:29:28 +02:00
<th>{{ __('log.message') }}</th>
</tr>
{% for entry in entries %}
{%- set type = 'default' %}
{%- if entry.level in ['notice', 'info'] %}
{%- set type = 'info' %}
{%- endif %}
{%- if entry.level in ['error', 'warning'] %}
{%- set type = 'warning' %}
{%- endif %}
{%- if entry.level in ['emergency', 'alert', 'critical'] %}
{%- set type = 'danger' %}
{%- endif %}
{%- set td_type = '' %}
{%- if type in ['warning', 'danger'] %}
{%- set td_type = type %}
{%- endif %}
<tr>
<td class="table-{{ td_type }} text-nowrap">{{ entry.created_at.format(__('general.datetime')) }}</td>
<td class="table-{{ td_type }} text-nowrap">
<span class="badge bg-{{ type }}">{{ entry.level|capitalize }}</span> <!-- //todo bs5 -->
2020-05-01 16:29:28 +02:00
</td>
<td class="text-nowrap">{% if entry.user %}{{ m.user(entry.user) }}{% endif %}</td>
2020-05-01 16:29:28 +02:00
<td>{{ entry.message|nl2br }}</td>
</tr>
{% endfor %}
</table>
</div>
</div>
</div>
{% endblock %}