fix sort based on lastseen

This commit is contained in:
Christopher Bisset 2022-08-13 21:02:55 +10:00
parent e50bcb77f6
commit c81e61d87f

View file

@ -286,6 +286,10 @@
});
await headscaleDeviceResponse.json().then((data) => {
// flip the sort direction if based on lastSeen
if(sortKey == "lastSeen") {
sortDirection == 'ascending' ? sortDirection = 'descending' : sortDirection = 'ascending';
}
if (sortDirection == 'ascending') {
headscaleDevices = data.machines.sort((a: Device, b: Device) => (a[sortKey as keyof Device] < b[sortKey as keyof Device] ? -1 : 1));
} else {