Edit Access Point OK
This commit is contained in:
parent
f14292c8bd
commit
128de54b9b
|
@ -10,6 +10,8 @@ import { updateAccessPoints } from '../../lib/accessPoints'
|
|||
|
||||
import prisma from '../../prisma'
|
||||
|
||||
import { ACCESS_POINTS_UPDATED, pubsub } from '../../pubsub'
|
||||
|
||||
const Mutation = {
|
||||
async login(parent, { data }) {
|
||||
return User.login(data.username, data.password)
|
||||
|
@ -121,6 +123,29 @@ const Mutation = {
|
|||
})
|
||||
throw e
|
||||
}
|
||||
},
|
||||
async updateAccessPoint(
|
||||
parent,
|
||||
{ data: { id, name, local, notes } },
|
||||
context,
|
||||
info
|
||||
) {
|
||||
console.log(id, name, local, notes)
|
||||
|
||||
const accessPoint = await prisma.accessPoint.update({
|
||||
where: { id: parseInt(id) },
|
||||
data: { name, local, notes }
|
||||
})
|
||||
|
||||
const accessPoints = await prisma.accessPoint.findMany({
|
||||
include: { wifiDevices: true }
|
||||
})
|
||||
|
||||
pubsub.publish(ACCESS_POINTS_UPDATED, {
|
||||
accessPointsUpdated: accessPoints
|
||||
})
|
||||
|
||||
return accessPoint
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -103,6 +103,10 @@ const typeDefs = gql`
|
|||
|
||||
"Force Update Access Points"
|
||||
updateAccessPoints: String! @auth(roles: ["superAdmin"])
|
||||
|
||||
"Update an Access Point"
|
||||
updateAccessPoint(data: UpdateAccessPointInput): AccessPoint!
|
||||
@auth(roles: ["superAdmin"])
|
||||
}
|
||||
|
||||
type Subscription {
|
||||
|
@ -357,6 +361,13 @@ const typeDefs = gql`
|
|||
description: String!
|
||||
note: String
|
||||
}
|
||||
|
||||
input UpdateAccessPointInput {
|
||||
id: ID!
|
||||
name: String
|
||||
local: String
|
||||
notes: String
|
||||
}
|
||||
`
|
||||
|
||||
export { typeDefs }
|
||||
|
|
|
@ -17,14 +17,16 @@
|
|||
label="Nome"
|
||||
hint="Nome amigável ou apelido (opcional)"
|
||||
outlined
|
||||
clearable
|
||||
/>
|
||||
<v-text-field
|
||||
v-model="local"
|
||||
label="Local"
|
||||
hint="Localização aproximada (opcional)"
|
||||
outlined
|
||||
clearable
|
||||
/>
|
||||
<v-textarea v-model="notes" label="Observações" outlined />
|
||||
<v-textarea v-model="notes" label="Observações" outlined clearable />
|
||||
<v-card-actions>
|
||||
<v-spacer />
|
||||
<v-btn color="primary" @click="onUpdateAccessPoint">
|
||||
|
@ -63,7 +65,38 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
onUpdateAccessPoint() {}
|
||||
async onUpdateAccessPoint() {
|
||||
this.errors = []
|
||||
this.loading = true
|
||||
try {
|
||||
await this.$apollo.mutate({
|
||||
mutation: gql`
|
||||
mutation ($id: ID!, $name: String, $local: String, $notes: String) {
|
||||
updateAccessPoint(
|
||||
data: { id: $id, name: $name, local: $local, notes: $notes }
|
||||
) {
|
||||
id
|
||||
name
|
||||
local
|
||||
notes
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
id: this.$route.params.id,
|
||||
name: this.name,
|
||||
local: this.local,
|
||||
notes: this.notes
|
||||
}
|
||||
})
|
||||
|
||||
this.$router.push({ name: 'access-points' })
|
||||
} catch (e) {
|
||||
this.errors = e.graphQLErrors.map(error => error.message)
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
}
|
||||
},
|
||||
apollo: {
|
||||
accessPoint: {
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
:search="search"
|
||||
calculate-widths
|
||||
class="elevation-1"
|
||||
sort-by="ip"
|
||||
:footer-props="{ itemsPerPageOptions: [10, 25, 50, 100, 150] }"
|
||||
>
|
||||
<template #[`item.name`]="{ item }">
|
||||
|
@ -154,8 +155,7 @@ export default {
|
|||
'clients',
|
||||
'uptime',
|
||||
'updatedAt',
|
||||
// 'notes',
|
||||
'controller',
|
||||
'notes',
|
||||
'mac'
|
||||
],
|
||||
allHeaders: [
|
||||
|
|
Loading…
Reference in New Issue
Block a user