Merge branch 'onewire_detect' into staging_environment
This commit is contained in:
commit
a7fee2f76d
13 changed files with 380 additions and 24 deletions
|
|
@ -23,6 +23,7 @@ export interface IDeviceAPIContext {
|
|||
) => Promise<AxiosResponse<pond.GetDevicePageDataResponse>>;
|
||||
getMulti: (ids: number[] | string[], otherTeam?: string) => Promise<AxiosResponse<pond.GetMultiDeviceResponse>>;
|
||||
detectI2C: (id: number, otherTeam?: string) => Promise<AxiosResponse<pond.DetectI2CResponse>>;
|
||||
detectOneWire: (id: number, port: number, otherTeam?: string) => Promise<AxiosResponse<pond.DetectOneWireResponse>>
|
||||
listFoundComponents: (id: number, otherTeam?: string) => Promise<AxiosResponse<pond.ListFoundComponentsResponse>>
|
||||
getGeoJson: (id: number | string, demo?: boolean, otherTeam?: string) => Promise<any>;
|
||||
getMultiGeoJson: (ids: number[] | string[], otherTeam?: string) => Promise<any>;
|
||||
|
|
@ -148,7 +149,8 @@ export interface IDeviceAPIContext {
|
|||
keys?: string[],
|
||||
types?: string[]
|
||||
) => Promise<any>;
|
||||
removeFoundComponents: (id: number, key: string, otherTeam?: string) => Promise<AxiosResponse<pond.RemoveFoundComponentsResponse>>;
|
||||
removeAllFoundComponents: (id: number,otherTeam?: string) => Promise<AxiosResponse<pond.RemoveAllFoundComponentsResponse>>;
|
||||
removeFoundComponents: (id: number, key: string, type: pond.ObjectType, otherTeam?: string) => Promise<AxiosResponse<pond.RemoveFoundComponentsResponse>>;
|
||||
}
|
||||
|
||||
export const DeviceAPIContext = createContext<IDeviceAPIContext>({} as IDeviceAPIContext);
|
||||
|
|
@ -962,6 +964,19 @@ export default function DeviceProvider(props: PropsWithChildren<Props>) {
|
|||
})
|
||||
}
|
||||
|
||||
const detectOneWire = (id: number, port: number, otherTeam?: string) => {
|
||||
let url = "/devices/" + id + "/detectOneWire?port=" + port;
|
||||
const view = otherTeam ? otherTeam : as
|
||||
if(view) url = url + "?as=" + view
|
||||
return new Promise<AxiosResponse<pond.DetectOneWireResponse>>((resolve, reject) => {
|
||||
put<pond.DetectOneWireResponse>(pondURL(url)).then(resp => {
|
||||
return resolve(resp)
|
||||
}).catch(err => {
|
||||
return reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const listFoundComponents = (id: number, otherTeam?: string) => {
|
||||
let url = "/devices/" + id + "/listScannedComponents";
|
||||
const view = otherTeam ? otherTeam : as
|
||||
|
|
@ -975,10 +990,10 @@ export default function DeviceProvider(props: PropsWithChildren<Props>) {
|
|||
})
|
||||
}
|
||||
|
||||
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<AxiosResponse<pond.RemoveFoundComponentsResponse>>((resolve, reject) => {
|
||||
del<pond.RemoveFoundComponentsResponse>(pondURL(url)).then(resp => {
|
||||
return resolve(resp)
|
||||
|
|
@ -988,6 +1003,19 @@ export default function DeviceProvider(props: PropsWithChildren<Props>) {
|
|||
})
|
||||
}
|
||||
|
||||
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<AxiosResponse<pond.RemoveAllFoundComponentsResponse>>((resolve, reject) => {
|
||||
del<pond.RemoveAllFoundComponentsResponse>(pondURL(url)).then(resp => {
|
||||
return resolve(resp)
|
||||
}).catch(err => {
|
||||
return reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<DeviceAPIContext.Provider
|
||||
value={{
|
||||
|
|
@ -1035,8 +1063,10 @@ export default function DeviceProvider(props: PropsWithChildren<Props>) {
|
|||
updateComponentPreferences,
|
||||
listDeviceComponentPreferences,
|
||||
detectI2C,
|
||||
detectOneWire,
|
||||
listFoundComponents,
|
||||
removeFoundComponents
|
||||
removeFoundComponents,
|
||||
removeAllFoundComponents
|
||||
}}>
|
||||
{children}
|
||||
</DeviceAPIContext.Provider>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue