Compare commits

..

No commits in common. "4dd4bfc8e60920b702755ffe2084fca3791e8b30" and "9964c5fac644c0f4d65164c7e0ef3a8525cbf719" have entirely different histories.

7 changed files with 11 additions and 15 deletions

View File

@ -1,12 +1,12 @@
{ {
"name": "ifms-pti-svr", "name": "ifms-pti-svr",
"version": "3.8.2", "version": "3.8.1",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "ifms-pti-svr", "name": "ifms-pti-svr",
"version": "3.8.2", "version": "3.8.1",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@prisma/client": "^5.5.2", "@prisma/client": "^5.5.2",

View File

@ -1,6 +1,6 @@
{ {
"name": "ifms-pti-svr", "name": "ifms-pti-svr",
"version": "3.8.2", "version": "3.8.1",
"description": "Servidor do Portal de TI do IFMS", "description": "Servidor do Portal de TI do IFMS",
"main": "src/index.js", "main": "src/index.js",
"prisma": { "prisma": {

View File

@ -38,14 +38,14 @@ async function getOnlineDevices() {
} }
async function updateDevicesStatus(onlineDevices) { async function updateDevicesStatus(onlineDevices) {
const now = new Date() const lastSeenThreshold = subMinutes(new Date(), RECENT_THRESHOLD_IN_MINUTES)
const lastSeenThreshold = subMinutes(now, RECENT_THRESHOLD_IN_MINUTES)
const onlineDevicesMacs = onlineDevices.map(device => device.mac) const onlineDevicesMacs = onlineDevices.map(device => device.mac)
const recent = prisma.wifiDevice.updateMany({ const recent = prisma.wifiDevice.updateMany({
where: { where: {
lastSeen: { gt: lastSeenThreshold }, lastSeen: { gt: lastSeenThreshold },
status: 'ONLINE',
mac: { notIn: onlineDevicesMacs } mac: { notIn: onlineDevicesMacs }
}, },
data: { status: 'RECENT' } data: { status: 'RECENT' }
@ -54,6 +54,7 @@ async function updateDevicesStatus(onlineDevices) {
const offline = prisma.wifiDevice.updateMany({ const offline = prisma.wifiDevice.updateMany({
where: { where: {
lastSeen: { lte: lastSeenThreshold }, lastSeen: { lte: lastSeenThreshold },
status: { not: 'OFFLINE' },
mac: { notIn: onlineDevicesMacs } mac: { notIn: onlineDevicesMacs }
}, },
data: { status: 'OFFLINE' } data: { status: 'OFFLINE' }

View File

@ -47,21 +47,19 @@ const User = {
isWatcher: parent => parent.roles.includes('watcher'), isWatcher: parent => parent.roles.includes('watcher'),
wifiDevices: async (parent, data, { auth }) => { wifiDevices: (parent, data, { auth }) => {
if ( if (
parent.sAMAccountName !== auth.sAMAccountName && parent.sAMAccountName !== auth.sAMAccountName &&
!auth.roles.includes('superAdmin') !auth.roles.includes('superAdmin')
) )
return [] return []
const wifiDevices = await prisma.wifiDevice.findMany({ return prisma.wifiDevice.findMany({
where: { where: {
accessPointId: { not: null }, accessPointId: { not: null },
user: { id: parent.id } user: { id: parent.id }
} }
}) })
return wifiDevices
}, },
campus: parent => { campus: parent => {

4
web/package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "ifms-pti", "name": "ifms-pti",
"version": "3.8.2", "version": "3.8.1",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "ifms-pti", "name": "ifms-pti",
"version": "3.8.2", "version": "3.8.1",
"dependencies": { "dependencies": {
"@mdi/font": "^6.9.96", "@mdi/font": "^6.9.96",
"apollo-link-ws": "^1.0.20", "apollo-link-ws": "^1.0.20",

View File

@ -1,6 +1,6 @@
{ {
"name": "ifms-pti", "name": "ifms-pti",
"version": "3.8.2", "version": "3.8.1",
"private": true, "private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",

View File

@ -18,9 +18,6 @@
<v-chip v-if="item.status == 'ONLINE'" color="green" dark x-small> <v-chip v-if="item.status == 'ONLINE'" color="green" dark x-small>
Online Online
</v-chip> </v-chip>
<v-chip v-else-if="item.status == 'RECENT'" color="orange" dark x-small>
Recente
</v-chip>
<v-chip v-else color="grey" dark x-small>Offline</v-chip> <v-chip v-else color="grey" dark x-small>Offline</v-chip>
</template> </template>