Filter offline clients

This commit is contained in:
Douglas Barone 2022-12-13 08:04:27 -04:00
parent 21be34ee3a
commit 8368d3fede

View File

@ -75,6 +75,8 @@ function getDevices() {
(devices = devices.concat(pageDevices)) (devices = devices.concat(pageDevices))
) )
devices = devices.filter(device => device.ST == 'Online')
resolve(devices) resolve(devices)
} catch (e) { } catch (e) {
logError({ logError({
@ -92,26 +94,28 @@ export async function getOnlineWifiDevices() {
const now = new Date() const now = new Date()
const restructuredOnlineDevices = onlineDevices.map(client => ({ const restructuredOnlineDevices = onlineDevices.map(client => {
user: client.Name == 'unknown' ? null : client.Name, return {
identity: client.Name == 'unknown' ? null : client.Name, user: client.Name == 'unknown' ? null : client.Name,
oui: ouiFinder(client.macaddr), identity: client.Name == 'unknown' ? null : client.Name,
mac: client.macaddr, oui: ouiFinder(client.macaddr),
hostname: client.HN == 'unknown' ? undefined : client.HN, mac: client.macaddr,
firstSeen: undefined, hostname: client.HN == 'unknown' ? undefined : client.HN,
lastSeen: now, firstSeen: undefined,
essid: client.SSID, lastSeen: now,
ip: client.IP, essid: client.SSID,
uptime: +client.UT, ip: client.IP,
apName: client.AP, uptime: +client.UT,
status: client.ST == 'Online' ? 'ONLINE' : 'OFFLINE', apName: client.AP,
controller: 'Cisco', status: client.ST == 'Online' ? 'ONLINE' : 'OFFLINE',
signalStrength: client.SS || null, controller: 'Cisco',
frequency: client.FB, signalStrength: client.SS || null,
protocol: client.PT, frequency: client.FB,
speed: client.SD, protocol: client.PT,
usage: client.bytes_total || 0 speed: client.SD,
})) usage: client.bytes_total || 0
}
})
return restructuredOnlineDevices return restructuredOnlineDevices
} }