diff --git a/smart-hut/src/components/AutomationModal.js b/smart-hut/src/components/AutomationModal.js
index 626a6c5..0cf1674 100644
--- a/smart-hut/src/components/AutomationModal.js
+++ b/smart-hut/src/components/AutomationModal.js
@@ -84,6 +84,7 @@ class AutomationModal extends Component {
render() {
return (
+ {/*
{!this.props.nicolaStop ? (
@@ -167,7 +168,7 @@ class AutomationModal extends Component {
{this.type === "new" ? "Add automation" : "Save changes"}
-
+ */}
);
}
diff --git a/smart-hut/src/components/dashboard/AutomationsPanel.js b/smart-hut/src/components/dashboard/AutomationsPanel.js
index 4e8ca37..c730332 100644
--- a/smart-hut/src/components/dashboard/AutomationsPanel.js
+++ b/smart-hut/src/components/dashboard/AutomationsPanel.js
@@ -16,7 +16,7 @@ import {
Divider,
Checkbox,
Menu,
- Label
+ Label,
} from "semantic-ui-react";
const operands = [
@@ -154,7 +154,7 @@ const SceneItem = (props) => {
checked={position + 1 > 0}
/>
-
+
{props.scene.name}
@@ -180,11 +180,13 @@ const Trigger = ({deviceName, trigger, onRemove, index}) => {
onRemove(device, index)}
+ onClick={() => onRemove(index)}
className="remove-icon"
name="remove"
/>
@@ -192,7 +194,7 @@ const Trigger = ({deviceName, trigger, onRemove, index}) => {
);
};
-const CreateAutomation = (props) => {
+export const CreateAutomation = (props) => {
const [triggerList, setTrigger] = useState([]);
const [order, setOrder] = useState([]);
const [stateScenes, setScenes] = useState(props.scenes);
@@ -250,8 +252,8 @@ const CreateAutomation = (props) => {
}
};
- const removeTrigger = (trigger) => {
- // TODO When this is connected to the backend each trigger will have an id which can be used to remove it
+ const removeTrigger = (index) => {
+ setTrigger((prevList) => prevList.filter((t, i) => i !== index));
};
// This gets triggered when the devices dropdown changes the value.
@@ -271,7 +273,6 @@ const CreateAutomation = (props) => {
if (value.length > 0) {
setScenes((prevScenes) => {
return stateScenes.filter((e) => {
- console.log(e.name.includes(value));
return e.name.includes(value);
});
});
@@ -301,17 +302,16 @@ const CreateAutomation = (props) => {
return false;
}
return true;
- }
+ };
const saveAutomation = () => {
- console.log("trigger list: ", triggerList);
//if(checkBeforeSave()){
const automation = {
- name: automationName
- }
+ name: automationName,
+ };
props.save({automation, triggerList, order});
//}
- }
+ };
return (
@@ -409,10 +409,9 @@ const CreateAutomation = (props) => {
-
-
-
-
+
@@ -420,9 +419,12 @@ const CreateAutomation = (props) => {
);
};
-const Automation = ({automation, devices}) => {
- const {triggers, scenes} = automation;
- const getOperator = (operand) => operands.filter(o => o.key == operand)[0].text;
+const Automation = ({automation, devices, scenes, removeAutomation}) => {
+ const {triggers} = automation;
+ const scenePriorities = automation.scenes;
+ const getOperator = (operand) =>
+ operands.filter((o) => o.key == operand)[0].text;
+
return (
@@ -435,6 +437,14 @@ const Automation = ({automation, devices}) => {
size="small"
icon={"edit"}
/>
+