diff --git a/server/package-lock.json b/server/package-lock.json index 0e41c69..150f141 100755 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -1,12 +1,12 @@ { "name": "ifms-pti-svr", - "version": "2.12.4", + "version": "2.12.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ifms-pti-svr", - "version": "2.12.4", + "version": "2.12.5", "license": "ISC", "dependencies": { "@prisma/client": "^3.11.0", diff --git a/server/package.json b/server/package.json index 1fdaabd..e4302ac 100755 --- a/server/package.json +++ b/server/package.json @@ -1,6 +1,6 @@ { "name": "ifms-pti-svr", - "version": "2.12.4", + "version": "2.12.5", "description": "Servidor do Portal de TI do IFMS", "main": "src/index.js", "scripts": { diff --git a/server/src/resolvers/Query/wifiDevices.js b/server/src/resolvers/Query/wifiDevices.js index f908c98..e6b2afe 100644 --- a/server/src/resolvers/Query/wifiDevices.js +++ b/server/src/resolvers/Query/wifiDevices.js @@ -1,6 +1,6 @@ import prisma from '../../prisma' -export async function wifiDevices(_, { take = 100, skip = 0, search }) { +export async function wifiDevices(parent, { take = 100, skip = 0, search }) { const mode = 'insensitive' if (search === null) diff --git a/server/src/resolvers/Query/wifiUsers.js b/server/src/resolvers/Query/wifiUsers.js index dcf61fe..5420709 100644 --- a/server/src/resolvers/Query/wifiUsers.js +++ b/server/src/resolvers/Query/wifiUsers.js @@ -1,15 +1,44 @@ import prisma from '../../prisma' // TODO: Add filtering -export async function wifiUsers() { - const wifiUsers = await prisma.user.findMany({ - where: { wifiDevices: { some: { id: { not: undefined } } } }, - include: { wifiDevices: true } - }) +export async function wifiUsers(parent, { take = 100, skip = 0, search }) { + const mode = 'insensitive' - return wifiUsers.sort( - (a, b) => - b.wifiDevices.filter(device => device.status == 'ONLINE').length - - a.wifiDevices.filter(device => device.status == 'ONLINE').length - ) + if (search === null) + search = undefined + + return prisma.user.findMany({ + where: { + AND: [ + { wifiDevices: { some: { id: { not: undefined } } } }, + { + OR: [ + { wifiDevices: { some: { hostname: { contains: search, mode } } } }, + { + wifiDevices: { + some: { + accessPoint: { + OR: [ + { name: { contains: search, mode } }, + { local: { contains: search, mode } }, + ] + } + } + } + }, + { wifiDevices: { some: { mac: { contains: search, mode } } } }, + { wifiDevices: { some: { ip: { contains: search, mode } } } }, + { displayName: { contains: search, mode } }, , + { sAMAccountName: { contains: search, mode } }, + ] + } + ] + }, + include: { wifiDevices: true }, + orderBy: [ + { wifiDevices: { _count: 'desc' } }, + { displayName: 'asc' }], + take, + skip + }) } diff --git a/server/src/typeDefs.js b/server/src/typeDefs.js index e23d8ee..4f24b6a 100644 --- a/server/src/typeDefs.js +++ b/server/src/typeDefs.js @@ -41,7 +41,10 @@ const typeDefs = gql` ): [WifiDevice]! @auth(roles: ["superAdmin"]) "Users that uses the Wi-Fi" - wifiUsers: [User]! @auth(roles: ["superAdmin"]) + wifiUsers( + search: String = "" + take: Int + skip: Int): [User]! @auth(roles: ["superAdmin"]) "Application Logs" logs( diff --git a/web/package-lock.json b/web/package-lock.json index 96ded32..57424ae 100755 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -1,12 +1,12 @@ { "name": "ifms-pti", - "version": "2.12.4", + "version": "2.12.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ifms-pti", - "version": "2.12.4", + "version": "2.12.5", "dependencies": { "@mdi/font": "^6.6.96", "apollo-link-ws": "^1.0.20", diff --git a/web/package.json b/web/package.json index 916bc2b..56a2452 100755 --- a/web/package.json +++ b/web/package.json @@ -1,6 +1,6 @@ { "name": "ifms-pti", - "version": "2.12.4", + "version": "2.12.5", "private": true, "scripts": { "serve": "vue-cli-service serve", diff --git a/web/src/mixins/Nav.js b/web/src/mixins/Nav.js index a7702ed..71a8a7c 100644 --- a/web/src/mixins/Nav.js +++ b/web/src/mixins/Nav.js @@ -59,18 +59,18 @@ export default { route: { name: 'wifi-devices' }, role: 'superAdmin' }, - { - title: 'Access Points', - icon: 'mdi-access-point', - route: { name: 'access-points' }, - role: 'superAdmin' - }, { title: 'Usuários Wi-Fi', icon: 'mdi-account-voice', route: { name: 'wifi-users' }, role: 'superAdmin' }, + { + title: 'Access Points', + icon: 'mdi-access-point', + route: { name: 'access-points' }, + role: 'superAdmin' + }, { title: 'Inspecionar Usuário', icon: 'mdi-account-search', diff --git a/web/src/views/WifiDevices.vue b/web/src/views/WifiDevices.vue index f9b430f..b4cbf19 100644 --- a/web/src/views/WifiDevices.vue +++ b/web/src/views/WifiDevices.vue @@ -1,16 +1,12 @@ - - + + @@ -29,171 +25,172 @@ - - - - {{ stats.onlineWifiDevices }} - - online de - - {{ stats.totalWifiDevices }} - - no total. - - - - - - - - - - - - - - {{ device.hostname }} - - {{ device.ip }} + + {{ stats.onlineWifiDevices }} + + online de + + {{ stats.totalWifiDevices }} + + no total. + + + + + + + + + - - - {{ - device.displayName - }} - - - - - - - - - mdi-wifi - - - - {{ device.essid }} - - SSID - - + + + + + {{ device.hostname }} + + {{ device.ip }} + + + {{ + device.displayName + }} + + + + + + + + + mdi-wifi + + + + {{ device.essid }} + + SSID + + - - - mdi-wifi-off - - - - {{ device.essid }} - - - Dispositivo off-line - - - + + + mdi-wifi-off + + + + {{ device.essid }} + + + Dispositivo off-line + + + - - - mdi-access-point - - - - {{ device.apName }} - - - Access Point ({{ device.controller }}) - - - + + + mdi-access-point + + + + {{ device.apName }} + + + Access Point ({{ device.controller }}) + + + - - - mdi-ip-network - - - - {{ device.ip }} - - - Último endereço IP conhecido - - - - - - mdi-expansion-card-variant - - - - {{ device.mac }} - - - {{ device.oui }} - - - - - - mdi-eye - - - - {{ device.lastSeen | dateAndTime }} - - - Visto pela última vez - - - - - - mdi-check-decagram - - - - {{ device.firstSeen | dateAndTime }} - - - Visto pela primeira vez - - - - - - - - - - {{ device.displayName }} - - - {{ device.sAMAccountName }} - - - - - - - - - - - + + + mdi-ip-network + + + + {{ device.ip }} + + + Último endereço IP conhecido + + + + + + mdi-expansion-card-variant + + + + {{ device.mac }} + + + {{ device.oui }} + + + + + + mdi-eye + + + + {{ device.lastSeen | dateAndTime }} + + + Visto pela última vez + + + + + + mdi-check-decagram + + + + {{ device.firstSeen | dateAndTime }} + + + Visto pela primeira vez + + + + + + + + + + {{ device.displayName }} + + + {{ device.sAMAccountName }} + + + + + + + + + + + São exibidos apenas os 100 primeiros resultados da pesquisa + +