Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b342088b96 | ||
|
|
c0c0d3181c | ||
|
|
cf013cc342 | ||
|
|
23b869d43e | ||
|
|
e333e80ea3 | ||
|
|
996e23038f | ||
|
|
0be03b1536 | ||
|
|
dc726ff184 | ||
|
|
7e5885a34d | ||
|
|
38396c4d98 | ||
|
|
ea832884f1 | ||
|
|
ea14cd4239 | ||
|
|
4e19bdf4c4 | ||
|
|
75c5870e00 |
No files matched your search
@@ -2,12 +2,39 @@ name: Deploy
|
|||||||
env:
|
env:
|
||||||
MONITORED_FILES: "apparmor.txt build.yaml config.yaml Dockerfile data rootfs"
|
MONITORED_FILES: "apparmor.txt build.yaml config.yaml Dockerfile data rootfs"
|
||||||
on:
|
on:
|
||||||
release:
|
# release:
|
||||||
types: [published]
|
# types: [published]
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- 'config.yaml'
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
|
metadata:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Metadata
|
||||||
|
outputs:
|
||||||
|
version: ${{ steps.version.outputs.VERSION }}
|
||||||
|
changlelog: ${{ steps.changlelog.outputs.CHANGELOG }}
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Get Version
|
||||||
|
id: version
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo ::set-output name=VERSION::$(cat config.yaml | sed -nr 's/version: (.*)/\1/p')
|
||||||
|
- name: Get Changelog
|
||||||
|
id: changlelog
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo ::set-output name=CHANGELOG::$(cat CHANGELOG.md)
|
||||||
|
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: ${{ matrix.arch }}
|
name: Build & Publish ${{ matrix.arch }}
|
||||||
|
needs:
|
||||||
|
- metadata
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
arch: ["aarch64", "amd64", "armhf", "armv7", "i386"]
|
arch: ["aarch64", "amd64", "armhf", "armv7", "i386"]
|
||||||
@@ -22,9 +49,30 @@ jobs:
|
|||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: ${{ github.ref }} / ${{ matrix.arch }}
|
- name: Build & Push to Dockerhub - ${{ matrix.arch }} / ${{ needs.metadata.outputs.version }}
|
||||||
uses: home-assistant/builder@2022.03.1
|
uses: home-assistant/builder@2022.03.1
|
||||||
with:
|
with:
|
||||||
args: |
|
args: |
|
||||||
--${{ matrix.arch }} \
|
--${{ matrix.arch }} \
|
||||||
--target .
|
--target .
|
||||||
|
|
||||||
|
publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- metadata
|
||||||
|
- build
|
||||||
|
name: Publish Github Release
|
||||||
|
steps:
|
||||||
|
- name: Publish Release ${{ needs.metadata.outputs.version }}
|
||||||
|
uses: actions/github-script@v6
|
||||||
|
env:
|
||||||
|
VERSION: ${{ needs.metadata.outputs.version }}
|
||||||
|
CHANGELOG: ${{ needs.metadata.outputs.changlelog }}
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
github.rest.repos.createRelease({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
tag_name: process.env.VERSION,
|
||||||
|
body: process.env.CHANGELOG,
|
||||||
|
});
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
.vscode/*.log
|
||||||
+3
-39
@@ -1,40 +1,4 @@
|
|||||||
# Changelog -- [](https://badge.fury.io/gh/asosnovsky%2FShortumation)
|
# Changelog -- v0.1.5
|
||||||
|
|
||||||
## [0.1.2] - Docker Hub Images
|
- Fixed up arrow styles due to typos
|
||||||
|
- Added selection color
|
||||||
- Publishing images to docker hub is now stable
|
|
||||||
|
|
||||||
## [0.0.15] - Publish to dockerhub
|
|
||||||
|
|
||||||
- Publishing images to docker hub
|
|
||||||
|
|
||||||
## [0.0.14] - Using vanila ha yaml
|
|
||||||
|
|
||||||
- Supporing vanilla out of the box HA yaml as oppose to parsing them (no more $smType)
|
|
||||||
- Conditions have now a more a explicit node
|
|
||||||
|
|
||||||
## [0.0.13] - Better Styling with react-flow
|
|
||||||
|
|
||||||
- Fixed up styling (using react-flow)
|
|
||||||
- cleaned up some button styles
|
|
||||||
|
|
||||||
## [0.0.12] - Tags
|
|
||||||
|
|
||||||
- Added tag management system for automations
|
|
||||||
|
|
||||||
## [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
|
|
||||||
|
|
||||||
|
|
||||||
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,6 +1,11 @@
|
|||||||
# Shortumation [](https://badge.fury.io/gh/asosnovsky%2FShortumation)
|
# Shortumation
|
||||||
|
|
||||||
|
A better way to write automations in home-assistant without having to install and run a seperate automation engine!
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
A [home-assistent addon](https://www.home-assistant.io/addons/) for a better UI for managing your automations & scripts. We provide a way to visualize and develop your automation using a visual-programming language that draws inspirations from [Node-Red](https://nodered.org/).
|
A [home-assistent addon](https://www.home-assistant.io/addons/) for a better UI for managing your automations & scripts. We provide a way to visualize and develop your automation using a visual-programming language that draws inspirations from [Node-Red](https://nodered.org/).
|
||||||
|
|
||||||
@@ -19,3 +24,16 @@ A [home-assistent addon](https://www.home-assistant.io/addons/) for a better UI
|
|||||||
See roadmap in [Version 1 Github Project](https://github.com/asosnovsky/Shortumation/projects/1).
|
See roadmap in [Version 1 Github Project](https://github.com/asosnovsky/Shortumation/projects/1).
|
||||||
|
|
||||||
|
|
||||||
|
## FAQ
|
||||||
|
|
||||||
|
**How is this different from Node-Red?**
|
||||||
|
|
||||||
|
> Node-Red is both an execution engine and an automation editor, which means that in order for you automations to run you have to have an additional component running and executing the automations. Shortumations simply provides a different editor and manager for writing Homeassistant automations, while relying on Homeassistant to execute the automations (this uses the `automations.yaml` file as the backend database)
|
||||||
|
|
||||||
|
**Which HA Installation does this support?**
|
||||||
|
|
||||||
|
> Currently this is only tested on HA OS. However, you should be able to get it working supervised installations as well (as they support addons). If you want to make it work for Container or Core, you will need to do some additional leg-work and I welcome a PR to get this working (it should be just a matter of mounting the `/config` path to the container running the images in this repo).
|
||||||
|
|
||||||
|
**Which version of HA does this require?**
|
||||||
|
|
||||||
|
> Since I am working on this project on my own, I can only test it against my own HA installations at home, and I tend to keep things as up to date as possible. The lowest version of HA this was tested on is `core-2022.5.4`
|
||||||
@@ -25,11 +25,11 @@ def make_automation_router(automations: AutomationManager) -> APIRouter:
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@router.post("")
|
@router.post("/item")
|
||||||
def upsert_auto(body: UpdateAutoRequest):
|
def upsert_auto(body: UpdateAutoRequest):
|
||||||
automations.update(body.index, body.data)
|
automations.update(body.index, body.data)
|
||||||
|
|
||||||
@router.delete("")
|
@router.delete("/item")
|
||||||
def delete_auto(body: DeleteAutoRequest):
|
def delete_auto(body: DeleteAutoRequest):
|
||||||
try:
|
try:
|
||||||
automations.delete(body.index)
|
automations.delete(body.index)
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
name: Shortumation
|
name: Shortumation
|
||||||
version: 0.1.2
|
version: 0.1.5
|
||||||
slug: shortumation
|
slug: shortumation
|
||||||
image: asosnovsky/shortumation-{arch}
|
image: asosnovsky/shortumation-{arch}
|
||||||
url: "https://github.com/asosnovsky/Shortumation"
|
url: "https://github.com/asosnovsky/Shortumation"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { AutomationData } from "types/automations";
|
import { AutomationData } from "types/automations";
|
||||||
import { API } from "./base";
|
import { API } from "./base";
|
||||||
import { ListData, ListParams } from "./types";
|
import { ListData, ListParams } from "./types";
|
||||||
import { AUTOMTAION_LIST, AUTOMTAION_ROOT } from './paths';
|
import { AUTOMTAION_LIST, AUTOMTAION_ITEM } from './paths';
|
||||||
|
|
||||||
|
|
||||||
export const makeAutomationAPI = (api: API) => ({
|
export const makeAutomationAPI = (api: API) => ({
|
||||||
@@ -14,19 +14,19 @@ export const makeAutomationAPI = (api: API) => ({
|
|||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
async update({index, auto}: {index: number, auto: AutomationData}) {
|
async update({ index, auto }: { index: number, auto: AutomationData }) {
|
||||||
return await api.makeCall({
|
return await api.makeCall({
|
||||||
path: AUTOMTAION_ROOT,
|
path: AUTOMTAION_ITEM,
|
||||||
data: {
|
data: {
|
||||||
index,
|
index,
|
||||||
data: auto
|
data: auto
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
async remove({index}: {index: number}) {
|
async remove({ index }: { index: number }) {
|
||||||
return await api.makeCall({
|
return await api.makeCall({
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
path: AUTOMTAION_ROOT,
|
path: AUTOMTAION_ITEM,
|
||||||
data: {
|
data: {
|
||||||
index,
|
index,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useRef } from 'react';
|
import { useRef } from 'react';
|
||||||
import { AutomationData } from 'types/automations';
|
import { AutomationData } from 'types/automations';
|
||||||
import { API } from './base';
|
import { API } from './base';
|
||||||
import { AUTOMTAION_LIST, AUTOMTAION_ROOT } from './paths';
|
import { AUTOMTAION_LIST, AUTOMTAION_ITEM } from './paths';
|
||||||
|
|
||||||
|
|
||||||
export const useMockAPI = (
|
export const useMockAPI = (
|
||||||
@@ -26,7 +26,7 @@ export const useMockAPI = (
|
|||||||
}))
|
}))
|
||||||
} as any
|
} as any
|
||||||
}
|
}
|
||||||
if (path === AUTOMTAION_ROOT) {
|
if (path === AUTOMTAION_ITEM) {
|
||||||
if (method === 'POST') {
|
if (method === 'POST') {
|
||||||
const { index, data: auto } = data as any;
|
const { index, data: auto } = data as any;
|
||||||
if (index >= automationsRef.current.length) {
|
if (index >= automationsRef.current.length) {
|
||||||
|
|||||||
@@ -2,3 +2,4 @@
|
|||||||
|
|
||||||
export const AUTOMTAION_ROOT = '/' as const;
|
export const AUTOMTAION_ROOT = '/' as const;
|
||||||
export const AUTOMTAION_LIST = `${AUTOMTAION_ROOT}list` as const;
|
export const AUTOMTAION_LIST = `${AUTOMTAION_ROOT}list` as const;
|
||||||
|
export const AUTOMTAION_ITEM = `${AUTOMTAION_ROOT}item` as const;
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.automation-editor--info-box.show {
|
.automation-editor--info-box.show {
|
||||||
min-width: 25em;
|
min-width: 20em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.automation-editor--info-box.hide {
|
.automation-editor--info-box.hide {
|
||||||
|
|||||||
@@ -10,10 +10,12 @@
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
.automation-list-box--body > * {
|
|
||||||
|
.automation-list-box--body>* {
|
||||||
padding-top: 0.5em;
|
padding-top: 0.5em;
|
||||||
padding-bottom: 0.5em;
|
padding-bottom: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.automation-list-box--body--group {
|
.automation-list-box--body--group {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -21,33 +23,37 @@
|
|||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
padding-bottom: 0.5em;
|
padding-bottom: 0.5em;
|
||||||
border-width: 1px;
|
border-width: 1px;
|
||||||
border-bottom-style: solid ;
|
border-bottom-style: solid;
|
||||||
border-color: white;
|
border-color: white;
|
||||||
}
|
}
|
||||||
.automation-list-box--body--group > .automation-list-box--body--group {
|
|
||||||
border-left-style: solid ;
|
.automation-list-box--body--group>.automation-list-box--body--group {
|
||||||
|
border-left-style: solid;
|
||||||
border-top-left-radius: 0;
|
border-top-left-radius: 0;
|
||||||
margin-left: 0.75em;
|
margin-left: 0.75em;
|
||||||
padding-left: 0.5em;
|
padding-left: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.automation-list-box--body--group > b {
|
.automation-list-box--body--group>b {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
padding: 0.1em;
|
padding: 0.1em;
|
||||||
}
|
}
|
||||||
.automation-list-box--body--group > b:hover {
|
|
||||||
|
.automation-list-box--body--group>b:hover {
|
||||||
background-color: var(--secondary-accent);
|
background-color: var(--secondary-accent);
|
||||||
color: var(--secondary);
|
color: var(--secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.automation-list-box--body--item:hover {
|
.automation-list-box--body--item:hover, .automation-list-box--body--item.selected {
|
||||||
background-color: var(--primary-accent);
|
background-color: var(--primary-accent);
|
||||||
color: var(--primary);
|
color: var(--primary);
|
||||||
}
|
}
|
||||||
.automation-list-box--body--item:hover > .automation-list-box--body--item--tags > span {
|
|
||||||
|
.automation-list-box--body--item:hover>.automation-list-box--body--item--tags>span {
|
||||||
border-color: var(--primary);
|
border-color: var(--primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.automation-list-box--body--item {
|
.automation-list-box--body--item {
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@@ -57,25 +63,31 @@
|
|||||||
gap: 1em;
|
gap: 1em;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.automation-list-box--body--item::before {
|
.automation-list-box--body--item::before {
|
||||||
content: "⊚ ";
|
content: "⊚ ";
|
||||||
}
|
}
|
||||||
|
|
||||||
.automation-list-box--body--item--title {
|
.automation-list-box--body--item--title {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
padding-left: 0.25em;
|
padding-left: 0.25em;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
.automation-list-box--body--item--title > b {
|
|
||||||
|
.automation-list-box--body--item--title>b {
|
||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
}
|
}
|
||||||
.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 {
|
||||||
font-size: 0.75em;
|
font-size: 0.75em;
|
||||||
}
|
}
|
||||||
.automation-list-box--body--item > button {
|
|
||||||
|
.automation-list-box--body--item>button {
|
||||||
padding: 0.25em !important;
|
padding: 0.25em !important;
|
||||||
margin: 0.5em !important;
|
margin: 0.5em !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.automation-list-box--body--item--tags {
|
.automation-list-box--body--item--tags {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -87,13 +99,15 @@
|
|||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
gap: 0.25em;
|
gap: 0.25em;
|
||||||
}
|
}
|
||||||
.automation-list-box--body--item--tags > span {
|
|
||||||
|
.automation-list-box--body--item--tags>span {
|
||||||
border-color: var(--primary-accent);
|
border-color: var(--primary-accent);
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
border-width: 1px;
|
border-width: 1px;
|
||||||
border-radius: 0.5em;
|
border-radius: 0.5em;
|
||||||
padding: 0.1em 0.5em;
|
padding: 0.1em 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.automation-list-box--bottom {
|
.automation-list-box--bottom {
|
||||||
margin-top: 0.5em;
|
margin-top: 0.5em;
|
||||||
margin-bottom: 0.5em;
|
margin-bottom: 0.5em;
|
||||||
@@ -102,7 +116,8 @@
|
|||||||
justify-content: space-around;
|
justify-content: space-around;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
.automation-list-box--bottom > button {
|
|
||||||
|
.automation-list-box--bottom>button {
|
||||||
background-color: #070;
|
background-color: #070;
|
||||||
color: var(--primary-accent);
|
color: var(--primary-accent);
|
||||||
padding: 0.5em 2em;
|
padding: 0.5em 2em;
|
||||||
|
|||||||
@@ -13,10 +13,12 @@ export default {
|
|||||||
|
|
||||||
|
|
||||||
const Template: ComponentStory<typeof AutomationListBox> = args => {
|
const Template: ComponentStory<typeof AutomationListBox> = args => {
|
||||||
const [autos, setAutos] = useState(args.automations)
|
const [selected, setSelected] = useState(args.selected)
|
||||||
console.log({ args })
|
|
||||||
return <div className="page">
|
return <div className="page">
|
||||||
<AutomationListBox {...args} automations={autos} />
|
<AutomationListBox {...args} automations={args.automations} selected={selected} onSelectAutomation={(i) => {
|
||||||
|
setSelected(i)
|
||||||
|
args.onSelectAutomation(i)
|
||||||
|
}} />
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { TrashIcon } from "components/Icons";
|
|||||||
|
|
||||||
export type Props = {
|
export type Props = {
|
||||||
automations: AutomationData[];
|
automations: AutomationData[];
|
||||||
|
selected: number;
|
||||||
onSelectAutomation: (i: number) => void;
|
onSelectAutomation: (i: number) => void;
|
||||||
onRemove: (i: number) => void;
|
onRemove: (i: number) => void;
|
||||||
onAdd: () => void;
|
onAdd: () => void;
|
||||||
@@ -16,6 +17,7 @@ export type Props = {
|
|||||||
|
|
||||||
export const AutomationListBox: FC<Props> = ({
|
export const AutomationListBox: FC<Props> = ({
|
||||||
automations,
|
automations,
|
||||||
|
selected,
|
||||||
onSelectAutomation,
|
onSelectAutomation,
|
||||||
onAdd,
|
onAdd,
|
||||||
onRemove,
|
onRemove,
|
||||||
@@ -23,9 +25,9 @@ export const AutomationListBox: FC<Props> = ({
|
|||||||
|
|
||||||
const tags = getTagList(automations);
|
const tags = getTagList(automations);
|
||||||
const [searchText, setSearchText] = useState('');
|
const [searchText, setSearchText] = useState('');
|
||||||
const [selected, setSelected] = useState<number[]>([]);
|
const [selectedTagIdx, setSelectedTagIdx] = useState<number[]>([]);
|
||||||
const filteredAutomations = filterAutomations(automations, searchText, selected, tags);
|
const filteredAutomations = filterAutomations(automations, searchText, selectedTagIdx, tags);
|
||||||
const groups = groupAutomations(filteredAutomations.map(([a, _]) => a), selected, tags);
|
const groups = groupAutomations(filteredAutomations.map(([a, _]) => a), selectedTagIdx, tags);
|
||||||
|
|
||||||
return <div className="automation-list-box">
|
return <div className="automation-list-box">
|
||||||
<div className="automation-list-box--nav">
|
<div className="automation-list-box--nav">
|
||||||
@@ -36,14 +38,14 @@ export const AutomationListBox: FC<Props> = ({
|
|||||||
/>
|
/>
|
||||||
<InputMultiSelect
|
<InputMultiSelect
|
||||||
label="Tags"
|
label="Tags"
|
||||||
selected={selected}
|
selected={selectedTagIdx}
|
||||||
onChange={setSelected}
|
onChange={setSelectedTagIdx}
|
||||||
options={tags}
|
options={tags}
|
||||||
max={3}
|
max={3}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="automation-list-box--body">
|
<div className="automation-list-box--body">
|
||||||
{convertGroupsToItems(groups, filteredAutomations, onSelectAutomation, onRemove)}
|
{convertGroupsToItems(groups, filteredAutomations, onSelectAutomation, onRemove, selected)}
|
||||||
</div>
|
</div>
|
||||||
<div className="automation-list-box--bottom">
|
<div className="automation-list-box--bottom">
|
||||||
<Button onClick={onAdd}>Add</Button>
|
<Button onClick={onAdd}>Add</Button>
|
||||||
@@ -123,13 +125,14 @@ const convertGroupsToItems = (
|
|||||||
autos: Array<[AutomationData, number]>,
|
autos: Array<[AutomationData, number]>,
|
||||||
onSelectAutomation: (i: number) => void,
|
onSelectAutomation: (i: number) => void,
|
||||||
onRemove: (i: number) => void,
|
onRemove: (i: number) => void,
|
||||||
|
selected: number,
|
||||||
) => {
|
) => {
|
||||||
if (Array.isArray(groups)) {
|
if (Array.isArray(groups)) {
|
||||||
return groups.map(i => {
|
return groups.map(i => {
|
||||||
const [auto, autoIndex] = autos[i];
|
const [auto, autoIndex] = autos[i];
|
||||||
return <div
|
return <div
|
||||||
key={i}
|
key={i}
|
||||||
className="automation-list-box--body--item"
|
className={["automation-list-box--body--item", selected === autoIndex ? 'selected' : ''].join(' ')}
|
||||||
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}`}
|
||||||
onClick={() => onSelectAutomation(autoIndex)}
|
onClick={() => onSelectAutomation(autoIndex)}
|
||||||
>
|
>
|
||||||
@@ -158,6 +161,7 @@ const convertGroupsToItems = (
|
|||||||
autos={autos}
|
autos={autos}
|
||||||
onSelectAutomation={onSelectAutomation}
|
onSelectAutomation={onSelectAutomation}
|
||||||
onRemove={onRemove}
|
onRemove={onRemove}
|
||||||
|
selected={selected}
|
||||||
/>
|
/>
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -170,16 +174,18 @@ const AutomationListBoxGroup: FC<{
|
|||||||
autos: Array<[AutomationData, number]>,
|
autos: Array<[AutomationData, number]>,
|
||||||
onSelectAutomation: (i: number) => void,
|
onSelectAutomation: (i: number) => void,
|
||||||
onRemove: (i: number) => void;
|
onRemove: (i: number) => void;
|
||||||
|
selected: number,
|
||||||
}> = ({
|
}> = ({
|
||||||
groupName,
|
groupName,
|
||||||
groups,
|
groups,
|
||||||
autos,
|
autos,
|
||||||
onSelectAutomation,
|
onSelectAutomation,
|
||||||
onRemove,
|
onRemove,
|
||||||
|
selected,
|
||||||
}) => {
|
}) => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
return <div className="automation-list-box--body--group">
|
return <div className="automation-list-box--body--group">
|
||||||
<b onClick={() => setOpen(!open)}>{groupName} {!open ? "⊕" : "⊖"}</b>
|
<b onClick={() => setOpen(!open)}>{groupName} {!open ? "⊕" : "⊖"}</b>
|
||||||
{open && convertGroupsToItems(groups, autos, onSelectAutomation, onRemove)}
|
{open && convertGroupsToItems(groups, autos, onSelectAutomation, onRemove, selected)}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
.automation-list--list {
|
.automation-list--list {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 400px;
|
|
||||||
max-width: 400px;
|
max-width: 400px;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ export const AutomationList: FC<AutomationListParams> = ({
|
|||||||
setCurrent(automations.length)
|
setCurrent(automations.length)
|
||||||
}}
|
}}
|
||||||
onSelectAutomation={setCurrent}
|
onSelectAutomation={setCurrent}
|
||||||
|
selected={current}
|
||||||
onRemove={onRemove}
|
onRemove={onRemove}
|
||||||
/>
|
/>
|
||||||
<ButtonIcon
|
<ButtonIcon
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ export const {
|
|||||||
primaryLightOpaque: 'var(--primary-light-opaque)',
|
primaryLightOpaque: 'var(--primary-light-opaque)',
|
||||||
secondary: 'var(--secondary)',
|
secondary: 'var(--secondary)',
|
||||||
secondaryOpaque: 'var(--secondary-opaque)',
|
secondaryOpaque: 'var(--secondary-opaque)',
|
||||||
primaryAccent: 'var(--primary-acccent)',
|
primaryAccent: 'var(--primary-accent)',
|
||||||
primaryAccentLight: 'var(--primary-acccent-light)',
|
primaryAccentLight: 'var(--primary-accent-light)',
|
||||||
secondaryAccent: 'var(--secondary-accent)',
|
secondaryAccent: 'var(--secondary-accent)',
|
||||||
condition: {
|
condition: {
|
||||||
primaryColor: 'var(--condition-primary)',
|
primaryColor: 'var(--condition-primary)',
|
||||||
|
|||||||
Reference in new issue
Block a user