-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61db15c
commit 2ed93ff
Showing
5 changed files
with
133 additions
and
104 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
src/DoctrineAuditBundle/Resources/views/Audit/audit_helper.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{% macro dump(value, separator) %} | ||
{% spaceless %} | ||
{% if value is iterable %} | ||
{# Ugly hack to guess if value is describing an object #} | ||
{% if value|length == 4 and value.label is defined %} | ||
{{ value.label }} | ||
{% else %} | ||
{% for k, v in value %} | ||
{{ k }}: {{ v }}{{ separator|default('<br/>')|raw }} | ||
{% endfor %} | ||
{% endif %} | ||
{% else %} | ||
{{ value }} | ||
{% endif %} | ||
{% endspaceless %} | ||
{% endmacro dump %} | ||
|
||
{% macro humanize(entity, entry) %} | ||
{% import _self as audit_helper %} | ||
|
||
{% if entry.getType() == 'insert' %} | ||
{% set action = 'inserted' %} | ||
{% elseif entry.getType() == 'update' %} | ||
{% set action = 'updated' %} | ||
{% elseif entry.getType() == 'remove' %} | ||
{% set action = 'deleted' %} | ||
{% elseif entry.getType() == 'associate' %} | ||
{% set action = 'associated' %} | ||
{% set target = entry.getDiffs() %} | ||
{% elseif entry.getType() == 'dissociate' %} | ||
{% set action = 'dissociated' %} | ||
{% set target = entry.getDiffs() %} | ||
{% else %} | ||
{% set action = '???' %} | ||
{% endif %} | ||
|
||
<code>{{ entity }}#{{ entry.getObjectId() }}</code> | ||
has been <b>{{ action }}</b> | ||
{% if target is defined %} | ||
{% set defaultLabel = target['target']['class'] ~ '#' ~ target['target']['id'] %} | ||
{{ entry.getType() == 'associate' ? 'with' : 'from' }} <code>{{ defaultLabel }}</code> | ||
{% if defaultLabel != target['target']['label'] %} | ||
(<em>{{ audit_helper.dump(target['target']) }}</em>) | ||
{% endif %} | ||
{% endif %} | ||
by <b>{{ entry.getUsername() is null ? 'unknown user' : entry.getUsername() }}</b> | ||
on {{ entry.getCreatedAt()|date('Y-m-d') }} at {{ entry.getCreatedAt()|date('H:i:s') }} | ||
{% if entry.getIp() is not empty %} | ||
, IP: {{ entry.getIp() }} | ||
{% endif %} | ||
{% endmacro %} |
54 changes: 28 additions & 26 deletions
54
src/DoctrineAuditBundle/Resources/views/Audit/audited_entities.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,32 @@ | ||
{% extends "@DHDoctrineAudit/layout.html.twig" %} | ||
|
||
{% block dh_doctrine_audit_content %} | ||
<nav aria-label="breadcrumb"> | ||
<ol class="breadcrumb"> | ||
<li class="breadcrumb-item active"><a href="{{ path('dh_doctrine_audit_list_audits') }}">Home</a></li> | ||
</ol> | ||
</nav> | ||
|
||
<h2 class="card-title">{{ audited|length }} audited entities</h2> | ||
|
||
<table class="table table-hover"> | ||
<thead class="thead-dark"> | ||
<th>Entity</th> | ||
<th>Table</th> | ||
<th></th> | ||
</thead> | ||
<tbody> | ||
{% for entity, table in audited %} | ||
<tr> | ||
<td><code>{{ entity|escape }}</code></td> | ||
<td>{{ table|escape }}</td> | ||
<td> | ||
<a href="{{ path('dh_doctrine_audit_show_entity_history', { 'entity': entity }) }}">View audits</a> | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
<div class="card"> | ||
<div class="card-body"> | ||
<nav aria-label="breadcrumb"> | ||
<ol class="breadcrumb"> | ||
<li class="breadcrumb-item active"><a href="{{ path('dh_doctrine_audit_list_audits') }}">Home</a></li> | ||
</ol> | ||
</nav> | ||
<h4 class="card-title">{{ audited|length }} audited entities</h4> | ||
<table class="table table-hover"> | ||
<thead class="thead-dark"> | ||
<th>Entity</th> | ||
<th>Table</th> | ||
<th></th> | ||
</thead> | ||
<tbody> | ||
{% for entity, table in audited %} | ||
<tr> | ||
<td><code>{{ entity|escape }}</code></td> | ||
<td>{{ table|escape }}</td> | ||
<td> | ||
<a href="{{ path('dh_doctrine_audit_show_entity_history', { 'entity': entity }) }}">View audits</a> | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
{% endblock dh_doctrine_audit_content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 29 additions & 38 deletions
67
src/DoctrineAuditBundle/Resources/views/Audit/entity_history.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,37 @@ | ||
{% extends "@DHDoctrineAudit/layout.html.twig" %} | ||
|
||
{% import '@DHDoctrineAudit/Audit/bootstrap.html.twig' as bootstrap %} | ||
|
||
{% import _self as audit_viewer %} | ||
{% import '@DHDoctrineAudit/Audit/audit_helper.html.twig' as audit_helper %} | ||
|
||
{% block dh_doctrine_audit_content %} | ||
<nav aria-label="breadcrumb"> | ||
<ol class="breadcrumb"> | ||
<li class="breadcrumb-item"><a href="{{ path('dh_doctrine_audit_list_audits') }}">Home</a></li> | ||
<li class="breadcrumb-item active" aria-current="page"><a href="{{ path('dh_doctrine_audit_show_entity_history', {'entity': entity}) }}">{{ entity }}</a></li> | ||
</ol> | ||
</nav> | ||
<div class="card"> | ||
<div class="card-body"> | ||
<nav aria-label="breadcrumb"> | ||
<ol class="breadcrumb"> | ||
<li class="breadcrumb-item"><a href="{{ path('dh_doctrine_audit_list_audits') }}">Home</a></li> | ||
<li class="breadcrumb-item active" aria-current="page"><a href="{{ path('dh_doctrine_audit_show_entity_history', {'entity': entity}) }}">{{ entity }}</a></li> | ||
</ol> | ||
</nav> | ||
|
||
<h2 class="card-title float-left"><code>{{ entity }}</code></h2> | ||
<h3 class="float-right">{{ bootstrap.badge(entries|length ~ ' operations', 'primary') }}</h3> | ||
<h4 class="card-title float-left"><code>{{ entity }}</code></h4> | ||
<h5 class="float-right">{{ bootstrap.badge(entries|length ~ ' operations', 'primary') }}</h5> | ||
|
||
<table class="table table-hover"> | ||
<thead class="thead-dark"> | ||
<th>Type</th> | ||
<th>Object Id</th> | ||
<th>User Id</th> | ||
<th>Username</th> | ||
<th>Firewall</th> | ||
<th>Class</th> | ||
<th>IP</th> | ||
<th>Created At</th> | ||
<th></th> | ||
</thead> | ||
<tbody> | ||
{% for entry in entries %} | ||
<tr> | ||
<td>{{ bootstrap.badge(entry.getType(), bootstrap.label_type(entry.getType())) }}</td> | ||
<td><a href="{{ path('dh_doctrine_audit_show_entity_history', { 'entity': entity, 'id': entry.getObjectId() }) }}">{{ entry.getObjectId() }}</a></td> | ||
<td>{{ entry.getUserId() }}</td> | ||
<td>{{ entry.getUsername() }}</td> | ||
<td>{{ entry.getUserFirewall() }}</td> | ||
<td>{{ entry.getUserFqdn() }}</td> | ||
<td>{{ entry.getIp() }}</td> | ||
<td>{{ entry.getCreatedAt() }}</td> | ||
<td><a href="{{ path('dh_doctrine_audit_show_audit_entry', { 'entity': entity, 'id': entry.id }) }}">View details</a></td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
<table class="table table-hover"> | ||
<thead class="thead-dark"> | ||
<th>Type</th> | ||
<th>Description</th> | ||
<th></th> | ||
</thead> | ||
<tbody> | ||
{% for entry in entries %} | ||
<tr> | ||
<td>{{ bootstrap.badge(entry.getType(), bootstrap.label_type(entry.getType())) }}</td> | ||
<td>{{ audit_helper.humanize(entity, entry) }}</td> | ||
<td><a href="{{ path('dh_doctrine_audit_show_audit_entry', { 'entity': entity, 'id': entry.id }) }}">View details</a></td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
{% endblock dh_doctrine_audit_content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters