updated as in the interactions api

This commit is contained in:
csawatzky 2025-04-21 16:40:30 -06:00
parent e8e32e1886
commit c617ebf868
12 changed files with 66 additions and 50 deletions

View file

@ -94,7 +94,7 @@ export default function BinConditioningInteraction(props: Props) {
const [sliderMarks, setSliderMarks] = useState<Map<quack.MeasurementType, number>>(new Map()); const [sliderMarks, setSliderMarks] = useState<Map<quack.MeasurementType, number>>(new Map());
//this is the emc value calculated from the interactions temp and humidity conditions //this is the emc value calculated from the interactions temp and humidity conditions
const [baseEMC, setBaseEMC] = useState<number | undefined>(); const [baseEMC, setBaseEMC] = useState<number | undefined>();
const [{ user }] = useGlobalState(); const [{ user, as }] = useGlobalState();
const classes = useStyles(); const classes = useStyles();
const interactionAPI = useInteractionsAPI(); const interactionAPI = useInteractionsAPI();
const { openSnack } = useSnackbar(); const { openSnack } = useSnackbar();
@ -144,7 +144,7 @@ export default function BinConditioningInteraction(props: Props) {
const updateInteraction = () => { const updateInteraction = () => {
interactionAPI interactionAPI
.updateInteraction(deviceId, interaction.settings) .updateInteraction(deviceId, interaction.settings, as)
.then(resp => { .then(resp => {
openSnack("Updated Interaction Conditions"); openSnack("Updated Interaction Conditions");
}) })

View file

@ -108,10 +108,10 @@ export default function GrainNodeInteractions(props: Props) {
}, [selectedNode]); }, [selectedNode]);
useEffect(() => { useEffect(() => {
interactionAPI.listInteractionsByComponent(device.id(), cable.location()).then(resp => { interactionAPI.listInteractionsByComponent(device.id(), cable.location(), undefined, as).then(resp => {
setCableInteractions(resp); setCableInteractions(resp);
}); });
}, [cable, device, interactionAPI]); }, [cable, device, interactionAPI, as]);
useEffect(() => { useEffect(() => {
//do the reversing to make the selected node match the array in the //do the reversing to make the selected node match the array in the
@ -163,7 +163,7 @@ export default function GrainNodeInteractions(props: Props) {
//TODO-CS: make function to update multiple interactions at once to avoid this loop if it becomes a problem //TODO-CS: make function to update multiple interactions at once to avoid this loop if it becomes a problem
cableInteractions.forEach(interaction => { cableInteractions.forEach(interaction => {
interactionAPI interactionAPI
.updateInteraction(device.id(), interaction.settings) .updateInteraction(device.id(), interaction.settings, as)
.then(resp => {}) .then(resp => {})
.catch(err => {}); .catch(err => {});
}); });
@ -359,7 +359,7 @@ export default function GrainNodeInteractions(props: Props) {
permissions={permissions} permissions={permissions}
refreshCallback={() => { refreshCallback={() => {
interactionAPI interactionAPI
.listInteractionsByComponent(device.id(), cable.location()) .listInteractionsByComponent(device.id(), cable.location(), undefined, as)
.then(resp => { .then(resp => {
setCableInteractions(resp); setCableInteractions(resp);
}); });
@ -440,7 +440,7 @@ export default function GrainNodeInteractions(props: Props) {
setNewInteraction(false); setNewInteraction(false);
}} }}
refreshCallback={() => { refreshCallback={() => {
interactionAPI.listInteractionsByComponent(device.id(), cable.location()).then(resp => { interactionAPI.listInteractionsByComponent(device.id(), cable.location(), undefined, as).then(resp => {
setCableInteractions(resp); setCableInteractions(resp);
}); });
}} }}

View file

@ -36,6 +36,7 @@ import CableTopNodeSummary from "bin/CableTopNodeSummary";
import { getTemperatureUnit } from "utils"; import { getTemperatureUnit } from "utils";
import { DevicePreset } from "models/DevicePreset"; import { DevicePreset } from "models/DevicePreset";
import { Ambient } from "models/Ambient"; import { Ambient } from "models/Ambient";
import { useGlobalState } from "providers";
/*const useStyles = makeStyles((theme: Theme) => /*const useStyles = makeStyles((theme: Theme) =>
createStyles({ createStyles({
@ -181,6 +182,7 @@ export default function DevicePresets(props: DevicePresetsProps) {
const [heaters, setHeaters] = useState<Controller[]>([]); const [heaters, setHeaters] = useState<Controller[]>([]);
const [fans, setFans] = useState<Component[]>([]); const [fans, setFans] = useState<Component[]>([]);
//const [subscribeBinToAutoTopNode, setSubscribeBinToAutoTopNode] = useState(false); //const [subscribeBinToAutoTopNode, setSubscribeBinToAutoTopNode] = useState(false);
const [{as}] = useGlobalState();
useEffect(() => { useEffect(() => {
if (deviceComponents.get(deviceIndex.toString())) return; if (deviceComponents.get(deviceIndex.toString())) return;
@ -190,7 +192,7 @@ export default function DevicePresets(props: DevicePresetsProps) {
if (!comps) { if (!comps) {
comps = []; comps = [];
setLoading(true); setLoading(true);
let interactionPromise = interactionAPI.listInteractionsByDevice(deviceIndex); let interactionPromise = interactionAPI.listInteractionsByDevice(deviceIndex, undefined, as);
let componentPromise = componentAPI.list(deviceIndex, undefined, [binKey], ["bin"], true); let componentPromise = componentAPI.list(deviceIndex, undefined, [binKey], ["bin"], true);
let dComponents = new Map<string, Component[]>(); let dComponents = new Map<string, Component[]>();
Promise.all([componentPromise, interactionPromise]) Promise.all([componentPromise, interactionPromise])
@ -215,7 +217,7 @@ export default function DevicePresets(props: DevicePresetsProps) {
setLoading(false); setLoading(false);
}); });
} }
}, [deviceIndex, binKey, componentAPI, interactionAPI, deviceComponents]); }, [deviceIndex, binKey, componentAPI, interactionAPI, deviceComponents, as]);
useEffect(() => { useEffect(() => {
if (loading) return; if (loading) return;
@ -604,14 +606,15 @@ export default function DevicePresets(props: DevicePresetsProps) {
return conflicting; return conflicting;
}); });
let deleteConflictingInteractions = conflictingInteractions.map(i => { let deleteConflictingInteractions = conflictingInteractions.map(i => {
return interactionAPI.removeInteraction(deviceIndex, i.key()); return interactionAPI.removeInteraction(deviceIndex, i.key(), as);
}); });
Promise.all([...deleteConflictingInteractions]).finally(() => { Promise.all([...deleteConflictingInteractions]).finally(() => {
if (preset === "shop") { if (preset === "shop") {
if (heater) { if (heater) {
interactionAPI.addInteraction( interactionAPI.addInteraction(
deviceIndex, deviceIndex,
buildHeatingInteraction(preset, sensor, heater, false, "greater") buildHeatingInteraction(preset, sensor, heater, false, "greater"),
as
); );
} }
} }
@ -620,7 +623,8 @@ export default function DevicePresets(props: DevicePresetsProps) {
interactionAPI interactionAPI
.addInteraction( .addInteraction(
deviceIndex, deviceIndex,
buildFanInteraction(preset, sensor, fan, "less", "greater") buildFanInteraction(preset, sensor, fan, "less", "greater"),
as
) )
.then(() => { .then(() => {
setConfirmPreset(null); setConfirmPreset(null);
@ -664,7 +668,7 @@ export default function DevicePresets(props: DevicePresetsProps) {
} }
if (multi.interactions.length > 0) { if (multi.interactions.length > 0) {
interactionAPI interactionAPI
.addMultiInteractions(deviceIndex, multi) .addMultiInteractions(deviceIndex, multi, as)
.then(resp => { .then(resp => {
updateControllers(); updateControllers();
setConfirmPreset(null); setConfirmPreset(null);

View file

@ -68,7 +68,7 @@ interface Props {
export default function Device(props: Props) { export default function Device(props: Props) {
const classes = useStyles(); const classes = useStyles();
const [{ user }] = useGlobalState(); const [{ user, as }] = useGlobalState();
const { error } = useSnackbar(); const { error } = useSnackbar();
const deviceID = props.device.id(); const deviceID = props.device.id();
const deviceAPI = useDeviceAPI(); const deviceAPI = useDeviceAPI();
@ -106,7 +106,7 @@ export default function Device(props: Props) {
["device"], ["device"],
true true
); );
let interactionsPromise = interactionsAPI.listInteractionsByDevice(deviceID); let interactionsPromise = interactionsAPI.listInteractionsByDevice(deviceID, undefined, as);
let groupPromise: Promise<any> = Promise.resolve(undefined); let groupPromise: Promise<any> = Promise.resolve(undefined);
Promise.all([userPromise, componentsPromise, interactionsPromise, groupPromise]) Promise.all([userPromise, componentsPromise, interactionsPromise, groupPromise])
.then(([userRes, componentsRes, interactionsRes]) => { .then(([userRes, componentsRes, interactionsRes]) => {
@ -165,7 +165,7 @@ export default function Device(props: Props) {
// } // }
// }) // })
// .catch(err => {}); // .catch(err => {});
}, [componentAPI, props.device, deviceID, error, interactionsAPI, /*usageAPI*/, userAPI, user]); }, [componentAPI, props.device, deviceID, error, interactionsAPI, /*usageAPI*/, userAPI, user, as]);
useEffect(() => { useEffect(() => {
load(); load();
@ -365,7 +365,7 @@ export default function Device(props: Props) {
device={device} device={device}
isPaused={isPaused()} isPaused={isPaused()}
components={getOrderedComponents()} components={getOrderedComponents()}
//interactions={interactions} interactions={interactions}
availablePositions={availablePositions} availablePositions={availablePositions}
availableOffsets={availableOffsets} availableOffsets={availableOffsets}
permissions={permissions} permissions={permissions}

View file

@ -36,7 +36,7 @@ const densityMap = new Map<number, number>([
//once we have numbers for presets it may never be used again //once we have numbers for presets it may never be used again
export default function GateDeviceInteraction(props: Props) { export default function GateDeviceInteraction(props: Props) {
const { open, close, gate, compDevice, densityTemp } = props; const { open, close, gate, compDevice, densityTemp } = props;
const [{ user }] = useGlobalState(); const [{ user, as }] = useGlobalState();
const [lowDelta, setLowDelta] = useState(0); const [lowDelta, setLowDelta] = useState(0);
const [highDelta, setHighDelta] = useState(0); const [highDelta, setHighDelta] = useState(0);
const [greenComponent, setGreenComponent] = useState<Component>(); const [greenComponent, setGreenComponent] = useState<Component>();
@ -207,7 +207,7 @@ export default function GateDeviceInteraction(props: Props) {
interactions: [greenToggle, redToggle] interactions: [greenToggle, redToggle]
}); });
interactionsAPI interactionsAPI
.addMultiInteractions(deviceID, multi) .addMultiInteractions(deviceID, multi, as)
.then(resp => { .then(resp => {
openSnack("Interactions added"); openSnack("Interactions added");
}) })

View file

@ -134,7 +134,7 @@ export default function InteractionSettings(props: Props) {
const prevComponents = usePrevious(components); const prevComponents = usePrevious(components);
const prevInitialComponent = usePrevious(initialComponent); const prevInitialComponent = usePrevious(initialComponent);
const classes = useStyles(); const classes = useStyles();
const [{ user }] = useGlobalState(); const [{ user, as }] = useGlobalState();
const interactionsAPI = useInteractionsAPI(); const interactionsAPI = useInteractionsAPI();
const [interaction, setInteraction] = useState<Interaction>( const [interaction, setInteraction] = useState<Interaction>(
Interaction.clone(initialInteraction) Interaction.clone(initialInteraction)
@ -307,7 +307,7 @@ export default function InteractionSettings(props: Props) {
switch (mode) { switch (mode) {
case "add": case "add":
interactionsAPI interactionsAPI
.addInteraction(Number(device.settings.deviceId), settings) .addInteraction(Number(device.settings.deviceId), settings, as)
.then(() => { .then(() => {
success("Interaction was successfully created"); success("Interaction was successfully created");
refreshCallback(); refreshCallback();
@ -320,7 +320,7 @@ export default function InteractionSettings(props: Props) {
let s = pond.InteractionPondSettings.create(); let s = pond.InteractionPondSettings.create();
s.sortPriority = interaction.settings.sortPriority; s.sortPriority = interaction.settings.sortPriority;
interactionsAPI interactionsAPI
.updateInteractionPondSettings(Number(device.settings.deviceId), interaction.key(), s) .updateInteractionPondSettings(Number(device.settings.deviceId), interaction.key(), s, as)
.then(() => { .then(() => {
success("Interaction pond settings were successfully updated"); success("Interaction pond settings were successfully updated");
refreshCallback(); refreshCallback();
@ -329,7 +329,7 @@ export default function InteractionSettings(props: Props) {
.finally(() => close()); .finally(() => close());
} else { } else {
interactionsAPI interactionsAPI
.updateInteraction(Number(device.settings.deviceId), settings) .updateInteraction(Number(device.settings.deviceId), settings, as)
.then(() => { .then(() => {
success("Interaction was successfully updated"); success("Interaction was successfully updated");
refreshCallback(); refreshCallback();

View file

@ -35,6 +35,7 @@ import { quack } from "protobuf-ts/quack";
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import InteractionSettings from "./InteractionSettings"; import InteractionSettings from "./InteractionSettings";
import { makeStyles } from "@mui/styles"; import { makeStyles } from "@mui/styles";
import { useGlobalState } from "providers";
const useStyles = makeStyles((theme: Theme) => { const useStyles = makeStyles((theme: Theme) => {
return ({ return ({
@ -70,6 +71,7 @@ interface Props {
export default function InteractionsOverview(props: Props) { export default function InteractionsOverview(props: Props) {
const classes = useStyles(); const classes = useStyles();
const [{as}] = useGlobalState();
const interactionsAPI = useInteractionsAPI(); const interactionsAPI = useInteractionsAPI();
const { success, error } = useSnackbar(); const { success, error } = useSnackbar();
const { device, component, components, permissions, refreshCallback } = props; const { device, component, components, permissions, refreshCallback } = props;
@ -200,7 +202,7 @@ export default function InteractionsOverview(props: Props) {
settings: pond.IInteractionSettings settings: pond.IInteractionSettings
) => { ) => {
interactionsAPI interactionsAPI
.updateInteraction(Number(deviceID), settings) .updateInteraction(Number(deviceID), settings, as)
.then((_response: any) => { .then((_response: any) => {
let updatedDirtyInteractions = cloneDeep(dirtyInteractions); let updatedDirtyInteractions = cloneDeep(dirtyInteractions);
updatedDirtyInteractions.set(index, false); updatedDirtyInteractions.set(index, false);

View file

@ -8,6 +8,7 @@ import {
} from "@mui/material"; } from "@mui/material";
import { useInteractionsAPI, useSnackbar } from "hooks"; import { useInteractionsAPI, useSnackbar } from "hooks";
import { Device, Interaction } from "models"; import { Device, Interaction } from "models";
import { useGlobalState } from "providers";
interface Props { interface Props {
device: Device; device: Device;
@ -19,6 +20,7 @@ interface Props {
export default function RemoveInteraction(props: Props) { export default function RemoveInteraction(props: Props) {
const { device, interaction, isDialogOpen, closeDialogCallback, refreshCallback } = props; const { device, interaction, isDialogOpen, closeDialogCallback, refreshCallback } = props;
const [{as}] = useGlobalState();
const interactionsAPI = useInteractionsAPI(); const interactionsAPI = useInteractionsAPI();
const { success, error, warning } = useSnackbar(); const { success, error, warning } = useSnackbar();
@ -28,7 +30,7 @@ export default function RemoveInteraction(props: Props) {
const submit = () => { const submit = () => {
interactionsAPI interactionsAPI
.removeInteraction(device.id(), interaction.key()) .removeInteraction(device.id(), interaction.key(), as)
.then((response: any) => { .then((response: any) => {
success("Interaction was successfully removed"); success("Interaction was successfully removed");
closeDialog(); closeDialog();

View file

@ -154,7 +154,7 @@ export default function ObjectAlerts(props: Props) {
//get the interactions for the component //get the interactions for the component
let device = componentDevices.get(key); let device = componentDevices.get(key);
if (device !== undefined) { if (device !== undefined) {
await interactionsAPI.listInteractionsByComponent(device, comp.location()).then(resp => { await interactionsAPI.listInteractionsByComponent(device, comp.location(), undefined, as).then(resp => {
if (resp.length > 0) { if (resp.length > 0) {
resp.forEach(interaction => { resp.forEach(interaction => {
icMap.set(interaction.key(), key); icMap.set(interaction.key(), key);
@ -366,7 +366,7 @@ export default function ObjectAlerts(props: Props) {
notify: true notify: true
}); });
interactionsAPI interactionsAPI
.addInteractionToComponents(compIds, newAlert) .addInteractionToComponents(compIds, newAlert, as)
.then(_resp => { .then(_resp => {
openSnack("interaction added to selected components"); openSnack("interaction added to selected components");
}) })

View file

@ -540,7 +540,7 @@ export default function Bins(props: Props) {
}); });
}); });
interactionsAPI interactionsAPI
.setAlertInteractions(alertList) .setAlertInteractions(alertList, as)
.then(resp => { .then(resp => {
openSnack("Successfully added " + resp.data.numAlertsSet + " alerts"); openSnack("Successfully added " + resp.data.numAlertsSet + " alerts");
}) })

View file

@ -131,12 +131,11 @@ export default function DeviceComponent() {
let isInteractionSettingsOpen = let isInteractionSettingsOpen =
JSON.stringify(or(selectedInteraction, getDefaultInteraction())) !== JSON.stringify(or(selectedInteraction, getDefaultInteraction())) !==
JSON.stringify(getDefaultInteraction()); JSON.stringify(getDefaultInteraction());
const [{ user, as }] = useGlobalState(); const [{ user, as, showErrors }] = useGlobalState();
const [unitMeasurements, setUnitMeasurements] = useState<UnitMeasurement[]>([]); const [unitMeasurements, setUnitMeasurements] = useState<UnitMeasurement[]>([]);
const [rm, setRM] = useState<pond.Measurement>(pond.Measurement.create()); const [rm, setRM] = useState<pond.Measurement>(pond.Measurement.create());
const [recentUnitMeasurement, setRecentUnitMeasurement] = useState<UnitMeasurement[]>([]); const [recentUnitMeasurement, setRecentUnitMeasurement] = useState<UnitMeasurement[]>([]);
const [recentGoodUnitMeasurement, setRecentGoodUnitMeasurement] = useState<UnitMeasurement[]>([]); const [recentGoodUnitMeasurement, setRecentGoodUnitMeasurement] = useState<UnitMeasurement[]>([]);
const [{ showErrors }] = useGlobalState();
const sampleLimit = 200; const sampleLimit = 200;
const [deviceComponentPrefs, setDeviceComponentPrefs] = useState< const [deviceComponentPrefs, setDeviceComponentPrefs] = useState<
pond.DeviceComponentPreferences pond.DeviceComponentPreferences
@ -193,7 +192,7 @@ export default function DeviceComponent() {
useEffect(() => { useEffect(() => {
if (component.key() !== "") { if (component.key() !== "") {
interactionsAPI interactionsAPI
.listInteractionsByComponent(deviceID, component.location()) .listInteractionsByComponent(deviceID, component.location(), undefined, as)
.then((rInteractions: Interaction[]) => { .then((rInteractions: Interaction[]) => {
setInteractions(rInteractions); setInteractions(rInteractions);
}) })

View file

@ -10,27 +10,31 @@ import { has } from "utils/types";
import { pondURL } from "./pond"; import { pondURL } from "./pond";
export interface IInteractionsAPIContext { export interface IInteractionsAPIContext {
addInteraction: (device: number, settings: pond.IInteractionSettings) => Promise<AxiosResponse<pond.AddInteractionResponse>>; addInteraction: (device: number, settings: pond.IInteractionSettings, as?: string) => Promise<AxiosResponse<pond.AddInteractionResponse>>;
addMultiInteractions: (device: number, settings: pond.MultiInteractionSettings) => Promise<AxiosResponse<pond.AddMultiInteractionsResponse>>; addMultiInteractions: (device: number, settings: pond.MultiInteractionSettings, as?: string) => Promise<AxiosResponse<pond.AddMultiInteractionsResponse>>;
addInteractionToComponents: ( addInteractionToComponents: (
fullComponentLocations: string[], fullComponentLocations: string[],
settings: pond.IInteractionSettings settings: pond.IInteractionSettings,
as?: string
) => Promise<AxiosResponse<pond.AddInteractionToComponentsResponse>>; ) => Promise<AxiosResponse<pond.AddInteractionToComponentsResponse>>;
updateInteraction: (device: number, settings: pond.IInteractionSettings) => Promise<AxiosResponse<pond.UpdateInteractionResponse>>; updateInteraction: (device: number, settings: pond.IInteractionSettings, as?: string) => Promise<AxiosResponse<pond.UpdateInteractionResponse>>;
updateInteractionPondSettings: ( updateInteractionPondSettings: (
device: number, device: number,
interaction: string, interaction: string,
settings: pond.IInteractionPondSettings settings: pond.IInteractionPondSettings,
as?: string
) => Promise<AxiosResponse<pond.UpdateInteractionPondSettingsResponse>>; ) => Promise<AxiosResponse<pond.UpdateInteractionPondSettingsResponse>>;
removeInteraction: (device: number, interaction: string) => Promise<AxiosResponse<pond.RemoveInteractionResponse>>; removeInteraction: (device: number, interaction: string, as?: string) => Promise<AxiosResponse<pond.RemoveInteractionResponse>>;
listInteractionsByDevice: (device: number | string, demo?: boolean) => Promise<Interaction[]>; listInteractionsByDevice: (device: number | string, demo?: boolean, as?: string) => Promise<Interaction[]>;
listInteractionsByComponent: ( listInteractionsByComponent: (
device: number, device: number,
component: quack.ComponentID, component: quack.ComponentID,
demo?: boolean demo?: boolean,
as?: string
) => Promise<Interaction[]>; ) => Promise<Interaction[]>;
setAlertInteractions: ( setAlertInteractions: (
alerts: pond.AlertData[] alerts: pond.AlertData[],
as?: string
) => Promise<AxiosResponse<pond.SetAlertInteractionsResponse>>; ) => Promise<AxiosResponse<pond.SetAlertInteractionsResponse>>;
} }
@ -56,9 +60,9 @@ function sanitizeInteraction(interaction: pond.IInteractionSettings): pond.IInte
export default function InteractionProvider(props: PropsWithChildren<Props>) { export default function InteractionProvider(props: PropsWithChildren<Props>) {
const { children } = props; const { children } = props;
const { get, post, put, del } = useHTTP(); const { get, post, put, del } = useHTTP();
const [{ as }] = useGlobalState(); //const [{ as }] = useGlobalState();
const addInteraction = (device: number, settings: pond.IInteractionSettings) => { const addInteraction = (device: number, settings: pond.IInteractionSettings, as?: string) => {
return new Promise<AxiosResponse<pond.AddInteractionResponse>>((resolve, reject) => { return new Promise<AxiosResponse<pond.AddInteractionResponse>>((resolve, reject) => {
post<pond.AddInteractionResponse>( post<pond.AddInteractionResponse>(
pondURL("/devices/" + device + "/interactions" + (as ? "?as=" + as : "")), pondURL("/devices/" + device + "/interactions" + (as ? "?as=" + as : "")),
@ -80,7 +84,8 @@ export default function InteractionProvider(props: PropsWithChildren<Props>) {
*/ */
const addInteractionToComponents = ( const addInteractionToComponents = (
fullComponentLocations: string[], fullComponentLocations: string[],
settings: pond.IInteractionSettings settings: pond.IInteractionSettings,
as?: string
) => { ) => {
let url = pondURL( let url = pondURL(
"/interactions/forComponents/" + "/interactions/forComponents/" +
@ -98,7 +103,7 @@ export default function InteractionProvider(props: PropsWithChildren<Props>) {
}) })
}; };
const addMultiInteractions = (device: number, settings: pond.MultiInteractionSettings) => { const addMultiInteractions = (device: number, settings: pond.MultiInteractionSettings, as?: string) => {
let url = pondURL("/devices/" + device + "/interactions/multi" + (as ? "?as=" + as : "")) let url = pondURL("/devices/" + device + "/interactions/multi" + (as ? "?as=" + as : ""))
return new Promise<AxiosResponse<pond.AddMultiInteractionsResponse>>((resolve, reject) => { return new Promise<AxiosResponse<pond.AddMultiInteractionsResponse>>((resolve, reject) => {
post<pond.AddMultiInteractionsResponse>(url,settings).then(resp => { post<pond.AddMultiInteractionsResponse>(url,settings).then(resp => {
@ -110,7 +115,7 @@ export default function InteractionProvider(props: PropsWithChildren<Props>) {
}) })
}; };
const updateInteraction = (device: number, settings: pond.IInteractionSettings) => { const updateInteraction = (device: number, settings: pond.IInteractionSettings, as?: string) => {
let url = pondURL( let url = pondURL(
"/devices/" + "/devices/" +
device + device +
@ -133,7 +138,8 @@ export default function InteractionProvider(props: PropsWithChildren<Props>) {
const updateInteractionPondSettings = ( const updateInteractionPondSettings = (
device: number, device: number,
interaction: string, interaction: string,
settings: pond.IInteractionPondSettings settings: pond.IInteractionPondSettings,
as?: string
) => { ) => {
let url = pondURL( let url = pondURL(
"/devices/" + "/devices/" +
@ -156,7 +162,7 @@ export default function InteractionProvider(props: PropsWithChildren<Props>) {
}) })
}; };
const removeInteraction = (device: number, interaction: string) => { const removeInteraction = (device: number, interaction: string, as?: string) => {
let url = pondURL("/devices/" + device + "/interactions/" + interaction + (as ? "?as=" + as : "")) let url = pondURL("/devices/" + device + "/interactions/" + interaction + (as ? "?as=" + as : ""))
return new Promise<AxiosResponse<pond.RemoveInteractionResponse>>((resolve, reject) => { return new Promise<AxiosResponse<pond.RemoveInteractionResponse>>((resolve, reject) => {
del<pond.RemoveInteractionResponse>(url).then(resp => { del<pond.RemoveInteractionResponse>(url).then(resp => {
@ -171,7 +177,8 @@ export default function InteractionProvider(props: PropsWithChildren<Props>) {
const listInteractionsByDevice = ( const listInteractionsByDevice = (
device: number | string, device: number | string,
demo: boolean = false demo: boolean = false,
as?: string
): Promise<Interaction[]> => { ): Promise<Interaction[]> => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
get(pondURL("/devices/" + device + "/interactions" + (as ? "?as=" + as : ""), demo)) get(pondURL("/devices/" + device + "/interactions" + (as ? "?as=" + as : ""), demo))
@ -209,7 +216,8 @@ export default function InteractionProvider(props: PropsWithChildren<Props>) {
const listInteractionsByComponent = ( const listInteractionsByComponent = (
device: number, device: number,
component: quack.ComponentID, component: quack.ComponentID,
demo: boolean = false demo: boolean = false,
as?: string
): Promise<Interaction[]> => { ): Promise<Interaction[]> => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
get( get(
@ -255,7 +263,8 @@ export default function InteractionProvider(props: PropsWithChildren<Props>) {
}; };
const setAlertInteractions = ( const setAlertInteractions = (
alerts: pond.AlertData[] alerts: pond.AlertData[],
as?: string
): Promise<AxiosResponse<pond.SetAlertInteractionsResponse>> => { ): Promise<AxiosResponse<pond.SetAlertInteractionsResponse>> => {
let url = pondURL("/interactions/setAlerts" + (as ? "?as=" + as : "")) let url = pondURL("/interactions/setAlerts" + (as ? "?as=" + as : ""))
return new Promise<AxiosResponse<pond.SetAlertInteractionsResponse>>((resolve, reject) => { return new Promise<AxiosResponse<pond.SetAlertInteractionsResponse>>((resolve, reject) => {