mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-04 01:01:35 -07:00
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:
@@ -425,17 +425,22 @@ async function renderSmallBoxes() {
|
||||
|
||||
const deviceData = await response.json();
|
||||
|
||||
// Derive status card appearance from shared getStatusBadgeParts —
|
||||
// ensures icon, color, label and lang key are always in sync with the rest of the UI.
|
||||
const statusBadge = badgeFromDevice(deviceData);
|
||||
const statusText = statusBadge.label;
|
||||
|
||||
// Prepare custom data
|
||||
const customData = [
|
||||
{
|
||||
"onclickEvent": "$('#tabDetails').trigger('click')",
|
||||
"color": "bg-aqua",
|
||||
"color": statusBadge.cssClass,
|
||||
"headerId": "deviceStatus",
|
||||
"headerStyle": "margin-left: 0em",
|
||||
"labelLang": "DevDetail_Shortcut_CurrentStatus",
|
||||
"iconId": "deviceStatusIcon",
|
||||
"iconClass": deviceData.devPresentLastScan == 1 ? "fa fa-check text-green" : "fa fa-xmark text-red",
|
||||
"dataValue": deviceData.devPresentLastScan == 1 ? getString("Gen_Online") : getString("Gen_Offline")
|
||||
"iconHtml": statusBadge.iconHtml,
|
||||
"dataValue": statusText
|
||||
},
|
||||
{
|
||||
"onclickEvent": "$('#tabSessions').trigger('click');",
|
||||
|
||||
Reference in New Issue
Block a user