Fix wifidevices update

This commit is contained in:
Douglas Barone 2022-12-08 11:54:09 -04:00
parent f6029ae134
commit db7090ab5d
4 changed files with 33 additions and 14 deletions

View File

@ -9,7 +9,7 @@
"version": "3.3.9", "version": "3.3.9",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@prisma/client": "^4.2.1", "@prisma/client": "^4.7.1",
"activedirectory2": "^2.1.0", "activedirectory2": "^2.1.0",
"apollo-server": "^2.19.0", "apollo-server": "^2.19.0",
"apollo-server-plugin-response-cache": "^0.5.6", "apollo-server-plugin-response-cache": "^0.5.6",
@ -37,7 +37,7 @@
"@babel/plugin-proposal-object-rest-spread": "^7.16.0", "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
"@babel/preset-env": "^7.16.0", "@babel/preset-env": "^7.16.0",
"nodemon": "^2.0.15", "nodemon": "^2.0.15",
"prisma": "^4.2.1" "prisma": "^4.7.1"
} }
}, },
"node_modules/@ampproject/remapping": { "node_modules/@ampproject/remapping": {

View File

@ -37,10 +37,10 @@
"@babel/plugin-proposal-object-rest-spread": "^7.16.0", "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
"@babel/preset-env": "^7.16.0", "@babel/preset-env": "^7.16.0",
"nodemon": "^2.0.15", "nodemon": "^2.0.15",
"prisma": "^4.2.1" "prisma": "^4.7.1"
}, },
"dependencies": { "dependencies": {
"@prisma/client": "^4.2.1", "@prisma/client": "^4.7.1",
"activedirectory2": "^2.1.0", "activedirectory2": "^2.1.0",
"apollo-server": "^2.19.0", "apollo-server": "^2.19.0",
"apollo-server-plugin-response-cache": "^0.5.6", "apollo-server-plugin-response-cache": "^0.5.6",

View File

@ -103,11 +103,13 @@ async function updateDB(onlineDevices) {
where: { mac: device.mac }, where: { mac: device.mac },
create: { create: {
...device, ...device,
network: { network: network.id
connect: { ? {
id: network.id connect: {
} id: network.id
}, }
}
: undefined,
hostname, hostname,
firstSeen: device.firstSeen || new Date(), firstSeen: device.firstSeen || new Date(),
user, user,
@ -119,11 +121,15 @@ async function updateDB(onlineDevices) {
}, },
update: { update: {
...device, ...device,
network: { network: network.id
connect: { ? {
id: network.id connect: {
} id: network.id
}, }
}
: {
disconnect: true
},
hostname, hostname,
user, user,
accessPoint: { accessPoint: {

View File

@ -63,6 +63,9 @@ const typeDefs = gql`
"One Access Point" "One Access Point"
accessPoint(id: ID!): AccessPoint! @auth(roles: ["superAdmin"]) accessPoint(id: ID!): AccessPoint! @auth(roles: ["superAdmin"])
"All Subnets"
subnets: [SubnetInfo!]! @auth(roles: ["superAdmin"])
} }
type Mutation { type Mutation {
@ -363,6 +366,15 @@ const typeDefs = gql`
sumUsage: String sumUsage: String
} }
"A Subnet stats"
type SubnetStats {
id: ID!
timestamp: String
clients: Int
avgUsage: Int
sumUsage: Int
}
"A WiFi Device Search result" "A WiFi Device Search result"
type WifiDevicesResult { type WifiDevicesResult {
data: [WifiDevice!]! data: [WifiDevice!]!
@ -388,6 +400,7 @@ const typeDefs = gql`
subnetMaskLength: String! subnetMaskLength: String!
numHosts: String! numHosts: String!
length: String! length: String!
stats: SubnetStats!
} }
input LoginInput { input LoginInput {