Moved infobox to modal
This commit is contained in:
1 parent
1719148c58
commit
0e4e4783fa
16 files changed
+222
-182
No files matched your search
@@ -1,31 +1,16 @@
|
|||||||
.automation-editor--info-box {
|
.automation-editor--info-box {
|
||||||
height: 100%;
|
|
||||||
padding-left: 10px;
|
|
||||||
padding-right: 10px;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: flex-start;
|
align-items: center;
|
||||||
overflow: hidden;
|
gap: 0.5em;
|
||||||
position: relative;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.automation-editor--info-box-inner {
|
.automation-editor--info-box-inner {
|
||||||
height: 100%;
|
max-width: 95vw;
|
||||||
|
max-height: 90vh;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.automation-editor--info-box.show {
|
|
||||||
min-width: 20em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.automation-editor--info-box.hide {
|
|
||||||
min-width: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.automation-editor--info-box.hide>.automation-editor--info-box-inner {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.automation-editor--info-box--tags {
|
.automation-editor--info-box--tags {
|
||||||
padding: 0.25em 0.75em 1em 0.75em;
|
padding: 0.25em 0.75em 1em 0.75em;
|
||||||
border-color: var(--mui-grey-400);
|
border-color: var(--mui-grey-400);
|
||||||
|
|||||||
@@ -1,40 +1,35 @@
|
|||||||
|
|
||||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||||
import { makeTagDB } from "components/AutomationList/TagDB";
|
import { makeTagDB } from "components/AutomationList/TagDB";
|
||||||
import { Page } from "components/Page";
|
import { Page } from "components/Page";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { AutoInfoBox } from "./AutoInfoBox";
|
import { AutoInfoBox } from "./AutoInfoBox";
|
||||||
import { defaultAutomation } from 'utils/defaults';
|
import { defaultAutomation } from "utils/defaults";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'App/AutomationList/Editor/InfoBox',
|
title: "App/AutomationList/Editor/InfoBox",
|
||||||
component: AutoInfoBox,
|
component: AutoInfoBox,
|
||||||
parameters: { actions: { argTypesRegex: '^on.*' } },
|
parameters: { actions: { argTypesRegex: "^on.*" } },
|
||||||
args: {
|
args: {
|
||||||
tagDB: makeTagDB([
|
tagDB: makeTagDB([defaultAutomation("test")]),
|
||||||
defaultAutomation("test")
|
},
|
||||||
])
|
|
||||||
}
|
|
||||||
} as ComponentMeta<typeof AutoInfoBox>;
|
} as ComponentMeta<typeof AutoInfoBox>;
|
||||||
|
|
||||||
|
export const NoTags: ComponentStory<typeof AutoInfoBox> = (args) => {
|
||||||
export const NoTags: ComponentStory<typeof AutoInfoBox> = args => {
|
const [[metadata, tags], setState] = useState([args.metadata, args.tags]);
|
||||||
const [[metadata, tags], setState] = useState([args.metadata, args.tags])
|
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
<AutoInfoBox
|
<AutoInfoBox
|
||||||
{...args}
|
{...args}
|
||||||
className=""
|
|
||||||
metadata={metadata}
|
metadata={metadata}
|
||||||
tags={tags}
|
tags={tags}
|
||||||
onUpdate={(m, t) => {
|
onUpdate={(m, t) => {
|
||||||
args.onUpdate(m, t)
|
args.onUpdate(m, t);
|
||||||
setState([m, t])
|
setState([m, t]);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Page>
|
</Page>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
NoTags.args = {
|
NoTags.args = {
|
||||||
...NoTags.args,
|
...NoTags.args,
|
||||||
tags: [],
|
tags: [],
|
||||||
@@ -43,13 +38,13 @@ NoTags.args = {
|
|||||||
alias: "Random",
|
alias: "Random",
|
||||||
description: "Example Metadata",
|
description: "Example Metadata",
|
||||||
trigger_variables: {
|
trigger_variables: {
|
||||||
'wowo': '!'
|
wowo: "!",
|
||||||
},
|
},
|
||||||
mode: 'single',
|
mode: "single",
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
|
|
||||||
export const SomeTags: ComponentStory<typeof AutoInfoBox> = NoTags.bind({})
|
export const SomeTags: ComponentStory<typeof AutoInfoBox> = NoTags.bind({});
|
||||||
SomeTags.args = {
|
SomeTags.args = {
|
||||||
...SomeTags.args,
|
...SomeTags.args,
|
||||||
tags: [
|
tags: [
|
||||||
@@ -61,8 +56,8 @@ SomeTags.args = {
|
|||||||
alias: "Bathroom Vent",
|
alias: "Bathroom Vent",
|
||||||
description: "Turn the vent when the humidity is high",
|
description: "Turn the vent when the humidity is high",
|
||||||
trigger_variables: {
|
trigger_variables: {
|
||||||
'wowo': '!'
|
wowo: "!",
|
||||||
},
|
},
|
||||||
mode: 'single',
|
mode: "single",
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
@@ -9,7 +9,6 @@ import { TagDB } from "components/AutomationList/TagDB";
|
|||||||
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className: string;
|
|
||||||
metadata: AutomationMetadata;
|
metadata: AutomationMetadata;
|
||||||
tags: Array<[string, string]>;
|
tags: Array<[string, string]>;
|
||||||
onUpdate: (m: AutomationMetadata, tags: Array<[string, string]>) => void;
|
onUpdate: (m: AutomationMetadata, tags: Array<[string, string]>) => void;
|
||||||
@@ -20,7 +19,6 @@ export const AutoInfoBox: FC<Props> = ({
|
|||||||
metadata,
|
metadata,
|
||||||
tags,
|
tags,
|
||||||
onUpdate,
|
onUpdate,
|
||||||
className,
|
|
||||||
children,
|
children,
|
||||||
tagDB,
|
tagDB,
|
||||||
}) => {
|
}) => {
|
||||||
@@ -97,7 +95,7 @@ export const AutoInfoBox: FC<Props> = ({
|
|||||||
]);
|
]);
|
||||||
// render
|
// render
|
||||||
return (
|
return (
|
||||||
<div className={`automation-editor--info-box ${className}`}>
|
<div className="automation-editor--info-box">
|
||||||
<div className="automation-editor--info-box-inner">
|
<div className="automation-editor--info-box-inner">
|
||||||
<InputText
|
<InputText
|
||||||
label="ID"
|
label="ID"
|
||||||
|
|||||||
@@ -50,6 +50,15 @@
|
|||||||
white-space: break-word;
|
white-space: break-word;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
padding-bottom: 0.25em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.automation-editor--flow-wrapper--toolbar .automation-editor--flow-wrapper--toolbar--title--text {
|
||||||
|
min-width: 5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.automation-editor--flow-wrapper--toolbar .automation-editor--flow-wrapper--toolbar--modes {
|
||||||
|
min-width: 6em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.automation-editor--flow-wrapper--toolbar .automation-editor--flow-wrapper--toolbar--modes .MuiSelect-select {
|
.automation-editor--flow-wrapper--toolbar .automation-editor--flow-wrapper--toolbar--modes .MuiSelect-select {
|
||||||
@@ -64,7 +73,8 @@
|
|||||||
left: -0.5em;
|
left: -0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.automation-editor--flow-wrapper.changed>.automation-editor--flow-wrapper--toolbar button {
|
.automation-editor.changed .automation-editor--flow-wrapper--toolbar--save-btn,
|
||||||
|
.automation-editor--info-box--buttons.changed .automation-editor--flow-wrapper--toolbar--save-btn {
|
||||||
border-color: var(--mui-success-light);
|
border-color: var(--mui-success-light);
|
||||||
color: var(--mui-success-light);
|
color: var(--mui-success-light);
|
||||||
}
|
}
|
||||||
@@ -92,21 +102,6 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.automation-editor .automation-editor--info-box--icon {
|
|
||||||
position: absolute;
|
|
||||||
left: 0.25em;
|
|
||||||
bottom: 0em;
|
|
||||||
z-index: 10;
|
|
||||||
max-width: 1.5em;
|
|
||||||
max-height: 1.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.automation-editor--info-box.hide>.automation-editor--info-box--icon {
|
|
||||||
transform: rotate(180deg);
|
|
||||||
z-index: 2;
|
|
||||||
left: 0.1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.automation-editor.loading .mock-list {
|
.automation-editor.loading .mock-list {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
@@ -128,3 +123,8 @@
|
|||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.automation-editor--info-box--buttons {
|
||||||
|
display: flex;
|
||||||
|
gap: 1em;
|
||||||
|
}
|
||||||
@@ -3,8 +3,9 @@ import Icon from "@mui/material/Icon";
|
|||||||
import { CheckMarkIcon } from "components/Icons";
|
import { CheckMarkIcon } from "components/Icons";
|
||||||
import { FC, useState } from "react";
|
import { FC, useState } from "react";
|
||||||
import { AutomationData } from "types/automations";
|
import { AutomationData } from "types/automations";
|
||||||
|
import { Modal } from "components/Modal";
|
||||||
import { AutoInfoBox } from "./AutoInfoBox";
|
import { AutoInfoBox } from "./AutoInfoBox";
|
||||||
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
import ModeEditOutlineTwoToneIcon from "@mui/icons-material/ModeEditOutlineTwoTone";
|
||||||
import { Button } from "components/Inputs/Button";
|
import { Button } from "components/Inputs/Button";
|
||||||
import { useAutomatioEditorState, EditorData } from "./state";
|
import { useAutomatioEditorState, EditorData } from "./state";
|
||||||
import { MiniFailure } from "types/validators/helper";
|
import { MiniFailure } from "types/validators/helper";
|
||||||
@@ -12,13 +13,12 @@ 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";
|
|
||||||
import { useCookies } from "react-cookie";
|
import { useCookies } from "react-cookie";
|
||||||
import { DAGDims } from "components/DAGGraph/elements/types";
|
import { DAGDims } from "components/DAGGraph/elements/types";
|
||||||
import { DAGAutomationGraph } from "components/DAGGraph";
|
import { DAGAutomationGraph } from "components/DAGGraph";
|
||||||
import { InputAutoComplete } from "components/Inputs/InputAutoComplete";
|
|
||||||
import { InputList } from "components/Inputs/InputList";
|
import { InputList } from "components/Inputs/InputList";
|
||||||
import { InputTextView } from "components/Inputs/InputTextView";
|
import { InputTextView } from "components/Inputs/InputTextView";
|
||||||
|
import { ControlButton } from "react-flow-renderer";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
automation?: AutomationData;
|
automation?: AutomationData;
|
||||||
@@ -43,7 +43,7 @@ export const AutomationEditor: FC<Props> = ({
|
|||||||
save,
|
save,
|
||||||
saveAndUpdate,
|
saveAndUpdate,
|
||||||
} = useAutomatioEditorState(propsAutos, propsOnUpdate);
|
} = useAutomatioEditorState(propsAutos, propsOnUpdate);
|
||||||
const [closeInfo, setCloseInfo] = useState(false);
|
const [infoBoxOpen, setInfoBox] = useState(false);
|
||||||
const [
|
const [
|
||||||
{ ckFlipped },
|
{ ckFlipped },
|
||||||
setCookies,
|
setCookies,
|
||||||
@@ -74,25 +74,34 @@ export const AutomationEditor: FC<Props> = ({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div className="automation-editor">
|
<div className={["automation-editor", state.status].join(" ")}>
|
||||||
{state.status === "saving" && (
|
{state.status === "saving" && (
|
||||||
<LinearProgress className="linear-loader" />
|
<LinearProgress className="linear-loader" />
|
||||||
)}
|
)}
|
||||||
<AutoInfoBox
|
<Modal open={infoBoxOpen}>
|
||||||
className={closeInfo ? "hide" : "show"}
|
<AutoInfoBox
|
||||||
metadata={state.data.metadata}
|
metadata={state.data.metadata}
|
||||||
tags={state.data.tags}
|
tags={state.data.tags}
|
||||||
onUpdate={updateMetadata}
|
onUpdate={updateMetadata}
|
||||||
tagDB={tagDB}
|
tagDB={tagDB}
|
||||||
>
|
>
|
||||||
<ButtonIcon
|
<div
|
||||||
className="automation-editor--info-box--icon"
|
className={[
|
||||||
onClick={() => setCloseInfo(!closeInfo)}
|
"automation-editor--info-box--buttons",
|
||||||
title={closeInfo ? "Show Metadata" : "Hide Metadata"}
|
state.status,
|
||||||
color="success"
|
].join(" ")}
|
||||||
icon={<ArrowBack />}
|
>
|
||||||
/>
|
<Button onClick={() => setInfoBox(false)}>Close</Button>
|
||||||
</AutoInfoBox>
|
<Button
|
||||||
|
className={"automation-editor--flow-wrapper--toolbar--save-btn"}
|
||||||
|
onClick={save}
|
||||||
|
disabled={state.status !== "changed"}
|
||||||
|
>
|
||||||
|
Save <CheckMarkIcon color="#bf4" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</AutoInfoBox>
|
||||||
|
</Modal>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
className={["automation-editor--flow-wrapper", state.status].join(" ")}
|
className={["automation-editor--flow-wrapper", state.status].join(" ")}
|
||||||
@@ -156,6 +165,7 @@ export const AutomationEditor: FC<Props> = ({
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
<InputTextView
|
<InputTextView
|
||||||
|
className="description"
|
||||||
value={state.data.metadata.description ?? ""}
|
value={state.data.metadata.description ?? ""}
|
||||||
placeholder="Description"
|
placeholder="Description"
|
||||||
onChange={(description) =>
|
onChange={(description) =>
|
||||||
@@ -194,6 +204,11 @@ export const AutomationEditor: FC<Props> = ({
|
|||||||
onTriggerUpdate={updateTrigger}
|
onTriggerUpdate={updateTrigger}
|
||||||
onConditionUpdate={updateCondition}
|
onConditionUpdate={updateCondition}
|
||||||
isFlipped={flipped}
|
isFlipped={flipped}
|
||||||
|
additionalControls={
|
||||||
|
<ControlButton onClick={() => setInfoBox(!infoBoxOpen)}>
|
||||||
|
<ModeEditOutlineTwoToneIcon />
|
||||||
|
</ControlButton>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -177,9 +177,10 @@ export const AutomationListBoxItem: FC<{
|
|||||||
onSave,
|
onSave,
|
||||||
}) => {
|
}) => {
|
||||||
// state
|
// state
|
||||||
const [{ tags, isModified }, setState] = useState({
|
const [{ tags, isModified, alias }, setState] = useState({
|
||||||
isModified: false,
|
isModified: false,
|
||||||
tags: Object.entries(auto.tags),
|
tags: Object.entries(auto.tags),
|
||||||
|
alias: auto.metadata.alias ?? "",
|
||||||
});
|
});
|
||||||
|
|
||||||
// effects
|
// effects
|
||||||
@@ -187,14 +188,22 @@ export const AutomationListBoxItem: FC<{
|
|||||||
setState({
|
setState({
|
||||||
isModified: false,
|
isModified: false,
|
||||||
tags: Object.entries(auto.tags),
|
tags: Object.entries(auto.tags),
|
||||||
|
alias: auto.metadata.alias ?? "",
|
||||||
});
|
});
|
||||||
}, [auto]);
|
}, [auto]);
|
||||||
|
|
||||||
// alias
|
// alias
|
||||||
|
const setAlias = (a: string) =>
|
||||||
|
setState({
|
||||||
|
isModified: true,
|
||||||
|
tags,
|
||||||
|
alias: a,
|
||||||
|
});
|
||||||
const setTags = (t: [string, string][]) =>
|
const setTags = (t: [string, string][]) =>
|
||||||
setState({
|
setState({
|
||||||
isModified: true,
|
isModified: true,
|
||||||
tags: t,
|
tags: t,
|
||||||
|
alias,
|
||||||
});
|
});
|
||||||
// sub elements
|
// sub elements
|
||||||
let title = "BadAuto<<Missing Metadata>>";
|
let title = "BadAuto<<Missing Metadata>>";
|
||||||
@@ -215,10 +224,14 @@ export const AutomationListBoxItem: FC<{
|
|||||||
onClick={() => onSelectAutomation(autoIndex)}
|
onClick={() => onSelectAutomation(autoIndex)}
|
||||||
>
|
>
|
||||||
<MetadataBox
|
<MetadataBox
|
||||||
metadata={auto.metadata}
|
metadata={{
|
||||||
|
...auto.metadata,
|
||||||
|
alias,
|
||||||
|
}}
|
||||||
tags={tags}
|
tags={tags}
|
||||||
tagsDB={tagsDB}
|
tagsDB={tagsDB}
|
||||||
onUpdate={setTags}
|
onTagUpdate={setTags}
|
||||||
|
onAliasUpdate={setAlias}
|
||||||
/>
|
/>
|
||||||
<div className="automation-list-box--body--item--buttons">
|
<div className="automation-list-box--body--item--buttons">
|
||||||
{isModified && (
|
{isModified && (
|
||||||
@@ -229,6 +242,10 @@ export const AutomationListBoxItem: FC<{
|
|||||||
onSave({
|
onSave({
|
||||||
...auto,
|
...auto,
|
||||||
tags: Object.fromEntries(tags),
|
tags: Object.fromEntries(tags),
|
||||||
|
metadata: {
|
||||||
|
...auto.metadata,
|
||||||
|
alias,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -7,6 +7,13 @@
|
|||||||
|
|
||||||
.automation-list-box--body--item--title>b {
|
.automation-list-box--body--item--title>b {
|
||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.25em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.automation-list-box--body--item--title .input-text-view span {
|
||||||
|
max-height: 1.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.automation-list-box--body--item--title>span, .automation-list-box--body--item--title>b>span {
|
.automation-list-box--body--item--title>span, .automation-list-box--body--item--title>b>span {
|
||||||
@@ -81,3 +88,14 @@
|
|||||||
.automation-list-box--body--item--tags--item>.text .icon:hover svg {
|
.automation-list-box--body--item--tags--item>.text .icon:hover svg {
|
||||||
fill: var(--mui-common-black);
|
fill: var(--mui-common-black);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.automation-list-box--body--item--tags--item .delete {
|
||||||
|
font-size: 1em;
|
||||||
|
color: var(--mui-error-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.automation-list-box--body--item--tags--item .delete:hover {
|
||||||
|
color: var(--mui-error-dark);
|
||||||
|
outline: 1px solid var(--mui-error-dark);
|
||||||
|
border-radius: 20px;
|
||||||
|
}
|
||||||
@@ -4,13 +4,16 @@ import { FC, useState } from "react";
|
|||||||
import { AutomationMetadata } from "types/automations";
|
import { AutomationMetadata } from "types/automations";
|
||||||
import { InputAutoComplete } from "components/Inputs/InputAutoComplete";
|
import { InputAutoComplete } from "components/Inputs/InputAutoComplete";
|
||||||
import { TagDB } from "./TagDB";
|
import { TagDB } from "./TagDB";
|
||||||
|
import DeleteIcon from "@mui/icons-material/ClearTwoTone";
|
||||||
|
import { InputTextView } from "components/Inputs/InputTextView";
|
||||||
|
|
||||||
export const MetadataBox: FC<{
|
export const MetadataBox: FC<{
|
||||||
metadata: AutomationMetadata;
|
metadata: AutomationMetadata;
|
||||||
onUpdate: (t: [string, string][]) => void;
|
onAliasUpdate: (t: string) => void;
|
||||||
|
onTagUpdate: (t: [string, string][]) => void;
|
||||||
tags: [string, string][];
|
tags: [string, string][];
|
||||||
tagsDB: TagDB;
|
tagsDB: TagDB;
|
||||||
}> = ({ tags, onUpdate, tagsDB, metadata }) => {
|
}> = ({ tags, onTagUpdate, onAliasUpdate, tagsDB, metadata }) => {
|
||||||
// state
|
// state
|
||||||
const [newTag, setNewTag] = useState<
|
const [newTag, setNewTag] = useState<
|
||||||
| {
|
| {
|
||||||
@@ -30,9 +33,12 @@ export const MetadataBox: FC<{
|
|||||||
if (metadata) {
|
if (metadata) {
|
||||||
title = (
|
title = (
|
||||||
<>
|
<>
|
||||||
<b>
|
<b className="text">
|
||||||
{String(metadata.alias ?? "").slice(0, 15)}{" "}
|
<InputTextView
|
||||||
<span>({String(metadata.id).slice(0, 5)})</span>
|
value={metadata.alias ?? ""}
|
||||||
|
onChange={onAliasUpdate}
|
||||||
|
/>
|
||||||
|
<span>({String(metadata.id).slice(0, 10)})</span>
|
||||||
</b>
|
</b>
|
||||||
<span>{String(metadata.description ?? "").slice(0, 25)}</span>
|
<span>{String(metadata.description ?? "").slice(0, 25)}</span>
|
||||||
</>
|
</>
|
||||||
@@ -47,8 +53,14 @@ export const MetadataBox: FC<{
|
|||||||
options={[tagOptions, tagsDB.getTagValues(tagName)]}
|
options={[tagOptions, tagsDB.getTagValues(tagName)]}
|
||||||
key={tagIndex}
|
key={tagIndex}
|
||||||
value={[tagName, tagValue]}
|
value={[tagName, tagValue]}
|
||||||
|
onDelete={() =>
|
||||||
|
onTagUpdate([
|
||||||
|
...tags.slice(0, tagIndex),
|
||||||
|
...tags.slice(tagIndex + 1),
|
||||||
|
])
|
||||||
|
}
|
||||||
onChange={([newName, newValue]) =>
|
onChange={([newName, newValue]) =>
|
||||||
onUpdate([
|
onTagUpdate([
|
||||||
...tags.slice(0, tagIndex),
|
...tags.slice(0, tagIndex),
|
||||||
[newName, newValue],
|
[newName, newValue],
|
||||||
...tags.slice(tagIndex + 1),
|
...tags.slice(tagIndex + 1),
|
||||||
@@ -56,29 +68,34 @@ export const MetadataBox: FC<{
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
{newTag.on && (
|
{newTag.on ? (
|
||||||
<MetadataBoxTag
|
<MetadataBoxTag
|
||||||
options={[tagOptions, tagsDB.getTagValues(newTag.name)]}
|
options={[tagOptions, tagsDB.getTagValues(newTag.name)]}
|
||||||
key="new"
|
key="new"
|
||||||
value={[newTag.name, newTag.value]}
|
value={[newTag.name, newTag.value]}
|
||||||
initialState={[true, true]}
|
initialState={true}
|
||||||
onChange={([name, value]) => {
|
onChange={([name, value]) => {
|
||||||
if (name.trim() !== "" && value.trim() !== "") {
|
setNewTag({
|
||||||
setNewTag({
|
on: true,
|
||||||
on: false,
|
name,
|
||||||
});
|
value,
|
||||||
onUpdate([...tags, [name, value]]);
|
});
|
||||||
} else {
|
}}
|
||||||
setNewTag({
|
onToggle={(em) => {
|
||||||
on: true,
|
if (!em) {
|
||||||
name,
|
if (newTag.name.trim() !== "" && newTag.value.trim() !== "") {
|
||||||
value,
|
onTagUpdate(tags.concat([[newTag.name, newTag.value]]));
|
||||||
});
|
setNewTag({
|
||||||
|
on: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
setNewTag({
|
||||||
|
on: false,
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
) : (
|
||||||
{!newTag.on && (
|
|
||||||
<span
|
<span
|
||||||
className="automation-list-box--body--item--tags--add"
|
className="automation-list-box--body--item--tags--add"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
@@ -101,16 +118,29 @@ export const MetadataBoxTag: FC<{
|
|||||||
value: [string, string];
|
value: [string, string];
|
||||||
onChange: (t: [string, string]) => void;
|
onChange: (t: [string, string]) => void;
|
||||||
options: [string[], string[]];
|
options: [string[], string[]];
|
||||||
initialState?: [boolean, boolean];
|
initialState?: boolean;
|
||||||
|
onToggle?: (em: boolean) => void;
|
||||||
|
onDelete?: () => void;
|
||||||
}> = (props) => {
|
}> = (props) => {
|
||||||
const [[editMode1, editMode2], setEditMode] = useState(
|
const [editMode, setEditMode] = useState(
|
||||||
props.initialState ? props.initialState : [false, false]
|
props.initialState ? props.initialState : false
|
||||||
);
|
);
|
||||||
const toggle1 = () => setEditMode([!editMode1, editMode2]);
|
const toggle = () => {
|
||||||
const toggle2 = () => setEditMode([editMode1, !editMode2]);
|
if (editMode) {
|
||||||
|
if (props.value[0].trim() === "" || props.value[1].trim() === "") {
|
||||||
|
props.onToggle && props.onToggle(true);
|
||||||
|
return setEditMode(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
props.onToggle && props.onToggle(!editMode);
|
||||||
|
setEditMode(!editMode);
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<span className="automation-list-box--body--item--tags--item">
|
<span className="automation-list-box--body--item--tags--item">
|
||||||
{editMode1 ? (
|
{props.onDelete && (
|
||||||
|
<DeleteIcon onClick={props.onDelete} className="delete" />
|
||||||
|
)}
|
||||||
|
{editMode ? (
|
||||||
<InputAutoComplete
|
<InputAutoComplete
|
||||||
multiple={false}
|
multiple={false}
|
||||||
className="text"
|
className="text"
|
||||||
@@ -118,17 +148,17 @@ export const MetadataBoxTag: FC<{
|
|||||||
options={props.options[0]}
|
options={props.options[0]}
|
||||||
label=""
|
label=""
|
||||||
value={props.value[0]}
|
value={props.value[0]}
|
||||||
onEnter={toggle1}
|
onEnter={toggle}
|
||||||
onChange={(v) => props.onChange([v ?? "", props.value[1]])}
|
onChange={(v) => props.onChange([v ?? "", props.value[1]])}
|
||||||
onlyShowLabel
|
onlyShowLabel
|
||||||
endAdornment={<CheckMarkIcon className="icon" onClick={toggle1} />}
|
endAdornment={<CheckMarkIcon className="icon" onClick={toggle} />}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<b className="text" onClick={toggle1}>
|
<b className="text" onClick={toggle}>
|
||||||
{props.value[0]}:
|
{props.value[0]}:
|
||||||
</b>
|
</b>
|
||||||
)}
|
)}
|
||||||
{editMode2 ? (
|
{editMode ? (
|
||||||
<InputAutoComplete
|
<InputAutoComplete
|
||||||
multiple={false}
|
multiple={false}
|
||||||
className="text"
|
className="text"
|
||||||
@@ -136,13 +166,13 @@ export const MetadataBoxTag: FC<{
|
|||||||
options={props.options[1]}
|
options={props.options[1]}
|
||||||
label=""
|
label=""
|
||||||
value={props.value[1]}
|
value={props.value[1]}
|
||||||
onEnter={toggle2}
|
onEnter={toggle}
|
||||||
onChange={(v) => props.onChange([props.value[0], v ?? ""])}
|
onChange={(v) => props.onChange([props.value[0], v ?? ""])}
|
||||||
onlyShowLabel
|
onlyShowLabel
|
||||||
endAdornment={<CheckMarkIcon className="icon" onClick={toggle2} />}
|
endAdornment={<CheckMarkIcon className="icon" onClick={toggle} />}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<span className="text" onClick={toggle2}>
|
<span className="text" onClick={toggle}>
|
||||||
{props.value[1]}
|
{props.value[1]}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -17,28 +17,6 @@
|
|||||||
left: 0.25em;
|
left: 0.25em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.automation-list--root.mobile .automation-editor--info-box {
|
|
||||||
min-width: 100vw;
|
|
||||||
min-height: calc(100vh - 5em);
|
|
||||||
max-width: 100vw;
|
|
||||||
max-height: calc(100vh - 5em);
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.automation-list--root.mobile .automation-editor--info-box-inner {
|
|
||||||
margin-top: 2.5em;
|
|
||||||
padding-left: 0.5em;
|
|
||||||
padding-right: 0.5em;
|
|
||||||
margin-bottom: 2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.automation-list--root.mobile .automation-editor--info-box--icon {
|
|
||||||
left: 0.5em;
|
|
||||||
bottom: 0em;
|
|
||||||
background-color: var(--mui-common-black);
|
|
||||||
transform: rotate(90deg);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* list hide */
|
/* list hide */
|
||||||
.automation-list--root.mobile .automation-list--list.hide {
|
.automation-list--root.mobile .automation-list--list.hide {
|
||||||
@@ -50,29 +28,11 @@
|
|||||||
.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;
|
top: 0.5em;
|
||||||
z-index: 5;
|
z-index: 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* info box hide */
|
.automation-list--root.mobile .automation-editor--flow-wrapper>.automation-editor--flow-wrapper--toolbar .input-text-view,
|
||||||
.automation-list--root.mobile .automation-editor--info-box.hide {
|
.automation-list--root.mobile .automation-editor--flow-wrapper>.automation-editor--flow-wrapper--toolbar .id {
|
||||||
width: 100vw;
|
display: none;
|
||||||
min-height: 0;
|
|
||||||
max-height: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.automation-list--root.mobile .automation-editor--info-box.hide .automation-editor--info-box--icon {
|
|
||||||
transform: rotate(270deg);
|
|
||||||
position: fixed;
|
|
||||||
top: 0em;
|
|
||||||
left: 0.25em;
|
|
||||||
z-index: 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.automation-list--root.mobile .automation-editor--flow-wrapper.unchanged>.automation-editor--flow-wrapper--toolbar {
|
|
||||||
height: 0;
|
|
||||||
opacity: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
}
|
||||||
@@ -152,16 +152,22 @@ export const ConnectedAutomationList: FC<ConnectedAutomationListParams> = ({
|
|||||||
dims,
|
dims,
|
||||||
}) => {
|
}) => {
|
||||||
const { reloadAutomations } = useHA();
|
const { reloadAutomations } = useHA();
|
||||||
|
const [saving, setSaving] = useState(false);
|
||||||
const removeAutomation = async (args: any) => {
|
const removeAutomation = async (args: any) => {
|
||||||
const resp = await methods.removeAutomation(args);
|
const resp = await methods.removeAutomation(args);
|
||||||
|
setSaving(true);
|
||||||
await reloadAutomations();
|
await reloadAutomations();
|
||||||
|
setSaving(false);
|
||||||
return resp;
|
return resp;
|
||||||
};
|
};
|
||||||
const updateAutomation = async (args: any) => {
|
const updateAutomation = async (args: any) => {
|
||||||
const resp = await methods.updateAutomation(args);
|
const resp = await methods.updateAutomation(args);
|
||||||
|
setSaving(true);
|
||||||
await reloadAutomations();
|
await reloadAutomations();
|
||||||
|
setSaving(false);
|
||||||
return resp;
|
return resp;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!automations.ready) {
|
if (!automations.ready) {
|
||||||
return (
|
return (
|
||||||
<div className="automation-list--root loading">
|
<div className="automation-list--root loading">
|
||||||
@@ -176,15 +182,18 @@ export const ConnectedAutomationList: FC<ConnectedAutomationListParams> = ({
|
|||||||
return <span>Error {automations.error}</span>;
|
return <span>Error {automations.error}</span>;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<AutomationList
|
<>
|
||||||
dims={dims}
|
{saving && <LinearProgress />}
|
||||||
automations={automations.data}
|
<AutomationList
|
||||||
onLoadMore={() => {}}
|
dims={dims}
|
||||||
onAdd={(auto) =>
|
automations={automations.data}
|
||||||
updateAutomation({ auto, index: automations.data.totalItems + 1 })
|
onLoadMore={() => {}}
|
||||||
}
|
onAdd={(auto) =>
|
||||||
onRemove={(index) => removeAutomation({ index })}
|
updateAutomation({ auto, index: automations.data.totalItems + 1 })
|
||||||
onUpdate={(index, auto) => updateAutomation({ index, auto })}
|
}
|
||||||
/>
|
onRemove={(index) => removeAutomation({ index })}
|
||||||
|
onUpdate={(index, auto) => updateAutomation({ index, auto })}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -1,10 +1,7 @@
|
|||||||
.dag-graphboard {
|
|
||||||
min-height: 100%;
|
|
||||||
min-width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dag-graphboard.loading {
|
.dag-graphboard.loading {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
min-height: 100%;
|
||||||
|
min-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dag-graphboard.loading span {
|
.dag-graphboard.loading span {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export const DAGGraphBoardInner: FC<DAGGraphBoardProps> = ({
|
|||||||
modalState,
|
modalState,
|
||||||
state,
|
state,
|
||||||
closeModal,
|
closeModal,
|
||||||
|
additionalControls,
|
||||||
}) => {
|
}) => {
|
||||||
// render unready or errored states
|
// render unready or errored states
|
||||||
if (!state.ready) {
|
if (!state.ready) {
|
||||||
@@ -69,7 +70,9 @@ export const DAGGraphBoardInner: FC<DAGGraphBoardProps> = ({
|
|||||||
nodesDraggable={false}
|
nodesDraggable={false}
|
||||||
{...elements}
|
{...elements}
|
||||||
>
|
>
|
||||||
<Controls showInteractive={false} showFitView />
|
<Controls showInteractive={false} showFitView>
|
||||||
|
{additionalControls}
|
||||||
|
</Controls>
|
||||||
</ReactFlow>
|
</ReactFlow>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ export type DAGGraphBoardProps = {
|
|||||||
state: DAGGraphBoardState;
|
state: DAGGraphBoardState;
|
||||||
modalState?: ModalState;
|
modalState?: ModalState;
|
||||||
closeModal: () => void;
|
closeModal: () => void;
|
||||||
|
additionalControls?: ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ModalState<
|
export type ModalState<
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { FC, useState } from "react";
|
import { FC, useState, ReactNode } from "react";
|
||||||
import { AutomationSequenceNode } from "types/automations";
|
import { AutomationSequenceNode } from "types/automations";
|
||||||
import { useHA } from "haService";
|
import { useHA } from "haService";
|
||||||
import { ModalState } from "./board/types";
|
import { ModalState } from "./board/types";
|
||||||
@@ -17,7 +17,9 @@ export const DAGAutomationGraph: FC<{
|
|||||||
onTriggerUpdate: (t: AutomationTrigger[]) => void;
|
onTriggerUpdate: (t: AutomationTrigger[]) => void;
|
||||||
onConditionUpdate: (c: AutomationCondition[]) => void;
|
onConditionUpdate: (c: AutomationCondition[]) => void;
|
||||||
isFlipped: boolean;
|
isFlipped: boolean;
|
||||||
|
additionalControls?: ReactNode;
|
||||||
}> = (props) => {
|
}> = (props) => {
|
||||||
|
console.log({ props });
|
||||||
const { namer } = useHA();
|
const { namer } = useHA();
|
||||||
const [modalState, setModalState] =
|
const [modalState, setModalState] =
|
||||||
useState<ModalState | undefined>(undefined);
|
useState<ModalState | undefined>(undefined);
|
||||||
@@ -62,6 +64,7 @@ export const DAGAutomationGraph: FC<{
|
|||||||
elements: elementData,
|
elements: elementData,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
|
additionalControls={props.additionalControls}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -1,9 +1,17 @@
|
|||||||
.input-text-view {
|
.input-text-view {
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
max-height: 2em;
|
max-height: 2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.input-text-view.view span {
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
word-break: break-all;
|
||||||
|
word-wrap: break-word;
|
||||||
|
line-break: loose;
|
||||||
|
overflow-wrap: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
.input-text-view.edit .MuiFilledInput-input {
|
.input-text-view.edit .MuiFilledInput-input {
|
||||||
padding-top: 0.5em;
|
padding-top: 0.5em;
|
||||||
padding-bottom: 0.5em;
|
padding-bottom: 0.5em;
|
||||||
@@ -38,4 +46,5 @@
|
|||||||
|
|
||||||
.input-text-view.view .input-text-view--edit:hover {
|
.input-text-view.view .input-text-view--edit:hover {
|
||||||
transform: rotate(15deg);
|
transform: rotate(15deg);
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@ export const InputTextView: FC<InputTextViewProps> = (props) => {
|
|||||||
return (
|
return (
|
||||||
<div className={className} onClick={() => setViewMode(false)}>
|
<div className={className} onClick={() => setViewMode(false)}>
|
||||||
{!!props.value ? (
|
{!!props.value ? (
|
||||||
props.value
|
<span>{props.value}</span>
|
||||||
) : (
|
) : (
|
||||||
<span className="input-text-view--placeholder">
|
<span className="input-text-view--placeholder">
|
||||||
{props.placeholder}
|
{props.placeholder}
|
||||||
|
|||||||
Reference in new issue
Block a user