Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
77c338eb90 | ||
|
|
967508c29e | ||
|
|
93fe26e787 | ||
|
|
b1c5bce584 | ||
|
|
50ba9f3d6b |
No files matched your search
@@ -0,0 +1,70 @@
|
|||||||
|
# For most projects, this workflow file will not need changing; you simply need
|
||||||
|
# to commit it to your repository.
|
||||||
|
#
|
||||||
|
# You may wish to alter this file to override the set of languages analyzed,
|
||||||
|
# or to provide custom queries or build logic.
|
||||||
|
#
|
||||||
|
# ******** NOTE ********
|
||||||
|
# We have attempted to detect the languages in your repository. Please check
|
||||||
|
# the `language` matrix defined below to confirm you have the correct set of
|
||||||
|
# supported CodeQL languages.
|
||||||
|
#
|
||||||
|
name: "CodeQL"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main ]
|
||||||
|
pull_request:
|
||||||
|
# The branches below must be a subset of the branches above
|
||||||
|
branches: [ main ]
|
||||||
|
schedule:
|
||||||
|
- cron: '29 23 * * 0'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
analyze:
|
||||||
|
name: Analyze
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: read
|
||||||
|
security-events: write
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
language: [ 'javascript', 'python' ]
|
||||||
|
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
||||||
|
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
# Initializes the CodeQL tools for scanning.
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v2
|
||||||
|
with:
|
||||||
|
languages: ${{ matrix.language }}
|
||||||
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
|
# By default, queries listed here will override any specified in a config file.
|
||||||
|
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||||
|
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||||
|
|
||||||
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
|
- name: Autobuild
|
||||||
|
uses: github/codeql-action/autobuild@v2
|
||||||
|
|
||||||
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
|
# 📚 https://git.io/JvXDl
|
||||||
|
|
||||||
|
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||||
|
# and modify them (or add more) to build your code if your project
|
||||||
|
# uses a compiled language
|
||||||
|
|
||||||
|
#- run: |
|
||||||
|
# make bootstrap
|
||||||
|
# make release
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v2
|
||||||
+8
-4
@@ -1,10 +1,14 @@
|
|||||||
# Changelog
|
# 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/),
|
## [0.0.10] - Zoom
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
||||||
|
- Introducing Zoom!
|
||||||
|
|
||||||
## [0.0.9] - First Working Version
|
## [0.0.9] - First Working Version
|
||||||
|
|
||||||
- Instalable verion via github
|
- 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
|
name: Shortumation
|
||||||
version: 0.0.8
|
version: 0.0.10
|
||||||
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."
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import "./index.css";
|
import "./index.css";
|
||||||
import { DAGBoardElmDims } from "components/DAGSvgs/DAGBoard";
|
import { DAGBoardElmDims } from "components/DAGSvgs/DAGBoard";
|
||||||
import { ArrowIcon } from "components/Icons";
|
import { ArrowIcon, ZoomIcon } from "components/Icons";
|
||||||
import { SequenceNodes } from "components/SequenceNodes";
|
import { SequenceNodes } from "components/SequenceNodes";
|
||||||
import { FC, useState } from "react";
|
import { FC, useState } from "react";
|
||||||
import { AutomationData, AutomationSequenceNode } from "types/automations";
|
import { AutomationData, AutomationSequenceNode } from "types/automations";
|
||||||
@@ -29,6 +29,7 @@ export const AutomationEditor: FC<Props> = ({
|
|||||||
onUpdate,
|
onUpdate,
|
||||||
}) => {
|
}) => {
|
||||||
// state
|
// state
|
||||||
|
const [zoomLevel, setZoomLevel] = useState(40);
|
||||||
const { ratioWbh } = useWindowSize();
|
const { ratioWbh } = useWindowSize();
|
||||||
const [closeInfo, setCloseInfo] = useState(false);
|
const [closeInfo, setCloseInfo] = useState(false);
|
||||||
const [modalState, setModalState] = useState<null | TriggerEditorModalState>(null);
|
const [modalState, setModalState] = useState<null | TriggerEditorModalState>(null);
|
||||||
@@ -72,38 +73,50 @@ export const AutomationEditor: FC<Props> = ({
|
|||||||
>{ArrowIcon}</ButtonIcon>
|
>{ArrowIcon}</ButtonIcon>
|
||||||
</AutoInfoBox>
|
</AutoInfoBox>
|
||||||
|
|
||||||
<SequenceNodes
|
<div className={classes.wrapper}>
|
||||||
zoomLevel={1.5}
|
<div className={classes.toolbar}>
|
||||||
startPoint={[2, 0.5]}
|
<ZoomIcon className={classes.zoomImg} size={1} color="white" />
|
||||||
dims={dims}
|
<input
|
||||||
sequence={automation.sequence}
|
type="number"
|
||||||
onChange={updateSequence}
|
min={1} max={100} step={1}
|
||||||
additionalElements={() => chain([
|
className={classes.zoom}
|
||||||
computeExtraField([1, 0.5], [2, 0.5]),
|
value={zoomLevel}
|
||||||
computeTriggerPos(
|
onChange={z => setZoomLevel(z.target.valueAsNumber ?? 40)}
|
||||||
[0.5, 0.5],
|
/>
|
||||||
automation.trigger,
|
</div>
|
||||||
[1.5, 0.5],
|
<SequenceNodes
|
||||||
updateTriggers,
|
zoomLevel={zoomLevel * 200 / 100 + 50}
|
||||||
() => {
|
startPoint={[2, 0.5]}
|
||||||
setModalState({
|
dims={dims}
|
||||||
trigger: {
|
sequence={automation.sequence}
|
||||||
$smType: "trigger",
|
onChange={updateSequence}
|
||||||
platform: "device",
|
additionalElements={() => chain([
|
||||||
device_id: "",
|
computeExtraField([1, 0.5], [2, 0.5]),
|
||||||
domain: "",
|
computeTriggerPos(
|
||||||
type: "",
|
[0.5, 0.5],
|
||||||
subtype: ""
|
automation.trigger,
|
||||||
},
|
[1.5, 0.5],
|
||||||
onSave: (t) => updateTriggers([...automation.trigger, t])
|
updateTriggers,
|
||||||
});
|
() => {
|
||||||
},
|
setModalState({
|
||||||
(trigger, onSave) => setModalState({
|
trigger: {
|
||||||
trigger,
|
$smType: "trigger",
|
||||||
onSave,
|
platform: "device",
|
||||||
})
|
device_id: "",
|
||||||
),
|
domain: "",
|
||||||
])}
|
type: "",
|
||||||
/>
|
subtype: ""
|
||||||
|
},
|
||||||
|
onSave: (t) => updateTriggers([...automation.trigger, t])
|
||||||
|
});
|
||||||
|
},
|
||||||
|
(trigger, onSave) => setModalState({
|
||||||
|
trigger,
|
||||||
|
onSave,
|
||||||
|
})
|
||||||
|
),
|
||||||
|
])}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,15 @@ export const useEditorStyles = createAppUseStyles<{
|
|||||||
closeInfo: boolean;
|
closeInfo: boolean;
|
||||||
horizontalMode: boolean;
|
horizontalMode: boolean;
|
||||||
}>(theme => ({
|
}>(theme => ({
|
||||||
root: ({horizontalMode}) => ({
|
wrapper: {
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
alignItems: "flex-end",
|
||||||
|
height: '100%',
|
||||||
|
width: '100%',
|
||||||
|
overflow: 'hidden',
|
||||||
|
},
|
||||||
|
root: ({ horizontalMode }) => ({
|
||||||
height: '100%',
|
height: '100%',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
color: theme.primaryAccent,
|
color: theme.primaryAccent,
|
||||||
@@ -18,7 +26,24 @@ export const useEditorStyles = createAppUseStyles<{
|
|||||||
borderColor: theme.secondaryAccent,
|
borderColor: theme.secondaryAccent,
|
||||||
width: '100%',
|
width: '100%',
|
||||||
},
|
},
|
||||||
infoIcon: ({horizontalMode}) => ({
|
infoIcon: ({ horizontalMode }) => ({
|
||||||
bottom: horizontalMode ? '90%' : 10
|
bottom: horizontalMode ? '90%' : 10
|
||||||
})
|
}),
|
||||||
|
zoom: {
|
||||||
|
backgroundColor: theme.secondary,
|
||||||
|
color: theme.secondaryAccent,
|
||||||
|
textAlign: 'center',
|
||||||
|
maxWidth: "3em",
|
||||||
|
},
|
||||||
|
zoomImg: {
|
||||||
|
// width: "1em",
|
||||||
|
|
||||||
|
},
|
||||||
|
toolbar: {
|
||||||
|
width: "100%",
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "row",
|
||||||
|
justifyContent: 'start',
|
||||||
|
alignItems: "center",
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
@@ -16,25 +16,26 @@ export const SVGBoard: FC<{
|
|||||||
minGraphWidth = 300,
|
minGraphWidth = 300,
|
||||||
nodeHeight = NODE_HEIGHT,
|
nodeHeight = NODE_HEIGHT,
|
||||||
nodeWidth = NODE_WIDTH,
|
nodeWidth = NODE_WIDTH,
|
||||||
zoomLevel = 1,
|
zoomLevel = 100,
|
||||||
}) => {
|
}) => {
|
||||||
|
|
||||||
// state
|
// state
|
||||||
const { ratioWbh } = useWindowSize();
|
const { ratioWbh } = useWindowSize();
|
||||||
// alias
|
// alias
|
||||||
|
const paddedZoomLevel = zoomLevel / 100;
|
||||||
const graphWidth = Math.max(
|
const graphWidth = Math.max(
|
||||||
Math.round(graphHeight * ratioWbh),
|
Math.round(graphHeight * ratioWbh),
|
||||||
minGraphWidth
|
minGraphWidth
|
||||||
);
|
);
|
||||||
const { classes, theme } = useBoardStyles({
|
const { classes, theme } = useBoardStyles({
|
||||||
boardHeight: Math.max(nodeHeight, graphHeight) * zoomLevel,
|
boardHeight: Math.max(nodeHeight, graphHeight) * paddedZoomLevel,
|
||||||
boardWidth: Math.max(4 * nodeWidth, graphWidth) * zoomLevel,
|
boardWidth: Math.max(4 * nodeWidth, graphWidth) * paddedZoomLevel,
|
||||||
});
|
});
|
||||||
// render
|
// render
|
||||||
return <div className={classes.dag} >
|
return <div className={classes.dag} >
|
||||||
<svg
|
<svg
|
||||||
className={classes.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"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
>
|
>
|
||||||
<defs>
|
<defs>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export default {
|
|||||||
component: DAGBoard,
|
component: DAGBoard,
|
||||||
parameters: { actions: { argTypesRegex: '^on.*' } },
|
parameters: { actions: { argTypesRegex: '^on.*' } },
|
||||||
args: {
|
args: {
|
||||||
zoomLevel: 1,
|
zoomLevel: 100,
|
||||||
settings: {
|
settings: {
|
||||||
nodeHeight: NODE_HEIGHT,
|
nodeHeight: NODE_HEIGHT,
|
||||||
nodeWidth: NODE_WIDTH,
|
nodeWidth: NODE_WIDTH,
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { ComponentStory } from "@storybook/react";
|
import { ComponentStory } from "@storybook/react";
|
||||||
|
|
||||||
import { IconBase } from "./base";
|
import { IconBase } from "./base";
|
||||||
import { PencilIcon, CheckMarkIcon, TrashIcon, InfoIcon, ArrowIcon } from ".";
|
import { PencilIcon, CheckMarkIcon, TrashIcon, InfoIcon, ArrowIcon, AddIcon, ZoomIcon } from ".";
|
||||||
import { AddIcon } from './index';
|
|
||||||
import { ButtonIcon } from "./ButtonIcons";
|
import { ButtonIcon } from "./ButtonIcons";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -19,6 +18,7 @@ export const IconList: ComponentStory<typeof IconBase> = (args) => {
|
|||||||
<AddIcon {...args} />
|
<AddIcon {...args} />
|
||||||
<TrashIcon {...args} />
|
<TrashIcon {...args} />
|
||||||
<InfoIcon {...args} />
|
<InfoIcon {...args} />
|
||||||
|
<ZoomIcon {...args} />
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
IconList.args = {
|
IconList.args = {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { FC } from "react";
|
import { FC } from "react";
|
||||||
import { IconBase, IconBaseProps } from "./base";
|
import { IconBase, IconBaseProps } from './base';
|
||||||
|
|
||||||
|
|
||||||
export const PencilIcon: FC<IconBaseProps> = props => <IconBase {...props}
|
export const PencilIcon: FC<IconBaseProps> = props => <IconBase {...props}
|
||||||
@@ -54,3 +54,14 @@ export const ArrowIcon: FC<IconBaseProps> = props => <IconBase
|
|||||||
>
|
>
|
||||||
<path d="M3 12l18-12v24z" />
|
<path d="M3 12l18-12v24z" />
|
||||||
</IconBase>
|
</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;
|
label: string;
|
||||||
value: number | undefined;
|
value: number | undefined;
|
||||||
onChange: (v: number | undefined) => void;
|
onChange: (v: number | undefined) => void;
|
||||||
|
className?: string;
|
||||||
|
min?: number,
|
||||||
|
max?: number,
|
||||||
|
step?: number,
|
||||||
}
|
}
|
||||||
export default function InputNumber({
|
export default function InputNumber({
|
||||||
label,
|
label,
|
||||||
value = undefined,
|
value = undefined,
|
||||||
onChange,
|
onChange,
|
||||||
|
className = "",
|
||||||
|
min, max, step,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const { classes } = useInputNumberStyles({});
|
const { classes } = useInputNumberStyles({});
|
||||||
return <InputWrapper label={label} labelSize={value !== undefined ? 'small' : 'normal'}>
|
return <InputWrapper className={className} label={label} labelSize={value !== undefined ? 'small' : 'normal'}>
|
||||||
<input
|
<input
|
||||||
className={classes.input}
|
className={classes.input}
|
||||||
type="number"
|
type="number"
|
||||||
value={value ?? ""}
|
value={value ?? ""}
|
||||||
onChange={e => {
|
onChange={e => {
|
||||||
e.preventDefault();
|
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>}
|
{value && <button className={classes.deleteIcon} onClick={() => onChange(undefined)}>X</button>}
|
||||||
</InputWrapper>
|
</InputWrapper>
|
||||||
|
|||||||
@@ -97,8 +97,8 @@ export const useInputNumberStyles = createAppUseStyles<{}>(theme => {
|
|||||||
},
|
},
|
||||||
deleteIcon: {
|
deleteIcon: {
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
left: 30,
|
left: "1em",
|
||||||
top: 17,
|
top: "1.5em",
|
||||||
color: theme.secondaryAccent,
|
color: theme.secondaryAccent,
|
||||||
backgroundColor: theme.secondary,
|
backgroundColor: theme.secondary,
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default {
|
|||||||
component: SequenceNodes,
|
component: SequenceNodes,
|
||||||
parameters: { actions: { argTypesRegex: '^on.*' } },
|
parameters: { actions: { argTypesRegex: '^on.*' } },
|
||||||
args: {
|
args: {
|
||||||
zoomLevel: 1.5,
|
zoomLevel: 100,
|
||||||
startPoint: [0.5, 0.5],
|
startPoint: [0.5, 0.5],
|
||||||
dims: {
|
dims: {
|
||||||
nodeHeight: NODE_HEIGHT,
|
nodeHeight: NODE_HEIGHT,
|
||||||
|
|||||||
Reference in new issue
Block a user