moving things around
This commit is contained in:
1 parent
549f52655b
commit
d22bba8c4d
41 files changed
+227
-337
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import "./AutoInfoBox.css";
|
||||
import { AutomationMetadata } from "types/automations";
|
||||
import { InputList } from "components/Inputs/InputList";
|
||||
import InputText from "components/Inputs/InputText";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
import { FC, ReactNode, useRef, useState } from "react";
|
||||
import { AddIcon, TrashIcon } from "components/Icons";
|
||||
import InputAutoText from "components/Inputs/InputAutoText";
|
||||
|
||||
@@ -15,7 +15,7 @@ import { CheckMarkIcon } from "components/Icons";
|
||||
|
||||
import { Modal } from "components/Modal";
|
||||
import { Button } from "components/Inputs/Buttons/Button";
|
||||
import InputYaml from "components/Inputs/InputYaml";
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
import { TagDB } from "components/AutomationManager/TagDB";
|
||||
import { DAGDims } from "components/DAGGraph/elements/types";
|
||||
import { DAGAutomationGraph } from "components/DAGGraph";
|
||||
|
||||
@@ -5,7 +5,7 @@ import { FC, useState } from "react";
|
||||
|
||||
import ArrowIcon from "@mui/icons-material/ArrowBackIosNewOutlined";
|
||||
|
||||
import InputText from "components/Inputs/InputText";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
import InputMultiSelect from "components/Inputs/InputMultiSelect";
|
||||
|
||||
import { ListBoxGroup } from "../ListBoxGroup";
|
||||
|
||||
@@ -7,7 +7,7 @@ import { AutomationCondition } from "types/automations/conditions";
|
||||
import { getSubTypeList } from "utils/automations";
|
||||
import { getConditionDefaultValues } from "utils/defaults";
|
||||
import { useHA } from "haService";
|
||||
import InputYaml from "components/Inputs/InputYaml";
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
import { getViewer } from "./viewRender";
|
||||
import { getEditor } from "./editorRender";
|
||||
import useWindowSize from "utils/useWindowSize";
|
||||
|
||||
@@ -10,16 +10,16 @@ import {
|
||||
TriggerCondition,
|
||||
ZoneCondition,
|
||||
} from "types/automations/conditions";
|
||||
import InputNumber from "components/Inputs/InputNumber";
|
||||
import InputText from "components/Inputs/InputText";
|
||||
import InputNumber from "components/Inputs/Base/InputNumber";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
import { InputEntity } from "components/Inputs/AutoComplete/InputEntities";
|
||||
import {
|
||||
ConditionNodeBase,
|
||||
ConditionNodeBaseViewMode,
|
||||
} from "./ConditionNodeBase";
|
||||
import { genUpdateMethods } from "./nestedUpdater";
|
||||
import { InputTime } from "components/Inputs/InputTime";
|
||||
import InputYaml from "components/Inputs/InputYaml";
|
||||
import { InputTime } from "components/Inputs/Base/InputTime";
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
import { HAService } from "haService";
|
||||
import { DeviceEditor } from "components/DeviceEditor";
|
||||
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||
|
||||
@@ -12,7 +12,7 @@ import Edit from "@mui/icons-material/Edit";
|
||||
import KeyboardArrowDownSharpIcon from "@mui/icons-material/KeyboardArrowDownSharp";
|
||||
import AddOutlined from "@mui/icons-material/AddOutlined";
|
||||
|
||||
import InputBoolean from "components/Inputs/InputBoolean";
|
||||
import InputBoolean from "components/Inputs/Base/InputBoolean";
|
||||
import { SpeedDial } from "components/SpeedDial";
|
||||
import { SequenceNodeElementProps } from "./types";
|
||||
import { useSequenceNodeColor } from "./util";
|
||||
|
||||
@@ -4,10 +4,10 @@ import { useSnackbar } from "notistack";
|
||||
import { useRef } from "react";
|
||||
import { prettyName } from "utils/formatting";
|
||||
import { InputAutoComplete, Option } from "./InputAutoComplete";
|
||||
import InputBoolean from "../InputBoolean";
|
||||
import { InputTime } from "../InputDayTime";
|
||||
import InputNumber from "../InputNumber";
|
||||
import InputText from "../InputText";
|
||||
import InputBoolean from "components/Inputs/Base/InputBoolean";
|
||||
import { InputTime } from "../Base/InputTime";
|
||||
import InputNumber from "components/Inputs/Base/InputNumber";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
|
||||
export type InputDeviceCapabiltiesProps<T extends Record<string, any>> = {
|
||||
defn: HaFormSchema[];
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
isAutomationTimeString24Hours,
|
||||
} from "utils/time";
|
||||
import { InputEntity } from "./InputEntities";
|
||||
import { InputTime } from "../InputTime";
|
||||
import { InputTime } from "components/Inputs/Base/InputTime";
|
||||
|
||||
export type InputTimeEntityProps = {
|
||||
value: string;
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
@@ -1,4 +1,5 @@
|
||||
import "./InputTime.css";
|
||||
|
||||
import { useState, useEffect, FC } from "react";
|
||||
import TextField from "@mui/material/TextField";
|
||||
import EditIcon from "@mui/icons-material/Edit";
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,150 +0,0 @@
|
||||
import "./InputTime.css";
|
||||
import { useState, useEffect, FC } from "react";
|
||||
import TextField from "@mui/material/TextField";
|
||||
import EditIcon from "@mui/icons-material/Edit";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
import { AutomationTime, AutomationTimeObject } from "types/automations/common";
|
||||
import {
|
||||
convertAutomationTimeToTimeObject,
|
||||
convertObjectToAutomationTimeString,
|
||||
} from "utils/time";
|
||||
import { convertAutomationTimeToTimeString } from "utils/time";
|
||||
import { prettyName } from "utils/formatting";
|
||||
import InputLabel from "@mui/material/InputLabel";
|
||||
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||
|
||||
// constants
|
||||
const fields: Array<keyof AutomationTimeObject> = [
|
||||
"hours",
|
||||
"minutes",
|
||||
"seconds",
|
||||
"milliseconds",
|
||||
];
|
||||
export interface Props {
|
||||
label: string;
|
||||
value?: AutomationTime;
|
||||
onChange: (v?: AutomationTimeObject) => void;
|
||||
}
|
||||
export const InputTime: FC<Props> = (props) => {
|
||||
// state
|
||||
const [disabled, setDisabled] = useState(!props.value);
|
||||
const [displayValue, setDisplayValue] = useState(
|
||||
convertAutomationTimeToTimeObject(props.value)
|
||||
);
|
||||
|
||||
// process display input
|
||||
const updateOne = (k: keyof AutomationTimeObject) => (v: string) => {
|
||||
if (Number(v) < 0) {
|
||||
setDisplayValue({
|
||||
...displayValue,
|
||||
[k]: 0,
|
||||
});
|
||||
} else if (k === "hours") {
|
||||
setDisplayValue({
|
||||
...displayValue,
|
||||
[k]: Number(v),
|
||||
});
|
||||
} else if (k === "minutes") {
|
||||
let minutes = Number(v);
|
||||
let { hours = 0 } = displayValue;
|
||||
if (minutes > 59) {
|
||||
const additonalHours = Math.floor(minutes / 60);
|
||||
hours += additonalHours;
|
||||
minutes = minutes - additonalHours * 60;
|
||||
}
|
||||
setDisplayValue({
|
||||
...displayValue,
|
||||
minutes,
|
||||
hours,
|
||||
});
|
||||
} else if (k === "seconds") {
|
||||
let seconds = Number(v);
|
||||
let { hours = 0, minutes = 0 } = displayValue;
|
||||
if (seconds > 59) {
|
||||
const additonalHours = Math.floor(seconds / (60 * 60));
|
||||
hours += additonalHours;
|
||||
seconds = seconds - additonalHours * 60;
|
||||
}
|
||||
if (seconds > 59) {
|
||||
const additionalMinutes = Math.floor(seconds / 60);
|
||||
minutes += additionalMinutes;
|
||||
seconds = seconds - additionalMinutes * 60;
|
||||
}
|
||||
setDisplayValue({
|
||||
...displayValue,
|
||||
minutes,
|
||||
hours,
|
||||
seconds,
|
||||
});
|
||||
} else if (k === "milliseconds") {
|
||||
let milliseconds = Number(v);
|
||||
let { hours = 0, minutes = 0, seconds = 0 } = displayValue;
|
||||
if (milliseconds > 1000) {
|
||||
const additonalHours = Math.floor(milliseconds / (60 * 60 * 1000));
|
||||
hours += additonalHours;
|
||||
milliseconds = milliseconds - additonalHours * 60 * 60 * 1000;
|
||||
}
|
||||
if (milliseconds > 1000) {
|
||||
const additionalMinutes = Math.floor(milliseconds / (60 * 1000));
|
||||
minutes += additionalMinutes;
|
||||
milliseconds = milliseconds - additionalMinutes * 60 * 1000;
|
||||
}
|
||||
if (milliseconds > 1000) {
|
||||
const additionalSeconds = Math.floor(milliseconds / 1000);
|
||||
seconds += additionalSeconds;
|
||||
milliseconds = milliseconds - additionalSeconds * 1000;
|
||||
}
|
||||
setDisplayValue({
|
||||
...displayValue,
|
||||
minutes,
|
||||
hours,
|
||||
seconds,
|
||||
milliseconds,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// effect
|
||||
useEffect(() => {
|
||||
if (disabled && !props.value) {
|
||||
return;
|
||||
}
|
||||
if (disabled) {
|
||||
props.onChange(undefined);
|
||||
} else {
|
||||
const pVal = convertAutomationTimeToTimeString(props.value);
|
||||
const cVal = convertObjectToAutomationTimeString(displayValue);
|
||||
if (pVal !== cVal) {
|
||||
props.onChange(displayValue);
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line
|
||||
}, [disabled, displayValue]);
|
||||
|
||||
return (
|
||||
<div className="input-time">
|
||||
<InputLabel>{props.label}</InputLabel>
|
||||
<div className="input-time--inner">
|
||||
{fields.map((name) => (
|
||||
<TextField
|
||||
key={name}
|
||||
variant="filled"
|
||||
label={prettyName(name)}
|
||||
defaultValue="00"
|
||||
InputProps={{
|
||||
disabled,
|
||||
type: "number",
|
||||
title: prettyName(name),
|
||||
}}
|
||||
value={displayValue[name] ?? 0}
|
||||
onChange={(e) => updateOne(name)(e.target.value)}
|
||||
/>
|
||||
))}
|
||||
<ButtonIcon
|
||||
onClick={() => setDisabled(!disabled)}
|
||||
icon={disabled ? <EditIcon /> : <CloseIcon />}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { Page } from "components/Page";
|
||||
import InputText from "./InputText";
|
||||
import InputText from "./Base/InputText";
|
||||
|
||||
import { InputTextView } from "./InputTextView";
|
||||
|
||||
|
||||
@@ -1,33 +1,31 @@
|
||||
import InputYaml from "components/Inputs/InputYaml";
|
||||
import InputText from "components/Inputs/InputText";
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
import { FireEventAction } from "types/automations/actions";
|
||||
import { OptionManager, updateActionData } from "./OptionManager";
|
||||
|
||||
|
||||
export const ActionEventState: OptionManager<FireEventAction> = {
|
||||
defaultState: () => ({
|
||||
alias: "Fire Event",
|
||||
event: "",
|
||||
event_data: {},
|
||||
}),
|
||||
isReady: ({ alias, event }) => (
|
||||
alias !== '' &&
|
||||
event !== ""
|
||||
),
|
||||
isReady: ({ alias, event }) => alias !== "" && event !== "",
|
||||
renderOptionList: (state, setState) => {
|
||||
const update = updateActionData(state, setState);
|
||||
return <>
|
||||
<InputText
|
||||
textBoxFor="event"
|
||||
label="Event"
|
||||
value={state.event}
|
||||
onChange={event => update({ event })}
|
||||
/>
|
||||
<InputYaml
|
||||
label="Event Data"
|
||||
value={state.event_data}
|
||||
onChange={event_data => update({ event_data })}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<InputText
|
||||
textBoxFor="event"
|
||||
label="Event"
|
||||
value={state.event}
|
||||
onChange={(event) => update({ event })}
|
||||
/>
|
||||
<InputYaml
|
||||
label="Event Data"
|
||||
value={state.event_data}
|
||||
onChange={(event_data) => update({ event_data })}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
},
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
import InputNumber from "components/Inputs/InputNumber";
|
||||
import InputNumber from "components/Inputs/Base/InputNumber";
|
||||
import { RepeatAction } from "types/automations/actions";
|
||||
import { OptionManager } from "./OptionManager";
|
||||
import { InputAutoComplete } from "components/Inputs/AutoComplete/InputAutoComplete";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import InputText from "components/Inputs/InputText";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
import { StopAction } from "types/automations/actions";
|
||||
import { OptionManager } from "./OptionManager";
|
||||
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
import "./ActionWait.css";
|
||||
import InputBoolean from "components/Inputs/InputBoolean";
|
||||
import InputBoolean from "components/Inputs/Base/InputBoolean";
|
||||
import { InputList } from "components/Inputs/InputList";
|
||||
import InputNumber from "components/Inputs/InputNumber";
|
||||
import InputText from "components/Inputs/InputText";
|
||||
import { InputTime } from "components/Inputs/InputTime";
|
||||
import InputNumber from "components/Inputs/Base/InputNumber";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
import { InputTime } from "components/Inputs/Base/InputTime";
|
||||
import { useState } from "react";
|
||||
import { DelayAction, WaitAction } from "types/automations/actions";
|
||||
import { OptionManager, updateActionData } from './OptionManager';
|
||||
import InputYaml from "components/Inputs/InputYaml";
|
||||
import { OptionManager, updateActionData } from "./OptionManager";
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
|
||||
type ThisAction = WaitAction | DelayAction;
|
||||
type Option = 'delay' | 'template' | 'trigger'
|
||||
type Option = "delay" | "template" | "trigger";
|
||||
const getCurrentOption = (node: ThisAction): Option => {
|
||||
if ('delay' in node) {
|
||||
return 'delay'
|
||||
if ("delay" in node) {
|
||||
return "delay";
|
||||
} else {
|
||||
return 'template'
|
||||
return "template";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const ActionWaitState: OptionManager<ThisAction> = {
|
||||
defaultState: () => ({
|
||||
@@ -32,78 +32,108 @@ export const ActionWaitState: OptionManager<ThisAction> = {
|
||||
const base: any = {
|
||||
alias: state.alias,
|
||||
variables: state.variables,
|
||||
}
|
||||
if (opt === 'delay') {
|
||||
};
|
||||
if (opt === "delay") {
|
||||
setState({
|
||||
...base,
|
||||
delay: (state as any).delay ?? "",
|
||||
})
|
||||
});
|
||||
} else {
|
||||
base.timeout = (state as any).timeout
|
||||
base.continue_on_timeout = (state as any).continue_on_timeout
|
||||
if (opt === 'template') {
|
||||
base.timeout = (state as any).timeout;
|
||||
base.continue_on_timeout = (state as any).continue_on_timeout;
|
||||
if (opt === "template") {
|
||||
setState({
|
||||
...base,
|
||||
wait_template: (state as any).wait_template ?? "",
|
||||
})
|
||||
});
|
||||
} else {
|
||||
setState({
|
||||
...base,
|
||||
wait_for_trigger: (state as any).wait_for_trigger ?? "",
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
_setCurrent(opt)
|
||||
}
|
||||
_setCurrent(opt);
|
||||
};
|
||||
|
||||
// determine options
|
||||
let option: JSX.Element = <></>;
|
||||
if (current === "delay") {
|
||||
option = <>
|
||||
<InputTime className="for" label="for" value={(state as any).delay} onChange={delay => update({ delay })} />
|
||||
</>
|
||||
} else if (current === 'template') {
|
||||
option = (
|
||||
<>
|
||||
<InputTime
|
||||
className="for"
|
||||
label="for"
|
||||
value={(state as any).delay}
|
||||
onChange={(delay) => update({ delay })}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
} else if (current === "template") {
|
||||
state = state as WaitAction;
|
||||
option = <>
|
||||
<InputText
|
||||
label="Template"
|
||||
className="template"
|
||||
value={state.wait_template ?? ""}
|
||||
onChange={wait_template => update({ wait_template })}
|
||||
/>
|
||||
</>
|
||||
} else if (current === 'trigger') {
|
||||
option = (
|
||||
<>
|
||||
<InputText
|
||||
label="Template"
|
||||
className="template"
|
||||
value={state.wait_template ?? ""}
|
||||
onChange={(wait_template) => update({ wait_template })}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
} else if (current === "trigger") {
|
||||
state = state as WaitAction;
|
||||
option = <>
|
||||
<InputYaml
|
||||
className="triggers"
|
||||
label="Triggers"
|
||||
value={state.wait_for_trigger ?? []}
|
||||
onChange={wait_for_trigger => update({ wait_for_trigger })}
|
||||
/>
|
||||
</>
|
||||
option = (
|
||||
<>
|
||||
<InputYaml
|
||||
className="triggers"
|
||||
label="Triggers"
|
||||
value={state.wait_for_trigger ?? []}
|
||||
onChange={(wait_for_trigger) => update({ wait_for_trigger })}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
// render
|
||||
return <div className="node-editor--action-wait">
|
||||
<InputList
|
||||
className="wait-type"
|
||||
label="Wait Type" prettyOptionLabels
|
||||
options={["template", 'trigger', "delay"]}
|
||||
current={current} onChange={setCurrent} />
|
||||
{option}
|
||||
{current !== 'delay' ? <div className="wait-options">
|
||||
<InputNumber
|
||||
label="Timeout"
|
||||
value={(state as any).timeout ? Number((state as any).timeout) : undefined}
|
||||
onChange={timeout => update({ timeout: timeout === undefined ? undefined : String(timeout) })}
|
||||
return (
|
||||
<div className="node-editor--action-wait">
|
||||
<InputList
|
||||
className="wait-type"
|
||||
label="Wait Type"
|
||||
prettyOptionLabels
|
||||
options={["template", "trigger", "delay"]}
|
||||
current={current}
|
||||
onChange={setCurrent}
|
||||
/>
|
||||
<InputBoolean
|
||||
label="Continue on Timeout"
|
||||
value={(state as any).continue_on_timeout ?? false}
|
||||
onChange={continue_on_timeout => update({ continue_on_timeout })}
|
||||
/>
|
||||
</div> : <></>}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
{option}
|
||||
{current !== "delay" ? (
|
||||
<div className="wait-options">
|
||||
<InputNumber
|
||||
label="Timeout"
|
||||
value={
|
||||
(state as any).timeout
|
||||
? Number((state as any).timeout)
|
||||
: undefined
|
||||
}
|
||||
onChange={(timeout) =>
|
||||
update({
|
||||
timeout: timeout === undefined ? undefined : String(timeout),
|
||||
})
|
||||
}
|
||||
/>
|
||||
<InputBoolean
|
||||
label="Continue on Timeout"
|
||||
value={(state as any).continue_on_timeout ?? false}
|
||||
onChange={(continue_on_timeout) =>
|
||||
update({ continue_on_timeout })
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
import InputText from "components/Inputs/InputText";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
import { OptionManager } from "./OptionManager";
|
||||
import { AutomationTriggerEvent } from "../../../types/automations/triggers";
|
||||
import InputYaml from "components/Inputs/InputYaml";
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
|
||||
export const TriggerEventState: OptionManager<AutomationTriggerEvent> = {
|
||||
defaultState: () => ({
|
||||
|
||||
@@ -1,33 +1,34 @@
|
||||
import { OptionManager } from './OptionManager';
|
||||
import { AutomationTriggerMQTT } from 'types/automations/triggers';
|
||||
import InputText from 'components/Inputs/InputText';
|
||||
|
||||
import { OptionManager } from "./OptionManager";
|
||||
import { AutomationTriggerMQTT } from "types/automations/triggers";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
|
||||
export const TriggerMQTTState: OptionManager<AutomationTriggerMQTT> = {
|
||||
defaultState: () => ({
|
||||
"platform": "mqtt",
|
||||
"payload": "",
|
||||
"topic": "",
|
||||
"value_template": ""
|
||||
platform: "mqtt",
|
||||
payload: "",
|
||||
topic: "",
|
||||
value_template: "",
|
||||
}),
|
||||
isReady: () => true,
|
||||
renderOptionList: (state, setState) => {
|
||||
return <>
|
||||
<InputText
|
||||
label='Payload'
|
||||
value={state.payload}
|
||||
onChange={payload => setState({ ...state, payload })}
|
||||
/>
|
||||
<InputText
|
||||
label='Topic'
|
||||
value={state.topic}
|
||||
onChange={topic => setState({ ...state, topic })}
|
||||
/>
|
||||
<InputText
|
||||
label='Template'
|
||||
value={state.value_template}
|
||||
onChange={value_template => setState({ ...state, value_template })}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<InputText
|
||||
label="Payload"
|
||||
value={state.payload}
|
||||
onChange={(payload) => setState({ ...state, payload })}
|
||||
/>
|
||||
<InputText
|
||||
label="Topic"
|
||||
value={state.topic}
|
||||
onChange={(topic) => setState({ ...state, topic })}
|
||||
/>
|
||||
<InputText
|
||||
label="Template"
|
||||
value={state.value_template}
|
||||
onChange={(value_template) => setState({ ...state, value_template })}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
},
|
||||
};
|
||||
@@ -1,10 +1,10 @@
|
||||
import { OptionManager } from "./OptionManager";
|
||||
import { AutomationTriggerNumericState } from "types/automations/triggers";
|
||||
import InputText from "components/Inputs/InputText";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
import { InputEntity } from "components/Inputs/AutoComplete/InputEntities";
|
||||
import InputNumber from "components/Inputs/InputNumber";
|
||||
import { InputTime } from "components/Inputs/InputTime";
|
||||
import InputYaml from "components/Inputs/InputYaml";
|
||||
import InputNumber from "components/Inputs/Base/InputNumber";
|
||||
import { InputTime } from "components/Inputs/Base/InputTime";
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
|
||||
export const TriggerNumericState: OptionManager<AutomationTriggerNumericState> =
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { OptionManager } from "./OptionManager";
|
||||
import { AutomationTriggerState } from "types/automations/triggers";
|
||||
import InputText from "components/Inputs/InputText";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
import { InputEntity } from "components/Inputs/AutoComplete/InputEntities";
|
||||
import { InputTime } from "components/Inputs/InputTime";
|
||||
import { InputTime } from "components/Inputs/Base/InputTime";
|
||||
import { InputAutoComplete } from "components/Inputs/AutoComplete/InputAutoComplete";
|
||||
import { FC } from "react";
|
||||
import { getEntityDomains } from "utils/automations";
|
||||
|
||||
@@ -1,30 +1,33 @@
|
||||
import { OptionManager } from './OptionManager';
|
||||
import { AutomationTriggerTemplate } from 'types/automations/triggers';
|
||||
import InputText from 'components/Inputs/InputText';
|
||||
import { InputTime } from 'components/Inputs/InputTime';
|
||||
|
||||
import { OptionManager } from "./OptionManager";
|
||||
import { AutomationTriggerTemplate } from "types/automations/triggers";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
import { InputTime } from "components/Inputs/Base/InputTime";
|
||||
|
||||
export const TriggerTemplate: OptionManager<AutomationTriggerTemplate> = {
|
||||
defaultState: () => ({
|
||||
"platform": 'template',
|
||||
"value_template": "",
|
||||
platform: "template",
|
||||
value_template: "",
|
||||
}),
|
||||
isReady: () => true,
|
||||
renderOptionList: (state, setState) => {
|
||||
return <>
|
||||
<InputText
|
||||
label='Template'
|
||||
value={state.value_template}
|
||||
onChange={value_template => setState({ ...state, value_template })}
|
||||
/>
|
||||
<InputTime
|
||||
label="For"
|
||||
value={state.for}
|
||||
onChange={_for => setState({
|
||||
...state,
|
||||
for: _for,
|
||||
})}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<InputText
|
||||
label="Template"
|
||||
value={state.value_template}
|
||||
onChange={(value_template) => setState({ ...state, value_template })}
|
||||
/>
|
||||
<InputTime
|
||||
label="For"
|
||||
value={state.for}
|
||||
onChange={(_for) =>
|
||||
setState({
|
||||
...state,
|
||||
for: _for,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
},
|
||||
};
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
AutomationTriggerExactTime,
|
||||
AutomationTriggerTimePattern,
|
||||
} from "types/automations/triggers";
|
||||
import InputText from "components/Inputs/InputText";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
import { FC } from "react";
|
||||
import { InputList } from "components/Inputs/InputList";
|
||||
import { Button } from "components/Inputs/Buttons/Button";
|
||||
|
||||
@@ -1,20 +1,27 @@
|
||||
import { OptionManager } from './OptionManager';
|
||||
import { AutomationTriggerWebhook } from 'types/automations/triggers';
|
||||
import InputText from 'components/Inputs/InputText';
|
||||
|
||||
import { OptionManager } from "./OptionManager";
|
||||
import { AutomationTriggerWebhook } from "types/automations/triggers";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
|
||||
export const TriggerWebhook: OptionManager<AutomationTriggerWebhook> = {
|
||||
defaultState: () => ({
|
||||
"platform": 'webhook',
|
||||
"webhook_id": "",
|
||||
platform: "webhook",
|
||||
webhook_id: "",
|
||||
}),
|
||||
isReady: () => true,
|
||||
renderOptionList: (state, setState) => {
|
||||
return <>
|
||||
<InputText label="Webhook ID" value={state.webhook_id ?? ""} onChange={webhook_id => setState({
|
||||
...state,
|
||||
webhook_id
|
||||
})} />
|
||||
</>
|
||||
}
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<InputText
|
||||
label="Webhook ID"
|
||||
value={state.webhook_id ?? ""}
|
||||
onChange={(webhook_id) =>
|
||||
setState({
|
||||
...state,
|
||||
webhook_id,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
},
|
||||
};
|
||||
@@ -7,8 +7,8 @@ import {
|
||||
getSubTypeList,
|
||||
validateNode,
|
||||
} from "utils/automations";
|
||||
import InputYaml from "components/Inputs/InputYaml";
|
||||
import InputText from "components/Inputs/InputText";
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
import { getDescriptionFromAutomationNode } from "utils/formatting";
|
||||
import { useHA } from "haService";
|
||||
import { Generic } from "./Generic";
|
||||
|
||||
@@ -5,7 +5,7 @@ import { AutomationNode, AutomationNodeMapping } from "types/automations/index";
|
||||
import { useEditorNodeState } from "./OptionManager";
|
||||
import { InputList } from "components/Inputs/InputList";
|
||||
import { Button } from "components/Inputs/Buttons/Button";
|
||||
import InputBoolean from "components/Inputs/InputBoolean";
|
||||
import InputBoolean from "components/Inputs/Base/InputBoolean";
|
||||
import { useConfirm } from "material-ui-confirm";
|
||||
import { getNodeSubTypeDescription } from "./utils";
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import "./ServiceEditorField.css";
|
||||
import { FC, useRef } from "react";
|
||||
import { ServiceEditorOption } from "./options";
|
||||
import InputText from "components/Inputs/InputText";
|
||||
import InputNumber from "components/Inputs/InputNumber";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
import InputNumber from "components/Inputs/Base/InputNumber";
|
||||
import { RemoveCircle } from "@mui/icons-material";
|
||||
import {
|
||||
InputAutoComplete,
|
||||
Option,
|
||||
} from "components/Inputs/AutoComplete/InputAutoComplete";
|
||||
import { prettyName } from "utils/formatting";
|
||||
import InputBoolean from "components/Inputs/InputBoolean";
|
||||
import InputBoolean from "components/Inputs/Base/InputBoolean";
|
||||
import { SelectorNumber, SelectorText } from "haService/fieldTypes";
|
||||
import InputYaml from "components/Inputs/InputYaml";
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
import { useSnackbar } from "notistack";
|
||||
import { InputEntity } from "components/Inputs/AutoComplete/InputEntities";
|
||||
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||
|
||||
@@ -3,7 +3,7 @@ import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { Page } from "components/Page";
|
||||
import { ServiceEditor } from ".";
|
||||
import { TypedHassService } from "haService/fieldTypes";
|
||||
import InputYaml from "components/Inputs/InputYaml";
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
|
||||
export default {
|
||||
title: "Services/ServiceEditor",
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { FC, useEffect, useState } from "react";
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { Page } from "components/Page";
|
||||
import { useHA } from "haService";
|
||||
import InputYaml from "components/Inputs/InputYaml";
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
import { InputList } from "components/Inputs/InputList";
|
||||
import { Button } from "components/Inputs/Buttons/Button";
|
||||
import { ServiceEditor } from "components/ServiceEditor";
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { FC } from "react";
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { Page } from "components/Page";
|
||||
import { useHADeviceRegistry } from "haService";
|
||||
import InputYaml from "components/Inputs/InputYaml";
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
|
||||
const Test: FC<{ onRender: () => void }> = ({ onRender }) => {
|
||||
const conn = useHADeviceRegistry();
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { FC, useEffect, useState } from "react";
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { Page } from "components/Page";
|
||||
import { useHA } from "haService";
|
||||
import InputYaml from "components/Inputs/InputYaml";
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
import { InputList } from "components/Inputs/InputList";
|
||||
import { Button } from "components/Inputs/Buttons/Button";
|
||||
import { ServiceEditor } from "components/ServiceEditor";
|
||||
|
||||
Reference in new issue
Block a user