diff --git a/package-lock.json b/package-lock.json index 5f23d5a..0974c84 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10953,7 +10953,7 @@ }, "node_modules/protobuf-ts": { "version": "1.0.0", - "resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#b230f4b2779d21ca7b502798b1472f667f8bbdc0", + "resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#873cef415993fc91a18e8b3ff80cdc6531f4e78d", "dependencies": { "protobufjs": "^6.8.8" } diff --git a/src/device/DeviceWizard.tsx b/src/device/DeviceWizard.tsx index 6c8f361..cf0a061 100644 --- a/src/device/DeviceWizard.tsx +++ b/src/device/DeviceWizard.tsx @@ -142,8 +142,8 @@ export default function DeviceWizard(props: Props) { )} {selectedPort && - // selectedPort.addressType === quack.AddressType.ADDRESS_TYPE_CONFIGURABLE_PIN_ARRAY && - // device.featureSupported("detectOneWire") && + selectedPort.addressType === quack.AddressType.ADDRESS_TYPE_CONFIGURABLE_PIN_ARRAY && + device.featureSupported("detectOneWire") && selectedPort.autoDetectable && ( { if (scannedComponents.i2c) setScannedI2C(scannedComponents.i2c) @@ -207,8 +208,8 @@ export default function DeviceScannedComponents(props: Props){ setComponents(cloneList) } - const removeScan = (key: string) => { - deviceAPI.removeFoundComponents(device.settings.deviceId, key) + const removeScan = (key: string, type: pond.ObjectType) => { + deviceAPI.removeFoundComponents(device.settings.deviceId, key, type) .then(resp => { console.log("Cleared this scan") }).catch(err => { @@ -216,18 +217,45 @@ export default function DeviceScannedComponents(props: Props){ }) } + const removeAllScans = () => { + deviceAPI.removeAllFoundComponents(device.settings.deviceId) + .then(resp => { + console.log("Cleared all scans") + }).catch(err => { + console.log("There was a problem clearing scans") + }) + } + + const clearWarning = () => { + return ( + {setClearOpen(false)}}> + Clear All Scans + This action will clear all scans for this device. + + + + + + ) + } + return ( + {clearWarning()} + + Sensor Scan + + {scannedI2C !== undefined && - + I2C Sensors - + {validI2CCompAddresses.length > 0 ? validI2CCompAddresses.map((addr, index) => { return ( @@ -244,10 +272,10 @@ export default function DeviceScannedComponents(props: Props){ } - + } {scannedOneWire.length > 0 && - + Pin Port Sensors @@ -265,11 +293,11 @@ export default function DeviceScannedComponents(props: Props){ } }) return( - - + + Port: {portLabel} diff --git a/src/device/autoDetect/OneWire/PortComponent.tsx b/src/device/autoDetect/OneWire/PortComponent.tsx index ee2ab3f..b1e26e1 100644 --- a/src/device/autoDetect/OneWire/PortComponent.tsx +++ b/src/device/autoDetect/OneWire/PortComponent.tsx @@ -1,4 +1,5 @@ -import { Box, Checkbox, MenuItem, TextField, Tooltip } from "@mui/material" +import { Box, Checkbox, Grid2, MenuItem, TextField, Tooltip, Typography } from "@mui/material" +import { useMobile } from "hooks" import { getFriendlyName, getSubtypes, Subtype } from "pbHelpers/ComponentType" import { quack } from "protobuf-ts/quack" import React, { useEffect, useState } from "react" @@ -11,20 +12,21 @@ interface Props { export default function PortComponent(props: Props){ const {compData, componentSelect} = props // const [selectedSubtype, setSelectedSubtype] = useState(0) - const [subtypeVal, setSubtypeVal] = useState("none")//note that this is the friendly name and not the key or the value because it needs to be different from the other alias options + const [subtypeVal, setSubtypeVal] = useState("no subtype")//note that this is the friendly name and not the key or the value because it needs to be different from the other alias options const [subtypeMap, setSubtypeMap] = useState>(new Map()) const [subtypeOptions, setSubtypeOptions] = useState([]) const [added, setAdded] = useState(false) + const isMobile = useMobile() useEffect(()=>{ // setSelectedSubtype(compData.subtype) let validSubtypes: Subtype[] = [] let subMap: Map = new Map() - let subVal: string = "none" + let subVal: string = "no subtype" getSubtypes(compData.type).forEach(option => { if(compData.subtype === option.key || compData.subtype === 0){ validSubtypes.push(option) - if(subVal === "none"){ + if(subVal === "no subtype"){ subVal = option.friendlyName } } @@ -40,13 +42,14 @@ export default function PortComponent(props: Props){ { setSubtypeVal(event.target.value) // setSelectedSubtype(subtypeMap.get(event.target.value) ?? 0) compData.subtype = subtypeMap.get(event.target.value) ?? 0 }} select> - Select the Component Subtype + Select the Component Subtype {subtypeOptions.map((s, i) => ( {s.friendlyName} ))} @@ -71,15 +74,77 @@ export default function PortComponent(props: Props){ ) } + const desktopDisplay = () => { + return ( + + + + + {getFriendlyName(compData.type)} + + + + {subtypeOptions.length < 2 + ? + + {subtypeVal} + + : + subtypeSelector()} + + + + Cable ID: {compData.cableId} + + + + + Nodes: {compData.nodeCount} + + + + {selectCompCheckbox()} + + + + ) + } + + const mobileDisplay = () => { + return( + + + + + {getFriendlyName(compData.type)} + + + Cable ID: {compData.cableId} + + + Nodes: {compData.nodeCount} + + + + {subtypeOptions.length < 2 + ? + + {subtypeVal} + + : + subtypeSelector()} + + + {selectCompCheckbox()} + + + + ) + } + return ( - - {getFriendlyName(compData.type)} - Cable ID: {compData.cableId} - Number of nodes: {compData.nodeCount} - {subtypeOptions.length < 2 ? subtypeVal : subtypeSelector()} - {selectCompCheckbox()} - + {isMobile ? mobileDisplay() : desktopDisplay()} ) } \ No newline at end of file diff --git a/src/device/autoDetect/OneWire/ScannedOneWirePort.tsx b/src/device/autoDetect/OneWire/ScannedOneWirePort.tsx index 4fd99d8..e035660 100644 --- a/src/device/autoDetect/OneWire/ScannedOneWirePort.tsx +++ b/src/device/autoDetect/OneWire/ScannedOneWirePort.tsx @@ -1,4 +1,4 @@ -import { Box, MenuItem, TextField } from "@mui/material" +import { Box, MenuItem, TextField, Typography } from "@mui/material" import { extension, getFriendlyName, getSubtypes, Subtype } from "pbHelpers/ComponentType" import { pond } from "protobuf-ts/pond" import { quack } from "protobuf-ts/quack" @@ -42,13 +42,16 @@ export default function ScannedOneWirePort(props: Props){ return ( - {portComponents.map((compData, i) => { + {portComponents.length > 0 ? portComponents.map((compData, i) => { return ( { componentSelected(checked, component) }}/> ) - })} + }): + + No Components Found + } ) } \ No newline at end of file diff --git a/src/pages/Device.tsx b/src/pages/Device.tsx index e444a83..7344659 100644 --- a/src/pages/Device.tsx +++ b/src/pages/Device.tsx @@ -170,7 +170,7 @@ export default function DevicePage() { deviceAPI.listFoundComponents(parseInt(deviceID)) .then(resp => { console.log(resp.data) - if (resp.data.foundComponents){ + if (resp.data.foundComponents?.i2c || resp.data.foundComponents?.oneWire){ setScannedAddresses(pond.ListFoundComponentsResponse.fromObject(resp.data).foundComponents ?? undefined) } }) @@ -412,7 +412,16 @@ export default function DevicePage() { /> {/* add grid card here for I2C detected components */} - + {(scannedAddresses?.i2c || scannedAddresses?.oneWire) && + + + + } {diagnosticComponents.map(comp => ( Promise; - removeFoundComponents: (id: number, key: string, otherTeam?: string) => Promise>; + removeAllFoundComponents: (id: number,otherTeam?: string) => Promise>; + removeFoundComponents: (id: number, key: string, type: pond.ObjectType, otherTeam?: string) => Promise>; } export const DeviceAPIContext = createContext({} as IDeviceAPIContext); @@ -989,10 +990,10 @@ export default function DeviceProvider(props: PropsWithChildren) { }) } - const removeFoundComponents = (id: number, key: string, otherTeam?: string) => { - let url = "/devices/" + id + "/removeFoundComponents/" + key; + const removeFoundComponents = (id: number, key: string, type: pond.ObjectType, otherTeam?: string) => { + let url = "/devices/" + id + "/removeFoundComponents/" + key + "?scanType=" + type; const view = otherTeam ? otherTeam : as - if(view) url = url + "?as=" + view + if(view) url = url + "&as=" + view return new Promise>((resolve, reject) => { del(pondURL(url)).then(resp => { return resolve(resp) @@ -1002,6 +1003,19 @@ export default function DeviceProvider(props: PropsWithChildren) { }) } + const removeAllFoundComponents = (id: number, otherTeam?: string) => { + let url = "/devices/" + id + "/removeAllFoundComponents"; + const view = otherTeam ? otherTeam : as + if(view) url = url + "?as=" + view + return new Promise>((resolve, reject) => { + del(pondURL(url)).then(resp => { + return resolve(resp) + }).catch(err => { + return reject(err) + }) + }) + } + return ( ) { detectI2C, detectOneWire, listFoundComponents, - removeFoundComponents + removeFoundComponents, + removeAllFoundComponents }}> {children}