Read the statement by Michael Teeuw here.
config.js in JSON format
-
JSON converting may lose some js specific features like callback function, dynamic values by condition, etc. I doubt the benefit of strict json format.
And the user would still make mistakes to write strict JSON format.
I can’t agree JSON is the only or better way to make user-friendly configurable web UI. -
@Sean do you have some examples of these kinds of data elements? I’d be interested to pass them thru this simple converter to see the fidelity
-
- callback function as value;
Many of my modules use the callback functions to make user command or user-customizable dynamic features instead to modify the source itself. (eg. filter, sort, transform, …)
Here is the the sameple of MMM-NotificationTrigger;
{ module: "MMM-NotificationTrigger", config: { triggers:[ { trigger: "SOME_NOTIFICATION", fires: [ { fire:"SHOW_ALERT", payload: (payload) => { return { type:"notification", title:"Notification comming", message: payload.someOption } }, } ] }, ] } },
- dynamic values;
I manage several different configurations in oneconfig.js
for my convenience. like this;
(simplified concept)
const mode = "testA" const someValue = { "testA" : "testA", "testB" : "testB", "debug" : "debug", "release" : "release", ... } ... { module: "MMM-SOMEMODULE", config: { someField: ((mode == "testA") ? true : false), someField2: someValue[mode], ... } },
The real usage is more complex but you can catch my approach.
- callback function as value;
-
@Sean thanks… the 1st, with callbacks was preserved… the 2nd, with the algorithmic values, produced the results of the algorithm… the node runtime does the algorithmic replacement on load of the file… the converter would not know. (unless it processed the text)
{ module: 'MMM-SOMEMODULE', config: { someField: true, someField2: 'testA' } }
-
@lavolp3
@sdetweil
@Sean
here is a short video of what is done at the moment.
https://youtu.be/6w6Uovy9hbESo what I have:
-
Webserver which is based on the asws webserver. Updated version for MagicMirror is here. Changes made to cmd/asws.go file only.
Download git -
build docker container from it (go to asws directory and run "
docker build -t asws_new .
" -
Clone to
home/pi/www
sample web-interface for MagicMirror clock module settings. It is bases on free SB Admin 2 bootstrap template.
Git includesjs/settings.js
which is necessary for make everything works. Git is here: https://github.com/sergge1/www -
Run with a folloing command a docker container build in point 2 above:
sudo docker run -d --restart unless-stopped -e DEBUG=true -p 80:80 -v $(pwd)/www:/www asws_new
Sample config.js from video is located at www/config.js
-
-
I found this the other day, maybe it will help your UI
https://github.com/Toreke/MMM-Dynamic-Modules
allows live dynamically positioning module content