adding way of disabling the scan button
the button will be disabled once it has been clicked as well as on the device page if a scan is in progress (there are pending requests)
This commit is contained in:
parent
27228602e7
commit
5607672a4b
5 changed files with 39 additions and 6 deletions
|
|
@ -9,7 +9,7 @@ import ComponentForm from "component/ComponentForm";
|
|||
import { Component, Device } from "models";
|
||||
import { DeviceAvailabilityMap, OffsetAvailabilityMap } from "pbHelpers/DeviceAvailability";
|
||||
import ResponsiveDialog from "common/ResponsiveDialog";
|
||||
import { useComponentAPI, useSnackbar } from "hooks";
|
||||
import { useComponentAPI, useDeviceAPI, useSnackbar } from "hooks";
|
||||
|
||||
interface Props {
|
||||
scannedComponents: pond.ComponentAddressMap
|
||||
|
|
@ -27,6 +27,7 @@ interface CompStep {
|
|||
export default function DeviceScannedComponents(props: Props){
|
||||
const {scannedComponents, device, availablePositions, availableOffsets, refreshCallback} = props
|
||||
const compAPI = useComponentAPI();
|
||||
const deviceAPI = useDeviceAPI()
|
||||
const [scannedI2C, setScannedI2C] = useState<pond.DetectI2C>()
|
||||
const [components, setComponents] = useState<Component[]>([])
|
||||
const [steps, setSteps] = useState<CompStep[]>([]);
|
||||
|
|
@ -180,6 +181,15 @@ export default function DeviceScannedComponents(props: Props){
|
|||
setComponents(cloneList)
|
||||
}
|
||||
|
||||
const removeScan = (key: string) => {
|
||||
deviceAPI.removeFoundComponents(device.settings.deviceId, key)
|
||||
.then(resp => {
|
||||
console.log("Cleared this scan")
|
||||
}).catch(err => {
|
||||
console.log("There was a problem clearing this scan")
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
return (
|
||||
|
|
@ -187,10 +197,11 @@ export default function DeviceScannedComponents(props: Props){
|
|||
<Card raised sx={{padding: 1}}>
|
||||
{scannedI2C !== undefined &&
|
||||
<React.Fragment>
|
||||
<Box>
|
||||
<Box justifyContent="space-between" display="flex">
|
||||
<Typography sx={{fontWeight: 650}}>
|
||||
I2C Sensors
|
||||
</Typography>
|
||||
<Button variant="contained" color="primary" onClick={()=>{removeScan(scannedI2C.key)}}>Clear Scan</Button>
|
||||
</Box>
|
||||
{scannedI2C.settings?.foundAddresses && scannedI2C.settings.foundAddresses.length > 0 ? scannedI2C?.settings?.foundAddresses.map((addr, index) => {
|
||||
return (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue