Refactor network tree data structure and improve device status handling

- Updated the network tree data structure to use consistent naming conventions for device properties (e.g., devName, devMac).
- Enhanced the initTree function to utilize the new property names and improved the rendering of device nodes.
- Refactored the getStatusBadgeParts function to include additional parameters for archived and new device statuses.
- Introduced convenience functions (badgeFromDevice and badgeFromDataAttrs) to streamline badge generation from device objects and data attributes.
- Updated various language files to include new status labels and ensure consistency across translations.
- Modified the renderSmallBox function to allow for custom icon HTML, improving flexibility in UI components.
This commit is contained in:
Jokob @NetAlertX
2026-03-02 09:35:42 +00:00
parent 3e237bb452
commit 6724d250d4
28 changed files with 280 additions and 156 deletions

View File

@@ -75,8 +75,17 @@ const GRAPHQL_EXTRA_FIELDS = [
"devLastNotification",
"devIsNew",
"devIsArchived",
"devIsSleeping",
];
// Row positions for extra (non-display) fields.
// In dataSrc, extra fields are appended AFTER the display columns in each row,
// so their position = DEVICE_COLUMN_FIELDS.length + their index in GRAPHQL_EXTRA_FIELDS.
// Use COL_EXTRA.fieldName to access them in createdCell rowData.
const COL_EXTRA = Object.fromEntries(
GRAPHQL_EXTRA_FIELDS.map((name, i) => [name, DEVICE_COLUMN_FIELDS.length + i])
);
// Maps Device_TableHead_* language keys to their GraphQL/DB field names.
// Used by getColumnNameFromLangString() in ui_components.js and by
// column filter logic in devices.php.