Detect offline APs
This commit is contained in:
parent
05c3fc3e0e
commit
56dd500027
|
@ -39,7 +39,23 @@ export async function updateAccessPoints() {
|
||||||
|
|
||||||
const accessPoints = await getAccessPoints()
|
const accessPoints = await getAccessPoints()
|
||||||
|
|
||||||
const dbAccessPoints = await updateDB(accessPoints)
|
const updatedAccessPoints = await updateDB(accessPoints)
|
||||||
|
|
||||||
|
const dbAccessPoints = await prisma.accessPoint.findMany()
|
||||||
|
|
||||||
|
const offLineAps = dbAccessPoints.filter(dbAccessPoint => !updatedAccessPoints.find(updatedAccessPoint => updatedAccessPoint.mac === dbAccessPoint.mac))
|
||||||
|
|
||||||
|
await prisma.accessPoint.updateMany({
|
||||||
|
where: {
|
||||||
|
mac: {
|
||||||
|
in: offLineAps.map(offLineAccessPoint => offLineAccessPoint.mac)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
uptime: "-1"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
pubsub.publish(ACCESS_POINTS_UPDATED, { accessPointsUpdated: dbAccessPoints })
|
pubsub.publish(ACCESS_POINTS_UPDATED, { accessPointsUpdated: dbAccessPoints })
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,7 +206,7 @@ export async function getAccessPoints() {
|
||||||
({ mac, model, ip, uptime, name, num_sta }) => ({
|
({ mac, model, ip, uptime, name, num_sta }) => ({
|
||||||
mac,
|
mac,
|
||||||
hostname: name,
|
hostname: name,
|
||||||
uptime: uptime?.toString(),
|
uptime: uptime ? uptime.toString() : "-1",
|
||||||
controller: 'UniFi',
|
controller: 'UniFi',
|
||||||
model,
|
model,
|
||||||
ip,
|
ip,
|
||||||
|
|
|
@ -137,6 +137,7 @@
|
||||||
<template #[`item.clients`]="{ item }">
|
<template #[`item.clients`]="{ item }">
|
||||||
<div class="align-content-end">
|
<div class="align-content-end">
|
||||||
<v-btn
|
<v-btn
|
||||||
|
:disabled="item.uptime === '-1'"
|
||||||
block
|
block
|
||||||
small
|
small
|
||||||
rounded
|
rounded
|
||||||
|
@ -154,12 +155,12 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #[`item.uptime`]="{ item }">
|
<template #[`item.uptime`]="{ item }">
|
||||||
<span v-if="item.uptime">
|
<span v-if="item.uptime > 0">
|
||||||
<small>
|
<small>
|
||||||
{{ item.uptime | durationFromSeconds }}
|
{{ item.uptime | durationFromSeconds }}
|
||||||
</small>
|
</small>
|
||||||
</span>
|
</span>
|
||||||
<span v-else> Off-line </span>
|
<span v-else><small> Off-line ou não registrado</small> </span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #[`item.updatedAt`]="{ item }">
|
<template #[`item.updatedAt`]="{ item }">
|
||||||
|
@ -214,7 +215,7 @@ export default {
|
||||||
{
|
{
|
||||||
text: 'Clientes',
|
text: 'Clientes',
|
||||||
value: 'clients',
|
value: 'clients',
|
||||||
width: 140,
|
width: 130,
|
||||||
align: 'center'
|
align: 'center'
|
||||||
},
|
},
|
||||||
{ text: 'Uptime', value: 'uptime' },
|
{ text: 'Uptime', value: 'uptime' },
|
||||||
|
|
Loading…
Reference in New Issue
Block a user