That's better, make it a simple list

This commit is contained in:
shamoon 2024-04-09 23:03:42 -07:00
parent be8a91942b
commit a680c6e385
2 changed files with 34 additions and 47 deletions

View File

@ -14,53 +14,38 @@
@for (entry of entries; track entry.id) { @for (entry of entries; track entry.id) {
<li class="list-group-item"> <li class="list-group-item">
<div class="d-flex justify-content-between align-items-center"> <div class="d-flex justify-content-between align-items-center">
<div>
<ng-template #timestamp> <ng-template #timestamp>
<div class="text-light"> <div class="text-light">
{{ entry.timestamp | customDate:'longDate' }} {{ entry.timestamp | date:'shortTime' }} {{ entry.timestamp | customDate:'longDate' }} {{ entry.timestamp | date:'shortTime' }}
</div> </div>
</ng-template> </ng-template>
<span [ngbTooltip]="timestamp">{{ entry.timestamp | customDate:'relative' }}</span> <span class="text-muted" [ngbTooltip]="timestamp">{{ entry.timestamp | customDate:'relative' }}</span>
@if (entry.actor) { @if (entry.actor) {
<span class="ms-3 fst-italic">{{ entry.actor.username }}</span> <span class="ms-3 fst-italic">{{ entry.actor.username }}</span>
} @else { } @else {
<span class="ms-3 fst-italic">System</span> <span class="ms-3 fst-italic">System</span>
} }
<span class="badge bg-secondary ms-3">{{ entry.action | titlecase }}</span> <span class="badge bg-secondary ms-auto" [class.bg-primary]="entry.action === AuditLogAction.Create">{{ entry.action | titlecase }}</span>
</div> </div>
<button type="button" class="ml-auto btn btn-link" (click)="toggleEntry(entry)"> @if (entry.action === AuditLogAction.Update) {
<i-bs class="me-2" name="info-circle"></i-bs> <ul class="mt-2">
<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) { @for (change of entry.changes | keyvalue; track change.key) {
@if (change.value["type"] === 'm2m') { @if (change.value["type"] === 'm2m') {
<tr> <li>
<td>{{ change.key | titlecase }}:</td> <span class="fst-italic" i18n>{{ change.value["operation"] | titlecase }}</span>&nbsp;
<td> <span class="text-light">{{ change.key | titlecase }}</span>:&nbsp;
{{ change.value["operation"] | titlecase }} <code class="text-primary">{{ change.value["objects"].join(', ') }}</code>
<span class="fst-italic">{{ change.value["objects"].join(', ') }}</span> </li>
</td>
</tr>
} }
@else { @else {
<tr> <li>
<td>{{ change.key | titlecase }}:</td> <span class="text-light">{{ change.key | titlecase }}</span>:&nbsp;
<td>{{ change.value[1] }}</td> <code class="text-primary">{{ change.value[1] }}</code>
</tr> </li>
} }
} }
</tbody> </ul>
</table> }
</div>
</li> </li>
} }
} }

View File

@ -1,5 +1,5 @@
import { Component, Input, OnInit } from '@angular/core' import { Component, Input, OnInit } from '@angular/core'
import { AuditLogEntry } from 'src/app/data/auditlog-entry' import { AuditLogAction, AuditLogEntry } from 'src/app/data/auditlog-entry'
import { DocumentService } from 'src/app/services/rest/document.service' import { DocumentService } from 'src/app/services/rest/document.service'
@Component({ @Component({
@ -8,7 +8,9 @@ import { DocumentService } from 'src/app/services/rest/document.service'
styleUrl: './audit-log.component.scss', styleUrl: './audit-log.component.scss',
}) })
export class AuditLogComponent implements OnInit { export class AuditLogComponent implements OnInit {
_documentId: number public AuditLogAction = AuditLogAction
private _documentId: number
@Input() @Input()
set documentId(id: number) { set documentId(id: number) {
this._documentId = id this._documentId = id