better formatting

This commit is contained in:
ari committed 2022-05-18 22:57:51 -04:00
1 parent 8732ab8dda
commit 029a2dac9f
6 files changed
+64 -4

No files matched your search

@@ -510,6 +510,38 @@ export const BadAutmations = Template.bind({})
BadAutmations.args = {
...BadAutmations.args,
automations: [
{
"metadata": {
"alias": "Set Thermostat to 76 at 8am",
"description": "",
"mode": "single",
} as any,
"trigger": [
{
"at": "08:00:00",
"platform": "time"
}
],
"condition": [
{
"condition": "state",
"entity_id": "climate.thermostat",
"state": "cool"
}
],
"sequence": [
{
"data": {
"temperature": 76
},
"service": "climate.set_temperature",
"target": {
"entity_id": "climate.thermostat"
}
}
],
"tags": {},
},
{
condition: [],
tags: {},
-1
View File
@@ -127,7 +127,6 @@ export const DAGAutomationFlow: FC<DAGAutomationFlowProps> = ({
},
makeSequenceUpdater(sequence, onSequenceUpdate, setModalState),
);
console.log(flowData)
// render
return <>
<Modal open={!!modalState}>
@@ -41,9 +41,7 @@ export const sequenceToFlow = (
try {
const out = addChooseNode(node, position, nodeId, dims, updater, i);
position = out.lastPos
console.log(out);
flowData = mergeFlowDatas(flowData, out.flowData);
console.log(flowData);
} catch (err) {
console.error(err)
addErrorNode(flowData, nodeId, position, dims, err, updater.makeOnEditForBadNode(i));
+1
View File
@@ -78,6 +78,7 @@ export const useNodeStyles = createAppUseStyles<{
textOverflow: 'ellipsis',
overflow: "hidden",
whiteSpace: "break-spaces",
lineBreak: "anywhere",
cursor: 'default',
},
buttonDelete: {
@@ -1,6 +1,7 @@
import { AutomationTrigger } from 'types/automations/triggers';
import { DAGAutomationFlowDims, FlowData, TriggerMakerOptions } from './types';
import { makeAddButton } from './flowDataMods';
import { getDescriptionFromAutomationNode } from 'utils/formatting';
export const triggerToFlow = (
flowData: FlowData,
@@ -23,7 +24,7 @@ export const triggerToFlow = (
id: flowId,
type: 'dagnode',
data: {
label: t.alias ?? t.platform,
label: getDescriptionFromAutomationNode(t),
height: nodeHeight,
width: nodeWidth,
color: 'red',
+29
View File
@@ -16,10 +16,39 @@ export const convertTimeToString = (t: AutomationTime) => {
}
}
export const getDescriptionFromAutomationNode = <N extends AutomationNodeTypes>(node: AutomationNode<N>): string => {
console.log(node)
if (node.alias) {
return node.alias;
}
if ('platform' in node) {
if (node.platform === 'time') {
return node.at
}
if (node.platform === 'homeassistant') {
if (node.event === 'start') {
return 'HA is starting'
} else {
return 'HA is shutting down'
}
}
if (node.platform === 'tag') {
return `Tag = ${node.tag_id}`
}
if (node.platform === 'state') {
let out = "";
if (typeof node.entity_id === 'string') {
out = node.entity_id
} else {
out = node.entity_id[0] + " and more"
}
if (node.from) {
out += ` from ${node.from}`
}
if (node.to) {
out += ` to ${node.to}`
}
return out
}
return node.platform
}
if ('condition' in node) {