Merge branch 'main' into dependabot/npm_and_yarn/webapp/url-parse-1.5.10
This commit is contained in:
13 files changed
+168
-64
No files matched your search
+12
-4
@@ -1,10 +1,18 @@
|
||||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
## [0.0.11] - Zoom
|
||||
|
||||
- Added lazy saving
|
||||
|
||||
## [0.0.10] - Zoom
|
||||
|
||||
- Introducing Zoom!
|
||||
|
||||
## [0.0.9] - First Working Version
|
||||
|
||||
- Instalable verion via github
|
||||
- Initial POC done
|
||||
- Initial POC done
|
||||
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
name: Shortumation
|
||||
version: 0.0.9
|
||||
version: 0.0.11
|
||||
slug: shortumation
|
||||
url: "https://github.com/asosnovsky/Shortumation"
|
||||
description: "A homeassitant addon which provides better UI for automations & scripts."
|
||||
|
||||
@@ -27,7 +27,9 @@ const Template: ComponentStory<typeof AutomationEditor> = args => {
|
||||
<AutomationEditor
|
||||
{...args}
|
||||
automation={state}
|
||||
onUpdate={setState}
|
||||
onUpdate={s => {
|
||||
window.setTimeout(() => setState(s), 3000)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import "./index.css";
|
||||
import { DAGBoardElmDims } from "components/DAGSvgs/DAGBoard";
|
||||
import { ArrowIcon } from "components/Icons";
|
||||
import { ArrowIcon, CheckMarkIcon, ZoomIcon } from "components/Icons";
|
||||
import { SequenceNodes } from "components/SequenceNodes";
|
||||
import { FC, useState } from "react";
|
||||
import { FC, useEffect, useState } from "react";
|
||||
import { AutomationData, AutomationSequenceNode } from "types/automations";
|
||||
import useWindowSize from "utils/useWindowSize";
|
||||
import { AutoInfoBox } from "./AutoInfoBox";
|
||||
@@ -13,6 +13,7 @@ import { AutomationTrigger } from 'types/automations/triggers';
|
||||
import { Modal } from "components/Modal";
|
||||
import { NodeEditor } from "components/NodeEditor";
|
||||
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||
import { Button } from "components/Inputs/Button";
|
||||
|
||||
interface TriggerEditorModalState {
|
||||
trigger: AutomationTrigger;
|
||||
@@ -25,10 +26,14 @@ interface Props {
|
||||
}
|
||||
export const AutomationEditor: FC<Props> = ({
|
||||
dims,
|
||||
automation,
|
||||
onUpdate,
|
||||
automation: propsAutos,
|
||||
onUpdate: propsOnUpdate,
|
||||
}) => {
|
||||
// state
|
||||
const [[autoChanged, automation], setAutomation] = useState<[
|
||||
'unchanged' | 'changed' | 'loading', AutomationData]
|
||||
>(['unchanged', propsAutos]);
|
||||
const [zoomLevel, setZoomLevel] = useState(40);
|
||||
const { ratioWbh } = useWindowSize();
|
||||
const [closeInfo, setCloseInfo] = useState(false);
|
||||
const [modalState, setModalState] = useState<null | TriggerEditorModalState>(null);
|
||||
@@ -46,6 +51,12 @@ export const AutomationEditor: FC<Props> = ({
|
||||
...automation,
|
||||
trigger,
|
||||
});
|
||||
const onUpdate = (a: AutomationData) => setAutomation(['changed', a]);
|
||||
|
||||
// effects
|
||||
useEffect(() => {
|
||||
setAutomation(['unchanged', propsAutos]);
|
||||
}, [propsAutos])
|
||||
|
||||
// render
|
||||
return <div className={classes.root}>
|
||||
@@ -72,38 +83,64 @@ export const AutomationEditor: FC<Props> = ({
|
||||
>{ArrowIcon}</ButtonIcon>
|
||||
</AutoInfoBox>
|
||||
|
||||
<SequenceNodes
|
||||
zoomLevel={1.5}
|
||||
startPoint={[2, 0.5]}
|
||||
dims={dims}
|
||||
sequence={automation.sequence}
|
||||
onChange={updateSequence}
|
||||
additionalElements={() => chain([
|
||||
computeExtraField([1, 0.5], [2, 0.5]),
|
||||
computeTriggerPos(
|
||||
[0.5, 0.5],
|
||||
automation.trigger,
|
||||
[1.5, 0.5],
|
||||
updateTriggers,
|
||||
() => {
|
||||
setModalState({
|
||||
trigger: {
|
||||
$smType: "trigger",
|
||||
platform: "device",
|
||||
device_id: "",
|
||||
domain: "",
|
||||
type: "",
|
||||
subtype: ""
|
||||
},
|
||||
onSave: (t) => updateTriggers([...automation.trigger, t])
|
||||
});
|
||||
},
|
||||
(trigger, onSave) => setModalState({
|
||||
trigger,
|
||||
onSave,
|
||||
})
|
||||
),
|
||||
])}
|
||||
/>
|
||||
<div className={classes.wrapper}>
|
||||
<div className={classes.toolbar}>
|
||||
<div style={{ display: 'flex' }}>
|
||||
<ZoomIcon className={classes.zoomImg} size={1} color="white" />
|
||||
<input
|
||||
type="number"
|
||||
min={1} max={100} step={1}
|
||||
className={classes.zoom}
|
||||
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>
|
||||
<SequenceNodes
|
||||
zoomLevel={zoomLevel * 200 / 100 + 50}
|
||||
startPoint={[2, 0.5]}
|
||||
dims={dims}
|
||||
sequence={automation.sequence}
|
||||
onChange={updateSequence}
|
||||
additionalElements={() => chain([
|
||||
computeExtraField([1, 0.5], [2, 0.5]),
|
||||
computeTriggerPos(
|
||||
[0.5, 0.5],
|
||||
automation.trigger,
|
||||
[1.5, 0.5],
|
||||
updateTriggers,
|
||||
() => {
|
||||
setModalState({
|
||||
trigger: {
|
||||
$smType: "trigger",
|
||||
platform: "device",
|
||||
device_id: "",
|
||||
domain: "",
|
||||
type: "",
|
||||
subtype: ""
|
||||
},
|
||||
onSave: (t) => updateTriggers([...automation.trigger, t])
|
||||
});
|
||||
},
|
||||
(trigger, onSave) => setModalState({
|
||||
trigger,
|
||||
onSave,
|
||||
})
|
||||
),
|
||||
])}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -5,7 +5,15 @@ export const useEditorStyles = createAppUseStyles<{
|
||||
closeInfo: boolean;
|
||||
horizontalMode: boolean;
|
||||
}>(theme => ({
|
||||
root: ({horizontalMode}) => ({
|
||||
wrapper: {
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: "flex-end",
|
||||
height: '100%',
|
||||
width: '100%',
|
||||
overflow: 'hidden',
|
||||
},
|
||||
root: ({ horizontalMode }) => ({
|
||||
height: '100%',
|
||||
width: '100%',
|
||||
color: theme.primaryAccent,
|
||||
@@ -18,7 +26,30 @@ export const useEditorStyles = createAppUseStyles<{
|
||||
borderColor: theme.secondaryAccent,
|
||||
width: '100%',
|
||||
},
|
||||
infoIcon: ({horizontalMode}) => ({
|
||||
infoIcon: ({ horizontalMode }) => ({
|
||||
bottom: horizontalMode ? '90%' : 10
|
||||
})
|
||||
}),
|
||||
zoom: {
|
||||
backgroundColor: theme.secondary,
|
||||
color: theme.secondaryAccent,
|
||||
textAlign: 'center',
|
||||
maxWidth: "3em",
|
||||
},
|
||||
zoomImg: {
|
||||
|
||||
},
|
||||
toolbar: {
|
||||
width: "100%",
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
justifyContent: 'space-between',
|
||||
alignItems: "center",
|
||||
},
|
||||
saveBtn: {
|
||||
display: "flex",
|
||||
gap: '0.5em',
|
||||
maxHeight: '1em',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
}
|
||||
}))
|
||||
@@ -15,9 +15,7 @@
|
||||
}
|
||||
|
||||
.automation-list--viewer {
|
||||
/* flex: 6; */
|
||||
min-width: 100%;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* list children: on hide */
|
||||
|
||||
@@ -16,25 +16,26 @@ export const SVGBoard: FC<{
|
||||
minGraphWidth = 300,
|
||||
nodeHeight = NODE_HEIGHT,
|
||||
nodeWidth = NODE_WIDTH,
|
||||
zoomLevel = 1,
|
||||
zoomLevel = 100,
|
||||
}) => {
|
||||
|
||||
// state
|
||||
const { ratioWbh } = useWindowSize();
|
||||
// alias
|
||||
const paddedZoomLevel = zoomLevel / 100;
|
||||
const graphWidth = Math.max(
|
||||
Math.round(graphHeight * ratioWbh),
|
||||
minGraphWidth
|
||||
);
|
||||
const { classes, theme } = useBoardStyles({
|
||||
boardHeight: Math.max(nodeHeight, graphHeight) * zoomLevel,
|
||||
boardWidth: Math.max(4 * nodeWidth, graphWidth) * zoomLevel,
|
||||
boardHeight: Math.max(nodeHeight, graphHeight) * paddedZoomLevel,
|
||||
boardWidth: Math.max(4 * nodeWidth, graphWidth) * paddedZoomLevel,
|
||||
});
|
||||
// render
|
||||
return <div className={classes.dag} >
|
||||
<svg
|
||||
className={classes.svg}
|
||||
viewBox={[0, 0, graphWidth, graphHeight].join(" ")}
|
||||
viewBox={[0, 0, graphWidth / paddedZoomLevel, graphHeight / paddedZoomLevel].join(" ")}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<defs>
|
||||
|
||||
@@ -10,7 +10,7 @@ export default {
|
||||
component: DAGBoard,
|
||||
parameters: { actions: { argTypesRegex: '^on.*' } },
|
||||
args: {
|
||||
zoomLevel: 1,
|
||||
zoomLevel: 100,
|
||||
settings: {
|
||||
nodeHeight: NODE_HEIGHT,
|
||||
nodeWidth: NODE_WIDTH,
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { ComponentStory } from "@storybook/react";
|
||||
|
||||
import { IconBase } from "./base";
|
||||
import { PencilIcon, CheckMarkIcon, TrashIcon, InfoIcon, ArrowIcon } from ".";
|
||||
import { AddIcon } from './index';
|
||||
import { PencilIcon, CheckMarkIcon, TrashIcon, InfoIcon, ArrowIcon, AddIcon, ZoomIcon } from ".";
|
||||
import { ButtonIcon } from "./ButtonIcons";
|
||||
|
||||
export default {
|
||||
@@ -19,6 +18,7 @@ export const IconList: ComponentStory<typeof IconBase> = (args) => {
|
||||
<AddIcon {...args} />
|
||||
<TrashIcon {...args} />
|
||||
<InfoIcon {...args} />
|
||||
<ZoomIcon {...args} />
|
||||
</div>
|
||||
}
|
||||
IconList.args = {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { FC } from "react";
|
||||
import { IconBase, IconBaseProps } from "./base";
|
||||
import { IconBase, IconBaseProps } from './base';
|
||||
|
||||
|
||||
export const PencilIcon: FC<IconBaseProps> = props => <IconBase {...props}
|
||||
@@ -54,3 +54,14 @@ export const ArrowIcon: FC<IconBaseProps> = props => <IconBase
|
||||
>
|
||||
<path d="M3 12l18-12v24z" />
|
||||
</IconBase>
|
||||
|
||||
|
||||
export const ZoomIcon: FC<IconBaseProps> = props => <IconBase {...props}
|
||||
svgProps={{
|
||||
viewBox: "0 0 1000 1000",
|
||||
x: 0,
|
||||
y: 0
|
||||
}}
|
||||
>
|
||||
<path d="M410.9,10c54.3,0,106.2,10.6,155.7,31.8c49.5,21.2,92.1,49.7,127.9,85.4c35.7,35.7,64.2,78.4,85.4,127.9c21.2,49.5,31.8,101.4,31.8,155.7c0,46.6-7.6,91.3-22.8,134c-15.2,42.7-36.8,81.4-64.9,116.2l253,252.7c8.6,8.6,12.9,19.1,12.9,31.7c0,12.8-4.2,23.4-12.7,31.8c-8.5,8.5-19.1,12.7-31.8,12.7c-12.5,0-23.1-4.3-31.7-12.9l-252.7-253c-34.8,28.1-73.6,49.7-116.2,64.9c-42.7,15.2-87.3,22.8-134,22.8c-54.3,0-106.2-10.6-155.7-31.8c-49.5-21.2-92.1-49.7-127.9-85.4C91.5,658.8,63,616.2,41.8,566.7C20.6,517.1,10,465.2,10,410.9c0-54.3,10.6-106.2,31.8-155.7s49.7-92.2,85.4-127.9s78.3-64.2,127.9-85.4S356.6,10,410.9,10L410.9,10z M410.9,99.1c-42.2,0-82.6,8.2-121.1,24.7c-38.5,16.5-71.7,38.6-99.5,66.5c-27.8,27.8-50,61-66.5,99.5c-16.5,38.5-24.7,78.9-24.7,121.1c0,42.2,8.2,82.6,24.7,121.1c16.5,38.5,38.6,71.7,66.5,99.5s61,50,99.5,66.5c38.5,16.5,78.9,24.7,121.1,24.7c42.2,0,82.6-8.2,121.1-24.7c38.5-16.5,71.7-38.6,99.5-66.5s50-61,66.5-99.5c16.5-38.5,24.7-78.9,24.7-121.1c0-42.2-8.2-82.6-24.7-121.1c-16.5-38.5-38.6-71.7-66.5-99.5c-27.8-27.8-61-50-99.5-66.5C493.5,107.3,453.2,99.1,410.9,99.1z M410.9,232.7c12.3,0,22.8,4.4,31.5,13.1c8.7,8.7,13.1,19.2,13.1,31.5v89.1h89.1c12.3,0,22.8,4.4,31.5,13.1c8.7,8.7,13.1,19.2,13.1,31.5c0,12.3-4.4,22.8-13.1,31.5c-8.7,8.7-19.2,13.1-31.5,13.1h-89.1v89.1c0,12.3-4.4,22.8-13.1,31.5c-8.7,8.7-19.2,13.1-31.5,13.1c-12.3,0-22.8-4.4-31.5-13.1c-8.7-8.7-13.1-19.2-13.1-31.5v-89.1h-89.1c-12.3,0-22.8-4.4-31.5-13.1c-8.7-8.7-13.1-19.2-13.1-31.5c0-12.3,4.4-22.8,13.1-31.5c8.7-8.7,19.2-13.1,31.5-13.1h89.1v-89.1c0-12.3,4.4-22.8,13.1-31.5C388.1,237.1,398.6,232.7,410.9,232.7z" />
|
||||
</IconBase>
|
||||
@@ -6,22 +6,38 @@ export interface Props {
|
||||
label: string;
|
||||
value: number | undefined;
|
||||
onChange: (v: number | undefined) => void;
|
||||
className?: string;
|
||||
min?: number,
|
||||
max?: number,
|
||||
step?: number,
|
||||
}
|
||||
export default function InputNumber({
|
||||
label,
|
||||
value = undefined,
|
||||
onChange,
|
||||
className = "",
|
||||
min, max, step,
|
||||
}: Props) {
|
||||
const { classes } = useInputNumberStyles({});
|
||||
return <InputWrapper label={label} labelSize={value !== undefined ? 'small' : 'normal'}>
|
||||
return <InputWrapper className={className} label={label} labelSize={value !== undefined ? 'small' : 'normal'}>
|
||||
<input
|
||||
className={classes.input}
|
||||
type="number"
|
||||
value={value ?? ""}
|
||||
onChange={e => {
|
||||
e.preventDefault();
|
||||
onChange(Number(e.target.value))
|
||||
let v = Number(e.target.value);
|
||||
if (max) {
|
||||
v = Math.min(v, max)
|
||||
}
|
||||
if (min) {
|
||||
v = Math.max(v, min)
|
||||
}
|
||||
onChange(v)
|
||||
}}
|
||||
step={step}
|
||||
min={min}
|
||||
max={max}
|
||||
/>
|
||||
{value && <button className={classes.deleteIcon} onClick={() => onChange(undefined)}>X</button>}
|
||||
</InputWrapper>
|
||||
|
||||
@@ -29,8 +29,8 @@ const commonInputStyle = (theme: AppTheme) => ({
|
||||
export const useButtonStyles = createAppUseStyles<{}>(theme => ({
|
||||
input: {
|
||||
...commonInputStyle(theme).input,
|
||||
paddingTop: '2%',
|
||||
paddingBottom: '2%',
|
||||
paddingTop: '1em',
|
||||
paddingBottom: '1em',
|
||||
cursor: 'pointer',
|
||||
},
|
||||
}));
|
||||
@@ -97,8 +97,8 @@ export const useInputNumberStyles = createAppUseStyles<{}>(theme => {
|
||||
},
|
||||
deleteIcon: {
|
||||
position: "absolute",
|
||||
left: 30,
|
||||
top: 17,
|
||||
left: "1em",
|
||||
top: "1.5em",
|
||||
color: theme.secondaryAccent,
|
||||
backgroundColor: theme.secondary,
|
||||
borderWidth: 1,
|
||||
|
||||
@@ -11,7 +11,7 @@ export default {
|
||||
component: SequenceNodes,
|
||||
parameters: { actions: { argTypesRegex: '^on.*' } },
|
||||
args: {
|
||||
zoomLevel: 1.5,
|
||||
zoomLevel: 100,
|
||||
startPoint: [0.5, 0.5],
|
||||
dims: {
|
||||
nodeHeight: NODE_HEIGHT,
|
||||
|
||||
Reference in new issue
Block a user