Loading indicator, filter modified events, stronger typing
This commit is contained in:
parent
e15b3ae9de
commit
2adf32c2d6
@ -1,50 +1,64 @@
|
||||
<ul class="list-group list-group-">
|
||||
@for (entry of entries; track entry.id) {
|
||||
<li class="list-group-item">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
{{ entry.timestamp | customDate:'longDate' }}
|
||||
{{ entry.timestamp | date:'shortTime' }}
|
||||
@if (entry.actor) {
|
||||
<span class="ms-3 fst-italic">{{ entry.actor.username }}</span>
|
||||
} @else {
|
||||
<span class="ms-3 fst-italic">System</span>
|
||||
}
|
||||
<span class="badge bg-secondary ms-3">{{ entry.action | titlecase }}</span>
|
||||
@if (loading) {
|
||||
<div class="d-flex">
|
||||
<div class="spinner-border spinner-border-sm fw-normal" role="status"></div>
|
||||
</div>
|
||||
} @else {
|
||||
<ul class="list-group">
|
||||
@if (entries.length === 0) {
|
||||
<li class="list-group-item">
|
||||
<div class="d-flex justify-content-center">
|
||||
<span class="fst-italic" i18n>No entries found.</span>
|
||||
</div>
|
||||
<button type="button" class="ml-auto btn btn-link" (click)="toggleEntry(entry)">
|
||||
<i-bs class="me-2" name="info-circle"></i-bs>
|
||||
<ng-container i18n>Details</ng-container>
|
||||
</button>
|
||||
</div>
|
||||
<div #collapse="ngbCollapse" [ngbCollapse]="!openEntries.has(entry.id)">
|
||||
<table class="table table-borderless m-0 ms-2">
|
||||
<thead>
|
||||
<tr>
|
||||
<th i18n>Field</th>
|
||||
<th i18n>Change</th>
|
||||
</tr>
|
||||
<tbody>
|
||||
@for (change of entry.changes | keyvalue; track change.key) {
|
||||
@if (change.value["type"] === 'm2m') {
|
||||
<tr>
|
||||
<td>{{ change.key | titlecase }}:</td>
|
||||
<td>
|
||||
{{ change.value["operation"] | titlecase }}
|
||||
<span class="fst-italic">{{ change.value["objects"].join(', ') }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
</li>
|
||||
} @else {
|
||||
@for (entry of entries; track entry.id) {
|
||||
<li class="list-group-item">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
{{ entry.timestamp | customDate:'longDate' }}
|
||||
{{ entry.timestamp | date:'shortTime' }}
|
||||
@if (entry.actor) {
|
||||
<span class="ms-3 fst-italic">{{ entry.actor.username }}</span>
|
||||
} @else {
|
||||
<span class="ms-3 fst-italic">System</span>
|
||||
}
|
||||
@else if (change.key !== 'modified') {
|
||||
<span class="badge bg-secondary ms-3">{{ entry.action | titlecase }}</span>
|
||||
</div>
|
||||
<button type="button" class="ml-auto btn btn-link" (click)="toggleEntry(entry)">
|
||||
<i-bs class="me-2" name="info-circle"></i-bs>
|
||||
<ng-container i18n>Details</ng-container>
|
||||
</button>
|
||||
</div>
|
||||
<div #collapse="ngbCollapse" [ngbCollapse]="!openEntries.has(entry.id)">
|
||||
<table class="table table-borderless m-0 ms-2">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>{{ change.key | titlecase }}:</td>
|
||||
<td>{{ change.value[1] }}</td>
|
||||
<th i18n>Field</th>
|
||||
<th i18n>Change</th>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
<tbody>
|
||||
@for (change of entry.changes | keyvalue; track change.key) {
|
||||
@if (change.value["type"] === 'm2m') {
|
||||
<tr>
|
||||
<td>{{ change.key | titlecase }}:</td>
|
||||
<td>
|
||||
{{ change.value["operation"] | titlecase }}
|
||||
<span class="fst-italic">{{ change.value["objects"].join(', ') }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
@else {
|
||||
<tr>
|
||||
<td>{{ change.key | titlecase }}:</td>
|
||||
<td>{{ change.value[1] }}</td>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</li>
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
|
@ -28,6 +28,11 @@ export class AuditLogComponent implements OnInit {
|
||||
.getAuditLog(this._documentId)
|
||||
.subscribe((auditLogEntries) => {
|
||||
this.entries = auditLogEntries
|
||||
.map((entry) => {
|
||||
delete entry.changes['modified']
|
||||
return entry
|
||||
})
|
||||
.filter((entry) => Object.keys(entry.changes).length > 0)
|
||||
this.loading = false
|
||||
})
|
||||
}
|
||||
|
@ -10,7 +10,9 @@ export interface AuditLogEntry {
|
||||
id: number
|
||||
timestamp: string
|
||||
action: AuditLogAction
|
||||
changes: any
|
||||
changes: {
|
||||
[key: string]: string[]
|
||||
}
|
||||
remote_addr: string
|
||||
actor?: User
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user