diff --git a/package-lock.json b/package-lock.json index b3671a7..3ec7534 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11752,7 +11752,7 @@ }, "node_modules/protobuf-ts": { "version": "1.0.0", - "resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#aa9a59d8cc0b7ba1ee27d9bdcdade6136a00d1fb", + "resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#888ba52a4e56911ecb7df432009ecfc820c00eaf", "dependencies": { "protobufjs": "^6.8.8" } diff --git a/src/interactions/InteractionSettings.tsx b/src/interactions/InteractionSettings.tsx index c98742f..4a92bd9 100644 --- a/src/interactions/InteractionSettings.tsx +++ b/src/interactions/InteractionSettings.tsx @@ -150,6 +150,7 @@ export default function InteractionSettings(props: Props) { const [timezone, setTimezone] = useState(undefined); //whether is any node(0), average of all nodes(1), single node(2), or node diff(3) const [subtypeDropdown, setSubtypeDropdown] = useState(0); + const [interactionEnabled, setInteractionEnabled] = useState(true); //by default interactions are enabled const initialConditions = useCallback( (type: quack.ComponentType): pond.InteractionCondition[] => { @@ -168,6 +169,8 @@ export default function InteractionSettings(props: Props) { let interaction = getDefaultInteraction(); if (initialInteraction && mode === "update") { interaction = initialInteraction; + //set the switch's state value + setInteractionEnabled(!interaction.settings.inactive); if (interaction.settings.subtype === 0 || interaction.settings.subtype === 1) { setSubtypeDropdown(interaction.settings.subtype); } else { @@ -427,6 +430,13 @@ export default function InteractionSettings(props: Props) { setInteraction(updatedInteraction); }; + const changeInactive = (event: any) => { + let updatedInteraction = Interaction.clone(interaction); + //the switch uses true for active but the settings use true for inactive, so need to use the opposite of the switch + updatedInteraction.settings.inactive = !event.target.checked; + setInteraction(updatedInteraction); + }; + const describeSource = (measurementType: quack.MeasurementType): MeasurementDescriber => { const source: Component = or( mappedComponents.get(componentIDToString(interaction.settings.source)), @@ -1532,6 +1542,27 @@ export default function InteractionSettings(props: Props) { ); }; + const activeSwitch = () => { + return ( + { + setInteractionEnabled(!interactionEnabled) + changeInactive(event) + }} + value="active" + color="secondary" + /> + } + label="Active" + disabled={!canEdit} + /> + ) + } + const content = () => { return ( @@ -1540,10 +1571,14 @@ export default function InteractionSettings(props: Props) { {hasDeviceFeature(device.settings.upgradeChannel, "better-controls") && ( -
+
{priorityInput()} -
+ {/*
*/} {sortingInput()} + {/* this will do the check for the feature once we know what version the feature is supported on */} + {/* {device.featureSupported("disableInteractions") && activeSwitch()} */} + {/* this is for testing on dev */} + {activeSwitch()}
)} diff --git a/src/models/Device.ts b/src/models/Device.ts index 7b25c13..48abdd7 100644 --- a/src/models/Device.ts +++ b/src/models/Device.ts @@ -79,6 +79,21 @@ const featureVersions: Map = new Map([ v2CellBlue: "2.1.10", v2EthBlue: "2.1.10" } + ],[ + "disableInteractions", + { + photon: "N/A", + electron: "N/A", + v2Wifi: "N/A", + v2Cell: "N/A", + v2WifiS3: "N/A", + v2CellS3: "N/A", + v2CellBlack: "N/A", + v2CellGreen: "N/A", + v2WifiBlue: "N/A", + v2CellBlue: "N/A", + v2EthBlue: "N/A" + } ] ]); export class Device {