Better filtering

This commit is contained in:
Douglas Barone 2020-12-22 12:30:31 -04:00
parent bcbcb36c43
commit 07744878ed
4 changed files with 37 additions and 5 deletions

View File

@ -15,12 +15,17 @@ export async function userPresence(_, { search }) {
const filteredUsers = search const filteredUsers = search
? usersWithWifiDevices.filter( ? usersWithWifiDevices.filter(
user => user =>
user.displayName.toLowerCase().includes(search) || user.displayName?.toLowerCase().includes(search) ||
user.sAMAccountName.toLowerCase().includes(search) || user.sAMAccountName.toLowerCase().includes(search) ||
user.wifiDevices.some( user.title?.toLowerCase().includes(search) ||
user.department?.toLowerCase().includes(search) ||
user.description?.toLowerCase().includes(search) ||
user.wifiDevices?.some(
device => device =>
device.apName.toLowerCase().includes(search) || device.status != 'OFFLINE' &&
device.ip.startsWith(search) (device.apName?.toLowerCase().includes(search) ||
device.ip?.startsWith(search) ||
device.essid?.toLocaleLowerCase().includes(search))
) )
) )
: usersWithWifiDevices : usersWithWifiDevices

View File

@ -1,5 +1,6 @@
import prisma from '../../prisma' import prisma from '../../prisma'
// TODO: Add filtering
export async function wifiDevices(_, { identifiedOnly, nonIdentifiedOnly }) { export async function wifiDevices(_, { identifiedOnly, nonIdentifiedOnly }) {
if (identifiedOnly && nonIdentifiedOnly) if (identifiedOnly && nonIdentifiedOnly)
throw new Error('Invalid combination of filters') throw new Error('Invalid combination of filters')

View File

@ -1,5 +1,6 @@
import prisma from '../../prisma' import prisma from '../../prisma'
// TODO: Add filtering
export async function wifiUsers() { export async function wifiUsers() {
const wifiUsers = await prisma.user.findMany({ const wifiUsers = await prisma.user.findMany({
where: { wifiDevices: { some: { id: { not: undefined } } } }, where: { wifiDevices: { some: { id: { not: undefined } } } },

View File

@ -22,6 +22,30 @@
indeterminate indeterminate
/> />
</v-text-field> </v-text-field>
<v-spacer />
<v-dialog v-model="helpDialog" width="500px">
<template #activator="{ on, attrs }">
<v-btn class="ml-1" color="info" dark v-bind="attrs" v-on="on" icon>
<v-icon>mdi-help</v-icon>
</v-btn>
</template>
<v-card>
<v-card-title class="headline grey lighten-3"> Ajuda </v-card-title>
<v-card-text>
Você pode pesquisar pelo nome, SIAPE, CPF, nome do Access Point,
função do servidor, endereço IP dentre outros.
</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>
<v-progress-linear <v-progress-linear
height="2" height="2"
@ -230,7 +254,8 @@ export default {
return { return {
pageSize, pageSize,
search: '', search: '',
resultSize: pageSize resultSize: pageSize,
helpDialog: false
} }
}, },
apollo: { apollo: {