Added servant filter
This commit is contained in:
parent
71eb64c5e1
commit
3d7cdbf6dc
|
@ -1,10 +1,10 @@
|
||||||
import prisma from '../../prisma'
|
import prisma from '../../prisma'
|
||||||
import { getSubnetInfo } from '../../utils/subnetInfo'
|
import { getSubnetInfo } from '../../utils/subnetInfo'
|
||||||
|
|
||||||
export async function userPresence(_, { search }) {
|
export async function userPresence(_, { search, onlyServants }) {
|
||||||
if (!search) search = ''
|
if (!search) search = ''
|
||||||
|
|
||||||
const usersWithWifiDevices = await prisma.user.findMany({
|
let usersWithWifiDevices = await prisma.user.findMany({
|
||||||
where: {
|
where: {
|
||||||
wifiDevices: { some: { lastSeen: { not: null } } }
|
wifiDevices: { some: { lastSeen: { not: null } } }
|
||||||
},
|
},
|
||||||
|
@ -16,6 +16,11 @@ export async function userPresence(_, { search }) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (onlyServants)
|
||||||
|
usersWithWifiDevices = usersWithWifiDevices.filter(
|
||||||
|
({ extensionAttribute2 }) => extensionAttribute2 == 'Técnico-administrativo' || extensionAttribute2 == 'Docente'
|
||||||
|
)
|
||||||
|
|
||||||
search = search.toLowerCase().trim()
|
search = search.toLowerCase().trim()
|
||||||
|
|
||||||
const filteredUsers = search
|
const filteredUsers = search
|
||||||
|
@ -60,7 +65,7 @@ export async function userPresence(_, { search }) {
|
||||||
return 0
|
return 0
|
||||||
})
|
})
|
||||||
|
|
||||||
return sortedUsers
|
const userPresence = sortedUsers
|
||||||
.map(userPresence => ({
|
.map(userPresence => ({
|
||||||
id: userPresence.id,
|
id: userPresence.id,
|
||||||
displayName: userPresence.displayName,
|
displayName: userPresence.displayName,
|
||||||
|
@ -72,4 +77,6 @@ export async function userPresence(_, { search }) {
|
||||||
campus: getSubnetInfo(userPresence.wifiDevices[0].accessPoint?.ip).shortName
|
campus: getSubnetInfo(userPresence.wifiDevices[0].accessPoint?.ip).shortName
|
||||||
}))
|
}))
|
||||||
.slice(0, 200)
|
.slice(0, 200)
|
||||||
|
|
||||||
|
return userPresence
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ const typeDefs = gql`
|
||||||
stats: Stats!
|
stats: Stats!
|
||||||
|
|
||||||
"Users who has some device currently connected to Wi-Fi"
|
"Users who has some device currently connected to Wi-Fi"
|
||||||
userPresence(search: String = ""): [UserPresence!] @auth(roles: ["watcher"])
|
userPresence(search: String = "", onlyServants: Boolean = false): [UserPresence!] @auth(roles: ["watcher"])
|
||||||
|
|
||||||
"Devices that uses the Wi-Fi"
|
"Devices that uses the Wi-Fi"
|
||||||
wifiDevices(
|
wifiDevices(
|
||||||
|
|
|
@ -1,57 +1,25 @@
|
||||||
<template>
|
<template>
|
||||||
<v-container fluid class="mb-12">
|
<v-container fluid class="mb-12">
|
||||||
<v-toolbar class="mb-2" flat outlined max-width="400px">
|
<v-toolbar class="mb-2" flat outlined max-width="600px">
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="search"
|
v-model="search"
|
||||||
|
class="mr-4"
|
||||||
label="Pesquisar"
|
label="Pesquisar"
|
||||||
prepend-icon="mdi-account-search"
|
prepend-icon="mdi-account-search"
|
||||||
clearable
|
clearable
|
||||||
hide-details
|
hide-details
|
||||||
:loading="$apollo.queries.userPresence.loading"
|
:loading="$apollo.queries.userPresence.loading"
|
||||||
/>
|
/>
|
||||||
<v-dialog v-model="helpDialog" width="500px">
|
|
||||||
<template #activator="{ on, attrs }">
|
|
||||||
<v-btn class="ml-1" color="info" dark v-bind="attrs" icon v-on="on">
|
|
||||||
<v-icon>mdi-help</v-icon>
|
|
||||||
</v-btn>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<v-card>
|
<v-checkbox
|
||||||
<v-card-title class="headline primary white--text">
|
v-model="onlyServants"
|
||||||
Como pesquisar
|
class="mt-5 ml-4"
|
||||||
</v-card-title>
|
hint="Somente servidores"
|
||||||
<v-card-text>
|
label="Somente servidores"
|
||||||
Você pode pesquisar usuários pelo nome, SIAPE, CPF, setor do SUAP,
|
v-bind="attrs"
|
||||||
nome do Access Point, função do servidor, endereço IP dentre
|
v-on="on"
|
||||||
outros.<br />
|
>
|
||||||
Exemplos:
|
</v-checkbox>
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
<code>jose</code>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<code>pp</code>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<code>sala 102</code>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<code>10.7</code>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<code>PP-CEREL</code>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</v-card-text>
|
|
||||||
|
|
||||||
<v-divider></v-divider>
|
|
||||||
|
|
||||||
<v-card-actions>
|
|
||||||
<v-spacer></v-spacer>
|
|
||||||
<v-btn color="primary" text @click="helpDialog = false">OK</v-btn>
|
|
||||||
</v-card-actions>
|
|
||||||
</v-card>
|
|
||||||
</v-dialog>
|
|
||||||
</v-toolbar>
|
</v-toolbar>
|
||||||
|
|
||||||
<div v-if="stats" class="text-center my-4">
|
<div v-if="stats" class="text-center my-4">
|
||||||
|
@ -209,6 +177,49 @@
|
||||||
Ordenando por <em>"visto por último"</em>
|
Ordenando por <em>"visto por último"</em>
|
||||||
</span>
|
</span>
|
||||||
<v-spacer />
|
<v-spacer />
|
||||||
|
<v-dialog v-model="helpDialog" width="500px">
|
||||||
|
<template #activator="{ on, attrs }">
|
||||||
|
<v-btn color="info" dark icon v-bind="attrs" v-on="on">
|
||||||
|
<v-icon>mdi-help</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<v-card>
|
||||||
|
<v-card-title class="headline primary white--text">
|
||||||
|
Como pesquisar
|
||||||
|
</v-card-title>
|
||||||
|
<v-card-text>
|
||||||
|
Você pode pesquisar usuários pelo nome, SIAPE, CPF, setor do SUAP,
|
||||||
|
nome do Access Point, função do servidor, endereço IP dentre
|
||||||
|
outros.<br />
|
||||||
|
Exemplos:
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<code>jose</code>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<code>pp</code>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<code>sala 102</code>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<code>10.7</code>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<code>PP-CEREL</code>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</v-card-text>
|
||||||
|
|
||||||
|
<v-divider></v-divider>
|
||||||
|
|
||||||
|
<v-card-actions>
|
||||||
|
<v-spacer></v-spacer>
|
||||||
|
<v-btn color="primary" text @click="helpDialog = false">OK</v-btn>
|
||||||
|
</v-card-actions>
|
||||||
|
</v-card>
|
||||||
|
</v-dialog>
|
||||||
<v-btn
|
<v-btn
|
||||||
:elevation="0"
|
:elevation="0"
|
||||||
:disabled="
|
:disabled="
|
||||||
|
@ -268,11 +279,13 @@ export default {
|
||||||
components: { Avatar },
|
components: { Avatar },
|
||||||
data: () => {
|
data: () => {
|
||||||
const pageSize = 12
|
const pageSize = 12
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pageSize,
|
pageSize,
|
||||||
search: '',
|
search: '',
|
||||||
resultSize: pageSize,
|
resultSize: pageSize,
|
||||||
helpDialog: false
|
helpDialog: false,
|
||||||
|
onlyServants: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -295,8 +308,8 @@ export default {
|
||||||
userPresence: {
|
userPresence: {
|
||||||
// fetchPolicy: 'cache-and-network',
|
// fetchPolicy: 'cache-and-network',
|
||||||
query: gql`
|
query: gql`
|
||||||
query ($search: String = "") {
|
query ($search: String = "", $onlyServants: Boolean = false) {
|
||||||
userPresence(search: $search) {
|
userPresence(search: $search, onlyServants: $onlyServants) {
|
||||||
id
|
id
|
||||||
displayName
|
displayName
|
||||||
thumbnailPhoto
|
thumbnailPhoto
|
||||||
|
@ -310,7 +323,8 @@ export default {
|
||||||
`,
|
`,
|
||||||
variables() {
|
variables() {
|
||||||
return {
|
return {
|
||||||
search: this.search?.trim()
|
search: this.search?.trim(),
|
||||||
|
onlyServants: this.onlyServants
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
debounce: 250
|
debounce: 250
|
||||||
|
|
Loading…
Reference in New Issue
Block a user