Skip to content

Commit 9c5c45b

Browse files
committed
Merge branch 'main' of github.com:netalertx/NetAlertX
2 parents 5bce6f6 + ed1ed6b commit 9c5c45b

File tree

2 files changed

+67
-28
lines changed

2 files changed

+67
-28
lines changed

front/css/app.css

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,15 +1413,48 @@ textarea[readonly],
14131413

14141414

14151415
#columnFilters {
1416-
display: flex;
1417-
flex-wrap: wrap;
1418-
gap: 10px; /* Add spacing between items */
1416+
display: grid;
1417+
grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
1418+
gap: 0.75em;
1419+
padding: 0.5em 0;
1420+
}
1421+
1422+
#columnFilters::before,
1423+
#columnFilters::after {
1424+
display: none !important;
14191425
}
14201426

14211427
.filter-group {
1422-
box-sizing: border-box; /* Ensure padding and borders are included in the width */
1423-
padding: 1em;
1424-
padding-top: 0;
1428+
box-sizing: border-box;
1429+
padding: 0.4em;
1430+
margin: 0;
1431+
border-radius: 3px;
1432+
display: flex;
1433+
flex-direction: column;
1434+
align-items: stretch;
1435+
gap: 0.15em;
1436+
white-space: normal;
1437+
}
1438+
1439+
.filter-group label {
1440+
box-sizing: border-box;
1441+
margin: 0;
1442+
border-radius: 3px;
1443+
display: flex;
1444+
flex-direction: column;
1445+
align-items: stretch;
1446+
gap: 0.15em;
1447+
white-space: normal;
1448+
padding-left: 15px;
1449+
padding-right: 0px;
1450+
}
1451+
1452+
.filter-dropdown {
1453+
width: 100%;
1454+
}
1455+
.filter-group select {
1456+
margin-left: 15px;
1457+
padding-right: 0px;
14251458
}
14261459

14271460
.filter-dropdown

front/devices.php

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -430,29 +430,35 @@ function initFilters() {
430430
filters: []
431431
};
432432

433-
// Group data by columnName
434-
resultJSON.forEach(entry => {
435-
const existingFilter = transformed.filters.find(filter => filter.column === entry.columnName);
436-
437-
if (existingFilter) {
438-
// Add the unique columnValue to options if not already present
439-
if (!existingFilter.options.some(opt => opt.value === entry.columnValue)) {
440-
existingFilter.options.push({
441-
value: entry.columnValue,
442-
label: entry.columnLabel || entry.columnValue
443-
});
433+
// Build filters in the exact order of columnFilters
434+
columnFilters.forEach(([columnName, headerKey]) => {
435+
// Get matching entries for this column
436+
const entries = resultJSON.filter(e => e.columnName === columnName);
437+
438+
if (entries.length === 0) return;
439+
440+
// Build options (unique)
441+
const optionsMap = new Map();
442+
443+
entries.forEach(entry => {
444+
const value = entry.columnValue;
445+
const label = entry.columnLabel || value;
446+
447+
if (!optionsMap.has(value)) {
448+
optionsMap.set(value, { value, label });
444449
}
445-
} else {
446-
// Create a new filter entry
447-
transformed.filters.push({
448-
column: entry.columnName,
449-
headerKey: entry.columnHeaderStringKey,
450-
options: [{
451-
value: entry.columnValue,
452-
label: entry.columnLabel || entry.columnValue
453-
}]
454-
});
455-
}
450+
});
451+
452+
const options = Array.from(optionsMap.values());
453+
454+
// Sort options alphabetically
455+
options.sort((a, b) => a.label.localeCompare(b.label));
456+
457+
transformed.filters.push({
458+
column: columnName,
459+
headerKey: headerKey,
460+
options: options
461+
});
456462
});
457463

458464
// Sort options alphabetically by label for better readability

0 commit comments

Comments
 (0)