Skip to content

Commit 7a45e64

Browse files
committed
Search -> filter (refactor), array -> (multi)Row(s)
Front end ======== - ObjectArray -> MultiRow: refactor search -> filter - MultiInput: currentTime reactive Back End ======= - Module: execOnUpdate() and update() from state to service to check for originID for saveNeeded, array to rows - Devices, tasks: property -> control, use ModuleState::update - IO: add Cube202010 - E_MoonLight: random speed->fade
1 parent 6816ab5 commit 7a45e64

File tree

15 files changed

+14902
-14966
lines changed

15 files changed

+14902
-14966
lines changed

docs/develop/modules.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,28 @@ ModuleDemo(PsychicHttpServer *server
3939
4040
```cpp
4141
void setupDefinition(JsonArray root) override{
42-
JsonObject property; // state.data has one or more properties
43-
JsonArray details; // if a property is an array, this is the details of the array
44-
JsonArray values; // if a property is a select, this is the values of the select
42+
JsonObject control; // state.data has one or more properties
43+
JsonArray details; // if a control is an array, this is the details of the array
44+
JsonArray values; // if a control is a select, this is the values of the select
4545
46-
property = root.add<JsonObject>(); property["name"] = "hostName"; property["type"] = "text"; property["default"] = "MoonLight";
47-
property = root.add<JsonObject>(); property["name"] = "connectionMode"; property["type"] = "select"; property["default"] = "Signal Strength"; values = property["values"].to<JsonArray>();
46+
control = root.add<JsonObject>(); control["name"] = "hostName"; control["type"] = "text"; control["default"] = "MoonLight";
47+
control = root.add<JsonObject>(); control["name"] = "connectionMode"; control["type"] = "select"; control["default"] = "Signal Strength"; values = control["values"].to<JsonArray>();
4848
values.add("Offline");
4949
values.add("Signal Strength");
5050
values.add("Priority");
5151
52-
property = root.add<JsonObject>(); property["name"] = "savedNetworks"; property["type"] = "array"; details = property["n"].to<JsonArray>();
52+
control = root.add<JsonObject>(); control["name"] = "savedNetworks"; control["type"] = "rows"; details = control["n"].to<JsonArray>();
5353
{
54-
property = details.add<JsonObject>(); property["name"] = "SSID"; property["type"] = "text"; property["default"] = "ewtr"; property["min"] = 3; property["max"] = 32;
55-
property = details.add<JsonObject>(); property["name"] = "Password"; property["type"] = "password"; property["default"] = "";
54+
control = details.add<JsonObject>(); control["name"] = "SSID"; control["type"] = "text"; control["default"] = "ewtr"; control["min"] = 3; control["max"] = 32;
55+
control = details.add<JsonObject>(); control["name"] = "Password"; control["type"] = "password"; control["default"] = "";
5656
}
5757
5858
}
5959
6060
```
6161

6262
* Implement function **onUpdate** to define what happens if data changes
63-
* struct UpdatedItem defines the update (parent property (including index in case of multiple records), name of property and value)
63+
* struct UpdatedItem defines the update (parent control (including index in case of multiple records), name of control and value)
6464
* This runs in the httpd / webserver task. To run it in another task (application task) use runInAppTask - see [ModuleLightsControl](https://github.com/MoonModules/MoonLight/blob/main/src/MoonLight/ModuleLightsControl.h)
6565

6666
```cpp
@@ -131,7 +131,7 @@ submenu: [
131131

132132
### Readonly data
133133

134-
A module can consist of data which is edited by the user (e.g. selecting a live script to run) and data which is send from the server to the UI (e.g. a list of running processes). Currently both type of valuas are stored in state data and definition. Distinguished by property["ro"] = true in setupDefinition. So the client uses state data and definition to build a screen with both types visually mixed together (what is desirable). Currently there are 2 websocket events: one for the entire state (including readonly) and one only for readonly which only contains the changed values. Module.svelte handles readonly differently by the function handleRO which calls updateRecursive which only update the parts of the data which has changed.
134+
A module can consist of data which is edited by the user (e.g. selecting a live script to run) and data which is send from the server to the UI (e.g. a list of running processes). Currently both type of values are stored in state data and definition. Distinguished by control["ro"] = true in setupDefinition. So the client uses state data and definition to build a screen with both types visually mixed together (what is desirable). Currently there are 2 websocket events: one for the entire state (including readonly) and one only for readonly which only contains the changed values. Module.svelte handles readonly differently by the function handleRO which calls updateRecursive which only update the parts of the data which has changed.
135135

136136
It might be arguable that readonly variables are not stored in state data.
137137

interface/src/lib/components/moonbase/EditObject.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import Cancel from '~icons/tabler/x';
77
88
import MultiInput from '$lib/components/moonbase/MultiInput.svelte';
9-
import ObjectArray from '$lib/components/moonbase/ObjectArray.svelte';
9+
import MultiRow from '$src/lib/components/moonbase/MultiRow.svelte';
1010
1111
interface Props {
1212
property: any;
@@ -51,13 +51,13 @@
5151
{#each property.n as propertyN}
5252
{#if propertyN.type == 'array'}
5353
<label for={propertyN.name}>{propertyN.name}</label>
54-
<ObjectArray
54+
<MultiRow
5555
property={propertyN}
5656
bind:data={dataEditable}
5757
definition={localDefinition}
5858
{onChange}
5959
{changeOnInput}
60-
></ObjectArray>
60+
></MultiRow>
6161
{:else if propertyN.type == 'controls'}
6262
{#each dataEditable[propertyN.name] as control}
6363
<!-- e.g. dE["controls"] -> {"name":"xFrequency","type":"slider","default":64,"p":1070417419,"value":64} -->

0 commit comments

Comments
 (0)