Fix View button in logs page not working
- Store log details in data-details attribute instead of inline onclick - Update showDetails() to read from data attribute - Prevents JSON quote conflicts breaking the onclick handler
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
<td>{{ log.message }}</td>
|
||||
<td>
|
||||
{% if log.details %}
|
||||
<button class="btn btn-sm btn-link" onclick="showDetails({{ log.details|tojson }})">View</button>
|
||||
<button class="btn btn-sm btn-link" data-details='{{ log.details|tojson }}' onclick="showDetails(this)">View</button>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
@@ -71,9 +71,10 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function showDetails(details) {
|
||||
function showDetails(button) {
|
||||
const details = button.getAttribute('data-details');
|
||||
try {
|
||||
const parsed = typeof details === 'string' ? JSON.parse(details) : details;
|
||||
const parsed = JSON.parse(details);
|
||||
document.getElementById('detailsContent').textContent = JSON.stringify(parsed, null, 2);
|
||||
} catch (e) {
|
||||
document.getElementById('detailsContent').textContent = details;
|
||||
|
||||
Reference in New Issue
Block a user