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:
csawatzky 2025-06-30 16:46:39 -06:00
parent 27228602e7
commit 5607672a4b
5 changed files with 39 additions and 6 deletions

View file

@ -148,6 +148,7 @@ export interface IDeviceAPIContext {
keys?: string[],
types?: string[]
) => Promise<any>;
removeFoundComponents: (id: number, key: string, otherTeam?: string) => Promise<AxiosResponse<pond.RemoveFoundComponentsResponse>>;
}
export const DeviceAPIContext = createContext<IDeviceAPIContext>({} as IDeviceAPIContext);
@ -974,6 +975,19 @@ export default function DeviceProvider(props: PropsWithChildren<Props>) {
})
}
const removeFoundComponents = (id: number, key: string, otherTeam?: string) => {
let url = "/devices/" + id + "/removeFoundComponents/" + key;
const view = otherTeam ? otherTeam : as
if(view) url = url + "?as=" + view
return new Promise<AxiosResponse<pond.RemoveFoundComponentsResponse>>((resolve, reject) => {
del<pond.RemoveFoundComponentsResponse>(pondURL(url)).then(resp => {
return resolve(resp)
}).catch(err => {
return reject(err)
})
})
}
return (
<DeviceAPIContext.Provider
value={{
@ -1021,7 +1035,8 @@ export default function DeviceProvider(props: PropsWithChildren<Props>) {
updateComponentPreferences,
listDeviceComponentPreferences,
detectI2C,
listFoundComponents
listFoundComponents,
removeFoundComponents
}}>
{children}
</DeviceAPIContext.Provider>