Skip to content

Commit

Permalink
Network diagram - Alphabetical sorting #860
Browse files Browse the repository at this point in the history
  • Loading branch information
jokob-sk committed Oct 24, 2024
1 parent 4c46b27 commit 8404138
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 614 deletions.
40 changes: 25 additions & 15 deletions front/network.php
Original file line number Diff line number Diff line change
Expand Up @@ -481,21 +481,31 @@ function createPane($node_mac, $node_name, $node_status, $node_type, $node_ports
return;
}

devicesListnew = rawData["data"].map(item => { return {
"name":item[0],
"type":item[2],
"icon":item[3],
"mac":item[11],
"parentMac":item[14],
"rowid":item[13],
"status":item[10],
"childrenQty":item[15],
"port":item[18]
}})

setCache('devicesListNew', JSON.stringify(devicesListnew))

// init global variable
devicesListnew = rawData["data"].map(item => {
return {
"name": item[0],
"type": item[2],
"icon": item[3],
"mac": item[11],
"parentMac": item[14],
"rowid": item[13],
"status": item[10],
"childrenQty": item[15],
"port": item[18]
};
}).sort((a, b) => {
// First sort by name alphabetically
const nameCompare = a.name.localeCompare(b.name);
if (nameCompare !== 0) {
return nameCompare;
}
// If names are the same, sort by port numerically
return a.port - b.port;
});

setCache('devicesListNew', JSON.stringify(devicesListnew));

// Init global variable
deviceListGlobal = devicesListnew;


Expand Down
Loading

0 comments on commit 8404138

Please sign in to comment.