removed old web
This commit is contained in:
1 parent
dd74c400d4
commit
2cd3ddb7d8
80 files changed
+1
-42789
No files matched your search
+1
-1
@@ -1 +1 @@
|
||||
<mxfile host="Electron" modified="2021-12-01T17:29:11.968Z" agent="5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/13.7.3 Chrome/85.0.4183.98 Electron/10.1.2 Safari/537.36" etag="caxgVF6QPDG2CSn0U_-B" version="13.7.3" type="device"><diagram id="jPQkoFvJ-TX3pFbO5KUV" name="Page-1">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</diagram></mxfile>
|
||||
<mxfile host="Electron" modified="2021-12-22T03:54:11.568Z" agent="5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/13.7.3 Chrome/85.0.4183.98 Electron/10.1.2 Safari/537.36" etag="iCt_sJUKtRmHqF9E0YOU" version="13.7.3" type="device" pages="2"><diagram id="jPQkoFvJ-TX3pFbO5KUV" name="autos">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</diagram><diagram id="7X2k5OJ-jCNTzSic57L4" name="Page-2">ldFPD4IgFADwT8OxTaGpne3fobrYqlsjIGVDn0Oa1qfPBmasS52AH48H74FIWnYrTetiC1wohAPeITJHGIc4TvrhJXcrUeAg15K7oBEy+RAOA6c3yUXjBRoAZWTtI4OqEsx4RrWG1g+7gvJvrWkuviBjVH3rUXJTWE1wPPpayLwYbg6jmd0p6RDsKmkKyqH9ILJAJNUAxs7KLhXq1byhL4m57KZ0P42DM9scMjjdGZ7YZMt/jrxL0KIyv6buJ+PT+oX3wWTxBA==</diagram></mxfile>
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"plugins": [
|
||||
[
|
||||
"module-resolver",
|
||||
{
|
||||
"root": ["./src"],
|
||||
"alias": {
|
||||
"~": "./src"
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
# http://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
# Use 4 spaces for the Python files
|
||||
[*.py]
|
||||
indent_size = 4
|
||||
max_line_length = 80
|
||||
|
||||
# The JSON files contain newlines inconsistently
|
||||
[*.json]
|
||||
insert_final_newline = ignore
|
||||
|
||||
# Minified JavaScript files shouldn't be changed
|
||||
[**.min.js]
|
||||
indent_style = ignore
|
||||
insert_final_newline = ignore
|
||||
|
||||
# Makefiles always use tabs for indentation
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
|
||||
# Batch files use tabs for indentation
|
||||
[*.bat]
|
||||
indent_style = tab
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
module.exports = {
|
||||
"stories": [
|
||||
"../src/**/*.stories.mdx",
|
||||
"../src/**/*.stories.@(js|jsx|ts|tsx)"
|
||||
],
|
||||
"addons": [
|
||||
"@storybook/addon-links",
|
||||
"@storybook/addon-essentials"
|
||||
]
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
export const parameters = {
|
||||
actions: { argTypesRegex: "^on[A-Z].*" },
|
||||
controls: {
|
||||
matchers: {
|
||||
color: /(background|color)$/i,
|
||||
date: /Date$/,
|
||||
},
|
||||
},
|
||||
}
|
||||
Vendored
-4
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"typescript.tsdk": "node_modules/typescript/lib",
|
||||
"jest.jestCommandLine": "node_modules/.bin/jest"
|
||||
}
|
||||
Generated
-20280
File diff suppressed because it is too large.
Load diff
@@ -1,72 +0,0 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"chroma-js": "^2.1.2",
|
||||
"color": "^4.0.1",
|
||||
"js-yaml": "^4.1.0",
|
||||
"jss": "^10.8.2",
|
||||
"jss-preset-default": "^10.8.2",
|
||||
"parcel": "^2.0.0",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-jss": "^10.8.2",
|
||||
"react-router-dom": "^5.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.16.0",
|
||||
"@parcel/transformer-sass": "^2.0.0",
|
||||
"@parcel/transformer-yaml": "^2.0.0",
|
||||
"@storybook/addon-actions": "^6.3.12",
|
||||
"@storybook/addon-essentials": "^6.3.12",
|
||||
"@storybook/addon-links": "^6.3.12",
|
||||
"@storybook/react": "^6.3.12",
|
||||
"@testing-library/jest-dom": "^5.15.0",
|
||||
"@types/chroma-js": "^2.1.3",
|
||||
"@types/color": "^3.0.2",
|
||||
"@types/jest": "^27.0.2",
|
||||
"@types/js-yaml": "^4.0.4",
|
||||
"@types/node": "^16.11.6",
|
||||
"@types/react": "^17.0.33",
|
||||
"@types/react-dom": "^17.0.10",
|
||||
"@types/react-router-dom": "^5.3.2",
|
||||
"babel-loader": "^8.2.3",
|
||||
"babel-plugin-module-resolver": "^4.1.0",
|
||||
"concurrently": "^6.3.0",
|
||||
"husky": "^7.0.4",
|
||||
"instead": "^1.0.3",
|
||||
"jest": "^27.3.1",
|
||||
"jest-extended": "^1.1.0",
|
||||
"prettier": "^2.4.1",
|
||||
"react-test-renderer": "^17.0.2",
|
||||
"react-testing-library": "^8.0.1",
|
||||
"ts-jest": "^27.0.7",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-react": "^5.0.0",
|
||||
"typescript": "^4.4.4"
|
||||
},
|
||||
"scripts": {
|
||||
"develop": "concurrently -r \"npm:type-check:watch\" \"npm:start\"",
|
||||
"start": "parcel ./src/index.html",
|
||||
"build": "npm run type-check && parcel build ./src/index.html --public-url '/web'",
|
||||
"prettify": "prettier --write './src/**/*.{ts,tsx}'",
|
||||
"test": "jest",
|
||||
"test:watch": "jest --watch",
|
||||
"type-check": "tsc --noEmit",
|
||||
"type-check:watch": "tsc --noEmit --watch",
|
||||
"storybook": "NODE_OPTIONS=--openssl-legacy-provider start-storybook -p 6006",
|
||||
"build-storybook": "NODE_OPTIONS=--openssl-legacy-provider build-storybook"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "ts-jest",
|
||||
"moduleFileExtensions": [
|
||||
"ts",
|
||||
"tsx",
|
||||
"js"
|
||||
],
|
||||
"setupFilesAfterEnv": [
|
||||
"<rootDir>/src/setupTests.ts"
|
||||
],
|
||||
"moduleNameMapper": {
|
||||
".+\\.css$": "<rootDir>/src/styleMock.ts"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
import { AutomationCondition, LogicCondition, NumericCondition, StateCondition, TemplateCondition, TimeCondition, TriggerCondition, ZoneCondition } from "./types/conditions";
|
||||
|
||||
|
||||
export const getConditionDefaultValues = (condition: AutomationCondition['condition']): AutomationCondition['condition_data'] => {
|
||||
if (
|
||||
(condition === 'or') ||
|
||||
(condition === 'and') ||
|
||||
(condition === 'not')
|
||||
) {
|
||||
return {
|
||||
conditions: []
|
||||
} as LogicCondition['condition_data']
|
||||
} else if (condition === 'template') {
|
||||
return {
|
||||
value_template: ""
|
||||
} as TemplateCondition['condition_data']
|
||||
} else if (condition === 'numeric_state') {
|
||||
return {
|
||||
entity_id: []
|
||||
} as NumericCondition['condition_data']
|
||||
} else if (condition === 'state') {
|
||||
return {
|
||||
entity_id: [],
|
||||
state: [],
|
||||
} as StateCondition['condition_data']
|
||||
} else if (condition === 'time') {
|
||||
return {
|
||||
} as TimeCondition['condition_data']
|
||||
} else if (condition === 'trigger') {
|
||||
return {
|
||||
id: []
|
||||
} as TriggerCondition['condition_data']
|
||||
} else if (condition === 'zone') {
|
||||
return {
|
||||
zone: "",
|
||||
entity_id: [],
|
||||
state: [],
|
||||
} as ZoneCondition['condition_data']
|
||||
}
|
||||
throw new Error("NOT IMPLEMENTED!")
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
import { AutomationSequenceNode } from ".";
|
||||
import { AutomationTime } from "./common";
|
||||
import { AutomationCondition } from "./conditions";
|
||||
|
||||
interface AutomationActionNodeBase<Name extends String,Data extends Object> {
|
||||
$smType: 'action';
|
||||
action: Name;
|
||||
action_data: Data & {
|
||||
alias?: string;
|
||||
variables?: Record<string, any>;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ServiceAction extends AutomationActionNodeBase<"service", {
|
||||
service: string;
|
||||
target: any;
|
||||
data: any;
|
||||
}>{}
|
||||
export interface RepeatAction extends AutomationActionNodeBase<"repeat", {
|
||||
repeat: {
|
||||
count: number;
|
||||
sequence: AutomationAction[];
|
||||
}
|
||||
}>{}
|
||||
export interface WaitAction extends AutomationActionNodeBase<"wait", {
|
||||
wait_template: string;
|
||||
timeout?: AutomationTime;
|
||||
continue_on_timeout?: boolean;
|
||||
}>{}
|
||||
export interface FireEventAction extends AutomationActionNodeBase<"event", {
|
||||
event: string;
|
||||
event_data: any;
|
||||
}>{}
|
||||
export interface DeviceAction extends AutomationActionNodeBase<"device", {
|
||||
type: string;
|
||||
device_id: string;
|
||||
entity_id?: string;
|
||||
domain: string;
|
||||
}>{}
|
||||
export interface ChooseAction extends AutomationActionNodeBase<"choose", {
|
||||
choose: Array<{
|
||||
conditions: AutomationCondition[];
|
||||
sequence: AutomationSequenceNode[];
|
||||
}>;
|
||||
default: AutomationAction[];
|
||||
}>{}
|
||||
export type AutomationAction =
|
||||
| ServiceAction
|
||||
| RepeatAction
|
||||
| WaitAction
|
||||
| FireEventAction
|
||||
| DeviceAction
|
||||
| ChooseAction
|
||||
;
|
||||
export const ActionTypes = [
|
||||
'Service',
|
||||
'Repeat',
|
||||
'Wait',
|
||||
'Event',
|
||||
'Device',
|
||||
'Choose'
|
||||
] as const;
|
||||
export type ActionType = typeof ActionTypes[number];
|
||||
@@ -1,6 +0,0 @@
|
||||
export interface AutomationTime {
|
||||
hours?: number;
|
||||
minutes?: number;
|
||||
seconds?: number;
|
||||
milliseconds?: number;
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
import { AutomationTime } from "./common";
|
||||
|
||||
interface AutomationConditionNodeBase<Name extends String,Data extends Object> {
|
||||
$smType: 'condition';
|
||||
condition: Name;
|
||||
condition_data: Data & {
|
||||
alias?: string;
|
||||
};
|
||||
}
|
||||
export interface LogicCondition extends AutomationConditionNodeBase<'and' | 'or' | 'not',{
|
||||
conditions: AutomationCondition[];
|
||||
}> {}
|
||||
export interface NumericCondition extends AutomationConditionNodeBase<'numeric_state', {
|
||||
entity_id: string | string[];
|
||||
above?: string;
|
||||
below?: string;
|
||||
attribute?: string;
|
||||
value_template?: string;
|
||||
}> {}
|
||||
export interface StateCondition extends AutomationConditionNodeBase<'state',{
|
||||
entity_id: string | string[];
|
||||
state: string | string[];
|
||||
for?: AutomationTime;
|
||||
attribute?: string;
|
||||
}>{}
|
||||
export interface TemplateCondition extends AutomationConditionNodeBase<'template',{
|
||||
value_template: string;
|
||||
}> {}
|
||||
export interface TimeCondition extends AutomationConditionNodeBase<'time', {
|
||||
after?: AutomationTime;
|
||||
before?: AutomationTime;
|
||||
weekday?: Array<'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat' | 'sun'>;
|
||||
}> {}
|
||||
export interface TriggerCondition extends AutomationConditionNodeBase <'trigger', {
|
||||
id: string | string[];
|
||||
}>{}
|
||||
export interface ZoneCondition extends AutomationConditionNodeBase <'zone', {
|
||||
zone: string;
|
||||
entity_id: string | string[];
|
||||
state: string | string[];
|
||||
}>{}
|
||||
export type AutomationCondition =
|
||||
| LogicCondition
|
||||
| NumericCondition
|
||||
| StateCondition
|
||||
| TemplateCondition
|
||||
| TimeCondition
|
||||
| TriggerCondition
|
||||
| ZoneCondition
|
||||
;
|
||||
@@ -1,26 +0,0 @@
|
||||
import { AutomationAction } from "./actions";
|
||||
import { AutomationCondition } from "./conditions";
|
||||
import { AutomationTrigger } from "./triggers";
|
||||
|
||||
|
||||
export interface AutomationMetadata {
|
||||
id: string;
|
||||
alias: string;
|
||||
description: string;
|
||||
trigger_variables?: Record<string, string>;
|
||||
mode: "single" | "restart" | "queued" | "parallel";
|
||||
}
|
||||
export interface AutomationData {
|
||||
metadata: AutomationMetadata;
|
||||
trigger: AutomationTrigger[];
|
||||
sequence: AutomationSequenceNode[];
|
||||
}
|
||||
export type AutomationSequenceNode = AutomationAction | AutomationCondition;
|
||||
type AutomationNodeMapping = {
|
||||
"trigger": AutomationTrigger;
|
||||
"action": AutomationAction;
|
||||
"condition": AutomationCondition;
|
||||
"sequence": AutomationSequenceNode;
|
||||
}
|
||||
export type AutomationNodeTypes = keyof AutomationNodeMapping;
|
||||
export type AutomationNode<N extends AutomationNodeTypes = any> = AutomationNodeMapping[N];
|
||||
@@ -1,110 +0,0 @@
|
||||
import { AutomationTime } from "./common";
|
||||
|
||||
interface AutomationTriggerBase {
|
||||
alias?: string;
|
||||
}
|
||||
|
||||
export interface AutomationTriggerEvent extends AutomationTriggerBase {
|
||||
platform: 'event';
|
||||
event_type: string | string[];
|
||||
event_data?: any;
|
||||
context?: any;
|
||||
}
|
||||
export interface AutomationTriggerHA extends AutomationTriggerBase {
|
||||
platform: 'homeassistant';
|
||||
event: 'start' | 'shutdown';
|
||||
}
|
||||
export interface AutomationTriggerMQTT extends AutomationTriggerBase {
|
||||
platform: 'mqtt';
|
||||
topic: string;
|
||||
payload: string;
|
||||
value_template: string;
|
||||
}
|
||||
export interface AutomationTriggerNumericState extends AutomationTriggerBase {
|
||||
platform: 'numeric_state';
|
||||
entity_id: string | string[];
|
||||
attribute?: string;
|
||||
value_template?: string;
|
||||
above?: string;
|
||||
below?: string;
|
||||
for?: AutomationTime;
|
||||
}
|
||||
export interface AutomationTriggerState extends AutomationTriggerBase {
|
||||
platform: 'state';
|
||||
entity_id: string | string[];
|
||||
attribute?: string;
|
||||
from?: string | string[];
|
||||
to?: string | string[];
|
||||
for?: AutomationTime;
|
||||
}
|
||||
export interface AutomationTriggerTag extends AutomationTriggerBase {
|
||||
platform: 'tag';
|
||||
tag_id: string | string[];
|
||||
device_id: string | string[];
|
||||
}
|
||||
export interface AutomationTriggerTemplate extends AutomationTriggerBase {
|
||||
platform: 'template';
|
||||
value_template: string;
|
||||
for?: AutomationTime;
|
||||
}
|
||||
export interface AutomationTriggerTime extends AutomationTriggerBase {
|
||||
platform: 'time';
|
||||
at: string | string[];
|
||||
}
|
||||
export interface AutomationTriggerTimePattern extends AutomationTriggerBase {
|
||||
platform: 'time_pattern';
|
||||
hours?: string;
|
||||
minutes?: string;
|
||||
seconds?: string;
|
||||
}
|
||||
export interface AutomationTriggerWebhook extends AutomationTriggerBase {
|
||||
platform: 'webhook';
|
||||
webhook_id: string;
|
||||
}
|
||||
export interface AutomationTriggerZone extends AutomationTriggerBase {
|
||||
platform: 'zone';
|
||||
entity_id: string;
|
||||
zone: string;
|
||||
event: 'enter' | 'leave';
|
||||
}
|
||||
export interface AutomationTriggerDevice extends AutomationTriggerBase {
|
||||
platform: 'device';
|
||||
device_id: string;
|
||||
domain: string;
|
||||
type: string;
|
||||
subtype: string;
|
||||
}
|
||||
export interface AutomationTriggerGeneric extends AutomationTriggerBase {
|
||||
platform: string;
|
||||
}
|
||||
export type AutomationTrigger =
|
||||
| AutomationTriggerEvent
|
||||
| AutomationTriggerHA
|
||||
| AutomationTriggerMQTT
|
||||
| AutomationTriggerNumericState
|
||||
| AutomationTriggerState
|
||||
| AutomationTriggerTag
|
||||
| AutomationTriggerTemplate
|
||||
| AutomationTriggerTime
|
||||
| AutomationTriggerTimePattern
|
||||
| AutomationTriggerWebhook
|
||||
| AutomationTriggerZone
|
||||
| AutomationTriggerDevice
|
||||
| AutomationTriggerGeneric
|
||||
;
|
||||
export const triggerTypes = [
|
||||
'Event',
|
||||
'Home Assistant',
|
||||
'MQTT',
|
||||
'Numeric State',
|
||||
'State',
|
||||
'Tag',
|
||||
'Template',
|
||||
'Time',
|
||||
'Time Pattern',
|
||||
'Webhook',
|
||||
'Zone',
|
||||
'Device',
|
||||
'Generic',
|
||||
] as const;
|
||||
export type TriggerType = typeof triggerTypes[number];
|
||||
@@ -1,215 +0,0 @@
|
||||
|
||||
import {convertTimeToString, getDescriptionFromAutomationNode} from "./utils";
|
||||
|
||||
test('converting time to a string', () => {
|
||||
expect(convertTimeToString({hours: 1})).toEqual('01:00:00:00')
|
||||
expect(convertTimeToString({hours: 1, minutes:5})).toEqual('01:05:00:00')
|
||||
expect(convertTimeToString({hours: 1, minutes:5, seconds: 24})).toEqual('01:05:24:00')
|
||||
expect(convertTimeToString({hours: 1, milliseconds: 100})).toEqual('01:00:00:100')
|
||||
})
|
||||
|
||||
test('using alias as description', () => {
|
||||
expect(getDescriptionFromAutomationNode({
|
||||
$smType: "action",
|
||||
action: "service",
|
||||
action_data: {
|
||||
alias: "Start Music In Kitchen",
|
||||
service: 'media_player.play_media',
|
||||
target: {
|
||||
entity_id: "media_player.kitchen_dot"
|
||||
},
|
||||
data: {
|
||||
media_content_id: "Good Morning",
|
||||
media_content_type: "SPOTIFY",
|
||||
}
|
||||
}
|
||||
})).toEqual("Start Music In Kitchen")
|
||||
})
|
||||
|
||||
|
||||
test('get service action description', () => {
|
||||
expect(getDescriptionFromAutomationNode({
|
||||
$smType: "action",
|
||||
action: "service",
|
||||
action_data: {
|
||||
service: 'media_player.play_media',
|
||||
target: {
|
||||
entity_id: "media_player.kitchen_dot"
|
||||
},
|
||||
data: {
|
||||
media_content_id: "Good Morning",
|
||||
media_content_type: "SPOTIFY",
|
||||
}
|
||||
}
|
||||
})).toEqual("media_player.play_media")
|
||||
})
|
||||
|
||||
test('get repeat action description', () => {
|
||||
expect(getDescriptionFromAutomationNode({
|
||||
$smType: "action",
|
||||
action: "repeat",
|
||||
action_data: {
|
||||
repeat: {
|
||||
count: 10,
|
||||
sequence: []
|
||||
}
|
||||
}
|
||||
})).toEqual("Repeat 10")
|
||||
})
|
||||
|
||||
|
||||
test('get wait action description', () => {
|
||||
expect(getDescriptionFromAutomationNode({
|
||||
$smType: "action",
|
||||
action: "wait",
|
||||
action_data: {
|
||||
wait_template: "states(switch.kitchen_light) == 'on'"
|
||||
}
|
||||
})).toEqual("Wait on states(switch.kitchen_light) == 'on'")
|
||||
expect(getDescriptionFromAutomationNode({
|
||||
$smType: "action",
|
||||
action: "wait",
|
||||
action_data: {
|
||||
wait_template: "states(switch.kitchen_light) == 'on'",
|
||||
// timeout: '00:01:00',
|
||||
timeout: {
|
||||
'minutes': 1,
|
||||
}
|
||||
}
|
||||
})).toEqual("Wait on states(switch.kitchen_light) == 'on' for 00:01:00:00")
|
||||
})
|
||||
|
||||
test('get fire event action description', () => {
|
||||
expect(getDescriptionFromAutomationNode({
|
||||
$smType: 'action',
|
||||
action: 'event',
|
||||
action_data: {
|
||||
event: 'test_event',
|
||||
event_data: {},
|
||||
}
|
||||
})).toEqual("Trigger test_event")
|
||||
})
|
||||
|
||||
test('get device action description', () => {
|
||||
expect(getDescriptionFromAutomationNode({
|
||||
$smType: 'action',
|
||||
action: 'device',
|
||||
action_data: {
|
||||
device_id: "12310das01231",
|
||||
domain: "zwave_js",
|
||||
type: "set_value"
|
||||
}
|
||||
|
||||
})).toEqual("set_value on 12310das01231")
|
||||
})
|
||||
|
||||
test('get choose action description', () => {
|
||||
expect(getDescriptionFromAutomationNode({
|
||||
$smType: 'action',
|
||||
action: 'choose',
|
||||
action_data: {
|
||||
choose: [],
|
||||
default: [],
|
||||
}
|
||||
})).toEqual("Choose")
|
||||
})
|
||||
|
||||
test('get and/or/not condition description', () => {
|
||||
expect(getDescriptionFromAutomationNode({
|
||||
$smType: 'condition',
|
||||
condition: 'and',
|
||||
condition_data: {
|
||||
conditions: [],
|
||||
}
|
||||
})).toEqual("Logic")
|
||||
expect(getDescriptionFromAutomationNode({
|
||||
$smType: 'condition',
|
||||
condition: 'or',
|
||||
condition_data: {
|
||||
conditions: [],
|
||||
}
|
||||
})).toEqual("Logic")
|
||||
expect(getDescriptionFromAutomationNode({
|
||||
$smType: 'condition',
|
||||
condition: 'not',
|
||||
condition_data: {
|
||||
conditions: [],
|
||||
}
|
||||
})).toEqual("Logic")
|
||||
})
|
||||
|
||||
test('get Numeric State condition description', () => {
|
||||
expect(getDescriptionFromAutomationNode({
|
||||
$smType: 'condition',
|
||||
condition: 'numeric_state',
|
||||
condition_data: {
|
||||
entity_id: 'sensor.temperature',
|
||||
}
|
||||
})).toEqual("sensor.temperature?>?<")
|
||||
expect(getDescriptionFromAutomationNode({
|
||||
$smType: 'condition',
|
||||
condition: 'numeric_state',
|
||||
condition_data: {
|
||||
entity_id: ""
|
||||
}
|
||||
})).toEqual("Numeric State Condition")
|
||||
expect(getDescriptionFromAutomationNode({
|
||||
$smType: 'condition',
|
||||
condition: "numeric_state",
|
||||
condition_data: {
|
||||
entity_id: 'sensor.temperature',
|
||||
above: '17',
|
||||
}
|
||||
})).toEqual("sensor.temperature > 17")
|
||||
expect(getDescriptionFromAutomationNode({
|
||||
$smType: 'condition',
|
||||
condition: 'numeric_state',
|
||||
condition_data: {
|
||||
entity_id: 'sensor.temperature',
|
||||
below: '5',
|
||||
}
|
||||
})).toEqual("sensor.temperature < 5")
|
||||
expect(getDescriptionFromAutomationNode({
|
||||
$smType: 'condition',
|
||||
condition: 'numeric_state',
|
||||
condition_data: {
|
||||
entity_id: 'sensor.temperature',
|
||||
above: '17',
|
||||
below: '20',
|
||||
}
|
||||
})).toEqual("17 < sensor.temperature < 20")
|
||||
expect(getDescriptionFromAutomationNode({
|
||||
$smType: 'condition',
|
||||
condition: 'numeric_state',
|
||||
condition_data: {
|
||||
entity_id: 'sensor.temperature',
|
||||
above: '17',
|
||||
below: '20',
|
||||
value_template: "{{ float(state.state) + 2 }}"
|
||||
}
|
||||
})).toEqual("17 < sensor.temperature < 20")
|
||||
expect(getDescriptionFromAutomationNode({
|
||||
$smType: 'condition',
|
||||
condition: 'numeric_state',
|
||||
condition_data: {
|
||||
entity_id: [
|
||||
"sensor.kitchen_temperature",
|
||||
"sensor.living_room_temperature"
|
||||
],
|
||||
above: '17',
|
||||
below: '20',
|
||||
value_template: "{{ float(state.state) + 2 }}"
|
||||
}
|
||||
})).toEqual("17 < ... < 20")
|
||||
})
|
||||
|
||||
test('get State condition description', () => {
|
||||
expect(getDescriptionFromAutomationNode({
|
||||
$smType: 'condition',
|
||||
condition: 'state',
|
||||
condition_data: {
|
||||
entity_id: 'switch.kitchen_light',
|
||||
state: "on"
|
||||
}
|
||||
})).toEqual("switch.kitchen_light is 'on'")
|
||||
})
|
||||
@@ -1,162 +0,0 @@
|
||||
import { AutomationNode, AutomationNodeTypes } from "./types";
|
||||
import { AutomationTime } from "./types/common";
|
||||
|
||||
|
||||
export const convertTimeToString = ({
|
||||
hours=0,
|
||||
minutes=0,
|
||||
seconds=0,
|
||||
milliseconds=0,
|
||||
}: AutomationTime) => [hours,minutes,seconds,milliseconds].map(n => String(n).padStart(2, '0')).join(':')
|
||||
|
||||
export const getDescriptionFromAutomationNode = <N extends AutomationNodeTypes>(node: AutomationNode<N>): string => {
|
||||
if ('$smType' in node) {
|
||||
switch (node['$smType']) {
|
||||
case "action":
|
||||
if (node.action_data.alias) {
|
||||
return node.action_data.alias;
|
||||
}
|
||||
switch(node.action) {
|
||||
case 'service':
|
||||
return node.action_data.service
|
||||
case 'repeat':
|
||||
return 'Repeat ' + node.action_data.repeat.count;
|
||||
case 'wait':
|
||||
let out= 'Wait on ' + node.action_data.wait_template;
|
||||
if (node.action_data.timeout) {
|
||||
out += (' for ' + convertTimeToString(node.action_data.timeout))
|
||||
}
|
||||
return out;
|
||||
case 'event':
|
||||
return `Trigger ${node.action_data.event}`
|
||||
case 'device':
|
||||
return `${node.action_data.type} on ${node.action_data.device_id}`
|
||||
case 'choose':
|
||||
return "Choose"
|
||||
}
|
||||
case "condition":
|
||||
if (node.condition_data.alias) {
|
||||
return node.condition_data.alias;
|
||||
}
|
||||
if(
|
||||
(node.condition === 'and') ||
|
||||
(node.condition === 'or') ||
|
||||
(node.condition === 'not')
|
||||
) {
|
||||
return "Logic"
|
||||
} else {
|
||||
switch(node.condition) {
|
||||
case "numeric_state":
|
||||
if(node.condition_data.entity_id) {
|
||||
const center = prettyEntityId(node.condition_data.entity_id);
|
||||
if(node.condition_data.above) {
|
||||
if(node.condition_data.below) {
|
||||
return `${node.condition_data.above} < ${center} < ${node.condition_data.below}`
|
||||
}
|
||||
return `${center} > ${node.condition_data.above}`
|
||||
}
|
||||
if(node.condition_data.below) {
|
||||
return `${center} < ${node.condition_data.below}`
|
||||
}
|
||||
return `${center}?>?<`
|
||||
}
|
||||
return "Numeric State Condition"
|
||||
case "state":
|
||||
return `${node.condition_data.entity_id} is '${node.condition_data.state}'`
|
||||
case 'template':
|
||||
return node.condition_data.value_template
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (node.alias) {
|
||||
return node.alias;
|
||||
}
|
||||
return node.platform
|
||||
}
|
||||
return 'n/a'
|
||||
}
|
||||
|
||||
export const prettyEntityId = (entityId: string| string[]) => {
|
||||
if (typeof entityId === 'string') {
|
||||
return entityId
|
||||
} else if(entityId.length === 1) {
|
||||
return entityId[0]
|
||||
} else {
|
||||
return "..."
|
||||
}
|
||||
}
|
||||
|
||||
// export const determineNodeTypes = (action: AutomationNode<any>) : [AutomationNodeType, NodeSubType] => {
|
||||
// if ('condition' in action) {
|
||||
// switch (action.condition) {
|
||||
// case 'and':
|
||||
// return ['condition', 'Logic']
|
||||
// case 'or':
|
||||
// return ['condition', 'Logic']
|
||||
// case 'not':
|
||||
// return ['condition', 'Logic']
|
||||
// case 'numeric_state':
|
||||
// return ['condition', 'Numeric State']
|
||||
// case 'state':
|
||||
// return ['condition', 'State']
|
||||
// case 'template':
|
||||
// return ['condition', 'Template']
|
||||
// case 'trigger':
|
||||
// return ['condition', 'Trigger']
|
||||
// case 'zone':
|
||||
// return ['condition', 'Zone']
|
||||
// default:
|
||||
// return ['condition', 'Generic']
|
||||
|
||||
// }
|
||||
// }
|
||||
// if ('platform' in action) {
|
||||
// switch (action.platform) {
|
||||
// case 'event':
|
||||
// return ['trigger', 'Event']
|
||||
// case 'homeassistant':
|
||||
// return ['trigger', 'Home Assistant']
|
||||
// case 'mqtt':
|
||||
// return ['trigger', 'MQTT']
|
||||
// case 'numeric_state':
|
||||
// return ['trigger', 'Numeric State']
|
||||
// case 'state':
|
||||
// return ['trigger', 'State']
|
||||
// case 'tag':
|
||||
// return ['trigger', 'Tag']
|
||||
// case 'template':
|
||||
// return ['trigger', 'Template']
|
||||
// case 'time':
|
||||
// return ['trigger', 'Time']
|
||||
// case 'time_pattern':
|
||||
// return ['trigger', 'Time Pattern']
|
||||
// case 'webhook':
|
||||
// return ['trigger', 'Webhook']
|
||||
// case 'zone':
|
||||
// return ['trigger', 'Zone']
|
||||
// default:
|
||||
// return ['trigger', 'Generic']
|
||||
|
||||
// }
|
||||
// }
|
||||
// if ('service' in action) {
|
||||
// return ["action", "Service"]
|
||||
// }
|
||||
// if ('repeat' in action) {
|
||||
// return ["action", "Repeat"]
|
||||
// }
|
||||
// if ('wait_template' in action) {
|
||||
// return ["action", "Wait"]
|
||||
// }
|
||||
// if ('event' in action) {
|
||||
// return ["action", "Event"]
|
||||
// }
|
||||
// if (('type' in action) && ('device_id' in action)) {
|
||||
// return ["action", "Device"]
|
||||
// }
|
||||
// if ('choose' in action) {
|
||||
// return ["action", "Choose"]
|
||||
// }
|
||||
// throw Error(`Could not determine node type ${JSON.stringify(action)}`)
|
||||
// }
|
||||
@@ -1,40 +0,0 @@
|
||||
import { AutomationMetadata } from "~/automations/types";
|
||||
import InputList from "../Inputs/InputList";
|
||||
import InputText from "../Inputs/InputText";
|
||||
import InputTextArea from "../Inputs/InputTextArea";
|
||||
|
||||
interface Props {
|
||||
className: string;
|
||||
metadata: AutomationMetadata;
|
||||
onUpdate: (m: AutomationMetadata) => void;
|
||||
}
|
||||
export default function AutoInfoBox({
|
||||
metadata,
|
||||
onUpdate,
|
||||
className,
|
||||
}: Props) {
|
||||
|
||||
// aliases
|
||||
const onUpdateMetadata = <K extends keyof AutomationMetadata>(k: K) =>(update: AutomationMetadata[K]) => onUpdate({
|
||||
...metadata,
|
||||
[k]: update
|
||||
})
|
||||
|
||||
// render
|
||||
return <div className={className}>
|
||||
<InputText label="ID" value={metadata.id} onChange={onUpdateMetadata('id')} />
|
||||
<InputText label="Name" value={metadata.alias} onChange={onUpdateMetadata('alias')} />
|
||||
<InputTextArea label="Description" value={metadata.description} onChange={onUpdateMetadata('description')} />
|
||||
<InputList
|
||||
label="Mode"
|
||||
current={metadata.mode}
|
||||
onChange={onUpdateMetadata('mode')}
|
||||
options={[
|
||||
'parallel',
|
||||
'single',
|
||||
'queued',
|
||||
'restart'
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
import { EdgeDirection, Point } from "./types"
|
||||
|
||||
|
||||
|
||||
export interface EdgeProp {
|
||||
p1: Point,
|
||||
p2: Point,
|
||||
direction: EdgeDirection,
|
||||
className: string,
|
||||
}
|
||||
export default ({
|
||||
p1: [x1,y1],
|
||||
p2: [x2,y2],
|
||||
direction,
|
||||
className,
|
||||
}: EdgeProp) => {
|
||||
const [_,my] = [(x1+x2)/2, (y1+y2)/2]
|
||||
const theta = Math.atan2(y2 -y1, x2-x1) - Math.PI / 2
|
||||
const cx1 = x1 - 45 * Math.sin(theta)
|
||||
const cy1 = my - 30 * Math.cos(theta)
|
||||
const cx2 = x2 + 45 * Math.sin(theta)
|
||||
const cy2 = my + 30 * Math.cos(theta)
|
||||
|
||||
return <path className={className}
|
||||
d={ `M${x1} ${y1} C${cx1} ${cy1}, ${cx2} ${cy2}, ${x2} ${y2}`}
|
||||
fill="none"
|
||||
markerStart={
|
||||
(direction === '1<-2' || direction === '1<->2') ?
|
||||
"url(#arrow)" : ''
|
||||
}
|
||||
markerEnd={
|
||||
(direction === '1->2' || direction === '1<->2') ?
|
||||
"url(#arrow)" : ''
|
||||
}
|
||||
/>
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
import Color from "chroma-js";
|
||||
import { PencilIcon } from "~/icons/icons"
|
||||
import { NODE_HEIGHT, NODE_WIDTH } from "./constants"
|
||||
import { useNodeStyles } from "./styles"
|
||||
import { Node } from "./types"
|
||||
|
||||
|
||||
|
||||
export interface NodeProp extends Node {
|
||||
height?: number;
|
||||
width?: number;
|
||||
onXClick?: () => void;
|
||||
onOpenClick?: () => void;
|
||||
}
|
||||
export default ({
|
||||
loc: [x, y],
|
||||
text,
|
||||
height = NODE_HEIGHT,
|
||||
width = NODE_WIDTH,
|
||||
onXClick = () => { },
|
||||
onOpenClick = () => { },
|
||||
color,
|
||||
}: NodeProp) => {
|
||||
const { classes, theme } = useNodeStyles({
|
||||
color,
|
||||
nodeHeight: height,
|
||||
nodeWidth: width,
|
||||
});
|
||||
return <foreignObject x={x} y={y} width={width} height={height}>
|
||||
<div className={classes.root}>
|
||||
<div className={classes.inner}>
|
||||
<div className={classes.leftEdge} onClick={onXClick}>
|
||||
<button className={classes.buttonDelete}>X</button>
|
||||
</div>
|
||||
<div className={classes.textWrap}>
|
||||
<span className={classes.text}>
|
||||
{text}
|
||||
</span>
|
||||
</div>
|
||||
<div className={classes.rightEdge} onClick={onOpenClick}>
|
||||
<button className={classes.buttonEdit}>
|
||||
<PencilIcon size={1.1} color={Color(theme.primary).set('rgb.g', 200).hex()} />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</foreignObject>
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
import { FC } from "react";
|
||||
import { AutomationSequenceNode } from "~/automations/types";
|
||||
import { getDescriptionFromAutomationNode } from "~/automations/utils";
|
||||
import DAGEdge from "./DAGEdge";
|
||||
import DAGNode from "./DAGNode";
|
||||
import { useNodeStyles } from "./styles";
|
||||
import { Point } from "./types";
|
||||
|
||||
|
||||
interface Props extends RenderSequenceProps {
|
||||
styles: ReturnType<typeof useNodeStyles>,
|
||||
sequence: AutomationSequenceNode[],
|
||||
triggerPoint: Point,
|
||||
}
|
||||
export const SequenceNodes: FC<Props> = ({
|
||||
sequence,
|
||||
triggerPoint,
|
||||
...renderSequenceProps
|
||||
}) => {
|
||||
const renderSequence = makeRenderSequence(renderSequenceProps);
|
||||
return <g id="sequence">
|
||||
{sequence.map((n, i) => renderSequence(triggerPoint, n, i))}
|
||||
</g>
|
||||
}
|
||||
|
||||
interface RenderSequenceProps {
|
||||
styles: ReturnType<typeof useNodeStyles>,
|
||||
onUpdate: (i: number, s: AutomationSequenceNode | null) => void,
|
||||
nodeWidth: number,
|
||||
nodeHeight: number,
|
||||
nHDF: number,
|
||||
}
|
||||
const makeRenderSequence = ({
|
||||
onUpdate,
|
||||
nodeHeight,
|
||||
nodeWidth,
|
||||
nHDF,
|
||||
styles: { classes }
|
||||
}: RenderSequenceProps) => (
|
||||
startPoint: Point,
|
||||
node: AutomationSequenceNode,
|
||||
i: number
|
||||
) => {
|
||||
const nodeLoc: Point = [startPoint[0] + nodeWidth / 2, 0];
|
||||
let lastNodeLoc = startPoint;
|
||||
if (i > 0) {
|
||||
lastNodeLoc = [nodeLoc[0] + nodeWidth * ((i - 1) * nHDF + 1), nodeLoc[1] + nodeHeight / 2];
|
||||
nodeLoc[0] += nodeWidth * i * nHDF
|
||||
}
|
||||
const curretEdgeLoc: Point = [nodeLoc[0], nodeLoc[1] + nodeHeight / 2];
|
||||
const nextAddLoc: Point = [nodeLoc[0] + nodeWidth * nHDF, nodeLoc[1] + nodeHeight / 2];
|
||||
return <>
|
||||
<DAGEdge
|
||||
key={`edge.${i}`}
|
||||
p1={lastNodeLoc}
|
||||
p2={curretEdgeLoc}
|
||||
direction="1->2"
|
||||
className={classes.dagEdge}
|
||||
/>
|
||||
<DAGNode
|
||||
height={nodeHeight}
|
||||
width={nodeWidth}
|
||||
key={`node.${i}`}
|
||||
loc={nodeLoc}
|
||||
text={getDescriptionFromAutomationNode(node)}
|
||||
color={node.$smType === 'action' ? 'green' : 'blue'}
|
||||
onXClick={() => onUpdate(i, null)}
|
||||
/>
|
||||
<DAGEdge
|
||||
key={`edge.${i}`}
|
||||
p1={curretEdgeLoc}
|
||||
p2={nextAddLoc}
|
||||
direction="1->2"
|
||||
className={classes.dagEdge}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
|
||||
export function* getJSXNodes(
|
||||
{ classes }: ReturnType<typeof useNodeStyles>,
|
||||
onUpdate: (i: number, s: AutomationSequenceNode | null) => void, it: Generator<NodeEdgeLocation, Point, never>
|
||||
) {
|
||||
let next = it.next();
|
||||
while (!next.done) {
|
||||
const { node, nodeLoc, curretEdgeLoc, nextAddLoc, lastStartPoint, nodeHeight, nodeWidth } = next.value;
|
||||
yield <>
|
||||
<DAGEdge
|
||||
key={`edge.${i}`}
|
||||
p1={nodeLoc}
|
||||
p2={curretEdgeLoc}
|
||||
direction="1->2"
|
||||
className={classes.dagEdge}
|
||||
/>
|
||||
<DAGNode
|
||||
height={nodeHeight}
|
||||
width={nodeWidth}
|
||||
key={`node.${i}`}
|
||||
loc={nodeLoc}
|
||||
text={getDescriptionFromAutomationNode(node)}
|
||||
color={node.$smType === 'action' ? 'green' : 'blue'}
|
||||
onXClick={() => onUpdate(i, null)}
|
||||
/>
|
||||
<DAGEdge
|
||||
key={`edge.${i}`}
|
||||
p1={curretEdgeLoc}
|
||||
p2={nextAddLoc}
|
||||
direction="1->2"
|
||||
className={classes.dagEdge}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
}
|
||||
|
||||
type NodeEdgeLocation = {
|
||||
nodeId: string;
|
||||
node: AutomationSequenceNode;
|
||||
nodeLoc: Point;
|
||||
lastStartPoint: Point;
|
||||
curretEdgeLoc: Point;
|
||||
nextAddLoc: Point | null;
|
||||
nodeWidth: number;
|
||||
nodeHeight: number;
|
||||
}
|
||||
export function* computeNodeEdgeLocation(
|
||||
startPoint: Point,
|
||||
nodeWidth: number,
|
||||
nodeHeight: number,
|
||||
distanceFactor: number,
|
||||
sequence: AutomationSequenceNode[]
|
||||
): Generator<NodeEdgeLocation, Point, never> {
|
||||
let lastStartPoint: Point = [...startPoint];
|
||||
for (let i = 0; i < sequence.length; i++) {
|
||||
const node = sequence[i];
|
||||
const nodeLoc: Point = lastStartPoint = [lastStartPoint[0], lastStartPoint[1] + nodeWidth * distanceFactor];
|
||||
const curretEdgeLoc: Point = [nodeLoc[0], nodeLoc[1] + nodeHeight / 2];
|
||||
const nextAddLoc: Point | null = i < sequence.length ? null : [nodeLoc[0] + nodeWidth * distanceFactor, nodeLoc[1] + nodeHeight / 2];
|
||||
// if ((node.$smType === 'action') && (node.action === 'choose')) {
|
||||
// for (let { sequence } of node.action_data.choose) {
|
||||
// for (let parsedChild of computeNodeEdgeLocation(
|
||||
// nodeLoc,
|
||||
// nodeWidth,
|
||||
// nodeHeight,
|
||||
// distanceFactor,
|
||||
// sequence
|
||||
// )) {
|
||||
// yield parsedChild;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
yield { node, nodeLoc, lastStartPoint, curretEdgeLoc, nextAddLoc, nodeHeight, nodeWidth }
|
||||
}
|
||||
return lastStartPoint
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
|
||||
|
||||
|
||||
export const NODE_WIDTH = 100 as const;
|
||||
export const NODE_HEIGHT = 40 as const;
|
||||
@@ -1,211 +0,0 @@
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { useState } from "react";
|
||||
import { AutomationData } from "~/automations/types";
|
||||
import { usePageTheme } from "~/styles/page";
|
||||
import AutomationEditor from ".";
|
||||
|
||||
export default {
|
||||
title: 'AutomationEditor',
|
||||
component: AutomationEditor,
|
||||
parameters: { actions: { argTypesRegex: '^on.*' } },
|
||||
} as ComponentMeta<typeof AutomationEditor>;
|
||||
|
||||
|
||||
const Template: ComponentStory<typeof AutomationEditor> = ({ automation, ...args }) => {
|
||||
const { classes } = usePageTheme({});
|
||||
const [data, setData] = useState(automation);
|
||||
return <div className={classes.page}>
|
||||
<AutomationEditor {...args}
|
||||
automation={data}
|
||||
onUpdate={data => {
|
||||
setData(data)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
|
||||
export const ServiceAction = Template.bind({})
|
||||
ServiceAction.args = {
|
||||
automation: {
|
||||
metadata: {
|
||||
id: "X12314akx",
|
||||
alias: "root",
|
||||
description: 'Really Long Description',
|
||||
mode: 'single',
|
||||
},
|
||||
trigger: [
|
||||
{
|
||||
platform: 'time',
|
||||
at: '10:00:00'
|
||||
},
|
||||
{
|
||||
platform: "device",
|
||||
device_id: "34749",
|
||||
domain: "zha",
|
||||
type: "remote_button_double_press",
|
||||
subtype: "remote_button_double_press"
|
||||
}
|
||||
],
|
||||
sequence: [
|
||||
{
|
||||
$smType: "condition",
|
||||
condition: 'and',
|
||||
condition_data: {
|
||||
conditions: [
|
||||
{
|
||||
$smType: 'condition',
|
||||
condition: 'numeric_state',
|
||||
condition_data: {
|
||||
entity_id: 'sensor.temperature_kitchen',
|
||||
below: '15',
|
||||
}
|
||||
},
|
||||
{
|
||||
$smType: "condition",
|
||||
condition: 'template',
|
||||
condition_data: {
|
||||
value_template: 'states(switch.kitchen_light) == "on"'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
$smType: "action",
|
||||
action: "service",
|
||||
action_data: {
|
||||
alias: "Start Music In Kitchen",
|
||||
service: 'media_player.play_media',
|
||||
target: {
|
||||
entity_id: "media_player.kitchen_dot"
|
||||
},
|
||||
data: {
|
||||
media_content_id: "Good Morning",
|
||||
media_content_type: "SPOTIFY",
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
} as AutomationData
|
||||
}
|
||||
|
||||
|
||||
export const ChooseAction = Template.bind({})
|
||||
ChooseAction.args = {
|
||||
automation: {
|
||||
metadata: {
|
||||
id: "X12314akx",
|
||||
alias: "root",
|
||||
description: 'Really Long Description',
|
||||
mode: 'single',
|
||||
},
|
||||
trigger: [
|
||||
{
|
||||
platform: 'time',
|
||||
at: '10:00:00'
|
||||
},
|
||||
{
|
||||
platform: "device",
|
||||
device_id: "34749",
|
||||
domain: "zha",
|
||||
type: "remote_button_double_press",
|
||||
subtype: "remote_button_double_press"
|
||||
}
|
||||
],
|
||||
sequence: [
|
||||
{
|
||||
$smType: "condition",
|
||||
condition: 'and',
|
||||
condition_data: {
|
||||
conditions: [
|
||||
{
|
||||
$smType: 'condition',
|
||||
condition: 'numeric_state',
|
||||
condition_data: {
|
||||
entity_id: 'sensor.temperature_kitchen',
|
||||
below: '15',
|
||||
}
|
||||
},
|
||||
{
|
||||
$smType: "condition",
|
||||
condition: 'template',
|
||||
condition_data: {
|
||||
value_template: 'states(switch.kitchen_light) == "on"'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
$smType: "action",
|
||||
action: "choose",
|
||||
action_data: {
|
||||
choose: [
|
||||
{
|
||||
conditions: [
|
||||
{
|
||||
$smType: "condition",
|
||||
condition: 'time',
|
||||
condition_data: {
|
||||
after: {
|
||||
hours: 16,
|
||||
minutes: 30
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
sequence: [
|
||||
{
|
||||
$smType: 'action',
|
||||
action: 'event',
|
||||
action_data: {
|
||||
event: "superImportant_time",
|
||||
event_data: {
|
||||
time: '4:30PM'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
conditions: [
|
||||
{
|
||||
$smType: "condition",
|
||||
condition: 'time',
|
||||
condition_data: {
|
||||
after: {
|
||||
hours: 18,
|
||||
minutes: 45
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
sequence: [
|
||||
{
|
||||
$smType: 'action',
|
||||
action: 'event',
|
||||
action_data: {
|
||||
event: "superImportant_time",
|
||||
event_data: {
|
||||
time: '6:45PM'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
$smType: 'action',
|
||||
action: "service",
|
||||
action_data: {
|
||||
service: "light.turn_on",
|
||||
data: {
|
||||
entity_id: "light.kitchen"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
} as AutomationData
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
import { AutomationData } from "~/automations/types";
|
||||
import { AutomationTrigger } from "~/automations/types/triggers";
|
||||
import { getDescriptionFromAutomationNode } from "~/automations/utils";
|
||||
import useWindowSize from "~/utils/useWindowSize";
|
||||
import AutoInfoBox from "./AutoInfoBox";
|
||||
import { NODE_HEIGHT, NODE_WIDTH } from "./constants";
|
||||
import DAGEdge from "./DAGEdge";
|
||||
import DAGNode from "./DAGNode";
|
||||
import { SequenceNodes } from "./SequenceNodes";
|
||||
import { useEditorStyles } from "./styles";
|
||||
import { Point } from "./types";
|
||||
import { AutomationSequenceNode } from '../../automations/types/index';
|
||||
|
||||
interface Props {
|
||||
automation: AutomationData;
|
||||
onUpdate: (auto: AutomationData) => void;
|
||||
}
|
||||
export default function AutomationEditor({
|
||||
automation,
|
||||
onUpdate,
|
||||
}: Props) {
|
||||
|
||||
// state
|
||||
const { ratioWbh } = useWindowSize();
|
||||
const { classes, theme } = useEditorStyles({});
|
||||
|
||||
// alias
|
||||
const nHDF = 1.5 // node horizontal distance factor (aspect ratio)
|
||||
const graphHeight = 300;
|
||||
const graphWidth = Math.round(graphHeight * ratioWbh);
|
||||
const pointTrigToCond: Point = [NODE_WIDTH * nHDF, NODE_HEIGHT / 2]
|
||||
const updateSequence = (i: number, node: AutomationSequenceNode | null) => {
|
||||
const update = (sequence: AutomationSequenceNode[]) => onUpdate({
|
||||
...automation,
|
||||
sequence,
|
||||
})
|
||||
if (node === null) {
|
||||
update([
|
||||
...automation.sequence.slice(0, i),
|
||||
...automation.sequence.slice(i + 1),
|
||||
])
|
||||
} else {
|
||||
update([
|
||||
...automation.sequence.slice(0, i),
|
||||
node,
|
||||
...automation.sequence.slice(i + 1),
|
||||
])
|
||||
}
|
||||
};
|
||||
|
||||
// render funcs
|
||||
const renderTrigger = (trigger: AutomationTrigger, i: number) => {
|
||||
const nodeLoc: Point = [0, i * NODE_HEIGHT];
|
||||
return <>
|
||||
<DAGNode key={`node.${i}`}
|
||||
loc={nodeLoc}
|
||||
text={getDescriptionFromAutomationNode(trigger)}
|
||||
color="red"
|
||||
onXClick={() => {
|
||||
onUpdate({
|
||||
...automation,
|
||||
trigger: [
|
||||
...automation.trigger.slice(0, i),
|
||||
...automation.trigger.slice(i + 1),
|
||||
]
|
||||
})
|
||||
}}
|
||||
/>
|
||||
<DAGEdge
|
||||
key={`edge.${i}`}
|
||||
p1={[NODE_WIDTH, nodeLoc[1] + 0.5 * NODE_HEIGHT]}
|
||||
p2={pointTrigToCond}
|
||||
className={classes.dagEdge}
|
||||
direction="1->2"
|
||||
/>
|
||||
</>
|
||||
}
|
||||
|
||||
// render
|
||||
return <div className={classes.root} style={{
|
||||
flexDirection: ratioWbh >= 0.75 ? 'row' : 'column'
|
||||
}}>
|
||||
<AutoInfoBox
|
||||
className={classes.infoBox}
|
||||
metadata={automation.metadata}
|
||||
onUpdate={metadata => onUpdate({ ...automation, metadata })}
|
||||
/>
|
||||
<div className={classes.dag}>
|
||||
<svg
|
||||
className={classes.svg}
|
||||
viewBox={[0, 0, graphWidth, graphHeight].join(" ")}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<defs>
|
||||
<marker id="arrow" viewBox="0 0 10 10" refX="10" refY="5"
|
||||
markerWidth="6" markerHeight="6"
|
||||
orient="auto-start-reverse">
|
||||
<path d="M 0 0 L 10 5 L 0 10 z" fill={theme.secondaryAccent} />
|
||||
</marker>
|
||||
</defs>
|
||||
<g className="triggers">
|
||||
{automation.trigger.map(renderTrigger)}
|
||||
</g>
|
||||
<SequenceNodes
|
||||
styles={{ classes, theme }}
|
||||
sequence={automation.sequence}
|
||||
onUpdate={updateSequence}
|
||||
nHDF={nHDF}
|
||||
nodeHeight={NODE_HEIGHT}
|
||||
nodeWidth={NODE_WIDTH}
|
||||
triggerPoint={pointTrigToCond}
|
||||
/>
|
||||
<circle className={classes.circle} cx={pointTrigToCond[0]} cy={pointTrigToCond[1]} r={2} />
|
||||
<g className="actions">
|
||||
</g>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
import { Styles } from "jss";
|
||||
import Color from 'chroma-js';
|
||||
import { createAppUseStyles } from "~/styles/theme";
|
||||
import { Node } from "./types";
|
||||
|
||||
|
||||
export const useEditorStyles = createAppUseStyles(theme => ({
|
||||
root: {
|
||||
height: '99%',
|
||||
width: '99%',
|
||||
color: theme.primaryAccent,
|
||||
display: 'flex',
|
||||
flexDirection: 'row',
|
||||
},
|
||||
dag: {
|
||||
borderWidth: 1,
|
||||
borderStyle: 'solid',
|
||||
borderColor: theme.secondaryAccent,
|
||||
width: '100%',
|
||||
},
|
||||
svg: {
|
||||
height: '99%',
|
||||
width: '99%',
|
||||
padding: 0,
|
||||
margin: 0,
|
||||
},
|
||||
circle: {
|
||||
fill: Color(theme.secondary).set('rgb.b', 125).hex(),
|
||||
},
|
||||
infoBox: {
|
||||
paddingLeft: '10px',
|
||||
paddingRight: '10px',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-start',
|
||||
overflow: 'auto',
|
||||
},
|
||||
dagEdge: {
|
||||
stroke: theme.secondaryAccent,
|
||||
},
|
||||
}))
|
||||
|
||||
export const useNodeStyles = createAppUseStyles<{
|
||||
color: Node['color'],
|
||||
nodeHeight: number,
|
||||
nodeWidth: number,
|
||||
}>(theme => {
|
||||
const edgeStyle: Styles = {
|
||||
flex: '1',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
flexWrap: 'nowrap',
|
||||
borderRadius: '1em',
|
||||
justifyContent: 'space-around',
|
||||
alignItems: 'center',
|
||||
'&:hover': {
|
||||
backgroundColor: theme.primaryAccent,
|
||||
cursor: 'pointer',
|
||||
}
|
||||
}
|
||||
const buttonStyle: Styles = {
|
||||
fontSize: '8px',
|
||||
backgroundColor: "rgba(0,0,0,0)",
|
||||
color: theme.primaryAccent,
|
||||
borderStyle: 'none',
|
||||
height: '15px',
|
||||
width: '15px',
|
||||
cursor: 'pointer',
|
||||
transition: "500ms east-out",
|
||||
}
|
||||
return {
|
||||
root: {
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-end',
|
||||
height: `100%`,
|
||||
maxHeight: `100%`,
|
||||
maxWidth: '100%',
|
||||
width: '100%',
|
||||
fontSize: 10,
|
||||
},
|
||||
inner: ({ color }) => ({
|
||||
position: 'relative',
|
||||
display: 'flex',
|
||||
flexDirection: 'row',
|
||||
backgroundColor: theme.secondary,
|
||||
borderRadius: '1em',
|
||||
flex: 1,
|
||||
height: `100%`,
|
||||
maxHeight: `100%`,
|
||||
maxWidth: '100%',
|
||||
marginTop: '2.5px',
|
||||
marginBottom: '2.5px',
|
||||
borderTopWidth: '1px',
|
||||
borderTopStyle: 'solid',
|
||||
borderTopLeftRadius: '10px',
|
||||
borderTopRightRadius: '10px',
|
||||
borderTopColor: color === 'red' ? Color(theme.secondary).set('rgb.r', 125).hex() :
|
||||
color === 'blue' ? Color(theme.secondary).set('rgb.b', 125).hex() :
|
||||
color === 'green' ? Color(theme.secondary).set('rgb.g', 125).hex() :
|
||||
'none'
|
||||
}),
|
||||
textWrap: {
|
||||
display: 'flex',
|
||||
flex: 4,
|
||||
textAlign: 'center',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
height: '100%',
|
||||
maxHeight: '100%',
|
||||
maxWidth: "50%",
|
||||
},
|
||||
text: {
|
||||
textOverflow: 'ellipsis',
|
||||
overflow: "hidden",
|
||||
whiteSpace: "nowrap",
|
||||
},
|
||||
buttonDelete: {
|
||||
...buttonStyle,
|
||||
"&:hover": {
|
||||
color: theme.primary,
|
||||
}
|
||||
},
|
||||
buttonEdit: {
|
||||
...buttonStyle,
|
||||
"&:hover": {
|
||||
transform: "rotate(45deg)"
|
||||
}
|
||||
},
|
||||
leftEdge: {
|
||||
...edgeStyle,
|
||||
borderLef: `1px ${theme.secondaryAccent} solid`,
|
||||
borderTopRightRadius: 0,
|
||||
borderBottomRightRadius: 0,
|
||||
},
|
||||
rightEdge: {
|
||||
...edgeStyle,
|
||||
borderRight: `1px ${theme.secondaryAccent} solid`,
|
||||
borderTopLeftRadius: 0,
|
||||
borderBottomLeftRadius: 0,
|
||||
},
|
||||
}
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
export type Point = [number, number];
|
||||
export interface Node {
|
||||
loc: Point;
|
||||
text: string;
|
||||
color: 'red' | 'blue' | 'green';
|
||||
}
|
||||
export interface Edge {
|
||||
from: string;
|
||||
to: string;
|
||||
direction: '1->2' | '1<->2' | '1<-2';
|
||||
}
|
||||
export type EdgeDirection = Edge['direction'];
|
||||
export interface DAG {
|
||||
nodes: Record<string, Node>;
|
||||
edges: Array<Edge>;
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
import { Classes } from "jss";
|
||||
import { FC, useState } from "react";
|
||||
import { getConditionDefaultValues } from "~/automations/defaults";
|
||||
import { AutomationCondition } from "~/automations/types/conditions";
|
||||
import { CheckMarkIcon, PencilIcon } from "~/icons/icons";
|
||||
import InputList from "../Inputs/InputList";
|
||||
import InputYaml from "../Inputs/InputYaml";
|
||||
import { getEditor } from "./editorRender";
|
||||
import { useStyles } from "./style";
|
||||
import { getViewer } from "./viewRender";
|
||||
|
||||
|
||||
|
||||
export const ConditionNode: FC<{
|
||||
condition: AutomationCondition;
|
||||
displayMode: boolean;
|
||||
showDelete?: boolean;
|
||||
onDelete?: (which: 'root' | number) => void;
|
||||
onUpdate?: (data: AutomationCondition) => void;
|
||||
children?: (props: {
|
||||
classes: Classes<string>
|
||||
}) => JSX.Element,
|
||||
}> = ({
|
||||
condition,
|
||||
showDelete=false,
|
||||
onDelete=() => {},
|
||||
onUpdate=() => {},
|
||||
displayMode=() => {},
|
||||
children=() => {},
|
||||
}) => {
|
||||
// state
|
||||
const [internalDisplayMode, setInternalDisplayMode] = useState(true);
|
||||
const [yamlMode, setYamlMode] = useState(false);
|
||||
// alias
|
||||
const effectiveDM = displayMode && internalDisplayMode;
|
||||
const onAddChild = () => {
|
||||
if(
|
||||
(condition.condition === 'and') ||
|
||||
(condition.condition === 'or') ||
|
||||
(condition.condition === 'not')
|
||||
) {
|
||||
onUpdate({
|
||||
...condition,
|
||||
condition_data: {
|
||||
...condition.condition_data,
|
||||
conditions: condition.condition_data.conditions.concat({
|
||||
$smType: 'condition',
|
||||
condition: 'or',
|
||||
condition_data: {
|
||||
conditions: []
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
// children
|
||||
let childrenConditions: JSX.Element;
|
||||
if (effectiveDM) {
|
||||
const Viewer = getViewer(condition);
|
||||
childrenConditions = <Viewer condition={condition} onChange={data => {
|
||||
onUpdate(data)
|
||||
}}/>
|
||||
} else {
|
||||
const Editor = getEditor(condition);
|
||||
childrenConditions = <Editor condition={condition} onChange={data => {
|
||||
onUpdate(data)
|
||||
}}/>
|
||||
}
|
||||
// styles
|
||||
let hasChildren = false;
|
||||
if (condition.condition === "not") {
|
||||
hasChildren = true
|
||||
} else if (condition.condition ==='and') {
|
||||
hasChildren = true
|
||||
} else if (condition.condition ==='or') {
|
||||
hasChildren = true
|
||||
}
|
||||
const {classes} = useStyles({ hasChildren });
|
||||
|
||||
// components
|
||||
const DeleteButton = (p: {onClick?: () => void, isRoot?: boolean}) =>
|
||||
<button className={p.isRoot ? classes.deleteBtnRoot : classes.deleteBtn} onClick={p?.onClick}>X</button>
|
||||
|
||||
return <div className={classes.root}>
|
||||
{(showDelete || !effectiveDM) && <DeleteButton isRoot onClick={ () => onDelete('root')}/>}
|
||||
<div className={classes.title}>
|
||||
{/* <span className={classes.titleText}>{condition.condition.replace('_', ' ')}</span> */}
|
||||
<InputList
|
||||
label=""
|
||||
className={classes.titleText}
|
||||
current={condition.condition}
|
||||
options={[
|
||||
'or', 'not', 'and',
|
||||
'template',
|
||||
'numeric_state',
|
||||
'state',
|
||||
'time',
|
||||
'trigger',
|
||||
'zone',
|
||||
]}
|
||||
onChange={n => onUpdate({
|
||||
condition: n,
|
||||
condition_data: {
|
||||
...getConditionDefaultValues(n),
|
||||
...condition.condition_data,
|
||||
}
|
||||
} as any)}
|
||||
/>
|
||||
{effectiveDM && <button className={classes.yamlBtn} onClick={() => setYamlMode(!yamlMode)}>
|
||||
{yamlMode ? 'visual' : 'yaml'}
|
||||
</button>}
|
||||
{!yamlMode && <button className={classes.modifyBtn} onClick={() => setInternalDisplayMode(!effectiveDM)}>
|
||||
{effectiveDM ? <PencilIcon className={classes.icon}/> : <CheckMarkIcon className={classes.icon}/>}
|
||||
</button>}
|
||||
</div>
|
||||
<div className={classes.children}>
|
||||
{yamlMode && <InputYaml
|
||||
label=""
|
||||
value={condition.condition_data}
|
||||
onChange={update => onUpdate({
|
||||
...condition,
|
||||
condition_data: update as any
|
||||
})}
|
||||
resizable
|
||||
/>}
|
||||
{!yamlMode && childrenConditions}
|
||||
{!yamlMode && hasChildren && <div className={classes.addBtnContainer}>
|
||||
<button className={classes.addBtn} onClick={() => onAddChild()}>Add</button>
|
||||
</div>}
|
||||
</div>
|
||||
{children({classes})}
|
||||
</div>
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
import { FC } from "react";
|
||||
import { AutomationCondition, LogicCondition, NumericCondition, TemplateCondition } from "~/automations/types/conditions";
|
||||
import { getDescriptionFromAutomationNode } from "~/automations/utils";
|
||||
import InputNumber from "../Inputs/InputNumber";
|
||||
import InputText from "../Inputs/InputText";
|
||||
import InputTextArea from "../Inputs/InputTextArea";
|
||||
import { InputEntity } from "../Inputs/InputTextBubble";
|
||||
import { ConditionNode } from "./ConditionNode";
|
||||
import { genUpdateMethods } from "./nestedUpdater";
|
||||
|
||||
|
||||
interface Editor<C extends AutomationCondition> extends FC<{
|
||||
condition: C,
|
||||
onChange: (condition: C) => void;
|
||||
}> {}
|
||||
|
||||
|
||||
export const getEditor = (condition: AutomationCondition): Editor<any> => {
|
||||
switch (condition.condition) {
|
||||
case 'template':
|
||||
return TemplateEditor;
|
||||
case 'and':
|
||||
return LogicViewer;
|
||||
case 'or':
|
||||
return LogicViewer;
|
||||
case 'not':
|
||||
return LogicViewer;
|
||||
case 'numeric_state':
|
||||
return NumericStateEditor;
|
||||
default:
|
||||
return () => <div>Not Ready</div>
|
||||
}
|
||||
}
|
||||
|
||||
export const TemplateEditor: Editor<TemplateCondition> = ({
|
||||
onChange,
|
||||
condition,
|
||||
}) => {
|
||||
return <div>
|
||||
<InputText label="Alias" value={condition.condition_data.alias ?? getDescriptionFromAutomationNode(condition)} onChange={alias => onChange({
|
||||
...condition,
|
||||
condition_data: {
|
||||
...condition.condition_data,
|
||||
alias
|
||||
}
|
||||
})}/>
|
||||
<InputTextArea label="Template" value={condition.condition_data.value_template} onChange={value_template => onChange({
|
||||
...condition,
|
||||
condition_data: {
|
||||
...condition.condition_data,
|
||||
value_template
|
||||
}
|
||||
})} resizable/>
|
||||
</div>
|
||||
}
|
||||
|
||||
|
||||
export const NumericStateEditor: Editor<NumericCondition> = ({
|
||||
onChange,
|
||||
condition,
|
||||
}) => {
|
||||
return <div>
|
||||
<InputText label="Alias" value={condition.condition_data.alias ?? getDescriptionFromAutomationNode(condition)} onChange={alias => onChange({
|
||||
...condition,
|
||||
condition_data: {
|
||||
...condition.condition_data,
|
||||
alias
|
||||
}
|
||||
})}/>
|
||||
<InputEntity
|
||||
value={condition.condition_data.entity_id}
|
||||
onChange={entity_id => onChange({
|
||||
...condition,
|
||||
condition_data: {
|
||||
...condition.condition_data,
|
||||
entity_id
|
||||
}
|
||||
})}
|
||||
/>
|
||||
<InputText label="Attribute" value={condition.condition_data.attribute ?? ""} onChange={attribute => onChange({
|
||||
...condition,
|
||||
condition_data: {
|
||||
...condition.condition_data,
|
||||
attribute
|
||||
}
|
||||
})}/>
|
||||
<InputNumber
|
||||
label="Above"
|
||||
value={condition.condition_data.above ? Number(condition.condition_data.above) : undefined}
|
||||
onChange={above => onChange({
|
||||
...condition,
|
||||
condition_data: {
|
||||
...condition.condition_data,
|
||||
above: above ? String(above) : undefined,
|
||||
}
|
||||
})}
|
||||
/>
|
||||
<InputNumber
|
||||
label="Below"
|
||||
value={condition.condition_data.below ? Number(condition.condition_data.below) : undefined}
|
||||
onChange={below => onChange({
|
||||
...condition,
|
||||
condition_data: {
|
||||
...condition.condition_data,
|
||||
below: below ? String(below) : undefined,
|
||||
}
|
||||
})}
|
||||
/>
|
||||
<InputTextArea label="Template" value={condition.condition_data.value_template ?? ""} onChange={value_template => onChange({
|
||||
...condition,
|
||||
condition_data: {
|
||||
...condition.condition_data,
|
||||
value_template
|
||||
}
|
||||
})} resizable/>
|
||||
</div>
|
||||
}
|
||||
|
||||
|
||||
export const LogicViewer: Editor<LogicCondition> = ({
|
||||
condition,
|
||||
onChange,
|
||||
}) => {
|
||||
|
||||
return <>
|
||||
{condition.condition_data.conditions.map( (c, i) => {
|
||||
return <ConditionNode
|
||||
key={i}
|
||||
condition={c}
|
||||
displayMode={false}
|
||||
{...genUpdateMethods(condition, onChange)(i)}
|
||||
/>
|
||||
} )}
|
||||
</>
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { useState } from "react";
|
||||
import { AutomationCondition } from "~/automations/types/conditions";
|
||||
import { usePageTheme } from "~/styles/page";
|
||||
import { ConditionEditor } from ".";
|
||||
|
||||
export default {
|
||||
title: 'ConditionEditor',
|
||||
component: ConditionEditor,
|
||||
parameters: { actions: { argTypesRegex: '^on.*' } },
|
||||
} as ComponentMeta<typeof ConditionEditor>;
|
||||
|
||||
|
||||
const Template: ComponentStory<typeof ConditionEditor> = ({condition, ...args}) => {
|
||||
const {classes} = usePageTheme({});
|
||||
const [data, setData] = useState(condition);
|
||||
return <div className={classes.page}>
|
||||
<ConditionEditor {...args}
|
||||
condition={data}
|
||||
onUpdate={data => {
|
||||
setData(data)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
|
||||
export const TemplateViewer = Template.bind({})
|
||||
TemplateViewer.args = {
|
||||
condition: {
|
||||
$smType: 'condition',
|
||||
condition: 'template',
|
||||
condition_data: {
|
||||
value_template: "states('switch.light_kitchen') == 'on'"
|
||||
}
|
||||
} as AutomationCondition,
|
||||
}
|
||||
|
||||
|
||||
export const NumericStateViewer = Template.bind({})
|
||||
NumericStateViewer.args = {
|
||||
condition: {
|
||||
$smType: 'condition',
|
||||
condition: "numeric_state",
|
||||
condition_data: {
|
||||
entity_id: "sensor.humidity_kitchen",
|
||||
above: "10",
|
||||
}
|
||||
} as AutomationCondition,
|
||||
}
|
||||
|
||||
export const LogicCondition = Template.bind({})
|
||||
LogicCondition.args = {
|
||||
condition: {
|
||||
$smType: 'condition',
|
||||
condition: 'or',
|
||||
condition_data: {
|
||||
conditions: [
|
||||
{
|
||||
$smType: 'condition',
|
||||
condition: 'numeric_state',
|
||||
condition_data: {
|
||||
entity_id: 'sensor.humidity_kitchen',
|
||||
above: '60'
|
||||
}
|
||||
},
|
||||
{
|
||||
$smType: 'condition',
|
||||
condition: 'numeric_state',
|
||||
condition_data: {
|
||||
entity_id: 'sensor.humidity_living_room',
|
||||
above: '60'
|
||||
}
|
||||
},
|
||||
{
|
||||
$smType: 'condition',
|
||||
condition: 'and',
|
||||
condition_data: {
|
||||
conditions: [
|
||||
{
|
||||
$smType: 'condition',
|
||||
condition: 'numeric_state',
|
||||
condition_data: {
|
||||
entity_id: 'sensor.humidity_bedroom',
|
||||
above: '60'
|
||||
}
|
||||
},
|
||||
{
|
||||
$smType: 'condition',
|
||||
condition: 'numeric_state',
|
||||
condition_data: {
|
||||
entity_id: 'sensor.humidity_bathroom',
|
||||
above: '60'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
} as AutomationCondition,
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
import { FC } from "react";
|
||||
import { AutomationCondition } from "~/automations/types/conditions";
|
||||
import { ConditionNode } from "./ConditionNode";
|
||||
|
||||
|
||||
|
||||
|
||||
export const ConditionEditor: FC<{
|
||||
condition: AutomationCondition;
|
||||
onDelete: (which: 'root' | number) => void;
|
||||
onUpdate: (data: AutomationCondition) => void;
|
||||
}> = ({
|
||||
condition,
|
||||
onDelete,
|
||||
onUpdate,
|
||||
}) => {
|
||||
// state
|
||||
return <ConditionNode
|
||||
condition={condition}
|
||||
onDelete={onDelete}
|
||||
onUpdate={update => {
|
||||
onUpdate(update)
|
||||
}}
|
||||
displayMode
|
||||
showDelete
|
||||
/>
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
import { AutomationCondition, LogicCondition } from "~/automations/types/conditions";
|
||||
|
||||
|
||||
export const genUpdateMethods = (condition: LogicCondition, onChange: (c: LogicCondition) => void) => (i: number) => ({
|
||||
onUpdate: (update: AutomationCondition) => onChange({
|
||||
...condition,
|
||||
condition_data: {
|
||||
...condition.condition_data,
|
||||
conditions: [
|
||||
...condition.condition_data.conditions.slice(0, i),
|
||||
update,
|
||||
...condition.condition_data.conditions.slice(i+1)
|
||||
]
|
||||
}
|
||||
}),
|
||||
onDelete: (which: 'root' | number) => {
|
||||
if (which === 'root') {
|
||||
onChange({
|
||||
...condition,
|
||||
condition_data: {
|
||||
...condition.condition_data,
|
||||
conditions: condition.condition_data.conditions.slice(0, i).concat(
|
||||
condition.condition_data.conditions.slice(i+1)
|
||||
)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
const data = (c as LogicCondition).condition_data;
|
||||
const update = {
|
||||
...condition.condition_data,
|
||||
conditions: [
|
||||
...condition.condition_data.conditions.slice(0, i),
|
||||
{
|
||||
...c,
|
||||
condition_data: {
|
||||
...data,
|
||||
conditions: data.conditions.slice(0, which).concat(data.conditions.concat(which+1))
|
||||
}
|
||||
},
|
||||
...condition.condition_data.conditions.slice(i+1)
|
||||
]
|
||||
}
|
||||
onChange({
|
||||
...condition,
|
||||
condition_data: update as any
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -1,141 +0,0 @@
|
||||
import { Styles } from "jss";
|
||||
import Color from 'chroma-js';
|
||||
import { createAppUseStyles } from "~/styles/theme";
|
||||
|
||||
export const useStyles = createAppUseStyles<{
|
||||
hasChildren: boolean
|
||||
}>(theme => {
|
||||
const deleteBtn: Styles = {
|
||||
borderRadius: '10px',
|
||||
borderStyle: 'none',
|
||||
padding: '0',
|
||||
margin: '0',
|
||||
background: theme.red,
|
||||
width: '30px',
|
||||
height: '15px',
|
||||
fontSize: '10px',
|
||||
textAlign: 'center',
|
||||
cursor: 'pointer',
|
||||
"&:hover": {
|
||||
background: theme.redAccent,
|
||||
}
|
||||
}
|
||||
return {
|
||||
root: ({ hasChildren }) => ({
|
||||
background: theme.primary,
|
||||
padding: 0,
|
||||
position: 'relative',
|
||||
display: 'flex',
|
||||
flexDirection: hasChildren? 'column' : 'row',
|
||||
alignItems: hasChildren ? undefined : 'flex-start',
|
||||
}),
|
||||
title: ({hasChildren}) => ({
|
||||
display: 'flex',
|
||||
border: hasChildren ? `1px solid ${theme.primaryAccent}` : 'none',
|
||||
borderRadius: 10,
|
||||
borderBottomRightRadius: 0,
|
||||
borderBottomLeftRadius: 0,
|
||||
}),
|
||||
titleText: ({hasChildren}) => ({
|
||||
background: theme.condition.primaryColor,
|
||||
border: `1px solid ${theme.primaryAccent}`,
|
||||
borderRadius: 10,
|
||||
borderTopRightRadius: 0,
|
||||
borderBottomRightRadius: 0,
|
||||
borderBottomLeftRadius: hasChildren ? 0 : 10,
|
||||
padding: 10,
|
||||
maxWidth: 120,
|
||||
minWidth: 30,
|
||||
textOverflow: 'ellipsis',
|
||||
textAlign: 'center',
|
||||
cursor: 'pointer',
|
||||
color: theme.primaryAccent,
|
||||
}),
|
||||
deleteBtnRoot: {
|
||||
...deleteBtn,
|
||||
position: 'absolute',
|
||||
left: -35,
|
||||
top: 10,
|
||||
},
|
||||
modifyBtn: ({hasChildren}) => ({
|
||||
// styling
|
||||
backgroundColor: theme.primary,
|
||||
fill: theme.primaryAccent,
|
||||
borderColor: theme.primaryAccent,
|
||||
borderWidth: 1,
|
||||
borderRadius: hasChildren ? 10 : 0,
|
||||
borderTopLeftRadius: 0,
|
||||
borderBottomLeftRadius: 0,
|
||||
cursor: 'pointer',
|
||||
|
||||
// positioning
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
padding: '0px 10px',
|
||||
// position: hasChildren ? 'absolute' : 'block',
|
||||
right: 1,
|
||||
top: 10,
|
||||
|
||||
// on hover
|
||||
"&:hover": {
|
||||
backgroundColor: Color(theme.primary).brighten().hex(),
|
||||
fill: Color(theme.primaryAccent).brighten().hex(),
|
||||
},
|
||||
"&:hover $icon": {
|
||||
transform: "rotate(90deg)"
|
||||
}
|
||||
}),
|
||||
icon: {
|
||||
transition: "200ms ease-out"
|
||||
},
|
||||
deleteBtn,
|
||||
children: ({hasChildren}) => ({
|
||||
flex: 1,
|
||||
paddingLeft: hasChildren ? 50 : 10,
|
||||
paddingRight: hasChildren ? 0 : 10,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'center',
|
||||
border: `1px solid ${theme.primaryAccent}`,
|
||||
borderBottomRightRadius: hasChildren ? 10 : 0,
|
||||
borderBottomLeftRadius: hasChildren ? 10 : 0,
|
||||
minHeight: hasChildren ? undefined : '100%'
|
||||
}),
|
||||
addBtnContainer: {
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
},
|
||||
yamlBtn: {
|
||||
backgroundColor: theme.secondary,
|
||||
borderWidth: 1,
|
||||
borderStyle: 'solid',
|
||||
borderColor: theme.secondaryAccent,
|
||||
color: theme.secondaryAccent,
|
||||
paddingLeft: 20,
|
||||
paddingRight: 20,
|
||||
cursor: 'pointer',
|
||||
"&:hover": {
|
||||
backgroundColor: Color(theme.primary).brighten().hex(),
|
||||
fill: Color(theme.primaryAccent).brighten().hex(),
|
||||
},
|
||||
},
|
||||
addBtn: {
|
||||
backgroundColor: theme.secondary,
|
||||
borderWidth: 1,
|
||||
borderStyle: 'solid',
|
||||
borderColor: theme.secondaryAccent,
|
||||
color: theme.secondaryAccent,
|
||||
borderRadius: 5,
|
||||
marginTop: 5,
|
||||
marginBottom: 5,
|
||||
paddingLeft: 20,
|
||||
paddingRight: 20,
|
||||
cursor: 'pointer',
|
||||
"&:hover": {
|
||||
backgroundColor: Color(theme.primary).brighten().hex(),
|
||||
fill: Color(theme.primaryAccent).brighten().hex(),
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -1,44 +0,0 @@
|
||||
import { FC } from "react";
|
||||
import { AutomationCondition, LogicCondition, TemplateCondition } from "~/automations/types/conditions";
|
||||
import { getDescriptionFromAutomationNode } from "~/automations/utils";
|
||||
import { ConditionNode } from "./ConditionNode";
|
||||
import { genUpdateMethods } from "./nestedUpdater";
|
||||
|
||||
|
||||
interface Viewer<C extends AutomationCondition> extends FC<{
|
||||
condition: C;
|
||||
onChange: (condition: C) => void;
|
||||
}> {}
|
||||
|
||||
export const getViewer = (condition: AutomationCondition): Viewer<any> => {
|
||||
if(
|
||||
(condition.condition === 'and') ||
|
||||
(condition.condition === 'or') ||
|
||||
(condition.condition === 'not')
|
||||
)
|
||||
{
|
||||
return LogicViewer
|
||||
}
|
||||
return GenericViewer
|
||||
}
|
||||
|
||||
export const GenericViewer: Viewer<AutomationCondition> = ({
|
||||
condition,
|
||||
}) => {
|
||||
return <>
|
||||
{getDescriptionFromAutomationNode(condition)}
|
||||
</>
|
||||
}
|
||||
|
||||
export const LogicViewer: Viewer<LogicCondition> = ({
|
||||
condition,
|
||||
onChange,
|
||||
}) => {
|
||||
return <>
|
||||
{condition.condition_data.conditions.map( (c, i) => {
|
||||
return <ConditionNode key={i} condition={c} displayMode
|
||||
{...genUpdateMethods(condition, onChange)(i)}
|
||||
/>
|
||||
} )}
|
||||
</>
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
import InputWrapper from "./InputWrapper";
|
||||
|
||||
export interface Props {
|
||||
label: string;
|
||||
value: boolean;
|
||||
onChange: (v: boolean) => void;
|
||||
}
|
||||
export default function InputBoolean({
|
||||
label,
|
||||
value=false,
|
||||
onChange,
|
||||
}: Props) {
|
||||
return <InputWrapper label={label} style={{
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'space-between',
|
||||
marginTop: '3%',
|
||||
marginBottom: '3%'
|
||||
}}>
|
||||
<span className="checkbox" onClick={e => {
|
||||
e.preventDefault()
|
||||
onChange(!value)
|
||||
}}>
|
||||
{value ? '✔️' : ' '}
|
||||
</span>
|
||||
</InputWrapper>
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { useState } from "react";
|
||||
import { usePageTheme } from "~/styles/page";
|
||||
import InputList from "./InputList";
|
||||
|
||||
export default {
|
||||
title: 'Inputs/InputList',
|
||||
component: InputList,
|
||||
parameters: { actions: { argTypesRegex: '^on.*' } },
|
||||
} as ComponentMeta<typeof InputList>;
|
||||
|
||||
|
||||
const Template: ComponentStory<typeof InputList> = args => {
|
||||
const {classes} = usePageTheme({});
|
||||
const [value, setValue] = useState('')
|
||||
return <div className={classes.page}>
|
||||
<InputList {...args} current={value} onChange={setValue}/>
|
||||
</div>
|
||||
}
|
||||
|
||||
export const SimpleText = Template.bind({})
|
||||
SimpleText.args = {
|
||||
label: "Entity ID",
|
||||
options: [
|
||||
'Bob',
|
||||
'Martin',
|
||||
"Toots"
|
||||
]
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
import InputWrapper from "./InputWrapper";
|
||||
import { useInputListStyles } from "./styles";
|
||||
|
||||
|
||||
export interface Props<T extends string> {
|
||||
current: T;
|
||||
options: readonly T[];
|
||||
onChange: (n: T) => void;
|
||||
id?: string;
|
||||
className?: string;
|
||||
label: string;
|
||||
}
|
||||
export default function InputList<T extends string>({
|
||||
current, options, onChange, label,
|
||||
...selattr
|
||||
}: Props<T>) {
|
||||
const {classes} = useInputListStyles({});
|
||||
return <InputWrapper label={label} labelSize={'small'} noMargin>
|
||||
<select
|
||||
className={classes.input}
|
||||
{...selattr} value={current}
|
||||
onChange={e => {
|
||||
e.preventDefault();
|
||||
onChange(e.currentTarget.value);
|
||||
}}
|
||||
>
|
||||
{options.map((t, i) => <option id={String(i)} key={i}>{t}</option>)}
|
||||
</select>
|
||||
</InputWrapper>
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { useState } from "react";
|
||||
import { usePageTheme } from "~/styles/page";
|
||||
import InputNumber from "./InputNumber";
|
||||
|
||||
export default {
|
||||
title: 'Inputs/InputNumber',
|
||||
component: InputNumber,
|
||||
parameters: { actions: { argTypesRegex: '^on.*' } },
|
||||
argTypes: {
|
||||
label: {
|
||||
defaultValue: 'Sample Title'
|
||||
}
|
||||
}
|
||||
} as ComponentMeta<typeof InputNumber>;
|
||||
|
||||
|
||||
export const NullStart: ComponentStory<typeof InputNumber> = args => {
|
||||
const {classes} = usePageTheme({});
|
||||
const [value, setValue] = useState<number | undefined>(undefined)
|
||||
return <div className={classes.page}>
|
||||
<InputNumber {...args} value={value} onChange={setValue}/>
|
||||
</div>
|
||||
}
|
||||
export const SomeStuffAtStart: ComponentStory<typeof InputNumber> = args => {
|
||||
const {classes} = usePageTheme({});
|
||||
const [value, setValue] = useState<number | undefined>(10)
|
||||
return <div className={classes.page}>
|
||||
<InputNumber {...args} value={value} onChange={setValue}/>
|
||||
</div>
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
// import { useState } from "react";
|
||||
import InputWrapper from "./InputWrapper";
|
||||
import { useInputNumberStyles } from "./styles";
|
||||
|
||||
export interface Props {
|
||||
label: string;
|
||||
value: number | undefined;
|
||||
onChange: (v: number | undefined) => void;
|
||||
}
|
||||
export default function InputNumber({
|
||||
label,
|
||||
value=undefined,
|
||||
onChange,
|
||||
}: Props) {
|
||||
const {classes} = useInputNumberStyles({});
|
||||
return <InputWrapper label={label} labelSize={value !== undefined ? 'small' : 'normal'}>
|
||||
<input
|
||||
className={classes.input}
|
||||
type="number"
|
||||
value={value ?? ""}
|
||||
onChange={e => {
|
||||
e.preventDefault();
|
||||
console.log(e.target.value)
|
||||
onChange(Number(e.target.value))
|
||||
}}
|
||||
/>
|
||||
{value && <button className={classes.deleteIcon} onClick={() => onChange(undefined)}>X</button>}
|
||||
</InputWrapper>
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { useState } from "react";
|
||||
import { usePageTheme } from "~/styles/page";
|
||||
import InputText from "./InputText";
|
||||
|
||||
export default {
|
||||
title: 'Inputs/InputText',
|
||||
component: InputText,
|
||||
parameters: { actions: { argTypesRegex: '^on.*' } },
|
||||
} as ComponentMeta<typeof InputText>;
|
||||
|
||||
|
||||
const Template: ComponentStory<typeof InputText> = args => {
|
||||
const {classes} = usePageTheme({});
|
||||
const [value, setValue] = useState('')
|
||||
return <div className={classes.page}>
|
||||
<InputText {...args} value={value} onChange={setValue}/>
|
||||
</div>
|
||||
}
|
||||
|
||||
export const SimpleText = Template.bind({})
|
||||
SimpleText.args = {
|
||||
label: "Entity ID",
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
import { PropsWithChildren, useState } from "react";
|
||||
import { useToolTip } from "~/tooltip/context";
|
||||
import InputWrapper from "./InputWrapper";
|
||||
import { useInputTextStyles } from "./styles";
|
||||
|
||||
export interface Props {
|
||||
textBoxFor?: string;
|
||||
label: string;
|
||||
value: string;
|
||||
onChange: (v: string) => void;
|
||||
onEnter?: () => void;
|
||||
additionalTooltipFilters?: Record<string, string>;
|
||||
}
|
||||
export default function InputText({
|
||||
label,
|
||||
textBoxFor,
|
||||
value="",
|
||||
onChange,
|
||||
onEnter=()=>{},
|
||||
additionalTooltipFilters={},
|
||||
children,
|
||||
}: PropsWithChildren<Props>) {
|
||||
const {classes} = useInputTextStyles({});
|
||||
const tooltip = useToolTip();
|
||||
const [isFocused, setIsFocused] = useState(false)
|
||||
return <InputWrapper label={label} labelSize={(value === '') && !isFocused ? 'normal' : 'small'}>
|
||||
<input
|
||||
className={classes.input}
|
||||
value={value}
|
||||
onKeyDown={e => {
|
||||
if (e.key === 'Enter') {
|
||||
onEnter();
|
||||
}
|
||||
}}
|
||||
onChange={e => {
|
||||
e.preventDefault();
|
||||
onChange(e.target.value)
|
||||
}}
|
||||
onBlur={e => {
|
||||
setIsFocused(false)
|
||||
}}
|
||||
onFocus={e => {
|
||||
setIsFocused(true)
|
||||
if(textBoxFor) {
|
||||
tooltip.setFocus(
|
||||
e.target.getBoundingClientRect(),
|
||||
{
|
||||
searchObject: textBoxFor,
|
||||
searchText: value,
|
||||
filterObjects: additionalTooltipFilters,
|
||||
},
|
||||
onChange
|
||||
)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{children}
|
||||
</InputWrapper>
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { useState } from "react";
|
||||
import { usePageTheme } from "~/styles/page";
|
||||
import InputTextArea from "./InputTextArea";
|
||||
|
||||
export default {
|
||||
title: 'Inputs/InputTextArea',
|
||||
component: InputTextArea,
|
||||
parameters: { actions: { argTypesRegex: '^on.*' } },
|
||||
} as ComponentMeta<typeof InputTextArea>;
|
||||
|
||||
|
||||
const Template: ComponentStory<typeof InputTextArea> = args => {
|
||||
const {classes} = usePageTheme({});
|
||||
const [value, setValue] = useState('')
|
||||
return <div className={classes.page}>
|
||||
<InputTextArea {...args} value={value} onChange={setValue}/>
|
||||
</div>
|
||||
}
|
||||
|
||||
export const SimpleText = Template.bind({})
|
||||
SimpleText.args = {
|
||||
label: "Entity ID",
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
import { useState } from "react";
|
||||
import { useToolTip } from "~/tooltip/context";
|
||||
import InputWrapper from "./InputWrapper";
|
||||
import { useInputTextAreaStyles } from "./styles";
|
||||
|
||||
export interface Props {
|
||||
textBoxFor?: string;
|
||||
label: string;
|
||||
value: string;
|
||||
onChange: (v: string) => void;
|
||||
additionalTooltipFilters?: Record<string, string>;
|
||||
resizable?: boolean;
|
||||
}
|
||||
export default function InputTextArea({
|
||||
label,
|
||||
textBoxFor,
|
||||
value="",
|
||||
onChange,
|
||||
additionalTooltipFilters={},
|
||||
resizable=false,
|
||||
}: Props) {
|
||||
const {classes} = useInputTextAreaStyles({ resizable });
|
||||
const tooltip = useToolTip();
|
||||
const [isFocused, setIsFocused] = useState(false)
|
||||
return <InputWrapper label={label} labelSize={(value === '') && !isFocused ? 'normal' : 'small'}>
|
||||
<textarea
|
||||
className={classes.input}
|
||||
value={value}
|
||||
onChange={e => {
|
||||
e.preventDefault();
|
||||
onChange(e.target.value)
|
||||
}}
|
||||
onBlur={e => {
|
||||
setIsFocused(false)
|
||||
}}
|
||||
onFocus={e => {
|
||||
setIsFocused(true)
|
||||
if(textBoxFor) {
|
||||
tooltip.setFocus(
|
||||
e.target.getBoundingClientRect(),
|
||||
{
|
||||
searchObject: textBoxFor,
|
||||
searchText: value,
|
||||
filterObjects: additionalTooltipFilters,
|
||||
},
|
||||
onChange
|
||||
)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</InputWrapper>
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { useState } from "react";
|
||||
import { usePageTheme } from "~/styles/page";
|
||||
import InputTextBubble, { InputEntity } from "./InputTextBubble";
|
||||
|
||||
export default {
|
||||
title: 'Inputs/InputTextBubble',
|
||||
component: InputTextBubble,
|
||||
parameters: { actions: { argTypesRegex: '^on.*' } },
|
||||
argTypes: {
|
||||
label: {
|
||||
defaultValue: 'Sample Title'
|
||||
}
|
||||
}
|
||||
} as ComponentMeta<typeof InputTextBubble>;
|
||||
|
||||
|
||||
export const ArrayText: ComponentStory<typeof InputTextBubble> = args => {
|
||||
const {classes} = usePageTheme({});
|
||||
const [value, setValue] = useState<string | string[]>(['wow','lots of bubbles', 'itchen', 'bathroom'])
|
||||
return <div className={classes.page}>
|
||||
<div style={{maxWidth: '200px', overflow: 'hidden'}}>
|
||||
<InputTextBubble {...args} value={value} onChange={setValue}/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
export const JustText: ComponentStory<typeof InputTextBubble> = args => {
|
||||
const {classes} = usePageTheme({});
|
||||
const [value, setValue] = useState<string | string[]>('hello')
|
||||
return <div className={classes.page}>
|
||||
<InputTextBubble {...args} value={value} onChange={setValue}/>
|
||||
</div>
|
||||
}
|
||||
|
||||
|
||||
export const EntityId: ComponentStory<typeof InputTextBubble> = args => {
|
||||
const {classes} = usePageTheme({});
|
||||
const [value, setValue] = useState<string | string[]>(['sensor.bathroom'])
|
||||
return <div className={classes.page}>
|
||||
<InputEntity value={value} onChange={setValue}/>
|
||||
</div>
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
import { FC, useState } from "react";
|
||||
import { useToolTip } from "~/tooltip/context";
|
||||
import InputText from "./InputText";
|
||||
import InputWrapper from "./InputWrapper";
|
||||
import { useInputBubblesStyles, useInputTextStyles } from "./styles";
|
||||
|
||||
export interface Props {
|
||||
label: string;
|
||||
textBoxFor?: string;
|
||||
value: string | string[];
|
||||
onChange: (v: string[]) => void;
|
||||
additionalTooltipFilters?: Record<string, string>;
|
||||
}
|
||||
export default function InputTextBubble({
|
||||
value="",
|
||||
label,
|
||||
textBoxFor,
|
||||
onChange,
|
||||
additionalTooltipFilters={},
|
||||
}: Props) {
|
||||
const {classes} = useInputBubblesStyles({});
|
||||
let selected: string[];
|
||||
if (typeof value === 'string') {
|
||||
selected = [value]
|
||||
} else {
|
||||
selected = value
|
||||
}
|
||||
const [text, setText] = useState('');
|
||||
const addNew = () => {
|
||||
if(text) {
|
||||
onChange([text].concat(selected))
|
||||
setText("")
|
||||
}
|
||||
};
|
||||
|
||||
return <InputText
|
||||
label={label}
|
||||
value={text}
|
||||
textBoxFor={textBoxFor}
|
||||
onChange={t => setText(t)}
|
||||
onEnter={() => addNew()}
|
||||
additionalTooltipFilters={additionalTooltipFilters}
|
||||
>
|
||||
<div className={classes.bubbles}>
|
||||
{selected.map((s, i) => <div className={classes.bubble} onClick={() => onChange([
|
||||
...selected.slice(0, i),
|
||||
...selected.slice(i+1),
|
||||
])}>
|
||||
{s}
|
||||
<span className={classes.deleteIcon}>X</span>
|
||||
</div>)}
|
||||
</div>
|
||||
<button className={classes.addBtn} onClick={() => addNew()}>+</button>
|
||||
</InputText>
|
||||
}
|
||||
|
||||
export const InputEntity: FC<{
|
||||
value: string | string[];
|
||||
onChange: (v: string[]) => void;
|
||||
}> = ({
|
||||
value,
|
||||
onChange,
|
||||
}) => <InputTextBubble
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
label="Entity ID"
|
||||
textBoxFor="entity_id"
|
||||
/>
|
||||
@@ -1,16 +0,0 @@
|
||||
import { PropsWithChildren } from "react";
|
||||
import { useInputWrapperStyles } from "./styles";
|
||||
|
||||
|
||||
export interface Props {
|
||||
label: string;
|
||||
labelSize?: 'normal' | 'small';
|
||||
noMargin?: boolean;
|
||||
}
|
||||
export default function InputWrapper({label, children, labelSize='normal', noMargin=false}: PropsWithChildren<Props>) {
|
||||
const {classes} = useInputWrapperStyles({labelSize, noMargin})
|
||||
return <div className={classes.wrapper}>
|
||||
<label className={classes.label}>{label}</label>
|
||||
{children}
|
||||
</div>
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { useState } from "react";
|
||||
import { usePageTheme } from "~/styles/page";
|
||||
import InputYaml from "./InputYaml";
|
||||
|
||||
export default {
|
||||
title: 'Inputs/InputYaml',
|
||||
component: InputYaml,
|
||||
parameters: { actions: { argTypesRegex: '^on.*' } },
|
||||
} as ComponentMeta<typeof InputYaml>;
|
||||
|
||||
|
||||
const Template: ComponentStory<typeof InputYaml> = args => {
|
||||
const {classes} = usePageTheme({});
|
||||
const [value, setValue] = useState({
|
||||
"test": "data"
|
||||
})
|
||||
return <div className={classes.page}>
|
||||
<InputYaml {...args} value={value} onChange={setValue}/>
|
||||
</div>
|
||||
}
|
||||
|
||||
export const SimpleText = Template.bind({})
|
||||
SimpleText.args = {
|
||||
label: "Template",
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
import InputWrapper from "./InputWrapper";
|
||||
import * as yaml from "js-yaml";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import InputTextArea from "./InputTextArea";
|
||||
|
||||
export interface Props<T extends {}> {
|
||||
label: string;
|
||||
value: T;
|
||||
onChange: (v: T) => void;
|
||||
resizable?: boolean;
|
||||
}
|
||||
export default function InputYaml<T>({
|
||||
label,
|
||||
value={} as any,
|
||||
onChange,
|
||||
resizable,
|
||||
}: Props<T>) {
|
||||
const [text, setText] = useState("");
|
||||
useEffect(() => {
|
||||
setText(yaml.dump(value));
|
||||
}, [value]);
|
||||
const delayId = useRef<null | number>(null);
|
||||
const delayedUpdate = (update: string) => {
|
||||
setText(update)
|
||||
if (delayId.current) {
|
||||
window.clearTimeout(delayId.current);
|
||||
delayId.current = null;
|
||||
}
|
||||
delayId.current = window.setTimeout(() => {
|
||||
onChange(yaml.load(update) as any)
|
||||
}, 1000);
|
||||
}
|
||||
return <InputTextArea
|
||||
label={label}
|
||||
value={text}
|
||||
onChange={delayedUpdate}
|
||||
resizable={resizable}
|
||||
/>
|
||||
}
|
||||
Whitespace-only changes.
@@ -1,179 +0,0 @@
|
||||
import { createAppUseStyles, AppTheme } from "~/styles/theme";
|
||||
import Color from 'chroma-js';
|
||||
|
||||
const commonInputStyle = (theme: AppTheme) => ({
|
||||
input: {
|
||||
backgroundColor: theme.secondary,
|
||||
color: theme.secondaryAccent,
|
||||
borderColor: theme.primaryAccent,
|
||||
borderStyle: 'solid',
|
||||
borderWidth: 1,
|
||||
borderRadius: 5,
|
||||
padding: 15,
|
||||
marginLeft: 5,
|
||||
marginRight: 5,
|
||||
fontSize: 16,
|
||||
|
||||
"&:hover": {
|
||||
backgroundColor: theme.primary,
|
||||
borderColor: theme.secondaryAccent,
|
||||
},
|
||||
"&:disabled": {
|
||||
backgroundColor: '#403f3f',
|
||||
borderColor: '#403f3f',
|
||||
color: '#403f3faa',
|
||||
cursor: 'not-allowed',
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
export const useInputWrapperStyles = createAppUseStyles<{
|
||||
labelSize: 'normal' | 'small',
|
||||
noMargin: boolean,
|
||||
}>(theme => {
|
||||
return {
|
||||
wrapper: ({ noMargin }) => ({
|
||||
position: 'relative',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
marginTop: noMargin ? 0 : 10,
|
||||
marginBottom: noMargin ? 0 : '0.25em',
|
||||
}),
|
||||
label: ({ labelSize }) => ({
|
||||
fontSize: labelSize === 'normal' ? 16 : 10,
|
||||
position: 'absolute',
|
||||
left: labelSize === 'normal' ? '0.75em': '1em',
|
||||
top: labelSize === 'normal' ? '0.5em' : '0.25em',
|
||||
fontWeight: 'bold',
|
||||
transition: 'all 200ms',
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
export const useInputTextStyles = createAppUseStyles<{}>(theme => ({
|
||||
...commonInputStyle(theme),
|
||||
}));
|
||||
|
||||
export const useInputNumberStyles = createAppUseStyles<{}>(theme => {
|
||||
const styles = commonInputStyle(theme);
|
||||
return {
|
||||
input: {
|
||||
...styles.input,
|
||||
textAlign: 'center'
|
||||
},
|
||||
deleteIcon: {
|
||||
position: "absolute",
|
||||
left: 30,
|
||||
top: 17,
|
||||
color: theme.secondaryAccent,
|
||||
backgroundColor: theme.secondary,
|
||||
borderWidth: 1,
|
||||
borderStyle: 'solid',
|
||||
borderColor: theme.secondaryAccent,
|
||||
borderRadius: 5,
|
||||
cursor: 'pointer',
|
||||
padding: "1px 5px",
|
||||
"&:hover": {
|
||||
backgroundColor: theme.primary,
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
export const useInputListStyles = createAppUseStyles<{}>(theme => {
|
||||
const styles = commonInputStyle(theme);
|
||||
return {
|
||||
input: {
|
||||
...styles.input,
|
||||
cursor: 'pointer'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export const useInputTextAreaStyles = createAppUseStyles<{ resizable: boolean }>(theme => {
|
||||
const styles = commonInputStyle(theme);
|
||||
return {
|
||||
input: ({resizable}) => ({
|
||||
...styles.input,
|
||||
resize: resizable ? 'both' : 'none'
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
export const useInputViewEditStyles = createAppUseStyles<{
|
||||
isEditing: boolean;
|
||||
}>(theme => ({
|
||||
...commonInputStyle(theme),
|
||||
inputView: {
|
||||
|
||||
},
|
||||
checkmark: {
|
||||
|
||||
},
|
||||
pencil: {
|
||||
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
export const useInputBubblesStyles = createAppUseStyles<{}>(theme => ({
|
||||
bubbles: {
|
||||
display: 'flex',
|
||||
flexDirection: 'row',
|
||||
maxHeight: 50,
|
||||
maxWidth: '100%',
|
||||
overflowX: 'auto',
|
||||
overflowY: 'hidden',
|
||||
scrollbarWidth: 'thin',
|
||||
},
|
||||
bubble: {
|
||||
position: 'relative',
|
||||
border: `1px solid ${theme.primaryAccent}`,
|
||||
borderRadius: 10,
|
||||
backgroundColor: Color(theme.primary).set('rgb.g', 150).alpha(0.35).hex(),
|
||||
color: Color(theme.primary).brighten(5).hex(),
|
||||
fontSize: 16,
|
||||
|
||||
marginLeft: 1,
|
||||
padding: 5,
|
||||
width: 'fit-content',
|
||||
whiteSpace: 'nowrap',
|
||||
|
||||
cursor: 'pointer',
|
||||
"&:hover": {
|
||||
backgroundColor: Color(theme.primary).set('rgb.r', 150).alpha(0.35).hex(),
|
||||
color: Color(theme.primary).brighten(5).alpha(0.35).hex(),
|
||||
},
|
||||
|
||||
"&:hover $deleteIcon": {
|
||||
display: 'block',
|
||||
}
|
||||
},
|
||||
deleteIcon: {
|
||||
display: 'none',
|
||||
position: "absolute",
|
||||
left: "48%",
|
||||
top: 5,
|
||||
color: "white",
|
||||
},
|
||||
addBtn: {
|
||||
position: "absolute",
|
||||
top: 10,
|
||||
right: 10,
|
||||
fontSize: 20,
|
||||
cursor: 'pointer',
|
||||
borderStyle: 'solid',
|
||||
borderWidth: 1,
|
||||
borderColor: theme.secondary,
|
||||
backgroundColor: theme.secondary,
|
||||
color: theme.secondaryAccent,
|
||||
padding: "3px 7px",
|
||||
transition: "200ms ease-out",
|
||||
"&:hover": {
|
||||
borderRadius: 100,
|
||||
backgroundColor: Color(theme.primary).set('rgb.g', 150).alpha(0.35).hex(),
|
||||
borderColor: theme.secondaryAccent,
|
||||
},
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
import { AnchorHTMLAttributes, FC } from "react";
|
||||
import { createAppUseStyles } from "~/styles/theme";
|
||||
|
||||
|
||||
|
||||
export const useIconStyles = createAppUseStyles<{size: number, color?: string}>(theme => ({
|
||||
icon: ({size}) => ({
|
||||
height: `${size}em`,
|
||||
width: `${size}em`,
|
||||
display: 'flex',
|
||||
}),
|
||||
svg: ({color=theme.primaryAccent}) => ({
|
||||
fill: color
|
||||
})
|
||||
}))
|
||||
|
||||
export type IconBaseProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
|
||||
size?: number;
|
||||
color?: string;
|
||||
}
|
||||
export const IconBase: FC<IconBaseProps & { viewBox: string }> = ({
|
||||
children,
|
||||
viewBox,
|
||||
size=1,
|
||||
color,
|
||||
className="",
|
||||
...props
|
||||
}) => {
|
||||
const {classes} = useIconStyles({ size, color });
|
||||
return <a className={`${classes.icon} ${className}`} {...props}>
|
||||
<svg className={classes.svg} version="1.1" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox={viewBox}>
|
||||
<g>
|
||||
{children}
|
||||
</g>
|
||||
</svg>
|
||||
</a>
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
import { ComponentStory } from "@storybook/react";
|
||||
import { usePageTheme } from "~/styles/page";
|
||||
import { IconBase } from "./IconBase";
|
||||
import {PencilIcon, CheckMarkIcon} from "./icons";
|
||||
|
||||
export default {
|
||||
title: 'Icons',
|
||||
component: IconBase,
|
||||
};
|
||||
|
||||
|
||||
export const IconList: ComponentStory<typeof IconBase> = (args) => {
|
||||
const {classes} = usePageTheme({});
|
||||
return <div className={classes.page}>
|
||||
<PencilIcon {...args}/>
|
||||
<CheckMarkIcon {...args}/>
|
||||
</div>
|
||||
}
|
||||
IconList.args = {
|
||||
size: 2,
|
||||
color: 'red'
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import { FC } from "react";
|
||||
import { IconBase, IconBaseProps } from "./IconBase";
|
||||
|
||||
|
||||
export const PencilIcon: FC<IconBaseProps> = props => <IconBase {...props} viewBox="0 0 512 512">
|
||||
<path d="M358.752,51.159L70.113,339.798l102.063,102.064L455.088,158.95L512,0.282L358.752,51.159z M172.176,419.287
|
||||
l-79.488-79.489L349.536,82.949l0.069,11.622l22.52-0.089l0.089,22.667l22.625,0.048l-0.048,22.691l22.467-0.271l0.27,22.847
|
||||
l11.538-0.068L172.176,419.287z M442.648,146.351l-9.345,0.055l-0.27-22.946l-22.244,0.269l0.048-22.464l-22.721-0.048
|
||||
l-0.091-22.764l-22.551,0.089l-0.068-11.463l1.963-1.963l75.812-25.169l4.761,23.811l22.704,4.541L442.648,146.351z
|
||||
M461.506,50.195l-3.062-15.313l27.457-9.116l-9.808,27.346L461.506,50.195z"/>
|
||||
|
||||
<rect x="37.686" y="394.032" transform="matrix(-0.7071 -0.7071 0.7071 -0.7071 -97.0284 763.8365)" width="143.992" height="15.962"/>
|
||||
<path d="M10.388,399.522c-13.851,13.852-13.851,36.391,0,50.244l51.546,51.545c6.711,6.711,15.632,10.406,25.122,10.406
|
||||
s18.412-3.696,25.122-10.406l37.073-37.073L47.462,362.45L10.388,399.522z M100.891,490.025
|
||||
c-3.695,3.696-8.608,5.731-13.834,5.731s-10.139-2.036-13.834-5.731L21.676,438.48c-7.629-7.628-7.629-20.042,0-27.67
|
||||
l25.785-25.785l79.215,79.216L100.891,490.025z"/>
|
||||
</IconBase>;
|
||||
|
||||
export const CheckMarkIcon: FC<IconBaseProps> = props => <IconBase {...props} viewBox="0 0 24 24">
|
||||
<path d="M20.285 2l-11.285 11.567-5.286-5.011-3.714 3.716 9 8.728 15-15.285z"/>
|
||||
</IconBase>;
|
||||
@@ -1,31 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta
|
||||
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
|
||||
name="viewport"
|
||||
/>
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
|
||||
<meta name="mobile-web-app-capable" content="yes" />
|
||||
|
||||
<meta name="application-name" content="MurderFriends" />
|
||||
<meta name="apple-mobile-web-app-title" content="MurderFriends" />
|
||||
|
||||
<meta name="msapplication-starturl" content="/" />
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, shrink-to-fit=no"
|
||||
/>
|
||||
|
||||
<link rel="stylesheet" href="scss_styles/index.scss" />
|
||||
|
||||
<title>Shortumation</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="app"></div>
|
||||
<script src="main.tsx" type="module"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,6 +0,0 @@
|
||||
import ReactDOM from "react-dom";
|
||||
import App from "./router";
|
||||
|
||||
const app = document.getElementById("app");
|
||||
|
||||
ReactDOM.render(<App />, app);
|
||||
@@ -1,89 +0,0 @@
|
||||
import { useState } from "react";
|
||||
import { ConditionEditor } from "~/components/ConditionEditor";
|
||||
import { usePageTheme } from "~/styles/page";
|
||||
import { AutomationData } from "../automations/types";
|
||||
import AutomationEditor from "../components/AutomationEditor";
|
||||
|
||||
export function Home() {
|
||||
const {classes} = usePageTheme({});
|
||||
const [automation, setAutomation] = useState<AutomationData>({
|
||||
metadata: {
|
||||
id: "X12314akx",
|
||||
alias: "root",
|
||||
description: 'Really Long Description',
|
||||
mode: 'single',
|
||||
},
|
||||
trigger: [
|
||||
{
|
||||
platform: 'time',
|
||||
at: '10:00:00'
|
||||
},
|
||||
{
|
||||
platform: "device",
|
||||
device_id: "34749",
|
||||
domain: "zha",
|
||||
type: "remote_button_double_press",
|
||||
subtype: "remote_button_double_press"
|
||||
}
|
||||
],
|
||||
sequence: [
|
||||
{
|
||||
$smType: "condition",
|
||||
condition: 'and',
|
||||
condition_data: {
|
||||
conditions: [
|
||||
{
|
||||
$smType: 'condition',
|
||||
condition: 'numeric_state',
|
||||
condition_data: {
|
||||
entity_id: 'sensor.temperature_kitchen',
|
||||
below: '15',
|
||||
}
|
||||
},
|
||||
{
|
||||
$smType: "condition",
|
||||
condition: 'template',
|
||||
condition_data: {
|
||||
value_template: 'states(switch.kitchen_light) == "on"'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
$smType: "action",
|
||||
action: "service",
|
||||
action_data: {
|
||||
alias: "Start Music In Kitchen",
|
||||
service: 'media_player.play_media',
|
||||
target: {
|
||||
entity_id: "media_player.kitchen_dot"
|
||||
},
|
||||
data: {
|
||||
media_content_id: "Good Morning",
|
||||
media_content_type: "SPOTIFY",
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
});
|
||||
return (
|
||||
<div className={classes.page}>
|
||||
{/* <AutomationEditor
|
||||
automation={automation}
|
||||
onUpdate={setAutomation}
|
||||
/> */}
|
||||
<ConditionEditor
|
||||
onAddChild={() => {}}
|
||||
onDelete={() => {}}
|
||||
condition={{
|
||||
$smType: 'condition',
|
||||
condition: 'template',
|
||||
condition_data: {
|
||||
value_template: "states(asdacaca) is 'on'"
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
import { useState } from "react";
|
||||
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
|
||||
import { Home } from "./pages/Home";
|
||||
import Tooltip from "./tooltip";
|
||||
import { TooltipContext, TooltipState } from "./tooltip/context";
|
||||
|
||||
export default function App() {
|
||||
const [tooltipState, updateState] = useState<TooltipState>({
|
||||
updateState(s) { updateState(s) },
|
||||
searchResults: [
|
||||
"Option #1"
|
||||
],
|
||||
});
|
||||
return (
|
||||
<Router>
|
||||
<TooltipContext.Provider value={tooltipState}>
|
||||
<div>
|
||||
<Switch>
|
||||
<Route path="/">
|
||||
<Home />
|
||||
</Route>
|
||||
</Switch>
|
||||
</div>
|
||||
<Tooltip {...tooltipState}/>
|
||||
</TooltipContext.Provider>
|
||||
</Router>
|
||||
);
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
alias: On Balcony Door Open
|
||||
description: "Determines what to do when the door opens..."
|
||||
trigger:
|
||||
- type: opened
|
||||
platform: device
|
||||
device_id: bad6b55ae91b7ced810fd5310c0a0fce
|
||||
entity_id: binary_sensor.door_balcony
|
||||
domain: binary_sensor
|
||||
condition:
|
||||
- condition: and
|
||||
conditions:
|
||||
- condition: not
|
||||
conditions:
|
||||
- condition: template
|
||||
value_template: "{{ states('switch.plug_out_bug_lamp') == 'unavailable' }}"
|
||||
- condition: time
|
||||
after: "10:00:00"
|
||||
action:
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: "{{ states('switch.plug_out_bug_lamp') == 'unavailable' }}"
|
||||
sequence:
|
||||
- type: turn_on
|
||||
device_id: 03065414e37dafc42ce0597f5458a084
|
||||
entity_id: switch.plug_balcony_power
|
||||
domain: switch
|
||||
- wait_template: "{{ states('switch.plug_out_bug_lamp') != 'unavailable' }}"
|
||||
timeout: "00:05:00"
|
||||
- type: turn_on
|
||||
device_id: 687cb5b66de19eaab5eb64cbaad90c58
|
||||
entity_id: switch.plug_out_bug_lamp
|
||||
domain: switch
|
||||
default:
|
||||
- type: turn_on
|
||||
device_id: 687cb5b66de19eaab5eb64cbaad90c58
|
||||
entity_id: switch.plug_out_bug_lamp
|
||||
domain: switch
|
||||
mode: single
|
||||
@@ -1,10 +0,0 @@
|
||||
$primary: #111111;
|
||||
$secondary: #1c1c1c;
|
||||
$primary-accent: #bbbbbb;
|
||||
$secondary-accent: #929191;
|
||||
|
||||
$font-color-primary: #e1e1e1;
|
||||
|
||||
$gray: #403f3f;
|
||||
$green: #68caa4;
|
||||
$blue: #68aaca;
|
||||
@@ -1,125 +0,0 @@
|
||||
html,
|
||||
body,
|
||||
#app {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100vh;
|
||||
width: 100vw;
|
||||
overflow: hidden;
|
||||
font-family: Tahoma, Geneva, sans-serif;
|
||||
background-color: $primary;
|
||||
display: grid;
|
||||
align-items: center;
|
||||
justify-items: center;
|
||||
color: $font-color-primary;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5 {
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
display: flex;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* width */
|
||||
::-webkit-scrollbar {
|
||||
width: 10px;
|
||||
}
|
||||
|
||||
/* Track */
|
||||
::-webkit-scrollbar-track {
|
||||
background: $secondary;
|
||||
}
|
||||
|
||||
/* Handle */
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: $secondary-accent;
|
||||
}
|
||||
|
||||
/* Handle on hover */
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: $primary-accent;
|
||||
}
|
||||
|
||||
:root {
|
||||
touch-action: pan-x pan-y;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
button {
|
||||
background-color: $secondary;
|
||||
color: $primary-accent;
|
||||
border-color: $primary-accent;
|
||||
|
||||
&:hover {
|
||||
background-color: $primary;
|
||||
border-color: $secondary-accent;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
background-color: $gray;
|
||||
border-color: $gray;
|
||||
color: darken($gray, 50);
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
&.secondary {
|
||||
background-color: $primary;
|
||||
color: $secondary-accent;
|
||||
border-color: $secondary-accent;
|
||||
&:hover {
|
||||
background-color: $secondary;
|
||||
border-color: $primary-accent;
|
||||
}
|
||||
}
|
||||
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
padding: 2.5px;
|
||||
margin-left: 5px;
|
||||
margin-right: 5px;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
select {
|
||||
@extend button;
|
||||
margin: 0;
|
||||
}
|
||||
input {
|
||||
@extend button;
|
||||
margin: 0;
|
||||
cursor: text;
|
||||
}
|
||||
input[type="number"]::-webkit-inner-spin-button,
|
||||
::-webkit-outer-spin-button {
|
||||
opacity: 0;
|
||||
}
|
||||
textarea {
|
||||
@extend button;
|
||||
cursor: text;
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
}
|
||||
span.checkbox {
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
cursor: pointer;
|
||||
border: 1px $primary-accent solid;
|
||||
align-content: center;
|
||||
text-align: center;
|
||||
justify-content: center;
|
||||
display: flex;
|
||||
background-color: $primary;
|
||||
color: $primary-accent;
|
||||
overflow: hidden;
|
||||
|
||||
&:hover {
|
||||
background-color: $secondary;
|
||||
color: $secondary-accent;
|
||||
}
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
.automation-editor {
|
||||
height: 99%;
|
||||
width: 99%;
|
||||
color: $primary-accent;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
&-dag {
|
||||
border: 1px solid $secondary-accent;
|
||||
width: 100%;
|
||||
svg {
|
||||
height: 99%;
|
||||
width: 99%;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
|
||||
circle {
|
||||
fill: adjust-color($color: $secondary, $green: 125, $blue: 125);
|
||||
&.blue {
|
||||
fill: adjust-color($color: $secondary, $blue: 125);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&-info-box {
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
overflow: auto;
|
||||
}
|
||||
.edge {
|
||||
stroke: $secondary-accent;
|
||||
}
|
||||
#arrow > path {
|
||||
fill: $secondary-accent;
|
||||
}
|
||||
span {
|
||||
font-size: 8px;
|
||||
}
|
||||
|
||||
&--node {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
background-color: $secondary;
|
||||
border-radius: 1em;
|
||||
height: 100%;
|
||||
max-height: 100%;
|
||||
max-width: 100%;
|
||||
width: 100%;
|
||||
|
||||
&-inner {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex: 1;
|
||||
|
||||
&.top-color {
|
||||
&.red {
|
||||
border-top-color: adjust-color($color: $secondary, $red: 125);
|
||||
}
|
||||
&.blue {
|
||||
border-top-color: adjust-color($color: $secondary, $blue: 125);
|
||||
}
|
||||
&.green {
|
||||
border-top-color: adjust-color($color: $secondary, $green: 125);
|
||||
}
|
||||
|
||||
border-top-width: 1px;
|
||||
border-top-style: solid;
|
||||
border-top-left-radius: 10px;
|
||||
border-top-right-radius: 10px;
|
||||
}
|
||||
|
||||
&-text {
|
||||
flex: 2;
|
||||
display: flex;
|
||||
text-align: center;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
&-edge {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: nowrap;
|
||||
border-radius: 1em;
|
||||
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
|
||||
&.left {
|
||||
border-left: 1px $secondary-accent solid;
|
||||
border-top-right-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
&.right {
|
||||
border-right: 1px $secondary-accent solid;
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
&:hover {
|
||||
background-color: $primary-accent;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
.input-wrapper {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 0.25em;
|
||||
|
||||
label {
|
||||
font-size: 10px;
|
||||
position: absolute;
|
||||
left: 0.75em;
|
||||
top: 0.5em;
|
||||
font-weight: bold;
|
||||
}
|
||||
select,
|
||||
textarea,
|
||||
input {
|
||||
padding-top: 16px;
|
||||
padding-left: 8px;
|
||||
resize: none;
|
||||
}
|
||||
// .input-view {
|
||||
// @extend input;
|
||||
// cursor: default;
|
||||
// }
|
||||
// a.icon {
|
||||
// cursor: pointer;
|
||||
// position: absolute;
|
||||
// right: 0.5em;
|
||||
// top: 0.5em;
|
||||
|
||||
// &:hover {
|
||||
// transform: rotate(90deg);
|
||||
// > svg {
|
||||
// fill: $secondary-accent;
|
||||
// }
|
||||
// }
|
||||
|
||||
// &.opened {
|
||||
// transform: rotate(360deg);
|
||||
// height: 0.5em;
|
||||
// right: 0.25em;
|
||||
// &.checkmark {
|
||||
// opacity: 1;
|
||||
// z-index: 1;
|
||||
// }
|
||||
// &.pencil {
|
||||
// opacity: 0;
|
||||
// z-index: -1;
|
||||
// }
|
||||
// }
|
||||
|
||||
// &.pencil {
|
||||
// opacity: 1;
|
||||
// z-index: 1;
|
||||
// }
|
||||
// &.checkmark {
|
||||
// opacity: 0;
|
||||
// z-index: -1;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
.new-node-modal {
|
||||
position: absolute;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
left: 0;
|
||||
top: 0;
|
||||
&--background {
|
||||
position: absolute;
|
||||
z-index: 0;
|
||||
width: 100vw;
|
||||
height: 100vw;
|
||||
background-color: rgba($secondary, 0.5);
|
||||
}
|
||||
|
||||
&--inner {
|
||||
z-index: 1;
|
||||
max-width: 80%;
|
||||
max-height: 60%;
|
||||
min-height: 200px;
|
||||
min-width: 200px;
|
||||
border-radius: 20px;
|
||||
padding: 15px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background-color: $primary;
|
||||
border: 1px solid $primary-accent;
|
||||
}
|
||||
&--title {
|
||||
text-align: center;
|
||||
padding: 10px;
|
||||
font-weight: bold;
|
||||
}
|
||||
&--body {
|
||||
flex-grow: 1;
|
||||
}
|
||||
&--footer {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
.state-manager-options {
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
@import "./NewNodeModal.scss";
|
||||
@import "./InputWrapper.scss";
|
||||
@import "./AutomationDAG.scss";
|
||||
|
||||
* {
|
||||
transition: all 200ms ease-in;
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
a.icon {
|
||||
height: 1em;
|
||||
width: 1em;
|
||||
display: flex;
|
||||
svg {
|
||||
fill: $primary-accent;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
@import "./colors.scss";
|
||||
@import "./pages/index.scss";
|
||||
@import "./utils.scss";
|
||||
@import "./common.scss";
|
||||
@import "./components/index.scss";
|
||||
@import "./tooltip.scss";
|
||||
@import "./icons.scss";
|
||||
@@ -1,4 +0,0 @@
|
||||
#page--home {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
@import "./Home.scss";
|
||||
|
||||
.page {
|
||||
height: 100vh;
|
||||
width: 100vw;
|
||||
overflow: hidden;
|
||||
font-size: 16px;
|
||||
color: $font-color-primary;
|
||||
max-width: 100vw;
|
||||
max-height: 100vh;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
> div {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
.tooltip {
|
||||
&.hide {
|
||||
width: 0;
|
||||
height: 0;
|
||||
display: none;
|
||||
}
|
||||
&-bg {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
z-index: 9;
|
||||
}
|
||||
ul {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
z-index: 10;
|
||||
|
||||
li {
|
||||
@extend button;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
.box {
|
||||
background-color: $secondary;
|
||||
max-width: 80%;
|
||||
max-height: 30%;
|
||||
min-width: 80%;
|
||||
min-height: 30%;
|
||||
border-radius: 10px;
|
||||
padding: 10px;
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
import 'jest-extended'
|
||||
import '@testing-library/jest-dom'
|
||||
@@ -1 +0,0 @@
|
||||
module.exports = {}
|
||||
@@ -1,46 +0,0 @@
|
||||
import { createAppUseStyles } from "./theme";
|
||||
|
||||
export const usePageTheme = createAppUseStyles(theme => ({
|
||||
page: {
|
||||
// dims
|
||||
height: '100vh',
|
||||
width: '100vw',
|
||||
margin: 0,
|
||||
padding: 0,
|
||||
overflow: 'auto',
|
||||
maxWidth: '100vw',
|
||||
maxHeight: '100vh',
|
||||
|
||||
// font
|
||||
fontSize: '16px',
|
||||
fontFamily: 'Tahoma, Geneva, sans-serif',
|
||||
color: theme.primaryAccent,
|
||||
|
||||
// background
|
||||
backgroundColor: theme.primary,
|
||||
|
||||
// children
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-start',
|
||||
alignItems: 'center',
|
||||
|
||||
'> div': {
|
||||
flex: 1,
|
||||
},
|
||||
|
||||
// scroll
|
||||
'&::-webkit-scrollbar': {
|
||||
width: '10px'
|
||||
},
|
||||
'&::-webkit-scrollbar-track': {
|
||||
background: theme.secondary,
|
||||
},
|
||||
'&::-webkit-scrollbar-thumb': {
|
||||
background: theme.secondaryAccent,
|
||||
},
|
||||
'&::-webkit-scrollbar-thumb:hover': {
|
||||
background: theme.primaryAccent,
|
||||
},
|
||||
}
|
||||
}))
|
||||
@@ -1,37 +0,0 @@
|
||||
import { Classes } from "jss";
|
||||
import { Context, createContext } from "react"
|
||||
import { createUseStyles, Styles } from "react-jss";
|
||||
import { createTheming } from "theming"
|
||||
// import Color from 'color';
|
||||
|
||||
export const {
|
||||
context: ThemeContext,
|
||||
ThemeProvider,
|
||||
useTheme,
|
||||
} = createTheming(createContext({
|
||||
primary: '#111111',
|
||||
secondary: '#1c1c1c',
|
||||
primaryAccent: '#bbbbbb',
|
||||
secondaryAccent: '#929191',
|
||||
condition: {
|
||||
primaryColor: '#4f4f77',
|
||||
},
|
||||
red: '#ed0c0c',
|
||||
redAccent: '#9f3a3a',
|
||||
}));
|
||||
|
||||
export type GetThemeType<C extends Context<any>> = C extends Context<infer T> ? T : unknown;
|
||||
export type ClassNamesOfStyle<F extends Function> = Record<keyof ReturnType<F>, string>;
|
||||
export type AppTheme = GetThemeType<typeof ThemeContext>;
|
||||
export const createAppUseStyles = <
|
||||
Props extends {} = {},
|
||||
C extends string = string,
|
||||
>(f: (theme: AppTheme) => Styles<C, Props, AppTheme>) => (props: Props): {
|
||||
classes: Classes<keyof Styles<C, Props, AppTheme>>,
|
||||
theme: AppTheme,
|
||||
} => {
|
||||
const theme = useTheme();
|
||||
const useStyles = createUseStyles<C,Props,AppTheme>(f)
|
||||
const classes = useStyles({...props, theme}) as Classes<keyof Styles<C, Props, AppTheme>>;
|
||||
return {classes, theme};
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
import { createContext, useContext } from "react"
|
||||
|
||||
export interface TooltipSearchOption {
|
||||
searchObject: string;
|
||||
searchText: string;
|
||||
filterObjects: Record<string, string>;
|
||||
}
|
||||
export interface TooltipState {
|
||||
domrect?: DOMRect;
|
||||
searchOptions?: TooltipSearchOption;
|
||||
onSelected?: (s: string) => void;
|
||||
searchResults: string[];
|
||||
updateState: (s: TooltipState) => void;
|
||||
}
|
||||
export const TooltipContext = createContext<TooltipState>({
|
||||
updateState(s) {},
|
||||
searchResults: [],
|
||||
})
|
||||
|
||||
export const useToolTip = () => {
|
||||
const state = useContext(TooltipContext);
|
||||
|
||||
return {
|
||||
setFocus(
|
||||
domrect: DOMRect,
|
||||
searchOptions: TooltipSearchOption,
|
||||
onSelected: (s: string) => void
|
||||
){
|
||||
state.updateState({
|
||||
...state,
|
||||
domrect, searchOptions, onSelected
|
||||
})
|
||||
},
|
||||
setSearchResults(searchResults: string[]){
|
||||
state.updateState({
|
||||
...state,
|
||||
searchResults
|
||||
})
|
||||
},
|
||||
}
|
||||
};
|
||||
@@ -1,40 +0,0 @@
|
||||
import { TooltipState } from "./context";
|
||||
|
||||
export default function Tooltip({
|
||||
domrect,
|
||||
searchOptions,
|
||||
searchResults=[],
|
||||
onSelected=()=>{},
|
||||
updateState,
|
||||
}: TooltipState) {
|
||||
|
||||
// state alias
|
||||
const rootClassName = !!domrect && !!searchOptions ? "tooltip show" : "tooltip hide";
|
||||
let tooltipStyle = {};
|
||||
if (domrect) {
|
||||
const {left=0, top=0, height=0, width=0} = domrect;
|
||||
tooltipStyle = {
|
||||
top: `${top + height}px`,
|
||||
left: `${left}px`,
|
||||
width: `${width}px`,
|
||||
}
|
||||
}
|
||||
const unFocus = () => updateState({
|
||||
updateState,
|
||||
onSelected,
|
||||
searchResults: [],
|
||||
});
|
||||
|
||||
return <div className={rootClassName}>
|
||||
<div className="tooltip-bg" onClick={() => unFocus()}></div>
|
||||
<ul style={tooltipStyle}>
|
||||
{searchResults.map((r, i) => <li key={i} onClick={() => {
|
||||
onSelected(r);
|
||||
unFocus();
|
||||
}}>
|
||||
{r}
|
||||
</li>)}
|
||||
{searchResults.length === 0 ? <li onClick={() => unFocus()}>No Options...</li> : ""}
|
||||
</ul>
|
||||
</div>
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
import { useState, useEffect } from "react";
|
||||
|
||||
// Define general type for useWindowSize hook, which includes width and height
|
||||
interface Size {
|
||||
width: number;
|
||||
height: number;
|
||||
ratioWbh: number;
|
||||
}
|
||||
|
||||
// Hook
|
||||
export default function useWindowSize(): Size {
|
||||
// Initialize state with undefined width/height so server and client renders match
|
||||
// Learn more here: https://joshwcomeau.com/react/the-perils-of-rehydration/
|
||||
const [windowSize, setWindowSize] = useState<Size>({
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
ratioWbh: window.innerWidth / window.innerHeight,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
// Handler to call on window resize
|
||||
function handleResize() {
|
||||
// Set window width/height to state
|
||||
setWindowSize({
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
ratioWbh: window.innerWidth / window.innerHeight,
|
||||
});
|
||||
}
|
||||
|
||||
// Add event listener
|
||||
window.addEventListener("resize", handleResize);
|
||||
|
||||
// Call handler right away so state gets updated with initial window size
|
||||
handleResize();
|
||||
|
||||
// Remove event listener on cleanup
|
||||
return () => window.removeEventListener("resize", handleResize);
|
||||
}, []); // Empty array ensures that effect is only run on mount
|
||||
|
||||
return windowSize;
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
{
|
||||
"include": ["src/**/*"],
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"jsx": "react-jsx",
|
||||
"module": "commonjs",
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"noImplicitAny": true,
|
||||
"noUnusedLocals": true,
|
||||
"importHelpers": true,
|
||||
"moduleResolution": "node",
|
||||
"experimentalDecorators": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"resolveJsonModule": true,
|
||||
"pretty": true,
|
||||
"sourceMap": true,
|
||||
"rootDir": ".",
|
||||
"baseUrl": "./src",
|
||||
"allowJs": false,
|
||||
"lib": [
|
||||
"es6", "dom", "es2017"
|
||||
],
|
||||
"paths": {
|
||||
"~/*": ["./*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"defaultSeverity": "error",
|
||||
"extends": ["tslint-react", "tslint-config-prettier"],
|
||||
"jsRules": {},
|
||||
"rules": {
|
||||
"variable-name": false,
|
||||
"function-name": false,
|
||||
"jsx-no-lambda": false
|
||||
},
|
||||
"rulesDirectory": []
|
||||
}
|
||||
-4797
File diff suppressed because it is too large.
Load diff
-13856
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user