Skip to content

Commit c748517

Browse files
committed
Enhance dynamic table status handling and improve visibility logic
1 parent f1117ba commit c748517

File tree

1 file changed

+81
-10
lines changed

1 file changed

+81
-10
lines changed

src/templates/config_checks_report.html

Lines changed: 81 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@
5959
{% endfor %}
6060
{% endif %}
6161
{% endfor %}
62-
<table class="dynamic-table{% if is_nested %} nested-table{% endif %}">
62+
{% set has_status_column = 'status' in all_keys or 'Status' in all_keys %}
63+
<table class="dynamic-table{% if is_nested %} nested-table{% endif %}" data-has-status="{{ 'true' if has_status_column else 'false' }}">
6364
<thead>
6465
<tr>
6566
{% for key in all_keys %}
@@ -74,7 +75,13 @@
7475
{% for key in all_keys %}
7576
{% set value = item.get(key, '') %}
7677
{% if key|lower == 'status' %}
77-
<td class="status-{{ value|lower }}">{{ value }}</td>
78+
{% set status_class = value|lower %}
79+
{% if status_class == 'success' or status_class == 'ok' %}
80+
{% set status_class = 'passed' %}
81+
{% elif status_class == 'failed' or status_class == 'error' %}
82+
{% set status_class = 'failed' %}
83+
{% endif %}
84+
<td class="status-{{ status_class }}" data-status="{{ status_class }}">{{ value }}</td>
7885
{% else %}
7986
<td>
8087
{% if value is mapping %}
@@ -509,24 +516,47 @@
509516
font-weight: 700;
510517
}
511518

512-
.status-passed {
519+
.status-passed,
520+
.status-success,
521+
.status-ok {
513522
color: var(--success-color);
514523
font-weight: 700;
524+
background-color: rgba(16, 124, 16, 0.1);
525+
padding: 4px 8px;
526+
border-radius: 4px;
515527
}
516528

517-
.status-failed {
529+
.status-failed,
530+
.status-error {
518531
color: var(--error-color);
519532
font-weight: 700;
533+
background-color: rgba(209, 52, 56, 0.1);
534+
padding: 4px 8px;
535+
border-radius: 4px;
520536
}
521537

522538
.status-warning {
523539
color: var(--warning-color);
524540
font-weight: 700;
541+
background-color: rgba(255, 140, 0, 0.1);
542+
padding: 4px 8px;
543+
border-radius: 4px;
525544
}
526545

527546
.status-info {
528547
color: var(--info-color);
529548
font-weight: 700;
549+
background-color: rgba(0, 120, 215, 0.1);
550+
padding: 4px 8px;
551+
border-radius: 4px;
552+
}
553+
554+
.status-skipped {
555+
color: #6c757d;
556+
font-weight: 700;
557+
background-color: rgba(108, 117, 125, 0.1);
558+
padding: 4px 8px;
559+
border-radius: 4px;
530560
}
531561

532562
.summary-box {
@@ -1476,13 +1506,19 @@ <h4 class="section-header" onclick="toggleSection('section-{{ check.hostname }}-
14761506

14771507
function filterByStatus(status) {
14781508
const statusBoxes = document.querySelectorAll('.status-count')
1479-
const allRows = document.querySelectorAll('.config-checks-table tbody tr:not(.expanded-content)')
1509+
const mainTableRows = document.querySelectorAll('.config-checks-table tbody tr:not(.expanded-content)')
1510+
const dynamicTables = document.querySelectorAll('.dynamic-table')
14801511
if (activeFilter === status) {
14811512
activeFilter = null
14821513
statusBoxes.forEach(box => box.classList.remove('active'))
1483-
allRows.forEach(row => {
1514+
mainTableRows.forEach(row => {
14841515
row.style.display = ''
14851516
})
1517+
dynamicTables.forEach(table => {
1518+
table.style.display = ''
1519+
const rows = table.querySelectorAll('tbody tr')
1520+
rows.forEach(row => row.style.display = '')
1521+
})
14861522
return
14871523
}
14881524
activeFilter = status
@@ -1495,8 +1531,8 @@ <h4 class="section-header" onclick="toggleSection('section-{{ check.hostname }}-
14951531
}
14961532
})
14971533

1498-
// Filter table rows
1499-
allRows.forEach(row => {
1534+
// Filter main config-checks-table rows
1535+
mainTableRows.forEach(row => {
15001536
const statusCell = row.querySelector('td:nth-child(5)')
15011537
if (!statusCell) {
15021538
row.style.display = 'none'
@@ -1505,9 +1541,9 @@ <h4 class="section-header" onclick="toggleSection('section-{{ check.hostname }}-
15051541

15061542
const rowStatus = statusCell.textContent.toLowerCase().trim()
15071543
let mappedStatus = rowStatus
1508-
if (rowStatus === 'failed') {
1544+
if (rowStatus === 'failed' || rowStatus === 'error') {
15091545
mappedStatus = 'error'
1510-
} else if (rowStatus === 'ok' || rowStatus === 'passed') {
1546+
} else if (rowStatus === 'ok' || rowStatus === 'passed' || rowStatus === 'success') {
15111547
mappedStatus = 'passed'
15121548
}
15131549

@@ -1525,6 +1561,41 @@ <h4 class="section-header" onclick="toggleSection('section-{{ check.hostname }}-
15251561
}
15261562
}
15271563
})
1564+
1565+
dynamicTables.forEach(table => {
1566+
const hasStatusColumn = table.getAttribute('data-has-status') === 'true'
1567+
1568+
if (!hasStatusColumn) {
1569+
table.style.display = 'none'
1570+
} else {
1571+
table.style.display = ''
1572+
const rows = table.querySelectorAll('tbody tr')
1573+
let hasVisibleRows = false
1574+
rows.forEach(row => {
1575+
const statusCell = row.querySelector('td[data-status]')
1576+
if (!statusCell) {
1577+
row.style.display = 'none'
1578+
return
1579+
}
1580+
const rowStatus = statusCell.getAttribute('data-status')
1581+
let mappedStatus = rowStatus
1582+
if (rowStatus === 'failed' || rowStatus === 'error') {
1583+
mappedStatus = 'error'
1584+
} else if (rowStatus === 'ok' || rowStatus === 'passed' || rowStatus === 'success') {
1585+
mappedStatus = 'passed'
1586+
}
1587+
if (mappedStatus === status) {
1588+
row.style.display = ''
1589+
hasVisibleRows = true
1590+
} else {
1591+
row.style.display = 'none'
1592+
}
1593+
})
1594+
if (!hasVisibleRows) {
1595+
table.style.display = 'none'
1596+
}
1597+
}
1598+
})
15281599
}
15291600
</script>
15301601
</body>

0 commit comments

Comments
 (0)