Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d250018c9a | ||
|
|
95af6392ba | ||
|
|
fedc6c889a |
No files matched your search
@@ -1,5 +1,9 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [0.0.11] - Zoom
|
||||||
|
|
||||||
|
- Added lazy saving
|
||||||
|
|
||||||
## [0.0.10] - Zoom
|
## [0.0.10] - Zoom
|
||||||
|
|
||||||
- Introducing Zoom!
|
- Introducing Zoom!
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
name: Shortumation
|
name: Shortumation
|
||||||
version: 0.0.10
|
version: 0.0.11
|
||||||
slug: shortumation
|
slug: shortumation
|
||||||
url: "https://github.com/asosnovsky/Shortumation"
|
url: "https://github.com/asosnovsky/Shortumation"
|
||||||
description: "A homeassitant addon which provides better UI for automations & scripts."
|
description: "A homeassitant addon which provides better UI for automations & scripts."
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ const Template: ComponentStory<typeof AutomationEditor> = args => {
|
|||||||
<AutomationEditor
|
<AutomationEditor
|
||||||
{...args}
|
{...args}
|
||||||
automation={state}
|
automation={state}
|
||||||
onUpdate={setState}
|
onUpdate={s => {
|
||||||
|
window.setTimeout(() => setState(s), 3000)
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import "./index.css";
|
import "./index.css";
|
||||||
import { DAGBoardElmDims } from "components/DAGSvgs/DAGBoard";
|
import { DAGBoardElmDims } from "components/DAGSvgs/DAGBoard";
|
||||||
import { ArrowIcon, ZoomIcon } from "components/Icons";
|
import { ArrowIcon, CheckMarkIcon, ZoomIcon } from "components/Icons";
|
||||||
import { SequenceNodes } from "components/SequenceNodes";
|
import { SequenceNodes } from "components/SequenceNodes";
|
||||||
import { FC, useState } from "react";
|
import { FC, useEffect, useState } from "react";
|
||||||
import { AutomationData, AutomationSequenceNode } from "types/automations";
|
import { AutomationData, AutomationSequenceNode } from "types/automations";
|
||||||
import useWindowSize from "utils/useWindowSize";
|
import useWindowSize from "utils/useWindowSize";
|
||||||
import { AutoInfoBox } from "./AutoInfoBox";
|
import { AutoInfoBox } from "./AutoInfoBox";
|
||||||
@@ -13,6 +13,7 @@ import { AutomationTrigger } from 'types/automations/triggers';
|
|||||||
import { Modal } from "components/Modal";
|
import { Modal } from "components/Modal";
|
||||||
import { NodeEditor } from "components/NodeEditor";
|
import { NodeEditor } from "components/NodeEditor";
|
||||||
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||||
|
import { Button } from "components/Inputs/Button";
|
||||||
|
|
||||||
interface TriggerEditorModalState {
|
interface TriggerEditorModalState {
|
||||||
trigger: AutomationTrigger;
|
trigger: AutomationTrigger;
|
||||||
@@ -25,10 +26,13 @@ interface Props {
|
|||||||
}
|
}
|
||||||
export const AutomationEditor: FC<Props> = ({
|
export const AutomationEditor: FC<Props> = ({
|
||||||
dims,
|
dims,
|
||||||
automation,
|
automation: propsAutos,
|
||||||
onUpdate,
|
onUpdate: propsOnUpdate,
|
||||||
}) => {
|
}) => {
|
||||||
// state
|
// state
|
||||||
|
const [[autoChanged, automation], setAutomation] = useState<[
|
||||||
|
'unchanged' | 'changed' | 'loading', AutomationData]
|
||||||
|
>(['unchanged', propsAutos]);
|
||||||
const [zoomLevel, setZoomLevel] = useState(40);
|
const [zoomLevel, setZoomLevel] = useState(40);
|
||||||
const { ratioWbh } = useWindowSize();
|
const { ratioWbh } = useWindowSize();
|
||||||
const [closeInfo, setCloseInfo] = useState(false);
|
const [closeInfo, setCloseInfo] = useState(false);
|
||||||
@@ -47,6 +51,12 @@ export const AutomationEditor: FC<Props> = ({
|
|||||||
...automation,
|
...automation,
|
||||||
trigger,
|
trigger,
|
||||||
});
|
});
|
||||||
|
const onUpdate = (a: AutomationData) => setAutomation(['changed', a]);
|
||||||
|
|
||||||
|
// effects
|
||||||
|
useEffect(() => {
|
||||||
|
setAutomation(['unchanged', propsAutos]);
|
||||||
|
}, [propsAutos])
|
||||||
|
|
||||||
// render
|
// render
|
||||||
return <div className={classes.root}>
|
return <div className={classes.root}>
|
||||||
@@ -75,14 +85,28 @@ export const AutomationEditor: FC<Props> = ({
|
|||||||
|
|
||||||
<div className={classes.wrapper}>
|
<div className={classes.wrapper}>
|
||||||
<div className={classes.toolbar}>
|
<div className={classes.toolbar}>
|
||||||
<ZoomIcon className={classes.zoomImg} size={1} color="white" />
|
<div style={{ display: 'flex' }}>
|
||||||
<input
|
<ZoomIcon className={classes.zoomImg} size={1} color="white" />
|
||||||
type="number"
|
<input
|
||||||
min={1} max={100} step={1}
|
type="number"
|
||||||
className={classes.zoom}
|
min={1} max={100} step={1}
|
||||||
value={zoomLevel}
|
className={classes.zoom}
|
||||||
onChange={z => setZoomLevel(z.target.valueAsNumber ?? 40)}
|
value={zoomLevel}
|
||||||
/>
|
onChange={z => setZoomLevel(z.target.valueAsNumber ?? 40)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{autoChanged !== 'unchanged' && <Button
|
||||||
|
className={classes.saveBtn}
|
||||||
|
onClick={() => {
|
||||||
|
if (autoChanged === 'changed') {
|
||||||
|
setAutomation(['loading', automation]);
|
||||||
|
propsOnUpdate(automation);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
disabled={autoChanged !== 'changed'}
|
||||||
|
>
|
||||||
|
Save <CheckMarkIcon />
|
||||||
|
</Button>}
|
||||||
</div>
|
</div>
|
||||||
<SequenceNodes
|
<SequenceNodes
|
||||||
zoomLevel={zoomLevel * 200 / 100 + 50}
|
zoomLevel={zoomLevel * 200 / 100 + 50}
|
||||||
|
|||||||
@@ -36,14 +36,20 @@ export const useEditorStyles = createAppUseStyles<{
|
|||||||
maxWidth: "3em",
|
maxWidth: "3em",
|
||||||
},
|
},
|
||||||
zoomImg: {
|
zoomImg: {
|
||||||
// width: "1em",
|
|
||||||
|
|
||||||
},
|
},
|
||||||
toolbar: {
|
toolbar: {
|
||||||
width: "100%",
|
width: "100%",
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
justifyContent: 'start',
|
justifyContent: 'space-between',
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
saveBtn: {
|
||||||
|
display: "flex",
|
||||||
|
gap: '0.5em',
|
||||||
|
maxHeight: '1em',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
@@ -15,9 +15,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.automation-list--viewer {
|
.automation-list--viewer {
|
||||||
/* flex: 6; */
|
overflow: hidden;
|
||||||
min-width: 100%;
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* list children: on hide */
|
/* list children: on hide */
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ const commonInputStyle = (theme: AppTheme) => ({
|
|||||||
export const useButtonStyles = createAppUseStyles<{}>(theme => ({
|
export const useButtonStyles = createAppUseStyles<{}>(theme => ({
|
||||||
input: {
|
input: {
|
||||||
...commonInputStyle(theme).input,
|
...commonInputStyle(theme).input,
|
||||||
paddingTop: '2%',
|
paddingTop: '1em',
|
||||||
paddingBottom: '2%',
|
paddingBottom: '1em',
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in new issue
Block a user