automation list box finidhed
This commit is contained in:
1 parent
afc67a17ec
commit
7ea923a050
5 files changed
+91
-9
No files matched your search
@@ -5,18 +5,24 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.automation-list-box--body {
|
.automation-list-box--body {
|
||||||
overflow: scroll;
|
overflow: auto;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
.automation-list-box--body > * {
|
||||||
|
padding-top: 0.5em;
|
||||||
|
padding-bottom: 0.5em;
|
||||||
}
|
}
|
||||||
.automation-list-box--body--group {
|
.automation-list-box--body--group {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
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;
|
||||||
user-select: none;
|
|
||||||
}
|
}
|
||||||
.automation-list-box--body--group > .automation-list-box--body--group {
|
.automation-list-box--body--group > .automation-list-box--body--group {
|
||||||
border-left-style: solid ;
|
border-left-style: solid ;
|
||||||
@@ -26,23 +32,67 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.automation-list-box--body--group > b {
|
.automation-list-box--body--group > b {
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
.automation-list-box--body--item:hover {
|
.automation-list-box--body--item:hover {
|
||||||
background-color: var(--primary-accent);
|
background-color: var(--primary-accent);
|
||||||
|
color: var(--primary);
|
||||||
|
}
|
||||||
|
.automation-list-box--body--item:hover > .automation-list-box--body--item--tags > span {
|
||||||
|
border-color: var(--primary);
|
||||||
}
|
}
|
||||||
.automation-list-box--body--item {
|
.automation-list-box--body--item {
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 1em;
|
||||||
|
/* position: relative; */
|
||||||
}
|
}
|
||||||
.automation-list-box--body--item::before {
|
.automation-list-box--body--item::before {
|
||||||
content: "⊚ ";
|
content: "⊚ ";
|
||||||
}
|
}
|
||||||
|
.automation-list-box--body--item--title {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding-left: 0.25em;
|
||||||
|
}
|
||||||
|
.automation-list-box--body--item--title > b {
|
||||||
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
.automation-list-box--body--item--title > span, .automation-list-box--body--item--title > b > span {
|
||||||
|
font-size: 0.75em;
|
||||||
|
}
|
||||||
|
.automation-list-box--body--item > button {
|
||||||
|
padding: 0.25em !important;
|
||||||
|
margin: 0.5em !important;
|
||||||
|
}
|
||||||
|
.automation-list-box--body--item--tags {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
font-size: 0.75em;
|
||||||
|
justify-content: left;
|
||||||
|
align-items: flex-start;
|
||||||
|
overflow: auto;
|
||||||
|
max-height: 100%;
|
||||||
|
gap: 0.25em;
|
||||||
|
}
|
||||||
|
.automation-list-box--body--item--tags > span {
|
||||||
|
border-color: var(--primary-accent);
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 1px;
|
||||||
|
border-radius: 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;
|
||||||
@@ -52,5 +102,7 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
.automation-list-box--bottom > button {
|
.automation-list-box--bottom > button {
|
||||||
|
background-color: #070;
|
||||||
|
color: var(--primary-accent);
|
||||||
padding: 0.5em 2em;
|
padding: 0.5em 2em;
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ export const FewAutos = Template.bind({})
|
|||||||
FewAutos.args = {
|
FewAutos.args = {
|
||||||
...FewAutos.args,
|
...FewAutos.args,
|
||||||
automations: [
|
automations: [
|
||||||
createMockAuto({ "Room": "Bathroom", "Type": "Lights" }),
|
createMockAuto({ "Room": "Bathroom", "Type": "Lights", "NewDevice": "Yes", "Remote": "No", "Floor": "1" }),
|
||||||
createMockAuto({ "Room": "Bathroom", "Type": "Climate" }),
|
createMockAuto({ "Room": "Bathroom", "Type": "Climate" }),
|
||||||
createMockAuto({ "Room": "Living Room", "Type": "Climate" }),
|
createMockAuto({ "Room": "Living Room", "Type": "Climate" }),
|
||||||
createMockAuto({ "Type": "Climate" }),
|
createMockAuto({ "Type": "Climate" }),
|
||||||
|
|||||||
@@ -4,18 +4,21 @@ import { AutomationData } from "types/automations";
|
|||||||
import InputMultiSelect from "components/Inputs/InputMultiSelect";
|
import InputMultiSelect from "components/Inputs/InputMultiSelect";
|
||||||
import InputText from "components/Inputs/InputText";
|
import InputText from "components/Inputs/InputText";
|
||||||
import { Button } from "components/Inputs/Button";
|
import { Button } from "components/Inputs/Button";
|
||||||
|
import { TrashIcon } from "components/Icons";
|
||||||
|
|
||||||
|
|
||||||
export type Props = {
|
export type Props = {
|
||||||
automations: AutomationData[];
|
automations: AutomationData[];
|
||||||
onSelectAutomation: (i: number) => void;
|
onSelectAutomation: (i: number) => void;
|
||||||
onAdd: () => void;
|
onAdd: () => void;
|
||||||
|
onRemove: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AutomationListBox: FC<Props> = ({
|
export const AutomationListBox: FC<Props> = ({
|
||||||
automations,
|
automations,
|
||||||
onSelectAutomation,
|
onSelectAutomation,
|
||||||
onAdd,
|
onAdd,
|
||||||
|
onRemove,
|
||||||
}) => {
|
}) => {
|
||||||
|
|
||||||
const tags = getTagList(automations);
|
const tags = getTagList(automations);
|
||||||
@@ -39,7 +42,7 @@ export const AutomationListBox: FC<Props> = ({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="automation-list-box--body">
|
<div className="automation-list-box--body">
|
||||||
{convertGroupsToItems(groups, filteredAutomations, onSelectAutomation)}
|
{convertGroupsToItems(groups, filteredAutomations, onSelectAutomation, onRemove)}
|
||||||
</div>
|
</div>
|
||||||
<div className="automation-list-box--bottom">
|
<div className="automation-list-box--bottom">
|
||||||
<Button onClick={onAdd}>Add</Button>
|
<Button onClick={onAdd}>Add</Button>
|
||||||
@@ -118,11 +121,34 @@ const convertGroupsToItems = (
|
|||||||
groups: any,
|
groups: any,
|
||||||
autos: Array<[AutomationData, number]>,
|
autos: Array<[AutomationData, number]>,
|
||||||
onSelectAutomation: (i: number) => void,
|
onSelectAutomation: (i: number) => void,
|
||||||
|
onRemove: (i: number) => void,
|
||||||
) => {
|
) => {
|
||||||
if (Array.isArray(groups)) {
|
if (Array.isArray(groups)) {
|
||||||
return groups.map(i => <div key={i} className="automation-list-box--body--item" onClick={() => onSelectAutomation(autos[i][1])}>
|
return groups.map(i => {
|
||||||
{autos[i][0].metadata.id} {autos[i][0].metadata.alias}
|
const [auto, autoIndex] = autos[i];
|
||||||
</div>)
|
return <div
|
||||||
|
key={i}
|
||||||
|
className="automation-list-box--body--item"
|
||||||
|
title={`${auto.metadata.alias}\n ID=${auto.metadata.id}\n${auto.metadata.description}`}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="automation-list-box--body--item--title"
|
||||||
|
onClick={() => onSelectAutomation(autoIndex)}
|
||||||
|
>
|
||||||
|
<b>{auto.metadata.alias.slice(0, 15)} <span>({auto.metadata.id.slice(0, 5)})</span></b>
|
||||||
|
<span>{auto.metadata.description.slice(0, 25)}</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="automation-list-box--body--item--tags"
|
||||||
|
onClick={() => onSelectAutomation(autoIndex)}
|
||||||
|
>
|
||||||
|
{Object.keys(auto.metadata.tags).map(tagName => <span key={tagName}>
|
||||||
|
<b>{tagName}:</b> {auto.metadata.tags[tagName]}
|
||||||
|
</span>)}
|
||||||
|
</div>
|
||||||
|
<Button onClick={() => onRemove(autoIndex)}><TrashIcon /></Button>
|
||||||
|
</div>
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
return Object.keys(groups).map(groupName => {
|
return Object.keys(groups).map(groupName => {
|
||||||
return <AutomationListBoxGroup
|
return <AutomationListBoxGroup
|
||||||
@@ -131,6 +157,7 @@ const convertGroupsToItems = (
|
|||||||
groups={groups[groupName]}
|
groups={groups[groupName]}
|
||||||
autos={autos}
|
autos={autos}
|
||||||
onSelectAutomation={onSelectAutomation}
|
onSelectAutomation={onSelectAutomation}
|
||||||
|
onRemove={onRemove}
|
||||||
/>
|
/>
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -142,15 +169,17 @@ const AutomationListBoxGroup: FC<{
|
|||||||
groups: any,
|
groups: any,
|
||||||
autos: Array<[AutomationData, number]>,
|
autos: Array<[AutomationData, number]>,
|
||||||
onSelectAutomation: (i: number) => void,
|
onSelectAutomation: (i: number) => void,
|
||||||
|
onRemove: (i: number) => void;
|
||||||
}> = ({
|
}> = ({
|
||||||
groupName,
|
groupName,
|
||||||
groups,
|
groups,
|
||||||
autos,
|
autos,
|
||||||
onSelectAutomation,
|
onSelectAutomation,
|
||||||
|
onRemove,
|
||||||
}) => {
|
}) => {
|
||||||
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)}
|
{open && convertGroupsToItems(groups, autos, onSelectAutomation, onRemove)}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@@ -171,6 +171,7 @@ export const useInputMultiSelectStyles = createAppUseStyles<{
|
|||||||
userSelect: 'none',
|
userSelect: 'none',
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
width: "100%",
|
width: "100%",
|
||||||
|
zIndex: 10,
|
||||||
})),
|
})),
|
||||||
arrow: (({ open }) => ({
|
arrow: (({ open }) => ({
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { AutomationData } from 'types/automations';
|
|||||||
|
|
||||||
export const createMockAuto = (tags: Record<string, string> = {}): AutomationData => ({
|
export const createMockAuto = (tags: Record<string, string> = {}): AutomationData => ({
|
||||||
metadata: {
|
metadata: {
|
||||||
id: Math.random().toString(36).slice(2, 5),
|
id: Math.random().toString(36).slice(2, 15),
|
||||||
alias: "Random",
|
alias: "Random",
|
||||||
description: "Example Metadata",
|
description: "Example Metadata",
|
||||||
trigger_variables: {
|
trigger_variables: {
|
||||||
|
|||||||
Reference in new issue
Block a user