cleaned up styles a bit
This commit is contained in:
1 parent
3acbaf576d
commit
451b3638bf
28 files changed
+864
-705
No files matched your search
@@ -2,11 +2,12 @@ import "./AutoInfoBox.css";
|
|||||||
import { AutomationMetadata } from "types/automations";
|
import { AutomationMetadata } from "types/automations";
|
||||||
import { InputList } from "components/Inputs/InputList";
|
import { InputList } from "components/Inputs/InputList";
|
||||||
import InputText from "components/Inputs/InputText";
|
import InputText from "components/Inputs/InputText";
|
||||||
import { FC, ReactNode, useRef, useState } from 'react';
|
import { FC, ReactNode, useRef, useState } from "react";
|
||||||
import { AddIcon, TrashIcon } from "components/Icons";
|
import { AddIcon, TrashIcon } from "components/Icons";
|
||||||
import { Button } from "components/Inputs/Button";
|
|
||||||
import InputAutoText from "components/Inputs/InputAutoText";
|
import InputAutoText from "components/Inputs/InputAutoText";
|
||||||
import { TagDB } from "components/AutomationList/TagDB";
|
import { TagDB } from "components/AutomationList/TagDB";
|
||||||
|
import from "@mui/material/IconButton";
|
||||||
|
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className: string;
|
className: string;
|
||||||
@@ -25,122 +26,154 @@ export const AutoInfoBox: FC<Props> = ({
|
|||||||
tagDB,
|
tagDB,
|
||||||
}) => {
|
}) => {
|
||||||
// state
|
// state
|
||||||
const [newTag, setNewTag] = useState<[string, string]>(["", ""])
|
const [newTag, setNewTag] = useState<[string, string]>(["", ""]);
|
||||||
const [[errorIndex, error], _setError] = useState<[number | 'new', string]>([-1, ""]);
|
const [[errorIndex, error], _setError] = useState<[number | "new", string]>([
|
||||||
|
-1,
|
||||||
|
"",
|
||||||
|
]);
|
||||||
const errorTimeoutId = useRef(-1);
|
const errorTimeoutId = useRef(-1);
|
||||||
|
|
||||||
// aliases
|
// aliases
|
||||||
const foundNewTagNames = tagDB.getTagNames(tags.map(([n, _]) => n));
|
const foundNewTagNames = tagDB.getTagNames(tags.map(([n, _]) => n));
|
||||||
const setError = (index: number | 'new', msg: string) => {
|
const setError = (index: number | "new", msg: string) => {
|
||||||
_setError([index, msg])
|
_setError([index, msg]);
|
||||||
if (errorTimeoutId.current >= 0) {
|
if (errorTimeoutId.current >= 0) {
|
||||||
window.clearTimeout(errorTimeoutId.current);
|
window.clearTimeout(errorTimeoutId.current);
|
||||||
}
|
}
|
||||||
errorTimeoutId.current = window.setTimeout(() => _setError([-1, ""]), 5000);
|
errorTimeoutId.current = window.setTimeout(() => _setError([-1, ""]), 5000);
|
||||||
}
|
};
|
||||||
const onUpdateMetadata = <K extends keyof AutomationMetadata>(k: K) => (update: AutomationMetadata[K]) => onUpdate({
|
const onUpdateMetadata =
|
||||||
...metadata,
|
<K extends keyof AutomationMetadata>(k: K) =>
|
||||||
[k]: update
|
(update: AutomationMetadata[K]) =>
|
||||||
}, tags);
|
onUpdate(
|
||||||
|
{
|
||||||
|
...metadata,
|
||||||
|
[k]: update,
|
||||||
|
},
|
||||||
|
tags
|
||||||
|
);
|
||||||
const validTagName = (newName: string): string | undefined => {
|
const validTagName = (newName: string): string | undefined => {
|
||||||
if (newName.length <= 0) {
|
if (newName.length <= 0) {
|
||||||
return "Name must be at least 1 character long"
|
return "Name must be at least 1 character long";
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
for (const [name, _] of tags) {
|
for (const [name, _] of tags) {
|
||||||
if (name.trim() === newName.trim()) {
|
if (name.trim() === newName.trim()) {
|
||||||
return `The tag '${name}' already exists`
|
return `The tag '${name}' already exists`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
const updateTagName = (newName: string, tagIndex: number) => {
|
const updateTagName = (newName: string, tagIndex: number) => {
|
||||||
const error = validTagName(newName);
|
const error = validTagName(newName);
|
||||||
if (error) {
|
if (error) {
|
||||||
return setError(tagIndex, error)
|
return setError(tagIndex, error);
|
||||||
}
|
}
|
||||||
onUpdate(metadata, [
|
onUpdate(metadata, [
|
||||||
...tags.slice(0, tagIndex),
|
...tags.slice(0, tagIndex),
|
||||||
[newName, tags[tagIndex][1]],
|
[newName, tags[tagIndex][1]],
|
||||||
...tags.slice(tagIndex + 1),
|
...tags.slice(tagIndex + 1),
|
||||||
])
|
]);
|
||||||
}
|
};
|
||||||
const onUpdateTags = (tagValue: string, tagIndex: number) => onUpdate(metadata, [
|
const onUpdateTags = (tagValue: string, tagIndex: number) =>
|
||||||
...tags.slice(0, tagIndex),
|
onUpdate(metadata, [
|
||||||
[tags[tagIndex][0], tagValue],
|
...tags.slice(0, tagIndex),
|
||||||
...tags.slice(tagIndex + 1),
|
[tags[tagIndex][0], tagValue],
|
||||||
])
|
...tags.slice(tagIndex + 1),
|
||||||
|
]);
|
||||||
const addNewTag = () => {
|
const addNewTag = () => {
|
||||||
const error = validTagName(newTag[0]);
|
const error = validTagName(newTag[0]);
|
||||||
if (error) {
|
if (error) {
|
||||||
return setError('new', error)
|
return setError("new", error);
|
||||||
}
|
}
|
||||||
onUpdate(metadata, tags.concat([
|
onUpdate(
|
||||||
newTag.map(x => x.trim()) as [string, string]
|
metadata,
|
||||||
]));
|
tags.concat([newTag.map((x) => x.trim()) as [string, string]])
|
||||||
setNewTag(['', '']);
|
);
|
||||||
}
|
setNewTag(["", ""]);
|
||||||
const onRemoveTag = (tagIndex: number) => onUpdate(metadata, [
|
};
|
||||||
...tags.slice(0, tagIndex),
|
const onRemoveTag = (tagIndex: number) =>
|
||||||
...tags.slice(tagIndex + 1),
|
onUpdate(metadata, [
|
||||||
])
|
...tags.slice(0, tagIndex),
|
||||||
|
...tags.slice(tagIndex + 1),
|
||||||
|
]);
|
||||||
// render
|
// render
|
||||||
return <div className={`automation-editor--info-box ${className}`}>
|
return (
|
||||||
<div className="automation-editor--info-box-inner">
|
<div className={`automation-editor--info-box ${className}`}>
|
||||||
<InputText label="ID" value={metadata.id} onChange={onUpdateMetadata('id')} />
|
<div className="automation-editor--info-box-inner">
|
||||||
<InputText label="Name" value={metadata.alias ?? ""} onChange={onUpdateMetadata('alias')} />
|
<InputText
|
||||||
<InputText multiline label="Description" value={metadata.description ?? ""} onChange={onUpdateMetadata('description')} />
|
label="ID"
|
||||||
<InputList
|
value={metadata.id}
|
||||||
label="Mode"
|
onChange={onUpdateMetadata("id")}
|
||||||
current={metadata.mode}
|
/>
|
||||||
onChange={onUpdateMetadata('mode')}
|
<InputText
|
||||||
options={[
|
label="Name"
|
||||||
'parallel',
|
value={metadata.alias ?? ""}
|
||||||
'single',
|
onChange={onUpdateMetadata("alias")}
|
||||||
'queued',
|
/>
|
||||||
'restart'
|
<InputText
|
||||||
]}
|
multiline
|
||||||
/>
|
label="Description"
|
||||||
<div className="automation-editor--info-box--tags">
|
value={metadata.description ?? ""}
|
||||||
<h1>Tags</h1>
|
onChange={onUpdateMetadata("description")}
|
||||||
<div className="automation-editor--info-box--tag-list">
|
/>
|
||||||
{tags.map(([tagName, tagValue], tagIndex) => <div key={tagIndex} className="automation-editor--info-box--tag">
|
<InputList
|
||||||
|
label="Mode"
|
||||||
|
current={metadata.mode}
|
||||||
|
onChange={onUpdateMetadata("mode")}
|
||||||
|
options={["parallel", "single", "queued", "restart"]}
|
||||||
|
/>
|
||||||
|
<div className="automation-editor--info-box--tags">
|
||||||
|
<h1>Tags</h1>
|
||||||
|
<div className="automation-editor--info-box--tag-list">
|
||||||
|
{tags.map(([tagName, tagValue], tagIndex) => (
|
||||||
|
<div key={tagIndex} className="automation-editor--info-box--tag">
|
||||||
|
<InputAutoText
|
||||||
|
value={tagName}
|
||||||
|
label="Name"
|
||||||
|
onChange={(v) => updateTagName(v, tagIndex)}
|
||||||
|
options={foundNewTagNames}
|
||||||
|
error={errorIndex === tagIndex ? error : undefined}
|
||||||
|
/>
|
||||||
|
<InputAutoText
|
||||||
|
value={tagValue}
|
||||||
|
label="Tag"
|
||||||
|
onChange={(v) => onUpdateTags(v, tagIndex)}
|
||||||
|
options={tagDB.getTagValues(tagName)}
|
||||||
|
error={errorIndex === tagIndex ? error : undefined}
|
||||||
|
/>
|
||||||
|
<ButtonIcon
|
||||||
|
className="automation-editor--info-box--tag--trash"
|
||||||
|
onClick={() => onRemoveTag(tagIndex)}
|
||||||
|
icon={<TrashIcon />}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
<div className="automation-editor--info-box--tag">
|
||||||
<InputAutoText
|
<InputAutoText
|
||||||
value={tagName}
|
value={newTag[0]}
|
||||||
label="Name"
|
label="Name"
|
||||||
onChange={v => updateTagName(v, tagIndex)}
|
onChange={(v) => setNewTag([v, newTag[1]])}
|
||||||
options={foundNewTagNames}
|
options={foundNewTagNames}
|
||||||
error={errorIndex === tagIndex ? error : undefined}
|
error={errorIndex === "new" ? error : undefined}
|
||||||
/>
|
/>
|
||||||
<InputAutoText
|
<InputAutoText
|
||||||
value={tagValue}
|
value={newTag[1]}
|
||||||
label="Tag"
|
label="Tag"
|
||||||
onChange={v => onUpdateTags(v, tagIndex)}
|
onChange={(v) => setNewTag([newTag[0], v])}
|
||||||
options={tagDB.getTagValues(tagName)}
|
options={tagDB.getTagValues(newTag[0])}
|
||||||
error={errorIndex === tagIndex ? error : undefined}
|
error={errorIndex === "new" ? error : undefined}
|
||||||
/>
|
/>
|
||||||
<Button className="automation-editor--info-box--tag--trash" onClick={() => onRemoveTag(tagIndex)} ><TrashIcon /></Button>
|
<ButtonIcon
|
||||||
</div>)}
|
className="automation-editor--info-box--tag--add"
|
||||||
</div>
|
onClick={addNewTag}
|
||||||
<hr />
|
icon={<AddIcon />}
|
||||||
<div className="automation-editor--info-box--tag">
|
/>
|
||||||
<InputAutoText
|
</div>
|
||||||
value={newTag[0]}
|
|
||||||
label="Name"
|
|
||||||
onChange={v => setNewTag([v, newTag[1]])}
|
|
||||||
options={foundNewTagNames}
|
|
||||||
error={errorIndex === 'new' ? error : undefined}
|
|
||||||
/>
|
|
||||||
<InputAutoText
|
|
||||||
value={newTag[1]}
|
|
||||||
label="Tag"
|
|
||||||
onChange={v => setNewTag([newTag[0], v])}
|
|
||||||
options={tagDB.getTagValues(newTag[0])}
|
|
||||||
error={errorIndex === 'new' ? error : undefined}
|
|
||||||
/>
|
|
||||||
<Button className="automation-editor--info-box--tag--add" onClick={addNewTag} ><AddIcon /></Button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{children}
|
||||||
</div>
|
</div>
|
||||||
{children}
|
);
|
||||||
</div>
|
};
|
||||||
}
|
|
||||||
@@ -61,16 +61,19 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.automation-editor--info-box--icon {
|
.automation-editor .automation-editor--info-box--icon {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 0em;
|
left: 0.25em;
|
||||||
bottom: 0.5em;
|
bottom: 0em;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
|
max-width: 1.5em;
|
||||||
|
max-height: 1.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.automation-editor--info-box.hide>.automation-editor--info-box--icon {
|
.automation-editor--info-box.hide>.automation-editor--info-box--icon {
|
||||||
transform: rotate(180deg);
|
transform: rotate(180deg);
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
|
left: 0.1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.automation-editor.loading .mock-list {
|
.automation-editor.loading .mock-list {
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
import "./index.css";
|
import "./index.css";
|
||||||
import Icon from '@mui/material/Icon';
|
import Icon from "@mui/material/Icon";
|
||||||
import { ArrowIcon, CheckMarkIcon } from "components/Icons";
|
import { CheckMarkIcon } from "components/Icons";
|
||||||
import { FC, useEffect, useState } from "react";
|
import { FC, useEffect, useState } from "react";
|
||||||
import { AutomationData } from "types/automations";
|
import { AutomationData } from "types/automations";
|
||||||
import { AutoInfoBox } from "./AutoInfoBox";
|
import { AutoInfoBox } from "./AutoInfoBox";
|
||||||
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||||
import { Button } from "components/Inputs/Button";
|
import { Button } from "components/Inputs/Button";
|
||||||
import { useAutomatioEditorState, EditorData } from './state';
|
import { useAutomatioEditorState, EditorData } from "./state";
|
||||||
import { SafeDAGAutomationFlow } from "components/DAGFlow/safe";
|
import { SafeDAGAutomationFlow } from "components/DAGFlow/safe";
|
||||||
import { DAGAutomationFlowDims } from "components/DAGFlow/types";
|
import { DAGAutomationFlowDims } from "components/DAGFlow/types";
|
||||||
import { MiniFailure } from 'types/validators/helper';
|
import { MiniFailure } from "types/validators/helper";
|
||||||
import InputYaml from "components/Inputs/InputYaml";
|
import InputYaml from "components/Inputs/InputYaml";
|
||||||
import { TagDB } from "components/AutomationList/TagDB";
|
import { TagDB } from "components/AutomationList/TagDB";
|
||||||
import Skeleton from "@mui/material/Skeleton";
|
import Skeleton from "@mui/material/Skeleton";
|
||||||
import LinearProgress from "@mui/material/LinearProgress";
|
import LinearProgress from "@mui/material/LinearProgress";
|
||||||
|
import { ArrowBack } from "@mui/icons-material";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
automation?: AutomationData;
|
automation?: AutomationData;
|
||||||
@@ -44,129 +45,166 @@ export const AutomationEditor: FC<Props> = ({
|
|||||||
// effect
|
// effect
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (dims.flipped !== flipped) {
|
if (dims.flipped !== flipped) {
|
||||||
setFlipped(dims.flipped)
|
setFlipped(dims.flipped);
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
}, [dims.flipped])
|
}, [dims.flipped]);
|
||||||
|
|
||||||
// render
|
// render
|
||||||
if (state.status === 'loading') {
|
if (state.status === "loading") {
|
||||||
return <div className="automation-editor loading">
|
return (
|
||||||
<LinearProgress className="linear-loader" />
|
<div className="automation-editor loading">
|
||||||
<Skeleton className="mock-list" variant="rectangular" />
|
<LinearProgress className="linear-loader" />
|
||||||
<Skeleton className="mock-graph" variant="rectangular" />
|
<Skeleton className="mock-list" variant="rectangular" />
|
||||||
</div>
|
<Skeleton className="mock-graph" variant="rectangular" />
|
||||||
}
|
|
||||||
if (state.status === 'invalid') {
|
|
||||||
return <ValidationBox
|
|
||||||
failures={state.failures}
|
|
||||||
data={state.data}
|
|
||||||
validate={validate}
|
|
||||||
onSave={saveAndUpdate}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
return <div className="automation-editor">
|
|
||||||
{state.status === 'saving' && <LinearProgress className="linear-loader" />}
|
|
||||||
<AutoInfoBox
|
|
||||||
className={closeInfo ? "hide" : "show"}
|
|
||||||
metadata={state.data.metadata}
|
|
||||||
tags={state.data.tags}
|
|
||||||
onUpdate={updateMetadata}
|
|
||||||
tagDB={tagDB}
|
|
||||||
>
|
|
||||||
<ButtonIcon
|
|
||||||
className="automation-editor--info-box--icon"
|
|
||||||
onClick={() => setCloseInfo(!closeInfo)}
|
|
||||||
title={closeInfo ? "Show Metadata" : "Hide Metadata"}
|
|
||||||
Icon={ArrowIcon}
|
|
||||||
/>
|
|
||||||
</AutoInfoBox>
|
|
||||||
|
|
||||||
<div className={["automation-editor--flow-wrapper", state.status].join(" ")}>
|
|
||||||
<div className="automation-editor--flow-wrapper--toolbar">
|
|
||||||
{!dims.flipped && <Button
|
|
||||||
className={"automation-editor--flow-wrapper--toolbar--flip-btn"}
|
|
||||||
onClick={() => setFlipped(!flipped)}
|
|
||||||
>
|
|
||||||
<Icon>{flipped ? 'flip_to_front' : 'flip_to_back'}</Icon>
|
|
||||||
Flip
|
|
||||||
</Button>}
|
|
||||||
<Button
|
|
||||||
className={"automation-editor--flow-wrapper--toolbar--save-btn"}
|
|
||||||
onClick={save}
|
|
||||||
disabled={state.status !== 'changed'}
|
|
||||||
>
|
|
||||||
Save <CheckMarkIcon color="#bf4" />
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
<SafeDAGAutomationFlow
|
);
|
||||||
className="automation-editor--flow-wrapper--flow"
|
}
|
||||||
sequence={state.data.sequence}
|
if (state.status === "invalid") {
|
||||||
trigger={state.data.trigger}
|
return (
|
||||||
condition={state.data.condition}
|
<ValidationBox
|
||||||
onSequenceUpdate={updateSequence}
|
failures={state.failures}
|
||||||
onTriggerUpdate={updateTrigger}
|
data={state.data}
|
||||||
onConditionUpdate={updateCondition}
|
validate={validate}
|
||||||
dims={{
|
onSave={saveAndUpdate}
|
||||||
...dims,
|
|
||||||
flipped,
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
);
|
||||||
</div>
|
}
|
||||||
}
|
return (
|
||||||
|
<div className="automation-editor">
|
||||||
|
{state.status === "saving" && (
|
||||||
|
<LinearProgress className="linear-loader" />
|
||||||
|
)}
|
||||||
|
<AutoInfoBox
|
||||||
|
className={closeInfo ? "hide" : "show"}
|
||||||
|
metadata={state.data.metadata}
|
||||||
|
tags={state.data.tags}
|
||||||
|
onUpdate={updateMetadata}
|
||||||
|
tagDB={tagDB}
|
||||||
|
>
|
||||||
|
<ButtonIcon
|
||||||
|
className="automation-editor--info-box--icon"
|
||||||
|
onClick={() => setCloseInfo(!closeInfo)}
|
||||||
|
title={closeInfo ? "Show Metadata" : "Hide Metadata"}
|
||||||
|
color="success"
|
||||||
|
icon={<ArrowBack />}
|
||||||
|
/>
|
||||||
|
</AutoInfoBox>
|
||||||
|
|
||||||
|
<div
|
||||||
|
className={["automation-editor--flow-wrapper", state.status].join(" ")}
|
||||||
|
>
|
||||||
|
<div className="automation-editor--flow-wrapper--toolbar">
|
||||||
|
{!dims.flipped && (
|
||||||
|
<Button
|
||||||
|
className={"automation-editor--flow-wrapper--toolbar--flip-btn"}
|
||||||
|
onClick={() => setFlipped(!flipped)}
|
||||||
|
>
|
||||||
|
<Icon>{flipped ? "flip_to_front" : "flip_to_back"}</Icon>
|
||||||
|
Flip
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
<Button
|
||||||
|
className={"automation-editor--flow-wrapper--toolbar--save-btn"}
|
||||||
|
onClick={save}
|
||||||
|
disabled={state.status !== "changed"}
|
||||||
|
>
|
||||||
|
Save <CheckMarkIcon color="#bf4" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<SafeDAGAutomationFlow
|
||||||
|
className="automation-editor--flow-wrapper--flow"
|
||||||
|
sequence={state.data.sequence}
|
||||||
|
trigger={state.data.trigger}
|
||||||
|
condition={state.data.condition}
|
||||||
|
onSequenceUpdate={updateSequence}
|
||||||
|
onTriggerUpdate={updateTrigger}
|
||||||
|
onConditionUpdate={updateCondition}
|
||||||
|
dims={{
|
||||||
|
...dims,
|
||||||
|
flipped,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const ValidationBox: FC<{
|
export const ValidationBox: FC<{
|
||||||
failures: MiniFailure[]
|
failures: MiniFailure[];
|
||||||
validate: (d: any) => MiniFailure[] | null,
|
validate: (d: any) => MiniFailure[] | null;
|
||||||
data: EditorData,
|
data: EditorData;
|
||||||
onSave: (d: EditorData) => void,
|
onSave: (d: EditorData) => void;
|
||||||
}> = props => {
|
}> = (props) => {
|
||||||
|
|
||||||
const [{ failures, data }, setState] = useState({
|
const [{ failures, data }, setState] = useState({
|
||||||
failures: props.failures,
|
failures: props.failures,
|
||||||
data: props.data,
|
data: props.data,
|
||||||
});
|
});
|
||||||
|
|
||||||
const makeSave = <K extends keyof EditorData>(k: K) => (d: EditorData[K]) => {
|
const makeSave =
|
||||||
const newData = {
|
<K extends keyof EditorData>(k: K) =>
|
||||||
...data,
|
(d: EditorData[K]) => {
|
||||||
[k]: d,
|
const newData = {
|
||||||
}
|
...data,
|
||||||
const newFails = props.validate(newData);
|
[k]: d,
|
||||||
if (newFails) {
|
};
|
||||||
setState({
|
const newFails = props.validate(newData);
|
||||||
failures: newFails,
|
if (newFails) {
|
||||||
data: newData,
|
setState({
|
||||||
})
|
failures: newFails,
|
||||||
} else {
|
data: newData,
|
||||||
setState({
|
});
|
||||||
failures: [],
|
} else {
|
||||||
data: newData,
|
setState({
|
||||||
})
|
failures: [],
|
||||||
}
|
data: newData,
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return <div className="automation-editor-failures">
|
return (
|
||||||
<ul>
|
<div className="automation-editor-failures">
|
||||||
{failures.map((f, i) => <>
|
<ul>
|
||||||
<li key={i}>
|
{failures.map((f, i) => (
|
||||||
<b>{f.path}</b>:
|
<>
|
||||||
<ul>
|
<li key={i}>
|
||||||
{f.message.map((m, j) => <li key={j}>
|
<b>{f.path}</b>:
|
||||||
{m}
|
<ul>
|
||||||
</li>)}
|
{f.message.map((m, j) => (
|
||||||
</ul>
|
<li key={j}>{m}</li>
|
||||||
</li>
|
))}
|
||||||
</>)}
|
</ul>
|
||||||
</ul>
|
</li>
|
||||||
<span>Please correct the automation file manually and then continue!</span>
|
</>
|
||||||
<InputYaml label="Metadata" value={data.metadata} onChange={makeSave('metadata')} />
|
))}
|
||||||
<InputYaml label="Tags" value={data.tags} onChange={makeSave('tags')} />
|
</ul>
|
||||||
<InputYaml label="Trigger" value={data.trigger} onChange={makeSave('trigger')} />
|
<span>
|
||||||
<InputYaml label="Condition" value={data.condition} onChange={makeSave('condition')} />
|
Please correct the automation file manually and then continue!
|
||||||
<InputYaml label="Actions" value={data.sequence} onChange={makeSave('sequence')} />
|
</span>
|
||||||
<Button disabled={failures.length > 0} onClick={() => props.onSave(data)}>Save</Button>
|
<InputYaml
|
||||||
</div>
|
label="Metadata"
|
||||||
}
|
value={data.metadata}
|
||||||
|
onChange={makeSave("metadata")}
|
||||||
|
/>
|
||||||
|
<InputYaml label="Tags" value={data.tags} onChange={makeSave("tags")} />
|
||||||
|
<InputYaml
|
||||||
|
label="Trigger"
|
||||||
|
value={data.trigger}
|
||||||
|
onChange={makeSave("trigger")}
|
||||||
|
/>
|
||||||
|
<InputYaml
|
||||||
|
label="Condition"
|
||||||
|
value={data.condition}
|
||||||
|
onChange={makeSave("condition")}
|
||||||
|
/>
|
||||||
|
<InputYaml
|
||||||
|
label="Actions"
|
||||||
|
value={data.sequence}
|
||||||
|
onChange={makeSave("sequence")}
|
||||||
|
/>
|
||||||
|
<Button disabled={failures.length > 0} onClick={() => props.onSave(data)}>
|
||||||
|
Save
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import "./AutomationListBox.css";
|
import "./AutomationListBox.css";
|
||||||
import { FC, useState } from 'react';
|
import { FC, useState } from "react";
|
||||||
import { AutomationData } from "types/automations";
|
import { AutomationData } from "types/automations";
|
||||||
import InputMultiSelect from "components/Inputs/InputMultiSelect";
|
import InputMultiSelect from "components/Inputs/InputMultiSelect";
|
||||||
import InputText from "components/Inputs/InputText";
|
import InputText from "components/Inputs/InputText";
|
||||||
@@ -8,126 +8,135 @@ import { makeGrouping } from "./automationGrouper";
|
|||||||
import { AutomationListBoxGroup } from "./AutomationListBoxGroup";
|
import { AutomationListBoxGroup } from "./AutomationListBoxGroup";
|
||||||
import { useCookies } from "react-cookie";
|
import { useCookies } from "react-cookie";
|
||||||
|
|
||||||
|
|
||||||
export type Props = {
|
export type Props = {
|
||||||
automations: AutomationData[];
|
automations: AutomationData[];
|
||||||
selected: number;
|
selected: number;
|
||||||
onSelectAutomation: (i: number) => void;
|
onSelectAutomation: (i: number) => void;
|
||||||
onRemove: (i: number) => void;
|
onRemove: (i: number) => void;
|
||||||
onAdd: () => void;
|
onAdd: () => void;
|
||||||
}
|
};
|
||||||
|
|
||||||
const useAutomationListBoxState = () => {
|
const useAutomationListBoxState = () => {
|
||||||
const [
|
const [
|
||||||
cookies,
|
cookies,
|
||||||
setCookies,
|
setCookies,
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
_
|
_,
|
||||||
] = useCookies(['albSearchText', 'albSelected']);
|
] = useCookies(["albSearchText", "albSelected"]);
|
||||||
let initialSelected = [];
|
let initialSelected = [];
|
||||||
try {
|
try {
|
||||||
initialSelected = JSON.parse(cookies.albSelected)
|
initialSelected = JSON.parse(cookies.albSelected);
|
||||||
if (!Array.isArray(initialSelected)) {
|
if (!Array.isArray(initialSelected)) {
|
||||||
initialSelected = [initialSelected]
|
initialSelected = [initialSelected];
|
||||||
}
|
|
||||||
initialSelected = initialSelected.map(Number)
|
|
||||||
// eslint-disable-next-line
|
|
||||||
} catch (_) { }
|
|
||||||
const [searchText, setSearchText] = useState(cookies.albSearchText ?? "");
|
|
||||||
const [selectedTagIdx, setSelectedTagIdx] = useState<number[]>(initialSelected);
|
|
||||||
|
|
||||||
return {
|
|
||||||
searchText,
|
|
||||||
setSearchText(v: string) {
|
|
||||||
setSearchText(v)
|
|
||||||
setCookies('albSearchText', v)
|
|
||||||
},
|
|
||||||
setSelectedTagIdx(n: number[]) {
|
|
||||||
setSelectedTagIdx(n)
|
|
||||||
setCookies('albSelected', JSON.stringify(n))
|
|
||||||
},
|
|
||||||
selectedTagIdx,
|
|
||||||
}
|
}
|
||||||
}
|
initialSelected = initialSelected.map(Number);
|
||||||
|
// eslint-disable-next-line
|
||||||
|
} catch (_) {}
|
||||||
|
const [searchText, setSearchText] = useState(cookies.albSearchText ?? "");
|
||||||
|
const [selectedTagIdx, setSelectedTagIdx] =
|
||||||
|
useState<number[]>(initialSelected);
|
||||||
|
|
||||||
|
return {
|
||||||
|
searchText,
|
||||||
|
setSearchText(v: string) {
|
||||||
|
setSearchText(v);
|
||||||
|
setCookies("albSearchText", v);
|
||||||
|
},
|
||||||
|
setSelectedTagIdx(n: number[]) {
|
||||||
|
setSelectedTagIdx(n);
|
||||||
|
setCookies("albSelected", JSON.stringify(n));
|
||||||
|
},
|
||||||
|
selectedTagIdx,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
export const AutomationListBox: FC<Props> = ({
|
export const AutomationListBox: FC<Props> = ({
|
||||||
automations,
|
automations,
|
||||||
selected,
|
selected,
|
||||||
onSelectAutomation,
|
onSelectAutomation,
|
||||||
onAdd,
|
onAdd,
|
||||||
onRemove,
|
onRemove,
|
||||||
}) => {
|
}) => {
|
||||||
|
const tags = getTagList(automations);
|
||||||
|
const { searchText, setSearchText, selectedTagIdx, setSelectedTagIdx } =
|
||||||
|
useAutomationListBoxState();
|
||||||
|
const filteredAutomations = filterAutomations(
|
||||||
|
automations,
|
||||||
|
searchText.toLowerCase()
|
||||||
|
);
|
||||||
|
const grouping = makeGrouping(
|
||||||
|
filteredAutomations.map(([a, _]) => a),
|
||||||
|
selectedTagIdx.map((i) => tags[i]),
|
||||||
|
selected
|
||||||
|
);
|
||||||
|
|
||||||
const tags = getTagList(automations);
|
return (
|
||||||
const {
|
<div className="automation-list-box">
|
||||||
searchText,
|
<div className="automation-list-box--nav">
|
||||||
setSearchText,
|
<InputText label="Search" value={searchText} onChange={setSearchText} />
|
||||||
selectedTagIdx,
|
<InputMultiSelect
|
||||||
setSelectedTagIdx,
|
label="Tags"
|
||||||
} = useAutomationListBoxState();
|
selected={selectedTagIdx}
|
||||||
const filteredAutomations = filterAutomations(automations, searchText.toLowerCase(), selectedTagIdx, tags);
|
onChange={setSelectedTagIdx}
|
||||||
const grouping = makeGrouping(
|
options={tags}
|
||||||
filteredAutomations.map(([a, _]) => a),
|
max={3}
|
||||||
selectedTagIdx.map(i => tags[i]),
|
/>
|
||||||
selected,
|
</div>
|
||||||
)
|
<div className="automation-list-box--body">
|
||||||
|
<AutomationListBoxGroup
|
||||||
return <div className="automation-list-box">
|
events={{
|
||||||
<div className="automation-list-box--nav">
|
onSelectAutomation,
|
||||||
<InputText
|
onRemove,
|
||||||
label="Search"
|
}}
|
||||||
value={searchText}
|
autos={filteredAutomations}
|
||||||
onChange={setSearchText}
|
grouping={grouping}
|
||||||
/>
|
selectedAutomationIdx={selected}
|
||||||
<InputMultiSelect
|
/>
|
||||||
label="Tags"
|
</div>
|
||||||
selected={selectedTagIdx}
|
<div className="automation-list-box--bottom">
|
||||||
onChange={setSelectedTagIdx}
|
<Button onClick={onAdd}>Add</Button>
|
||||||
options={tags}
|
<span>
|
||||||
max={3}
|
Showing Automations: {filteredAutomations.length} out of{" "}
|
||||||
/>
|
{automations.length}
|
||||||
</div>
|
</span>
|
||||||
<div className="automation-list-box--body">
|
</div>
|
||||||
<AutomationListBoxGroup
|
|
||||||
events={{
|
|
||||||
onSelectAutomation,
|
|
||||||
onRemove
|
|
||||||
}}
|
|
||||||
autos={filteredAutomations}
|
|
||||||
grouping={grouping}
|
|
||||||
selectedAutomationIdx={selected}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="automation-list-box--bottom">
|
|
||||||
<Button onClick={onAdd}>Add</Button>
|
|
||||||
<span>Showing Automations: {filteredAutomations.length} out of {automations.length}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
}
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getTagList = (autos: AutomationData[]): string[] =>
|
||||||
export const getTagList = (autos: AutomationData[]): string[] => Object.keys(autos
|
Object.keys(
|
||||||
.map(a => Object.keys(a.tags))
|
autos
|
||||||
.reduce((all: any, keys) => {
|
.map((a) => Object.keys(a.tags))
|
||||||
|
.reduce((all: any, keys) => {
|
||||||
for (const k of keys) {
|
for (const k of keys) {
|
||||||
all[k] = 1
|
all[k] = 1;
|
||||||
}
|
}
|
||||||
return all;
|
return all;
|
||||||
}, {}))
|
}, {})
|
||||||
|
);
|
||||||
|
|
||||||
const filterAutomations = (autos: AutomationData[], searchText: string, selected: number[], tags: string[]): Array<[AutomationData, number]> => autos.map<[AutomationData, number]>((a, i) => [a, i]).filter(([a, i]) => {
|
const filterAutomations = (
|
||||||
if (!a.metadata) {
|
autos: AutomationData[],
|
||||||
return true
|
searchText: string
|
||||||
}
|
): Array<[AutomationData, number]> =>
|
||||||
if (searchText.length > 0) {
|
autos
|
||||||
|
.map<[AutomationData, number]>((a, i) => [a, i])
|
||||||
|
.filter(([a, i]) => {
|
||||||
|
if (!a.metadata) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (searchText.length > 0) {
|
||||||
if (
|
if (
|
||||||
!(
|
!(
|
||||||
(a.metadata.description ?? "").toLocaleLowerCase().includes(searchText) ||
|
(a.metadata.description ?? "")
|
||||||
(a.metadata.alias ?? "").toLocaleLowerCase().includes(searchText)
|
.toLocaleLowerCase()
|
||||||
)
|
.includes(searchText) ||
|
||||||
|
(a.metadata.alias ?? "").toLocaleLowerCase().includes(searchText)
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
return false
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true
|
return true;
|
||||||
})
|
});
|
||||||
@@ -1,141 +1,166 @@
|
|||||||
|
|
||||||
import { TrashIcon } from "components/Icons";
|
import { TrashIcon } from "components/Icons";
|
||||||
import { Button } from "components/Inputs/Button";
|
|
||||||
import { MetadataBox } from "./AutomationMetadataBox";
|
import { MetadataBox } from "./AutomationMetadataBox";
|
||||||
import { AutomationData } from "types/automations";
|
import { AutomationData } from "types/automations";
|
||||||
import { AutomationGrouping } from "./automationGrouper";
|
import { AutomationGrouping } from "./automationGrouper";
|
||||||
import { FC, useState } from "react";
|
import { FC, useState } from "react";
|
||||||
|
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||||
|
|
||||||
export type AutomationListBoxEvents = {
|
export type AutomationListBoxEvents = {
|
||||||
onSelectAutomation: (i: number) => void,
|
onSelectAutomation: (i: number) => void;
|
||||||
onRemove: (i: number) => void,
|
onRemove: (i: number) => void;
|
||||||
}
|
};
|
||||||
export type AutomationListBoxGroups = {
|
export type AutomationListBoxGroups = {
|
||||||
grouping: AutomationGrouping,
|
grouping: AutomationGrouping;
|
||||||
currentNode: number,
|
currentNode: number;
|
||||||
}
|
};
|
||||||
export type AutomationListBoxProps = {
|
export type AutomationListBoxProps = {
|
||||||
events: AutomationListBoxEvents,
|
events: AutomationListBoxEvents;
|
||||||
groups: AutomationListBoxGroups,
|
groups: AutomationListBoxGroups;
|
||||||
autos: Array<[AutomationData, number]>,
|
autos: Array<[AutomationData, number]>;
|
||||||
selectedAutomationIdx: number,
|
selectedAutomationIdx: number;
|
||||||
};
|
};
|
||||||
export type AutomationListBoxGroupProps = {
|
export type AutomationListBoxGroupProps = {
|
||||||
events: AutomationListBoxEvents,
|
events: AutomationListBoxEvents;
|
||||||
grouping: AutomationGrouping,
|
grouping: AutomationGrouping;
|
||||||
autos: Array<[AutomationData, number]>,
|
autos: Array<[AutomationData, number]>;
|
||||||
selectedAutomationIdx: number,
|
selectedAutomationIdx: number;
|
||||||
}
|
};
|
||||||
export const AutomationListBoxGroup: FC<AutomationListBoxGroupProps> = ({
|
export const AutomationListBoxGroup: FC<AutomationListBoxGroupProps> = ({
|
||||||
events, grouping, autos, selectedAutomationIdx,
|
events,
|
||||||
|
grouping,
|
||||||
|
autos,
|
||||||
|
selectedAutomationIdx,
|
||||||
}) => {
|
}) => {
|
||||||
if (grouping.top.length === 1) {
|
if (grouping.top.length === 1) {
|
||||||
return <>
|
return (
|
||||||
{convertGroupsToItems(autos, {
|
<>
|
||||||
grouping, currentNode: grouping.top[0],
|
{convertGroupsToItems(
|
||||||
}, events, selectedAutomationIdx)}
|
autos,
|
||||||
</>
|
{
|
||||||
} else {
|
grouping,
|
||||||
return <>
|
currentNode: grouping.top[0],
|
||||||
{grouping.top.map(groupIdx => <AutomationListBoxGroupItem
|
},
|
||||||
key={groupIdx}
|
events,
|
||||||
autos={autos}
|
selectedAutomationIdx
|
||||||
groups={{
|
)}
|
||||||
grouping,
|
</>
|
||||||
currentNode: groupIdx
|
);
|
||||||
}}
|
} else {
|
||||||
events={events}
|
return (
|
||||||
selectedAutomationIdx={selectedAutomationIdx}
|
<>
|
||||||
/>)}
|
{grouping.top.map((groupIdx) => (
|
||||||
</>
|
<AutomationListBoxGroupItem
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const convertGroupsToItems = (
|
|
||||||
autos: Array<[AutomationData, number]>,
|
|
||||||
{ grouping, currentNode }: AutomationListBoxGroups,
|
|
||||||
events: AutomationListBoxEvents,
|
|
||||||
selectedAutomationIdx: number,
|
|
||||||
) => {
|
|
||||||
const automations = grouping.getAutomations(currentNode);
|
|
||||||
if (automations.length > 0) {
|
|
||||||
return automations.map(autoIndex =>
|
|
||||||
<AutomationListBoxItem
|
|
||||||
key={`${autoIndex}-${autos[autoIndex][1]}`}
|
|
||||||
events={events}
|
|
||||||
auto={autos[autoIndex]}
|
|
||||||
isSelected={selectedAutomationIdx === autos[autoIndex][1]}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
const subgroups = grouping.getSubGroups(currentNode);
|
|
||||||
if (subgroups.length > 0) {
|
|
||||||
return subgroups.map(groupIdx => <AutomationListBoxGroupItem
|
|
||||||
key={groupIdx}
|
key={groupIdx}
|
||||||
autos={autos}
|
autos={autos}
|
||||||
groups={{
|
groups={{
|
||||||
grouping,
|
grouping,
|
||||||
currentNode: groupIdx
|
currentNode: groupIdx,
|
||||||
}}
|
}}
|
||||||
events={events}
|
events={events}
|
||||||
selectedAutomationIdx={selectedAutomationIdx}
|
selectedAutomationIdx={selectedAutomationIdx}
|
||||||
/>)
|
/>
|
||||||
}
|
))}
|
||||||
return <></>
|
</>
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const convertGroupsToItems = (
|
||||||
|
autos: Array<[AutomationData, number]>,
|
||||||
|
{ grouping, currentNode }: AutomationListBoxGroups,
|
||||||
|
events: AutomationListBoxEvents,
|
||||||
|
selectedAutomationIdx: number
|
||||||
|
) => {
|
||||||
|
const automations = grouping.getAutomations(currentNode);
|
||||||
|
if (automations.length > 0) {
|
||||||
|
return automations.map((autoIndex) => (
|
||||||
|
<AutomationListBoxItem
|
||||||
|
key={`${autoIndex}-${autos[autoIndex][1]}`}
|
||||||
|
events={events}
|
||||||
|
auto={autos[autoIndex]}
|
||||||
|
isSelected={selectedAutomationIdx === autos[autoIndex][1]}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
}
|
||||||
|
const subgroups = grouping.getSubGroups(currentNode);
|
||||||
|
if (subgroups.length > 0) {
|
||||||
|
return subgroups.map((groupIdx) => (
|
||||||
|
<AutomationListBoxGroupItem
|
||||||
|
key={groupIdx}
|
||||||
|
autos={autos}
|
||||||
|
groups={{
|
||||||
|
grouping,
|
||||||
|
currentNode: groupIdx,
|
||||||
|
}}
|
||||||
|
events={events}
|
||||||
|
selectedAutomationIdx={selectedAutomationIdx}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return <></>;
|
||||||
|
};
|
||||||
|
|
||||||
export const AutomationListBoxGroupItem: FC<{
|
export const AutomationListBoxGroupItem: FC<{
|
||||||
events: AutomationListBoxEvents,
|
events: AutomationListBoxEvents;
|
||||||
groups: AutomationListBoxGroups,
|
groups: AutomationListBoxGroups;
|
||||||
autos: Array<[AutomationData, number]>,
|
autos: Array<[AutomationData, number]>;
|
||||||
selectedAutomationIdx: number,
|
selectedAutomationIdx: number;
|
||||||
}> = ({
|
}> = ({ autos, groups, events, selectedAutomationIdx }) => {
|
||||||
autos, groups, events, selectedAutomationIdx,
|
const groupData = groups.grouping.getData(groups.currentNode);
|
||||||
}) => {
|
const automations = groups.grouping.getAutomations(groups.currentNode);
|
||||||
const groupData = groups.grouping.getData(groups.currentNode);
|
const [open, setOpen] = useState(false);
|
||||||
const automations = groups.grouping.getAutomations(groups.currentNode);
|
const isOther = groupData.isOther;
|
||||||
const [open, setOpen] = useState(false);
|
const openIcon = !open ? "⊕" : "⊖";
|
||||||
const isOther = groupData.isOther;
|
const total = isOther ? (
|
||||||
const openIcon = !open ? "⊕" : "⊖";
|
<small>
|
||||||
const total = isOther ? <small>
|
{automations.length} automation{automations.length !== 1 ? "s" : ""}{" "}
|
||||||
{automations.length} automation{automations.length !== 1 ? 's' : ''} {groupData.isOther ? "" : "(untagged)"}
|
{groupData.isOther ? "" : "(untagged)"}
|
||||||
</small> : <></>
|
</small>
|
||||||
return <div className={[
|
) : (
|
||||||
"automation-list-box--body--group",
|
<></>
|
||||||
isOther ? 'other' : '',
|
);
|
||||||
groupData.selected ? 'selected' : '',
|
return (
|
||||||
].join(' ')}>
|
<div
|
||||||
<b onClick={() => setOpen(!open)}>{groupData.name} {openIcon} {total}</b>
|
className={[
|
||||||
{open && convertGroupsToItems(autos, groups, events, selectedAutomationIdx)}
|
"automation-list-box--body--group",
|
||||||
</div>
|
isOther ? "other" : "",
|
||||||
}
|
groupData.selected ? "selected" : "",
|
||||||
|
].join(" ")}
|
||||||
|
>
|
||||||
|
<b onClick={() => setOpen(!open)}>
|
||||||
|
{groupData.name} {openIcon} {total}
|
||||||
|
</b>
|
||||||
|
{open &&
|
||||||
|
convertGroupsToItems(autos, groups, events, selectedAutomationIdx)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const AutomationListBoxItem: FC<{
|
export const AutomationListBoxItem: FC<{
|
||||||
auto: [AutomationData, number],
|
auto: [AutomationData, number];
|
||||||
isSelected: boolean,
|
isSelected: boolean;
|
||||||
events: AutomationListBoxEvents,
|
events: AutomationListBoxEvents;
|
||||||
}> = ({
|
}> = ({
|
||||||
events: {
|
events: { onRemove, onSelectAutomation },
|
||||||
onRemove,
|
auto: [auto, autoIndex],
|
||||||
onSelectAutomation,
|
isSelected,
|
||||||
},
|
|
||||||
auto: [
|
|
||||||
auto, autoIndex
|
|
||||||
],
|
|
||||||
isSelected,
|
|
||||||
}) => {
|
}) => {
|
||||||
let title = "BadAuto<<Missing Metadata>>"
|
let title = "BadAuto<<Missing Metadata>>";
|
||||||
if (auto.metadata) {
|
if (auto.metadata) {
|
||||||
title = `Name = ${auto.metadata.alias}\nID = ${auto.metadata.id}\nDescription = ${auto.metadata.description}`
|
title = `Name = ${auto.metadata.alias}\nID = ${auto.metadata.id}\nDescription = ${auto.metadata.description}`;
|
||||||
}
|
}
|
||||||
return <div
|
return (
|
||||||
key={autoIndex}
|
<div
|
||||||
className={["automation-list-box--body--item", isSelected ? 'selected' : ''].join(' ')}
|
key={autoIndex}
|
||||||
title={title}
|
className={[
|
||||||
onClick={() => onSelectAutomation(autoIndex)}
|
"automation-list-box--body--item",
|
||||||
>
|
isSelected ? "selected" : "",
|
||||||
<MetadataBox metadata={auto.metadata} tags={auto.tags} />
|
].join(" ")}
|
||||||
<Button onClick={() => onRemove(autoIndex)}><TrashIcon /></Button>
|
title={title}
|
||||||
</div>
|
onClick={() => onSelectAutomation(autoIndex)}
|
||||||
}
|
>
|
||||||
|
<MetadataBox metadata={auto.metadata} tags={auto.tags} />
|
||||||
|
<ButtonIcon onClick={() => onRemove(autoIndex)} icon={<TrashIcon />} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -50,6 +50,7 @@
|
|||||||
|
|
||||||
.automation-list--list.hide>.automation-list--list-hide {
|
.automation-list--list.hide>.automation-list--list-hide {
|
||||||
transform: rotate(180deg);
|
transform: rotate(180deg);
|
||||||
|
left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* list children: normal */
|
/* list children: normal */
|
||||||
@@ -58,8 +59,10 @@
|
|||||||
border-width: 1px;
|
border-width: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.automation-list--list-hide {
|
.automation-list--list .automation-list--list-hide {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0.5em;
|
bottom: 0em;
|
||||||
right: 0.5em;
|
left: 0.5em;
|
||||||
|
max-width: 1.5em;
|
||||||
|
max-height: 1.5em;
|
||||||
}
|
}
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
.automation-list--root.mobile .automation-list--list-hide {
|
.automation-list--root.mobile .automation-list--list-hide {
|
||||||
transform: rotate(90deg);
|
transform: rotate(90deg);
|
||||||
left: 1.25em;
|
left: 0.25em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.automation-list--root.mobile .automation-editor--info-box {
|
.automation-list--root.mobile .automation-editor--info-box {
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.automation-list--root.mobile .automation-editor--info-box--icon {
|
.automation-list--root.mobile .automation-editor--info-box--icon {
|
||||||
left: 1.25em;
|
left: 0.5em;
|
||||||
bottom: 0em;
|
bottom: 0em;
|
||||||
background-color: var(--primary);
|
background-color: var(--primary);
|
||||||
transform: rotate(90deg);
|
transform: rotate(90deg);
|
||||||
@@ -50,8 +50,8 @@
|
|||||||
.automation-list--root.mobile .automation-list--list.hide .automation-list--list-hide {
|
.automation-list--root.mobile .automation-list--list.hide .automation-list--list-hide {
|
||||||
transform: rotate(270deg);
|
transform: rotate(270deg);
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0.75em;
|
top: 0;
|
||||||
z-index: 20;
|
z-index: 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* info box hide */
|
/* info box hide */
|
||||||
@@ -64,9 +64,9 @@
|
|||||||
.automation-list--root.mobile .automation-editor--info-box.hide .automation-editor--info-box--icon {
|
.automation-list--root.mobile .automation-editor--info-box.hide .automation-editor--info-box--icon {
|
||||||
transform: rotate(270deg);
|
transform: rotate(270deg);
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0.75em;
|
top: 0em;
|
||||||
background-color: var(--green-opaque);
|
left: 0.25em;
|
||||||
z-index: 30;
|
z-index: 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { AutomationEditor } from "components/AutomationEditor";
|
|||||||
import { FC, ReactNode, useState } from "react";
|
import { FC, ReactNode, useState } from "react";
|
||||||
import { AutomationData } from "types/automations";
|
import { AutomationData } from "types/automations";
|
||||||
import { defaultAutomation } from "utils/defaults";
|
import { defaultAutomation } from "utils/defaults";
|
||||||
import { ArrowIcon } from "components/Icons";
|
|
||||||
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||||
import { ApiService } from "apiService/core";
|
import { ApiService } from "apiService/core";
|
||||||
import { AutomationListBox } from "./AutomationListBox";
|
import { AutomationListBox } from "./AutomationListBox";
|
||||||
@@ -15,6 +14,7 @@ import LinearProgress from "@mui/material/LinearProgress";
|
|||||||
import CircularProgress from "@mui/material/CircularProgress";
|
import CircularProgress from "@mui/material/CircularProgress";
|
||||||
import { useCookies } from "react-cookie";
|
import { useCookies } from "react-cookie";
|
||||||
import { useHA } from "haService";
|
import { useHA } from "haService";
|
||||||
|
import { ArrowBack } from "@mui/icons-material";
|
||||||
|
|
||||||
interface AutomationListParams {
|
interface AutomationListParams {
|
||||||
automations: AutomationData[];
|
automations: AutomationData[];
|
||||||
@@ -97,7 +97,7 @@ export const AutomationList: FC<AutomationListParams> = ({
|
|||||||
<ButtonIcon
|
<ButtonIcon
|
||||||
onClick={() => setHideList(!hideList)}
|
onClick={() => setHideList(!hideList)}
|
||||||
className="automation-list--list-hide"
|
className="automation-list--list-hide"
|
||||||
Icon={ArrowIcon}
|
icon={<ArrowBack />}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="automation-list--viewer">
|
<div className="automation-list--viewer">
|
||||||
|
|||||||
@@ -39,11 +39,13 @@ export function DeviceEditor<DBT extends DeviceBaseType>({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<InputDevice
|
<InputDevice
|
||||||
|
key="devices"
|
||||||
label="Device"
|
label="Device"
|
||||||
value={state.device_id ?? ""}
|
value={state.device_id ?? ""}
|
||||||
onChange={(device_id) => setState({ device_id: device_id ?? "" })}
|
onChange={(device_id) => setState({ device_id: device_id ?? "" })}
|
||||||
/>
|
/>
|
||||||
<InputAutoComplete
|
<InputAutoComplete
|
||||||
|
key="action"
|
||||||
label="Action"
|
label="Action"
|
||||||
multiple={false}
|
multiple={false}
|
||||||
value={actionId}
|
value={actionId}
|
||||||
@@ -76,6 +78,7 @@ export function DeviceEditor<DBT extends DeviceBaseType>({
|
|||||||
)}
|
)}
|
||||||
{caps?.extra_fields && (
|
{caps?.extra_fields && (
|
||||||
<InputDeviceCapabilties
|
<InputDeviceCapabilties
|
||||||
|
key="caps"
|
||||||
state={state}
|
state={state}
|
||||||
setState={setState}
|
setState={setState}
|
||||||
defn={caps.extra_fields}
|
defn={caps.extra_fields}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
.MuiButtonBase-root.icon-button[type="button"] {
|
||||||
|
border-width: 1px;
|
||||||
|
border-style: solid;
|
||||||
|
max-width: 1.5em;
|
||||||
|
max-height: 1.5em;
|
||||||
|
}
|
||||||
@@ -1,30 +1,24 @@
|
|||||||
import { FC } from 'react';
|
import "./ButtonIcons.css";
|
||||||
import { IconBaseProps } from './base';
|
import { FC, ReactNode } from "react";
|
||||||
import { createAppUseStyles } from 'styles/theme';
|
import MuiIconButton, { IconButtonTypeMap } from "@mui/material/IconButton";
|
||||||
|
|
||||||
export interface ButtonIconStyleProps {
|
export const ButtonIcon: FC<{
|
||||||
}
|
icon: ReactNode;
|
||||||
export interface ButtonIconProps extends IconBaseProps, ButtonIconStyleProps {
|
onClick?: () => void;
|
||||||
Icon: FC<IconBaseProps>;
|
className?: string;
|
||||||
}
|
title?: string;
|
||||||
const useButtonIconStyles = createAppUseStyles(theme => ({
|
disabled?: boolean;
|
||||||
buttonIcon: {
|
color?: IconButtonTypeMap["props"]["color"];
|
||||||
borderRadius: "100%",
|
}> = (props) => {
|
||||||
borderWidth: 1,
|
return (
|
||||||
borderStyle: "groove",
|
<MuiIconButton
|
||||||
padding: "0.25em",
|
className={["icon-button", props.className ?? ""].join(" ")}
|
||||||
"&:hover": {
|
onClick={props.onClick}
|
||||||
backgroundColor: theme.secondaryAccent,
|
title={props.title}
|
||||||
cursor: 'pointer',
|
color={props.color}
|
||||||
}
|
disabled={props.disabled}
|
||||||
}
|
>
|
||||||
}))
|
{props.icon}
|
||||||
|
</MuiIconButton>
|
||||||
|
);
|
||||||
export const ButtonIcon: FC<ButtonIconProps> = ({
|
};
|
||||||
Icon,
|
|
||||||
className,
|
|
||||||
...props
|
|
||||||
}) => <Icon
|
|
||||||
className={`${useButtonIconStyles({}).classes.buttonIcon} ${className}`} {...props}
|
|
||||||
/>
|
|
||||||
@@ -1,41 +1,50 @@
|
|||||||
import { ComponentStory } from "@storybook/react";
|
import { ComponentStory } from "@storybook/react";
|
||||||
|
|
||||||
import { IconBase } from "./base";
|
import { IconBase } from "./base";
|
||||||
import { PencilIcon, CheckMarkIcon, TrashIcon, InfoIcon, ArrowIcon, AddIcon, ZoomIcon, GearIcon } from ".";
|
import {
|
||||||
|
PencilIcon,
|
||||||
|
CheckMarkIcon,
|
||||||
|
TrashIcon,
|
||||||
|
InfoIcon,
|
||||||
|
ArrowIcon,
|
||||||
|
AddIcon,
|
||||||
|
ZoomIcon,
|
||||||
|
GearIcon,
|
||||||
|
} from ".";
|
||||||
import { ButtonIcon } from "./ButtonIcons";
|
import { ButtonIcon } from "./ButtonIcons";
|
||||||
import { Page } from "components/Page";
|
import { Page } from "components/Page";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'Icons',
|
title: "Icons",
|
||||||
component: IconBase,
|
component: IconBase,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const IconList: ComponentStory<typeof IconBase> = (args) => {
|
export const IconList: ComponentStory<typeof IconBase> = (args) => {
|
||||||
|
return (
|
||||||
return <Page>
|
<Page>
|
||||||
<PencilIcon {...args} />
|
<PencilIcon {...args} />
|
||||||
<CheckMarkIcon {...args} />
|
<CheckMarkIcon {...args} />
|
||||||
<AddIcon {...args} />
|
<AddIcon {...args} />
|
||||||
<TrashIcon {...args} />
|
<TrashIcon {...args} />
|
||||||
<InfoIcon {...args} />
|
<InfoIcon {...args} />
|
||||||
<ZoomIcon {...args} />
|
<ZoomIcon {...args} />
|
||||||
<GearIcon {...args} />
|
<GearIcon {...args} />
|
||||||
</Page>
|
</Page>
|
||||||
}
|
);
|
||||||
|
};
|
||||||
IconList.args = {
|
IconList.args = {
|
||||||
size: 2,
|
size: 2,
|
||||||
color: 'red'
|
color: "red",
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
export const ButtonIconExample: ComponentStory<typeof IconBase> = (args) => {
|
export const ButtonIconExample: ComponentStory<typeof IconBase> = (args) => {
|
||||||
|
return (
|
||||||
return <Page>
|
<Page>
|
||||||
<ButtonIcon {...args} Icon={ArrowIcon} />
|
<ButtonIcon icon={<ArrowIcon {...args} />} />
|
||||||
</Page>
|
</Page>
|
||||||
}
|
);
|
||||||
|
};
|
||||||
ButtonIconExample.args = {
|
ButtonIconExample.args = {
|
||||||
size: 2,
|
size: 2,
|
||||||
color: 'red'
|
color: "red",
|
||||||
}
|
};
|
||||||
@@ -1,7 +1,21 @@
|
|||||||
import { ButtonHTMLAttributes, FC } from "react";
|
import { FC, ReactNode } from "react";
|
||||||
import { useButtonStyles } from "./styles";
|
import MuiButton from "@mui/material/Button";
|
||||||
|
|
||||||
export const Button: FC<ButtonHTMLAttributes<HTMLButtonElement>> = props => {
|
export const Button: FC<{
|
||||||
const { classes } = useButtonStyles({});
|
className?: string;
|
||||||
return <button {...props} className={`${classes.input} ${props.className ?? ''}`} />
|
title?: string;
|
||||||
}
|
disabled?: boolean;
|
||||||
|
children?: ReactNode;
|
||||||
|
onClick?: () => void;
|
||||||
|
}> = (props) => {
|
||||||
|
return (
|
||||||
|
<MuiButton
|
||||||
|
className={props.className}
|
||||||
|
title={props.title}
|
||||||
|
disabled={props.disabled}
|
||||||
|
onClick={props.onClick}
|
||||||
|
variant="outlined"
|
||||||
|
children={props.children}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -2,7 +2,8 @@ import "./InputAutoComplete.css";
|
|||||||
import Autocomplete from "@mui/material/Autocomplete";
|
import Autocomplete from "@mui/material/Autocomplete";
|
||||||
import TextField from "@mui/material/TextField";
|
import TextField from "@mui/material/TextField";
|
||||||
import Chip from "@mui/material/Chip";
|
import Chip from "@mui/material/Chip";
|
||||||
import { Badge, Popper } from "@mui/material";
|
import Badge from "@mui/material/Badge";
|
||||||
|
import Popper from "@mui/material/Popper";
|
||||||
import { SearchItem } from "./extras";
|
import { SearchItem } from "./extras";
|
||||||
import { ReactNode } from "react";
|
import { ReactNode } from "react";
|
||||||
import { prettyName } from "utils/formatting";
|
import { prettyName } from "utils/formatting";
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ import Checkbox from "@mui/material/Checkbox";
|
|||||||
import FormGroup from "@mui/material/FormGroup";
|
import FormGroup from "@mui/material/FormGroup";
|
||||||
import FormControlLabel from "@mui/material/FormControlLabel";
|
import FormControlLabel from "@mui/material/FormControlLabel";
|
||||||
import { ReactNode } from "react";
|
import { ReactNode } from "react";
|
||||||
import { FormHelperText, InputAdornment } from "@mui/material";
|
import FormHelperText from "@mui/material/FormHelperText";
|
||||||
|
import InputAdornment from "@mui/material/InputAdornment";
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
label: string;
|
label: string;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { useState, useEffect, FC } from "react";
|
|||||||
import TextField from "@mui/material/TextField";
|
import TextField from "@mui/material/TextField";
|
||||||
import EditIcon from "@mui/icons-material/Edit";
|
import EditIcon from "@mui/icons-material/Edit";
|
||||||
import CloseIcon from "@mui/icons-material/Close";
|
import CloseIcon from "@mui/icons-material/Close";
|
||||||
import IconButton from "@mui/material/IconButton";
|
|
||||||
import { AutomationTime, AutomationTimeObject } from "types/automations/common";
|
import { AutomationTime, AutomationTimeObject } from "types/automations/common";
|
||||||
import {
|
import {
|
||||||
convertAutomationTimeToTimeObject,
|
convertAutomationTimeToTimeObject,
|
||||||
@@ -12,6 +11,7 @@ import {
|
|||||||
import { convertAutomationTimeToTimeString } from "utils/time";
|
import { convertAutomationTimeToTimeString } from "utils/time";
|
||||||
import { prettyName } from "utils/formatting";
|
import { prettyName } from "utils/formatting";
|
||||||
import InputLabel from "@mui/material/InputLabel";
|
import InputLabel from "@mui/material/InputLabel";
|
||||||
|
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||||
|
|
||||||
// constants
|
// constants
|
||||||
const fields: Array<keyof AutomationTimeObject> = [
|
const fields: Array<keyof AutomationTimeObject> = [
|
||||||
@@ -140,9 +140,10 @@ export const InputTime: FC<Props> = (props) => {
|
|||||||
onChange={(e) => updateOne(name)(e.target.value)}
|
onChange={(e) => updateOne(name)(e.target.value)}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
<IconButton onClick={() => setDisabled(!disabled)}>
|
<ButtonIcon
|
||||||
{disabled ? <EditIcon /> : <CloseIcon />}
|
onClick={() => setDisabled(!disabled)}
|
||||||
</IconButton>
|
icon={disabled ? <EditIcon /> : <CloseIcon />}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
.input-number .MuiButtonBase-root.icon-button[type="button"].icon-button {
|
||||||
|
border-style: none;
|
||||||
|
}
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
|
import "./InputNumber.css";
|
||||||
import Close from "@mui/icons-material/Close";
|
import Close from "@mui/icons-material/Close";
|
||||||
import TextField from "@mui/material/TextField";
|
import TextField from "@mui/material/TextField";
|
||||||
import IconButton from "@mui/material/IconButton";
|
|
||||||
import InputAdornment from "@mui/material/InputAdornment";
|
import InputAdornment from "@mui/material/InputAdornment";
|
||||||
import Edit from "@mui/icons-material/Edit";
|
import Edit from "@mui/icons-material/Edit";
|
||||||
import { ReactNode } from "react";
|
import { ReactNode } from "react";
|
||||||
|
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
label: string | JSX.Element;
|
label: string | JSX.Element;
|
||||||
@@ -57,7 +58,7 @@ export default function InputNumber({
|
|||||||
value={value}
|
value={value}
|
||||||
onChange={(e) => onChange(Number(e.target.value ?? 0))}
|
onChange={(e) => onChange(Number(e.target.value ?? 0))}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
className={className}
|
className={["input-number", className ?? ""].join(" ")}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
required={required}
|
required={required}
|
||||||
fullWidth
|
fullWidth
|
||||||
@@ -67,9 +68,10 @@ export default function InputNumber({
|
|||||||
endAdornment
|
endAdornment
|
||||||
) : (
|
) : (
|
||||||
<InputAdornment position="end">
|
<InputAdornment position="end">
|
||||||
<IconButton onClick={() => onChange(disabled ? 0 : undefined)}>
|
<ButtonIcon
|
||||||
{disabled ? <Edit /> : <Close />}
|
onClick={() => onChange(disabled ? 0 : undefined)}
|
||||||
</IconButton>
|
icon={disabled ? <Edit /> : <Close />}
|
||||||
|
/>
|
||||||
</InputAdornment>
|
</InputAdornment>
|
||||||
),
|
),
|
||||||
inputProps: {
|
inputProps: {
|
||||||
|
|||||||
@@ -2,6 +2,12 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
gap: 0;
|
gap: 0;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-time>.input-time--inner>.icon-button {
|
||||||
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.input-time>.input-time--inner>.MuiFormControl-root {
|
.input-time>.input-time--inner>.MuiFormControl-root {
|
||||||
|
|||||||
@@ -1,20 +1,24 @@
|
|||||||
import "./InputTime.css";
|
import "./InputTime.css";
|
||||||
import { useState, useEffect, FC } from "react";
|
import { useState, useEffect, FC } from "react";
|
||||||
import TextField from '@mui/material/TextField';
|
import TextField from "@mui/material/TextField";
|
||||||
import EditIcon from '@mui/icons-material/Edit';
|
import EditIcon from "@mui/icons-material/Edit";
|
||||||
import CloseIcon from "@mui/icons-material/Close";
|
import CloseIcon from "@mui/icons-material/Close";
|
||||||
import IconButton from "@mui/material/IconButton"
|
|
||||||
import { AutomationTime, AutomationTimeObject } from "types/automations/common";
|
import { AutomationTime, AutomationTimeObject } from "types/automations/common";
|
||||||
import { convertAutomationTimeToTimeObject, convertObjectToAutomationTimeString, convertAutomationTimeToTimeString } from 'utils/time';
|
import {
|
||||||
|
convertAutomationTimeToTimeObject,
|
||||||
|
convertObjectToAutomationTimeString,
|
||||||
|
convertAutomationTimeToTimeString,
|
||||||
|
} from "utils/time";
|
||||||
import { prettyName } from "utils/formatting";
|
import { prettyName } from "utils/formatting";
|
||||||
|
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||||
|
|
||||||
// constants
|
// constants
|
||||||
const fields: Array<keyof AutomationTimeObject> = [
|
const fields: Array<keyof AutomationTimeObject> = [
|
||||||
'hours',
|
"hours",
|
||||||
'minutes',
|
"minutes",
|
||||||
'seconds',
|
"seconds",
|
||||||
'milliseconds'
|
"milliseconds",
|
||||||
]
|
];
|
||||||
export interface Props {
|
export interface Props {
|
||||||
label: string;
|
label: string;
|
||||||
value?: AutomationTime;
|
value?: AutomationTime;
|
||||||
@@ -22,73 +26,73 @@ export interface Props {
|
|||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
export const InputTime: FC<Props> = (props) => {
|
export const InputTime: FC<Props> = (props) => {
|
||||||
|
|
||||||
|
|
||||||
// state
|
// state
|
||||||
const [disabled, setDisabled] = useState(!props.value)
|
const [disabled, setDisabled] = useState(!props.value);
|
||||||
const [displayValue, setDisplayValue] = useState(convertAutomationTimeToTimeObject(props.value))
|
const [displayValue, setDisplayValue] = useState(
|
||||||
|
convertAutomationTimeToTimeObject(props.value)
|
||||||
|
);
|
||||||
|
|
||||||
// process display input
|
// process display input
|
||||||
const updateOne = (k: keyof AutomationTimeObject) => (v: string) => {
|
const updateOne = (k: keyof AutomationTimeObject) => (v: string) => {
|
||||||
if (Number(v) < 0) {
|
if (Number(v) < 0) {
|
||||||
setDisplayValue({
|
setDisplayValue({
|
||||||
...displayValue,
|
...displayValue,
|
||||||
[k]: 0
|
[k]: 0,
|
||||||
})
|
});
|
||||||
} else if (k === "hours") {
|
} else if (k === "hours") {
|
||||||
setDisplayValue({
|
setDisplayValue({
|
||||||
...displayValue,
|
...displayValue,
|
||||||
[k]: Number(v)
|
[k]: Number(v),
|
||||||
})
|
});
|
||||||
} else if (k === "minutes") {
|
} else if (k === "minutes") {
|
||||||
let minutes = Number(v);
|
let minutes = Number(v);
|
||||||
let { hours = 0 } = displayValue
|
let { hours = 0 } = displayValue;
|
||||||
if (minutes > 59) {
|
if (minutes > 59) {
|
||||||
const additonalHours = Math.floor(minutes / 60)
|
const additonalHours = Math.floor(minutes / 60);
|
||||||
hours += additonalHours
|
hours += additonalHours;
|
||||||
minutes = minutes - additonalHours * 60
|
minutes = minutes - additonalHours * 60;
|
||||||
}
|
}
|
||||||
setDisplayValue({
|
setDisplayValue({
|
||||||
...displayValue,
|
...displayValue,
|
||||||
minutes,
|
minutes,
|
||||||
hours,
|
hours,
|
||||||
})
|
});
|
||||||
} else if (k === "seconds") {
|
} else if (k === "seconds") {
|
||||||
let seconds = Number(v);
|
let seconds = Number(v);
|
||||||
let { hours = 0, minutes = 0 } = displayValue
|
let { hours = 0, minutes = 0 } = displayValue;
|
||||||
if (seconds > 59) {
|
if (seconds > 59) {
|
||||||
const additonalHours = Math.floor(seconds / (60 * 60))
|
const additonalHours = Math.floor(seconds / (60 * 60));
|
||||||
hours += additonalHours
|
hours += additonalHours;
|
||||||
seconds = seconds - additonalHours * 60
|
seconds = seconds - additonalHours * 60;
|
||||||
}
|
}
|
||||||
if (seconds > 59) {
|
if (seconds > 59) {
|
||||||
const additionalMinutes = Math.floor(seconds / 60)
|
const additionalMinutes = Math.floor(seconds / 60);
|
||||||
minutes += additionalMinutes
|
minutes += additionalMinutes;
|
||||||
seconds = seconds - additionalMinutes * 60
|
seconds = seconds - additionalMinutes * 60;
|
||||||
}
|
}
|
||||||
setDisplayValue({
|
setDisplayValue({
|
||||||
...displayValue,
|
...displayValue,
|
||||||
minutes,
|
minutes,
|
||||||
hours,
|
hours,
|
||||||
seconds,
|
seconds,
|
||||||
})
|
});
|
||||||
} else if (k === "milliseconds") {
|
} else if (k === "milliseconds") {
|
||||||
let milliseconds = Number(v);
|
let milliseconds = Number(v);
|
||||||
let { hours = 0, minutes = 0, seconds = 0 } = displayValue
|
let { hours = 0, minutes = 0, seconds = 0 } = displayValue;
|
||||||
if (milliseconds > 1000) {
|
if (milliseconds > 1000) {
|
||||||
const additonalHours = Math.floor(milliseconds / (60 * 60 * 1000))
|
const additonalHours = Math.floor(milliseconds / (60 * 60 * 1000));
|
||||||
hours += additonalHours
|
hours += additonalHours;
|
||||||
milliseconds = milliseconds - additonalHours * 60 * 60 * 1000
|
milliseconds = milliseconds - additonalHours * 60 * 60 * 1000;
|
||||||
}
|
}
|
||||||
if (milliseconds > 1000) {
|
if (milliseconds > 1000) {
|
||||||
const additionalMinutes = Math.floor(milliseconds / (60 * 1000))
|
const additionalMinutes = Math.floor(milliseconds / (60 * 1000));
|
||||||
minutes += additionalMinutes
|
minutes += additionalMinutes;
|
||||||
milliseconds = milliseconds - additionalMinutes * 60 * 1000
|
milliseconds = milliseconds - additionalMinutes * 60 * 1000;
|
||||||
}
|
}
|
||||||
if (milliseconds > 1000) {
|
if (milliseconds > 1000) {
|
||||||
const additionalSeconds = Math.floor(milliseconds / 1000)
|
const additionalSeconds = Math.floor(milliseconds / 1000);
|
||||||
seconds += additionalSeconds
|
seconds += additionalSeconds;
|
||||||
milliseconds = milliseconds - additionalSeconds * 1000
|
milliseconds = milliseconds - additionalSeconds * 1000;
|
||||||
}
|
}
|
||||||
setDisplayValue({
|
setDisplayValue({
|
||||||
...displayValue,
|
...displayValue,
|
||||||
@@ -96,50 +100,51 @@ export const InputTime: FC<Props> = (props) => {
|
|||||||
hours,
|
hours,
|
||||||
seconds,
|
seconds,
|
||||||
milliseconds,
|
milliseconds,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
// effect
|
// effect
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (disabled && !props.value) {
|
if (disabled && !props.value) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
if (disabled) {
|
if (disabled) {
|
||||||
props.onChange(undefined)
|
props.onChange(undefined);
|
||||||
} else {
|
} else {
|
||||||
const pVal = convertAutomationTimeToTimeString(props.value);
|
const pVal = convertAutomationTimeToTimeString(props.value);
|
||||||
const cVal = convertObjectToAutomationTimeString(displayValue);
|
const cVal = convertObjectToAutomationTimeString(displayValue);
|
||||||
if (pVal !== cVal) {
|
if (pVal !== cVal) {
|
||||||
props.onChange(displayValue)
|
props.onChange(displayValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
}, [disabled, displayValue])
|
}, [disabled, displayValue]);
|
||||||
|
|
||||||
|
return (
|
||||||
return <div className={["input-time", props.className ?? ""].join(" ")}>
|
<div className={["input-time", props.className ?? ""].join(" ")}>
|
||||||
{/* <InputLabel >{props.label}</InputLabel> */}
|
{/* <InputLabel >{props.label}</InputLabel> */}
|
||||||
<div className="input-time--inner">
|
<div className="input-time--inner">
|
||||||
{fields.map(name =>
|
{fields.map((name) => (
|
||||||
<TextField
|
<TextField
|
||||||
key={name}
|
key={name}
|
||||||
variant="filled"
|
variant="filled"
|
||||||
label={prettyName(name)}
|
label={prettyName(name)}
|
||||||
defaultValue="00"
|
defaultValue="00"
|
||||||
InputProps={{
|
InputProps={{
|
||||||
disabled,
|
disabled,
|
||||||
type: "number",
|
type: "number",
|
||||||
title: prettyName(name),
|
title: prettyName(name),
|
||||||
}}
|
}}
|
||||||
value={displayValue[name] ?? 0}
|
value={displayValue[name] ?? 0}
|
||||||
onChange={e => updateOne(name)(e.target.value)}
|
onChange={(e) => updateOne(name)(e.target.value)}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
<ButtonIcon
|
||||||
|
onClick={() => setDisabled(!disabled)}
|
||||||
|
icon={disabled ? <EditIcon /> : <CloseIcon />}
|
||||||
/>
|
/>
|
||||||
)}
|
</div>
|
||||||
<IconButton onClick={() => setDisabled(!disabled)}>
|
|
||||||
{disabled ? <EditIcon /> : <CloseIcon />}
|
|
||||||
</IconButton>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
);
|
||||||
}
|
};
|
||||||
@@ -25,8 +25,8 @@
|
|||||||
|
|
||||||
.input-yaml .MuiInputAdornment-positionEnd {
|
.input-yaml .MuiInputAdornment-positionEnd {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 0;
|
right: 0.5em;
|
||||||
top: 55%;
|
top: 3.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.input-yaml .input-yaml--placeholder {
|
.input-yaml .input-yaml--placeholder {
|
||||||
@@ -34,4 +34,8 @@
|
|||||||
left: 2em;
|
left: 2em;
|
||||||
top: 2.5em;
|
top: 2.5em;
|
||||||
color: var(--primary-accent);
|
color: var(--primary-accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-yaml .MuiButtonBase-root.icon-button[type="button"].icon-button {
|
||||||
|
border-style: none;
|
||||||
}
|
}
|
||||||
@@ -5,8 +5,10 @@ import { useEffect, useState, ReactNode } from "react";
|
|||||||
import CodeMirror from "@uiw/react-codemirror";
|
import CodeMirror from "@uiw/react-codemirror";
|
||||||
import FormControl from "@mui/material/FormControl";
|
import FormControl from "@mui/material/FormControl";
|
||||||
import InputLabel from "@mui/material/InputLabel";
|
import InputLabel from "@mui/material/InputLabel";
|
||||||
import { FormHelperText, IconButton, InputAdornment } from "@mui/material";
|
import FormHelperText from "@mui/material/FormHelperText";
|
||||||
|
import InputAdornment from "@mui/material/InputAdornment";
|
||||||
import { Save } from "@mui/icons-material";
|
import { Save } from "@mui/icons-material";
|
||||||
|
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||||
|
|
||||||
export interface Props<T extends {}> {
|
export interface Props<T extends {}> {
|
||||||
label: string;
|
label: string;
|
||||||
@@ -94,15 +96,16 @@ export default function InputYaml<T extends {}>({
|
|||||||
{!!text ? "" : placeholder}
|
{!!text ? "" : placeholder}
|
||||||
</span>
|
</span>
|
||||||
<InputAdornment position="end">
|
<InputAdornment position="end">
|
||||||
<IconButton
|
<ButtonIcon
|
||||||
disabled={!hasChanged}
|
disabled={!hasChanged}
|
||||||
onClick={() => onSave()}
|
onClick={() => onSave()}
|
||||||
title={!!error ? "Invalid YAML" : hasChanged ? "Save" : ""}
|
title={!!error ? "Invalid YAML" : hasChanged ? "Save" : ""}
|
||||||
>
|
icon={
|
||||||
<Save
|
<Save
|
||||||
color={hasChanged ? (!!error ? "error" : "success") : "disabled"}
|
color={hasChanged ? (!!error ? "error" : "success") : "disabled"}
|
||||||
/>
|
/>
|
||||||
</IconButton>
|
}
|
||||||
|
/>
|
||||||
{endAdornment}
|
{endAdornment}
|
||||||
</InputAdornment>
|
</InputAdornment>
|
||||||
<FormHelperText variant="filled" error={!!error}>
|
<FormHelperText variant="filled" error={!!error}>
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
.modal--root {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
z-index: 10;
|
||||||
|
position: fixed;
|
||||||
|
height: 100vh;
|
||||||
|
width: 100vw;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal--root>div {
|
||||||
|
max-width: fit-content;
|
||||||
|
min-width: 100px;
|
||||||
|
padding: 0.25em;
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
|
import "./index.css";
|
||||||
|
import Paper from "@mui/material/Paper";
|
||||||
|
import MuiModal from "@mui/material/Modal";
|
||||||
import { FC, ReactNode } from "react";
|
import { FC, ReactNode } from "react";
|
||||||
import { createAppUseStyles } from "styles/theme";
|
|
||||||
|
|
||||||
export interface ModalStyleProps {
|
export interface ModalStyleProps {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@@ -7,55 +9,12 @@ export interface ModalStyleProps {
|
|||||||
export interface Props extends ModalStyleProps {
|
export interface Props extends ModalStyleProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
}
|
}
|
||||||
const useModalStyle = createAppUseStyles<ModalStyleProps>(theme => ({
|
export const Modal: FC<Props> = ({ children, ...props }) => {
|
||||||
root: ({ open }) => ({
|
return (
|
||||||
display: open ? 'flex' : 'none',
|
<MuiModal open={props.open}>
|
||||||
justifyContent: 'center',
|
<div className="modal--root">
|
||||||
alignItems: 'center',
|
<Paper>{children}</Paper>
|
||||||
zIndex: open ? 10 : -1,
|
</div>
|
||||||
position: 'fixed',
|
</MuiModal>
|
||||||
height: '100vh',
|
);
|
||||||
width: '100vw',
|
};
|
||||||
top: 0,
|
|
||||||
left: 0,
|
|
||||||
}),
|
|
||||||
background: {
|
|
||||||
zIndex: 5,
|
|
||||||
position: 'absolute',
|
|
||||||
height: '100vh',
|
|
||||||
width: '100vw',
|
|
||||||
top: 0,
|
|
||||||
left: 0,
|
|
||||||
backgroundColor: theme.secondaryOpaque,
|
|
||||||
},
|
|
||||||
inner: {
|
|
||||||
zIndex: 10,
|
|
||||||
maxWidth: '80vw',
|
|
||||||
maxHeight: '90vh',
|
|
||||||
minHeight: 'min-content',
|
|
||||||
minWidth: '100px',
|
|
||||||
padding: '15px',
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
backgroundColor: theme.primary,
|
|
||||||
borderSize: '1px',
|
|
||||||
borderStyle: 'solid',
|
|
||||||
borderColor: theme.primaryAccent,
|
|
||||||
borderRadius: '10px',
|
|
||||||
color: theme.primaryAccent,
|
|
||||||
overflow: "auto",
|
|
||||||
resize: "auto",
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
export const Modal: FC<Props> = ({
|
|
||||||
children,
|
|
||||||
...props
|
|
||||||
}) => {
|
|
||||||
const { classes } = useModalStyle(props);
|
|
||||||
return <div className={classes.root}>
|
|
||||||
<div className={classes.background} />
|
|
||||||
<div className={classes.inner}>
|
|
||||||
{children}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
@@ -1,80 +1,97 @@
|
|||||||
import "./index.css";
|
import "./index.css";
|
||||||
import { createRef, FC, ReactNode, useEffect, useRef } from 'react';
|
import { createRef, FC, ReactNode, useEffect, useRef } from "react";
|
||||||
import { createTheme, ThemeProvider, useTheme } from '@mui/material/styles';
|
import { createTheme, ThemeProvider, useTheme } from "@mui/material/styles";
|
||||||
import { VersionBox } from "components/VersionBox";
|
import { VersionBox } from "components/VersionBox";
|
||||||
import { SnackbarKey, SnackbarProvider, useSnackbar } from 'notistack';
|
import { SnackbarKey, SnackbarProvider, useSnackbar } from "notistack";
|
||||||
import { Button } from "@mui/material";
|
import Button from "@mui/material/Button";
|
||||||
import { useHAConnection } from 'haService/connection';
|
import { useHAConnection } from "haService/connection";
|
||||||
|
|
||||||
const theme = createTheme({
|
const theme = createTheme({
|
||||||
palette: {
|
palette: {
|
||||||
mode: 'dark'
|
mode: "dark",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const InternalPage: FC<{
|
export const InternalPage: FC<{
|
||||||
children: ReactNode
|
children: ReactNode;
|
||||||
}> = ({ children }) => {
|
}> = ({ children }) => {
|
||||||
const conn = useHAConnection();
|
const conn = useHAConnection();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const snackbar = useSnackbar();
|
const snackbar = useSnackbar();
|
||||||
const snackbarKeyHAConKey = useRef<SnackbarKey | null>(null);
|
const snackbarKeyHAConKey = useRef<SnackbarKey | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (conn.status === 'error') {
|
if (conn.status === "error") {
|
||||||
if (snackbarKeyHAConKey.current) {
|
if (snackbarKeyHAConKey.current) {
|
||||||
snackbar.closeSnackbar(snackbarKeyHAConKey.current)
|
snackbar.closeSnackbar(snackbarKeyHAConKey.current);
|
||||||
}
|
}
|
||||||
snackbarKeyHAConKey.current = snackbar.enqueueSnackbar(`Failed to connect to homeassistant due to "${JSON.stringify(conn.error)}"`, {
|
snackbarKeyHAConKey.current = snackbar.enqueueSnackbar(
|
||||||
"variant": "error",
|
`Failed to connect to homeassistant due to "${JSON.stringify(
|
||||||
"persist": true,
|
conn.error
|
||||||
})
|
)}"`,
|
||||||
} else if (conn.status === 'loading') {
|
{
|
||||||
if (snackbarKeyHAConKey.current) {
|
variant: "error",
|
||||||
snackbar.closeSnackbar(snackbarKeyHAConKey.current)
|
persist: true,
|
||||||
}
|
|
||||||
snackbarKeyHAConKey.current = snackbar.enqueueSnackbar(`Connecting to websocket...`, {
|
|
||||||
"variant": "info",
|
|
||||||
})
|
|
||||||
} else if (conn.status === "loaded") {
|
|
||||||
if (snackbarKeyHAConKey.current) {
|
|
||||||
snackbar.closeSnackbar(snackbarKeyHAConKey.current)
|
|
||||||
}
|
|
||||||
snackbarKeyHAConKey.current = snackbar.enqueueSnackbar(`Connected to HA!`, {
|
|
||||||
"variant": "success",
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}, [conn, snackbar])
|
);
|
||||||
|
} else if (conn.status === "loading") {
|
||||||
|
if (snackbarKeyHAConKey.current) {
|
||||||
|
snackbar.closeSnackbar(snackbarKeyHAConKey.current);
|
||||||
|
}
|
||||||
|
snackbarKeyHAConKey.current = snackbar.enqueueSnackbar(
|
||||||
|
`Connecting to websocket...`,
|
||||||
|
{
|
||||||
|
variant: "info",
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else if (conn.status === "loaded") {
|
||||||
|
if (snackbarKeyHAConKey.current) {
|
||||||
|
snackbar.closeSnackbar(snackbarKeyHAConKey.current);
|
||||||
|
}
|
||||||
|
snackbarKeyHAConKey.current = snackbar.enqueueSnackbar(
|
||||||
|
`Connected to HA!`,
|
||||||
|
{
|
||||||
|
variant: "success",
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}, [conn, snackbar]);
|
||||||
|
|
||||||
return <main className="page" style={{
|
return (
|
||||||
|
<main
|
||||||
|
className="page"
|
||||||
|
style={{
|
||||||
color: theme.palette.text.primary,
|
color: theme.palette.text.primary,
|
||||||
background: theme.palette.background.default,
|
background: theme.palette.background.default,
|
||||||
}}>
|
}}
|
||||||
<VersionBox />
|
>
|
||||||
{children}
|
<VersionBox />
|
||||||
|
{children}
|
||||||
</main>
|
</main>
|
||||||
}
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const Page: FC<{
|
export const Page: FC<{
|
||||||
children: ReactNode
|
children: ReactNode;
|
||||||
}> = ({ children }) => {
|
}> = ({ children }) => {
|
||||||
const notistackRef = createRef<any>();
|
const notistackRef = createRef<any>();
|
||||||
const onClickDismiss = (key: SnackbarKey) => () => {
|
const onClickDismiss = (key: SnackbarKey) => () => {
|
||||||
notistackRef.current.closeSnackbar(key);
|
notistackRef.current.closeSnackbar(key);
|
||||||
}
|
};
|
||||||
return <ThemeProvider theme={theme}>
|
return (
|
||||||
<SnackbarProvider
|
<ThemeProvider theme={theme}>
|
||||||
anchorOrigin={{
|
<SnackbarProvider
|
||||||
"vertical": "bottom",
|
anchorOrigin={{
|
||||||
"horizontal": "center"
|
vertical: "bottom",
|
||||||
}}
|
horizontal: "center",
|
||||||
ref={notistackRef}
|
}}
|
||||||
action={key => <Button onClick={onClickDismiss(key)}>Dismiss</Button>}
|
ref={notistackRef}
|
||||||
dense preventDuplicate
|
action={(key) => <Button onClick={onClickDismiss(key)}>Dismiss</Button>}
|
||||||
>
|
dense
|
||||||
<InternalPage>
|
preventDuplicate
|
||||||
{children}
|
>
|
||||||
</InternalPage>
|
<InternalPage>{children}</InternalPage>
|
||||||
</SnackbarProvider>
|
</SnackbarProvider>
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
}
|
);
|
||||||
|
};
|
||||||
@@ -16,4 +16,8 @@
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.service-editor--field .service-editor--field--remove.icon-button.MuiButtonBase-root.icon-button[type="button"] {
|
||||||
|
border-style: none;
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,6 @@ import { FC, useRef } from "react";
|
|||||||
import { ServiceEditorOption } from "./options";
|
import { ServiceEditorOption } from "./options";
|
||||||
import InputText from "components/Inputs/InputText";
|
import InputText from "components/Inputs/InputText";
|
||||||
import InputNumber from "components/Inputs/InputNumber";
|
import InputNumber from "components/Inputs/InputNumber";
|
||||||
import { IconButton } from "@mui/material";
|
|
||||||
import { RemoveCircle } from "@mui/icons-material";
|
import { RemoveCircle } from "@mui/icons-material";
|
||||||
import { InputAutoComplete, Option } from "components/Inputs/InputAutoComplete";
|
import { InputAutoComplete, Option } from "components/Inputs/InputAutoComplete";
|
||||||
import { prettyName } from "utils/formatting";
|
import { prettyName } from "utils/formatting";
|
||||||
@@ -12,6 +11,7 @@ import { SelectorNumber, SelectorText } from "haService/fieldTypes";
|
|||||||
import InputYaml from "components/Inputs/InputYaml";
|
import InputYaml from "components/Inputs/InputYaml";
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
import { InputEntity } from "components/Inputs/InputEntities";
|
import { InputEntity } from "components/Inputs/InputEntities";
|
||||||
|
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||||
|
|
||||||
export type ServiceEditorFieldProps = {
|
export type ServiceEditorFieldProps = {
|
||||||
option: ServiceEditorOption;
|
option: ServiceEditorOption;
|
||||||
@@ -34,13 +34,12 @@ export const ServiceEditorField: FC<ServiceEditorFieldProps> = ({
|
|||||||
const removeIcon = !onRemove ? (
|
const removeIcon = !onRemove ? (
|
||||||
<></>
|
<></>
|
||||||
) : (
|
) : (
|
||||||
<IconButton
|
<ButtonIcon
|
||||||
className="service-editor--field--remove"
|
className="service-editor--field--remove"
|
||||||
onClick={onRemove}
|
onClick={onRemove}
|
||||||
title={`Remove ${label}`}
|
title={`Remove ${label}`}
|
||||||
>
|
icon={<RemoveCircle color="secondary" />}
|
||||||
<RemoveCircle />
|
/>
|
||||||
</IconButton>
|
|
||||||
);
|
);
|
||||||
example = option.data.example ? `Example: ${option.data.example}` : "";
|
example = option.data.example ? `Example: ${option.data.example}` : "";
|
||||||
const prop = {
|
const prop = {
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ export const useHAEntities = () => {
|
|||||||
label: entities.collection.state[key].attributes.friendly_name ?? key,
|
label: entities.collection.state[key].attributes.friendly_name ?? key,
|
||||||
domain: key.split(".")[0] ?? "n/a",
|
domain: key.split(".")[0] ?? "n/a",
|
||||||
integration: entitySource.ready
|
integration: entitySource.ready
|
||||||
? entitySource.collection.state[key].domain ?? "n/a"
|
? (entitySource.collection.state[key] ?? {}).domain ?? "n/a"
|
||||||
: "...",
|
: "...",
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user