From 3bfea8783d1d4417d5036dd7976a4d208da83b75 Mon Sep 17 00:00:00 2001
From: TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com>
Date: Sun, 24 Apr 2022 14:08:44 -0400
Subject: [PATCH 1/2] Fix Device Paths
- Fix leveling instances
- Account for other uncommon circle instances
- Add 'radius' to gql api
- Version bump
---
package.json | 2 +-
server/src/graphql/scannerTypes.js | 1 +
server/src/models/Device.js | 2 ++
src/components/popups/DevicePoly.jsx | 19 +++++++++++++++++--
src/services/queries/device.js | 1 +
5 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/package.json b/package.json
index 072fd2939..634d46006 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "reactmap",
- "version": "1.2.1",
+ "version": "1.2.2",
"description": "React based frontend map.",
"main": "ReactMap.mjs",
"author": "TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com>",
diff --git a/server/src/graphql/scannerTypes.js b/server/src/graphql/scannerTypes.js
index d4de60488..e6db35ff9 100644
--- a/server/src/graphql/scannerTypes.js
+++ b/server/src/graphql/scannerTypes.js
@@ -10,6 +10,7 @@ module.exports = gql`
type: String
isMad: Boolean
route: JSON
+ radius: Int
}
type Gym {
diff --git a/server/src/models/Device.js b/server/src/models/Device.js
index 76b45f8e9..2bcdb8943 100644
--- a/server/src/models/Device.js
+++ b/server/src/models/Device.js
@@ -36,6 +36,8 @@ module.exports = class Device extends Model {
'instance_name',
raw('json_extract(data, "$.area")')
.as('route'),
+ raw('json_extract(data, "$.radius")')
+ .as('radius'),
)
}
if (areaRestrictions.length) {
diff --git a/src/components/popups/DevicePoly.jsx b/src/components/popups/DevicePoly.jsx
index 13f354599..6cc13413d 100644
--- a/src/components/popups/DevicePoly.jsx
+++ b/src/components/popups/DevicePoly.jsx
@@ -1,14 +1,29 @@
/* eslint-disable react/no-array-index-key */
import React, { memo } from 'react'
-import { Polyline, Polygon } from 'react-leaflet'
+import { Polyline, Polygon, Circle } from 'react-leaflet'
const DevicePoly = ({ device, color }) => {
if (typeof device.route === 'string') {
device.route = JSON.parse(device.route)
}
+ if (device.type === 'leveling') {
+ return (
+ <>
+
+
+ >
+ )
+ }
const arrayRoute = device.route[0].lat ? [device.route] : device.route
if (Array.isArray(arrayRoute)) {
- return device.type === 'circle_pokemon'
+ return device?.type?.includes('circle')
? arrayRoute.map((polygon, i) => (
Date: Sun, 24 Apr 2022 14:12:48 -0400
Subject: [PATCH 2/2] Return nothing if route is missing for some reason
---
src/components/popups/DevicePoly.jsx | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/components/popups/DevicePoly.jsx b/src/components/popups/DevicePoly.jsx
index 6cc13413d..01ed77af1 100644
--- a/src/components/popups/DevicePoly.jsx
+++ b/src/components/popups/DevicePoly.jsx
@@ -3,6 +3,8 @@ import React, { memo } from 'react'
import { Polyline, Polygon, Circle } from 'react-leaflet'
const DevicePoly = ({ device, color }) => {
+ if (!device.route) return null
+
if (typeof device.route === 'string') {
device.route = JSON.parse(device.route)
}