Merge branch 'object_status' into staging_environment
This commit is contained in:
commit
cc4d0d5736
7 changed files with 295 additions and 93 deletions
|
|
@ -36,6 +36,7 @@ export interface IInteractionsAPIContext {
|
|||
alerts: pond.AlertData[],
|
||||
otherTeam?: string
|
||||
) => Promise<AxiosResponse<pond.SetAlertInteractionsResponse>>;
|
||||
clearInteractions: (device: number, sources?: quack.ComponentID[], otherTeam?: string) => Promise<AxiosResponse<pond.ClearInteractionsResponse>>
|
||||
}
|
||||
|
||||
export const InteractionsAPIContext = createContext<IInteractionsAPIContext>(
|
||||
|
|
@ -285,6 +286,25 @@ export default function InteractionProvider(props: PropsWithChildren<Props>) {
|
|||
})
|
||||
};
|
||||
|
||||
const clearInteractions = (device: number, sources?: quack.ComponentID[], otherTeam?: string): Promise<AxiosResponse<pond.ClearInteractionsResponse>> => {
|
||||
const view = otherTeam ? otherTeam : as
|
||||
let sourceArray: string[] = []
|
||||
if (sources){
|
||||
sources.forEach(source => {
|
||||
sourceArray.push(componentIDToString(source))
|
||||
})
|
||||
}
|
||||
let url = pondURL("/devices/"+ device + "/interactions/clear" + (view ? "?as=" + view : "") + (sources ? "&sources=" + sourceArray.toString() : ""))
|
||||
return new Promise<AxiosResponse<pond.ClearInteractionsResponse>>((resolve, reject) => {
|
||||
post<pond.ClearInteractionsResponse>(url).then(resp => {
|
||||
resp.data = pond.ClearInteractionsResponse.fromObject(resp.data)
|
||||
return resolve(resp)
|
||||
}).catch(err => {
|
||||
return reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<InteractionsAPIContext.Provider
|
||||
value={{
|
||||
|
|
@ -296,7 +316,8 @@ export default function InteractionProvider(props: PropsWithChildren<Props>) {
|
|||
updateInteractionPondSettings,
|
||||
removeInteraction,
|
||||
listInteractionsByDevice,
|
||||
listInteractionsByComponent
|
||||
listInteractionsByComponent,
|
||||
clearInteractions
|
||||
}}>
|
||||
{children}
|
||||
</InteractionsAPIContext.Provider>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue