update and pare down to front legacy actions

This commit is contained in:
Loren Norman 2023-12-07 17:09:43 -05:00
parent 545436d3db
commit 4561c04314
14 changed files with 430 additions and 151 deletions

View file

@ -13,15 +13,22 @@ export default {
},
{
"type": "input_value",
"name": "FEED"
"name": "FEED",
"check": "feed",
"align": "RIGHT"
},
{
"type": "input_value",
"name": "VALUE"
"name": "VALUE",
"check": [
"Boolean",
"String",
"Number"
],
"align": "RIGHT"
}
],
"previousStatement": null,
"nextStatement": null,
"output": "action",
"colour": 345,
"tooltip": "",
"helpUrl": ""

View file

@ -4,66 +4,26 @@ export default {
json: {
"type": "action_root",
"message0": "Action Root %1 Max Frequency: %2 %3 %4 Triggers %5 Any: %6 %7 Actions %8 All: %9",
"message0": "Action Root %1 Trigger: %2 Action: %3",
"args0": [
{
"type": "input_dummy",
"align": "CENTRE"
},
{
"type": "field_dropdown",
"name": "ACTION_FREQUENCY",
"options": [
[
"10 seconds",
"10"
],
[
"30 seconds",
"30"
],
[
"1 minute",
"60"
],
[
"5 minutes",
"300"
],
[
"1 hour",
"3600"
]
]
"type": "input_value",
"name": "TRIGGER",
"check": "trigger",
"align": "RIGHT"
},
{
"type": "input_dummy"
},
{
"type": "input_dummy",
"align": "CENTRE"
},
{
"type": "input_dummy",
"align": "CENTRE"
},
{
"type": "input_statement",
"name": "TRIGGERS"
},
{
"type": "input_dummy",
"align": "CENTRE"
},
{
"type": "input_dummy",
"align": "CENTRE"
},
{
"type": "input_statement",
"name": "ACTIONS"
"type": "input_value",
"name": "ACTION",
"check": "action",
"align": "RIGHT"
}
],
"inputsInline": false,
"colour": 120,
"tooltip": "",
"helpUrl": ""

View file

@ -5,12 +5,18 @@ export default {
json: {
"type": "action_send_email",
"message0": "Send an Email %1 To: %2 %3 Subject: %4 %5 Body: %6",
"message0": "Send an Email %1 Select a Feed: %2 To: %3 %4 Subject: %5 %6 Body: %7",
"args0": [
{
"type": "input_dummy",
"align": "CENTRE"
},
{
"type": "input_value",
"name": "FEED",
"check": "feed",
"align": "RIGHT"
},
{
"type": "field_dropdown",
"name": "EMAIL_ADDRESS",
@ -35,7 +41,7 @@ export default {
{
"type": "field_input",
"name": "EMAIL_SUBJECT",
"text": "A Great Subject"
"text": "{{feed_name}} updated"
},
{
"type": "input_dummy"
@ -43,11 +49,10 @@ export default {
{
"type": "field_input",
"name": "EMAIL_BODY",
"text": "body with {{ value }}"
"text": "{{feed_name}} got value {{value}} at {{created_at}}"
}
],
"previousStatement": null,
"nextStatement": null,
"output": "action",
"colour": 345,
"tooltip": "",
"helpUrl": ""

View file

@ -0,0 +1,60 @@
export default {
toolbox: {
category: 'Comparisons',
},
json: {
"type": "comparison_selector",
"message0": "%1",
"args0": [
{
"type": "field_dropdown",
"name": "NAME",
"options": [
[
"any",
"any"
],
[
">",
"gt"
],
[
">=",
"gte"
],
[
"<",
"lt"
],
[
"<=",
"lte"
],
[
"=",
"eq"
],
[
"≠",
"neq"
],
[
"includes",
"includes"
]
]
}
],
"output": "comparison_operator",
"colour": 230,
"tooltip": "",
"helpUrl": ""
},
generators: {
json: (block, generator) => '""',
markdown: (block, generator) => '# comparison_selector.js'
}
}

View file

@ -26,7 +26,7 @@ export default {
]
}
],
"output": null,
"output": "feed",
"colour": 30,
"tooltip": "",
"helpUrl": ""

View file

@ -0,0 +1,96 @@
export default {
toolbox: {
category: 'Triggers'
},
json: {
"type": "reactive_trigger",
"implicitAlign0": "RIGHT",
"message0": "Reactive Trigger %1 Compare Feeds: %2 Feed %3 Operator %4 Feed or Number %5 Limit Every %6 %7 %8 %9 Notify on Reset",
"args0": [
{
"type": "input_dummy",
"align": "CENTRE"
},
{
"type": "input_dummy"
},
{
"type": "input_value",
"name": "FEED_A",
"check": "feed",
"align": "RIGHT"
},
{
"type": "input_value",
"name": "COMPARATOR",
"check": "comparison_operator",
"align": "RIGHT"
},
{
"type": "input_value",
"name": "FEED_B",
"check": [
"feed",
"Number"
],
"align": "RIGHT"
},
{
"type": "input_dummy",
"align": "CENTRE"
},
{
"type": "field_dropdown",
"name": "LIMIT_EVERY",
"options": [
[
"10 seconds",
"10"
],
[
"1 day",
"10000"
]
]
},
{
"type": "input_dummy",
"align": "CENTRE"
},
{
"type": "field_checkbox",
"name": "NAME",
"checked": true
}
],
"inputsInline": false,
"output": "trigger",
"colour": 230,
"tooltip": "",
"helpUrl": ""
},
generators: {
json: (block, generator) => {
const
feedToCheck = generator.valueToCode(block, 'FEED_CHECK', 0),
isReactive = block.getFieldValue('REACTIVE') === 'TRUE',
lines = [
`"trigger": "feed_check",`,
`"check": ${feedToCheck},`,
`"reactive": ${isReactive}`,
],
indentedLines = generator.prefixLines(lines.join('\n'), generator.INDENT)
return `{\n${ indentedLines }\n}`
},
markdown: (block, generator) => {
return 'markity'
}
}
}

View file

@ -1,3 +1,13 @@
// regex considerations:
// - timeout
// - case-sensitivity
// - single vs multi-line
// - regex-escaping strings
// - match? true/false
// - matches: 0 or more
// - numbered matches
// - named matches
export default {
toolbox: {
category: 'Transformers',

View file

@ -1,5 +1,4 @@
<xml xmlns="https://developers.google.com/blockly/xml">
<block type="factory_base" id="[U_m[b@5o0VRfwsl3cu]" deletable="false" movable="false" x="10" y="10">
<xml xmlns="https://developers.google.com/blockly/xml"><block type="factory_base" id="[U_m[b@5o0VRfwsl3cu]" deletable="false" movable="false" x="10" y="10">
<mutation connections="BOTH"></mutation>
<field name="NAME">action_publish_to_feed</field>
<field name="INLINE">AUTO</field>
@ -64,5 +63,4 @@
<field name="HUE">345</field>
</block>
</value>
</block>
</xml>
</block></xml>

View file

@ -1,5 +1,4 @@
<xml xmlns="https://developers.google.com/blockly/xml">
<block type="factory_base" id="pTm]Hpk1SYWSmtw3Fpnm" deletable="false" movable="false" x="10" y="10">
<xml xmlns="https://developers.google.com/blockly/xml"><block type="factory_base" id="pTm]Hpk1SYWSmtw3Fpnm" deletable="false" movable="false" x="10" y="10">
<mutation connections="NONE"></mutation>
<field name="NAME">action_root</field>
<field name="INLINE">AUTO</field>
@ -13,78 +12,80 @@
</block>
</statement>
<next>
<block type="input_dummy" id="L*j`dFgy#}rSo`!Aa2,D">
<field name="ALIGN">LEFT</field>
<block type="input_value" id="d6[JV^0k1;T:Z23?K85B">
<field name="INPUTNAME">TRIGGER</field>
<field name="ALIGN">RIGHT</field>
<statement name="FIELDS">
<block type="field_static" id="y@F%Xu-R~3@5+PxWl.(1">
<field name="TEXT">Max Frequency:</field>
<next>
<block type="field_dropdown" id="M@0A1E.s;at)9C_$cW5f">
<mutation options="[&quot;text&quot;,&quot;text&quot;,&quot;text&quot;,&quot;text&quot;,&quot;text&quot;]"></mutation>
<field name="FIELDNAME">ACTION_FREQUENCY</field>
<field name="USER0">10 seconds</field>
<field name="CPU0">10</field>
<field name="USER1">30 seconds</field>
<field name="CPU1">30</field>
<field name="USER2">1 minute</field>
<field name="CPU2">60</field>
<field name="USER3">5 minutes</field>
<field name="CPU3">300</field>
<field name="USER4">1 hour</field>
<field name="CPU4">3600</field>
</block>
</next>
<block type="field_static" id="M0HaRcqi~mv3cJ*EX=yB">
<field name="TEXT">Trigger:</field>
</block>
</statement>
<value name="TYPE">
<shadow type="type_null" id="JD?J`y9ls4t8tF8,J~/L"></shadow>
<block type="type_other" id="(fwh^0;EGGx:pRZKD7w!">
<field name="TYPE">trigger</field>
</block>
</value>
<next>
<block type="input_dummy" id="6lF{R3=jv);r5(M;%xU1">
<field name="ALIGN">CENTRE</field>
<block type="input_value" id="aj]d}3pJ)^9bdhDt~smL">
<field name="INPUTNAME">ACTION</field>
<field name="ALIGN">RIGHT</field>
<statement name="FIELDS">
<block type="field_static" id="@P.l1P6v!JN$+PQpzut#">
<field name="TEXT">Action:</field>
</block>
</statement>
<value name="TYPE">
<shadow type="type_null" id="}KQ4OZ]z2j0(FNvXgIa1"></shadow>
<block type="type_other" id="T4mugAdoltgx:{amQQn_">
<field name="TYPE">action</field>
</block>
</value>
<next>
<block type="input_dummy" id="k?wQ8*ny9:9w*Arx=t)u">
<block type="input_dummy" id="6lF{R3=jv);r5(M;%xU1">
<field name="ALIGN">CENTRE</field>
<statement name="FIELDS">
<block type="field_static" id="M0HaRcqi~mv3cJ*EX=yB">
<field name="TEXT">Triggers</field>
<block type="field_static" id="y@F%Xu-R~3@5+PxWl.(1">
<field name="TEXT">Limit Every</field>
</block>
</statement>
<next>
<block type="input_statement" id="hw_1LHy~rY70-eaRQ/,7">
<field name="INPUTNAME">TRIGGERS</field>
<field name="ALIGN">LEFT</field>
<block type="input_dummy" id="L*j`dFgy#}rSo`!Aa2,D">
<field name="ALIGN">CENTRE</field>
<statement name="FIELDS">
<block type="field_static" id="ylyOWeGo(Iwsvx3$do;)">
<field name="TEXT">Any:</field>
<block type="field_dropdown" id="M@0A1E.s;at)9C_$cW5f">
<mutation options="[&quot;text&quot;,&quot;text&quot;,&quot;text&quot;,&quot;text&quot;,&quot;text&quot;]"></mutation>
<field name="FIELDNAME">ACTION_FREQUENCY</field>
<field name="USER0">10 seconds</field>
<field name="CPU0">10</field>
<field name="USER1">30 seconds</field>
<field name="CPU1">30</field>
<field name="USER2">1 minute</field>
<field name="CPU2">60</field>
<field name="USER3">5 minutes</field>
<field name="CPU3">300</field>
<field name="USER4">1 hour</field>
<field name="CPU4">3600</field>
</block>
</statement>
<value name="TYPE">
<shadow type="type_null" id="RptP},Q;R;Vpb|c|QB!B"></shadow>
</value>
<next>
<block type="input_dummy" id="lGhQ.j).d(^i0xeCTwXe">
<block type="input_dummy" id="AH36V-v!K$=SE.-S^;~P">
<field name="ALIGN">CENTRE</field>
<next>
<block type="input_dummy" id="ev.;#.*J*JBn/%-Er},T">
<field name="ALIGN">CENTRE</field>
<statement name="FIELDS">
<block type="field_static" id="@P.l1P6v!JN$+PQpzut#">
<field name="TEXT">Actions</field>
</block>
</statement>
<statement name="FIELDS">
<block type="field_checkbox" id="=NlN%5}z7w|67Pa5`HYi">
<field name="CHECKED">TRUE</field>
<field name="FIELDNAME">NAME</field>
<next>
<block type="input_statement" id="{_pB)q@[pR5z{^=1w9l(">
<field name="INPUTNAME">ACTIONS</field>
<field name="ALIGN">LEFT</field>
<statement name="FIELDS">
<block type="field_static" id="c7d*ot[gT[.2?^]6mh~U">
<field name="TEXT">All:</field>
</block>
</statement>
<value name="TYPE">
<shadow type="type_null" id="X!+Vq3vrBqF/`:1ZtH#6"></shadow>
</value>
<block type="field_static" id="A[a.?AViz[}%cPh;/~#8">
<field name="TEXT">Notify on Reset?</field>
</block>
</next>
</block>
</statement>
<next>
<block type="input_dummy" id="Mwyq6uUw5e7=XUj?{I)X">
<field name="ALIGN">RIGHT</field>
</block>
</next>
</block>
</next>
@ -114,5 +115,4 @@
<field name="HUE">120</field>
</block>
</value>
</block>
</xml>
</block></xml>

View file

@ -1,5 +1,4 @@
<xml xmlns="https://developers.google.com/blockly/xml">
<block type="factory_base" id="7e$mQ!kdk:9$),f:.QJ|" deletable="false" movable="false" x="10" y="10">
<xml xmlns="https://developers.google.com/blockly/xml"><block type="factory_base" id="7e$mQ!kdk:9$),f:.QJ|" deletable="false" movable="false" x="10" y="10">
<mutation connections="BOTH"></mutation>
<field name="NAME">action_send_email</field>
<field name="INLINE">AUTO</field>
@ -90,5 +89,4 @@
<field name="HUE">345</field>
</block>
</value>
</block>
</xml>
</block></xml>

View file

@ -0,0 +1 @@
<xml xmlns="https://developers.google.com/blockly/xml"></xml>

View file

@ -0,0 +1,128 @@
<xml xmlns="https://developers.google.com/blockly/xml"><block type="factory_base" id="kneC*#A]MM_2!0RHNanv" deletable="false" movable="false" x="10" y="10">
<mutation connections="LEFT"></mutation>
<field name="NAME">reactive_trigger</field>
<field name="INLINE">EXT</field>
<field name="CONNECTIONS">LEFT</field>
<statement name="INPUTS">
<block type="input_dummy" id="O6a`6%ng_FwyZmN|k0_5">
<field name="ALIGN">CENTRE</field>
<statement name="FIELDS">
<block type="field_static" id="0Y-aeHqZsj(1B8V7jj@{">
<field name="TEXT">Reactive Trigger</field>
</block>
</statement>
<next>
<block type="input_dummy" id="Bf/K[r)Yj@zs#xw_,0-P">
<field name="ALIGN">LEFT</field>
<statement name="FIELDS">
<block type="field_static" id="d4$T9Tn3T6sDl~+[==q{">
<field name="TEXT">Compare Feeds:</field>
</block>
</statement>
<next>
<block type="input_value" id="@rB))~XP;NX+d^Qe]#Gt">
<field name="INPUTNAME">FEED_A</field>
<field name="ALIGN">RIGHT</field>
<statement name="FIELDS">
<block type="field_static" id="Em*M+8*LW6Bc%JVG~sWp">
<field name="TEXT">Feed A</field>
</block>
</statement>
<value name="TYPE">
<shadow type="type_null" id="1Ab-3fe}b[wGy7Y87gA["></shadow>
</value>
<next>
<block type="input_value" id="/fdo7^(mAqoJ6C}/?$-W">
<field name="INPUTNAME">COMPARATOR</field>
<field name="ALIGN">RIGHT</field>
<statement name="FIELDS">
<block type="field_static" id="U^LL$6-*nL.bZ8IwfS(e">
<field name="TEXT">Comparator</field>
</block>
</statement>
<value name="TYPE">
<shadow type="type_null" id=")]$yw71QaOG(%LBifjW/"></shadow>
</value>
<next>
<block type="input_value" id="#=(HCqw]L-JRH#6ulPDM">
<field name="INPUTNAME">FEED_B</field>
<field name="ALIGN">RIGHT</field>
<statement name="FIELDS">
<block type="field_static" id="5ctF9}eaaCJ^fn77DcT,">
<field name="TEXT">Feed B</field>
</block>
</statement>
<value name="TYPE">
<shadow type="type_null" id="z!yfB%a9*#qdIf7-gHss"></shadow>
</value>
<next>
<block type="input_dummy" id="SR$I1~/ur4j$N`XyP^J2">
<field name="ALIGN">CENTRE</field>
<statement name="FIELDS">
<block type="field_static" id="*W}*`~MS~MOjsEwX3vBd">
<field name="TEXT">Limit Every</field>
</block>
</statement>
<next>
<block type="input_dummy" id=";PrG?y^|5DMzf:{kx#7]">
<field name="ALIGN">CENTRE</field>
<statement name="FIELDS">
<block type="field_dropdown" id="rWqTY=t%TrvTqbQuDdb+">
<mutation options="[&quot;text&quot;,&quot;text&quot;]"></mutation>
<field name="FIELDNAME">LIMIT_EVERY</field>
<field name="USER0">10 seconds</field>
<field name="CPU0">10</field>
<field name="USER1">1 day</field>
<field name="CPU1">10000</field>
</block>
</statement>
<next>
<block type="input_dummy" id="qd2iQuBWq]c/udD[38Za">
<field name="ALIGN">RIGHT</field>
<statement name="FIELDS">
<block type="field_checkbox" id="Y{AESPu#(_gU+Bb2V7G(">
<field name="CHECKED">TRUE</field>
<field name="FIELDNAME">NAME</field>
<next>
<block type="field_static" id="h[)]lT1Q^%hr=85CNIMI">
<field name="TEXT">Notify on Reset</field>
</block>
</next>
</block>
</statement>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
<value name="TOOLTIP">
<block type="text" id="q[xY9u6~LvIqgx[kOql~" deletable="false" movable="false">
<field name="TEXT"></field>
</block>
</value>
<value name="HELPURL">
<block type="text" id="!/~nI!,M7AEYJyQ_@Z[|" deletable="false" movable="false">
<field name="TEXT"></field>
</block>
</value>
<value name="OUTPUTTYPE">
<shadow type="type_null" id="gf~9dDA4k`$w8Nz8%Pkf"></shadow>
</value>
<value name="COLOUR">
<block type="colour_hue" id="]|u1,NQi^I1]g)q#J:?h">
<mutation colour="#5b67a5"></mutation>
<field name="HUE">230</field>
</block>
</value>
</block></xml>

View file

@ -2,57 +2,72 @@ import * as Blockly from 'blockly';
import action_root from './custom/action_root'
import feed_selector from './custom/feed_selector'
import trigger_all from './custom/trigger_all'
import trigger_on_change from './custom/trigger_on_change'
// import trigger_all from './custom/trigger_all'
import reactive_trigger from './custom/reactive_trigger'
import comparison_selector from './custom/comparison_selector'
// import trigger_on_change from './custom/trigger_on_change'
import action_publish_to_feed from './custom/action_publish_to_feed'
import action_send_email from './custom/action_send_email'
import transform_regex from './custom/transform_regex'
// import transform_regex from './custom/transform_regex'
import math_number from './common/math_number'
import text from './common/text'
import text_multiline from './common/text_multiline'
import logic_boolean from './common/logic_boolean'
import logic_null from './common/logic_null'
import controls_if from './common/controls_if'
import logic_compare from './common/logic_compare'
import logic_negate from './common/logic_negate'
import logic_operation from './common/logic_operation'
import math_arithmetic from './common/math_arithmetic'
import variables_set from './common/variables_set'
import variables_get from './common/variables_get'
import math_change from './common/math_change'
// import controls_if from './common/controls_if'
// import logic_compare from './common/logic_compare'
// import logic_negate from './common/logic_negate'
// import logic_operation from './common/logic_operation'
// import math_arithmetic from './common/math_arithmetic'
// import variables_set from './common/variables_set'
// import variables_get from './common/variables_get'
// import math_change from './common/math_change'
const
ALL_BLOCKS = {
// not in toolbox
action_root,
// IO
// Feeds
feed_selector,
trigger_all,
trigger_on_change,
// Triggers
reactive_trigger,
// trigger_all,
// trigger_on_change,
// Actions
action_publish_to_feed,
action_send_email,
// Tools
// Values
math_number,
text,
text_multiline,
logic_boolean,
logic_null,
variables_set,
variables_get,
math_change,
// Comparisons
comparison_selector,
math_arithmetic,
// variables_set,
// variables_get,
// math_change,
transform_regex,
// math_arithmetic,
controls_if,
logic_compare,
logic_operation,
logic_negate,
// transform_regex,
// controls_if,
// logic_compare,
// logic_operation,
// logic_negate,
},
jsonGenerator = new Blockly.Generator('JSON'),
markdownGenerator = new Blockly.Generator('markdown')

View file

@ -11,10 +11,11 @@ const
SEP,
{ name: 'Tools' },
{ name: 'Values', colour: 156 },
{ name: 'Variables', colour: 208, extras: { custom: "VARIABLE" } },
{ name: 'Math', colour: 260 },
{ name: 'Transformers', colour: 285 },
{ name: 'Logic', colour: 312 },
{ name: 'Comparisons', colour: 208 },
// { name: 'Variables', colour: 208, extras: { custom: "VARIABLE" } },
// { name: 'Math', colour: 260 },
// { name: 'Transformers', colour: 285 },
// { name: 'Logic', colour: 312 },
]
export default {