Skip to content

Commit

Permalink
Merge pull request #63 from ConductionNL/feature/PC108-86/better-audi…
Browse files Browse the repository at this point in the history
…t-modal

improved audit modal
  • Loading branch information
remko48 authored Dec 2, 2024
2 parents 767505b + bce727c commit 0828013
Showing 1 changed file with 61 additions and 13 deletions.
74 changes: 61 additions & 13 deletions src/modals/zaken/ViewZaakAuditTrail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,34 @@ import { zaakStore, navigationStore } from '../../store/store.js'
<div class="audit-item">
<h3>Audit Trail ID: {{ auditTrail.id }}</h3>

<p><strong>Action:</strong> {{ auditTrail.action }}</p>
<p><strong>User:</strong> {{ auditTrail.userName }} ({{ auditTrail.user }})</p>
<p><strong>Session:</strong> {{ auditTrail.session }}</p>
<p><strong>IP Address:</strong> {{ auditTrail.ipAddress }}</p>
<p><strong>Created:</strong> {{ new Date(auditTrail.created).toLocaleString() }}</p>
<div class="audit-item-details">
<p><strong>Action:</strong> {{ auditTrail.action }}</p>
<p><strong>User:</strong> {{ auditTrail.userName }} ({{ auditTrail.user }})</p>
<p><strong>Session:</strong> {{ auditTrail.session }}</p>
<p><strong>IP Address:</strong> {{ auditTrail.ipAddress }}</p>
<p><strong>Created:</strong> {{ new Date(auditTrail.created).toLocaleString() }}</p>
</div>

<div v-if="auditTrail.changed">
<div v-if="auditTrail.changed" class="audit-trail-changes">
<h4>Changes:</h4>
<ul>
<li v-for="(change, key) in auditTrail.changed" :key="key">
<strong>{{ key }}:</strong><br>
<span>Old: {{ change.old ?? 'N/A' }}</span><br>
<span>New: {{ change.new ?? 'N/A' }}</span>
</li>
</ul>
<div class="audit-trail-table-container">
<table class="audit-trail-table">
<thead>
<tr>
<th>Field</th>
<th>Old Value</th>
<th>New Value</th>
</tr>
</thead>
<tbody>
<tr v-for="(change, key) in auditTrail.changed" :key="key">
<td><strong>{{ key }}</strong></td>
<td>{{ formatValue(change.old) }}</td>
<td>{{ formatValue(change.new) }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>

Expand Down Expand Up @@ -66,6 +79,16 @@ export default {
navigationStore.setModal(null)
zaakStore.setAuditTrailItem(null)
},
formatValue(value) {
if (value === null || value === undefined) {
return 'N/A' // Handle null or undefined
} else if (typeof value === 'object') {
return JSON.stringify(value, null, 2) // Format JSON objects
} else if (typeof value === 'boolean') {
return value ? 'True' : 'False' // Format booleans
}
return value // Return the value as is for other types
},
},
}
</script>
Expand All @@ -80,11 +103,36 @@ export default {
padding: 0 0 10px 0;
margin: 0 0 10px 0;
}
.audit-item > *:not(:last-child) {
margin-bottom: 1rem;
}
.navigation-buttons {
margin-top: 10px;
display: flex;
gap: 10px;
justify-content: center;
}
/* Changes Table */
.audit-trail-table-container {
max-height: 350px;
overflow-y: auto;
}
.audit-trail-table thead {
position: sticky;
top: 0;
background-color: var(--color-main-background);
}
.audit-trail-table th {
font-weight: bold;
font-size: 1rem;
}
.audit-trail-table th,
.audit-trail-table td {
padding: 0.5rem;
}
</style>

0 comments on commit 0828013

Please sign in to comment.