From 28f7c6fbff8e4a5a68c122f9a63f6565280c9d3e Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Sat, 26 Oct 2019 18:30:16 +0100 Subject: [PATCH] add kiosk mode (dangerous) --- .vscode/launch.json | 15 +++++++++++++++ README.md | 2 +- electronflow.json | 2 +- main.js | 16 +++++++++------- 4 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..364397c --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Electron Main", + "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron", + "program": "${workspaceFolder}/main.js" + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md index d898e72..7c07c6f 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ yarn && yarn dist -m // for mac These will generally fail the first time through and you will need to install some extra library in order to make it complete successfully. -The defaults are to build a `.msi` for Windows, a `.dmg` for Mac and both a `.deb` and `.rpm` for Linux. +The defaults are to build a `.msi` for Windows, a `.dmg` for Mac, and both a `.deb` and `.rpm` for Linux. These can be changed by editing the build section of the `package.json` file, see the [electron-builder config docs](https://www.electron.build/configuration/configuration) for more info. diff --git a/electronflow.json b/electronflow.json index da70a7b..7e2201c 100644 --- a/electronflow.json +++ b/electronflow.json @@ -1 +1 @@ -[{"id":"41f61d2.fbe09e4","type":"tab","label":"Flow 1"},{"id":"52a903f3.ad56fc","type":"ui_tab","z":"41f61d2.fbe09e4","name":"Home","icon":"dashboard"},{"id":"30e652f.d9de3ae","type":"ui_group","z":"41f61d2.fbe09e4","name":"Panel 2","tab":"52a903f3.ad56fc","order":5,"disp":true,"width":"6"},{"id":"a8ecb9.c60f4348","type":"ui_group","z":"41f61d2.fbe09e4","name":"Introduction","tab":"52a903f3.ad56fc","order":1,"disp":false,"width":"4","collapse":false},{"id":"bbdf3e02.e8fee","type":"ui_group","z":"41f61d2.fbe09e4","name":"Panel 1","tab":"52a903f3.ad56fc","order":2,"disp":true,"width":"6"},{"id":"d9ba26fa.6d2b18","type":"ui_base","theme":{"name":"theme-light","lightTheme":{"default":"#0094CE","baseColor":"#8e0d17","baseFont":"Gill Sans,Geneva,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#097479","baseFont":"Helvetica Neue","edited":false},"customTheme":{"name":"Untitled Theme 1","default":"#4B7930","baseColor":"#4B7930","baseFont":"Helvetica Neue"},"themeState":{"base-color":{"default":"#0094CE","value":"#d80005","edited":true},"page-titlebar-backgroundColor":{"value":"#8e0d17","edited":false},"page-backgroundColor":{"value":"#fafafa","edited":false},"page-sidebar-backgroundColor":{"value":"#000000","edited":false},"group-textColor":{"value":"#d41322","edited":false},"group-borderColor":{"value":"#ffffff","edited":false},"group-backgroundColor":{"value":"#ffffff","edited":false},"widget-textColor":{"value":"#111111","edited":false},"widget-backgroundColor":{"value":"#8e0d17","edited":false},"widget-borderColor":{"value":"#ffffff","edited":false},"base-font":{"value":"Gill Sans,Geneva,sans-serif"}}},"site":{"name":"Node-RED Dashboard","hideToolbar":"false","allowSwipe":"false","dateFormat":"DD/MM/YYYY","sizes":{"sx":48,"sy":48,"gx":6,"gy":6,"cx":6,"cy":6,"px":0,"py":0}}},{"id":"87356b62.92e3d8","type":"ui_group","z":"","name":"Text to Speech","tab":"52a903f3.ad56fc","order":3,"disp":true,"width":"6"},{"id":"c75ad4f0.0cede8","type":"ui_group","z":"","name":"Map","tab":"52a903f3.ad56fc","order":4,"disp":true,"width":"6"},{"id":"189cf871.681118","type":"ui_template","z":"41f61d2.fbe09e4","group":"a8ecb9.c60f4348","name":"Welcome","order":1,"width":"4","height":"9","format":"

Welcome to the Node-RED Dashboard

\n

On the right you will see a graph and a gauge logging data from the sliders underneath.

\n

There is also an example of embedding a small map.

","storeOutMessages":false,"fwdInMessages":false,"templateScope":"local","x":93,"y":45,"wires":[[]]},{"id":"9f19ee5c.beaef","type":"ui_chart","z":"41f61d2.fbe09e4","name":"","group":"bbdf3e02.e8fee","order":1,"width":"0","height":"0","label":"","chartType":"line","xformat":"HH:mm:ss","interpolate":"basis","nodata":"No Data","dot":false,"ymin":"0","ymax":"100","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"60","cutout":"","colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":2,"x":270,"y":200,"wires":[[],[]]},{"id":"799d9318.fd385c","type":"ui_gauge","z":"41f61d2.fbe09e4","name":"","group":"30e652f.d9de3ae","order":2,"width":"","height":"","gtype":"gage","title":"Title","label":"gauge","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"x":270,"y":140,"wires":[]},{"id":"6f18b200.666a4","type":"ui_button","z":"41f61d2.fbe09e4","name":"","group":"87356b62.92e3d8","order":2,"width":0,"height":0,"label":"press to talk","color":"","bgcolor":"","icon":"fa-volume-up","payload":"Hello to Jason Isaacs","payloadType":"str","topic":"","x":110,"y":320,"wires":[["f897d7c2.467a58"]]},{"id":"f897d7c2.467a58","type":"ui_audio","z":"41f61d2.fbe09e4","name":"","group":"30e652f.d9de3ae","voice":"0","x":300,"y":320,"wires":[]},{"id":"da0f7e67.0d38a","type":"ui_slider","z":"41f61d2.fbe09e4","name":"","label":"slider","group":"30e652f.d9de3ae","order":4,"width":0,"height":0,"passthru":true,"topic":"","min":0,"max":"100","step":1,"x":90,"y":140,"wires":[["799d9318.fd385c","219da65f.e0b0da"]]},{"id":"eabf2bd7.f4e0c8","type":"ui_slider","z":"41f61d2.fbe09e4","name":"","label":"slider","group":"bbdf3e02.e8fee","order":4,"width":0,"height":0,"passthru":true,"topic":"","min":0,"max":"100","step":1,"x":130,"y":200,"wires":[["9f19ee5c.beaef","ccee40e3.c1618"]]},{"id":"45508d88.744a54","type":"function","z":"41f61d2.fbe09e4","name":"","func":"// create random position\nvar lat = 51 + Math.random() * 0.2;\nvar lon = -1.45 + Math.random() * 0.2;\nmsg.payload={lat:lat, lon:lon, name:\"Jason\", icon:\"male\", url:\"IBM link\"};\nreturn msg;","outputs":1,"noerr":0,"x":290,"y":400,"wires":[["f76b15b1.dd27a8"]]},{"id":"6ca8cfc2.e0bce","type":"ui_button","z":"41f61d2.fbe09e4","name":"","group":"c75ad4f0.0cede8","order":1,"width":0,"height":0,"passthru":false,"label":"Where's Jason ?","color":"","bgcolor":"#910000","icon":"fa-male","payload":"","payloadType":"str","topic":"","x":110,"y":400,"wires":[["45508d88.744a54"]]},{"id":"219da65f.e0b0da","type":"debug","z":"41f61d2.fbe09e4","name":"","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"payload","x":300,"y":100,"wires":[]},{"id":"ccee40e3.c1618","type":"debug","z":"41f61d2.fbe09e4","name":"","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"payload","targetType":"msg","x":300,"y":260,"wires":[]},{"id":"1c597308.3cfc0d","type":"worldmap in","z":"41f61d2.fbe09e4","name":"worldmap in","path":"","events":"","x":110,"y":480,"wires":[["7d6cb82c.3f3ea8"]]},{"id":"7d6cb82c.3f3ea8","type":"debug","z":"41f61d2.fbe09e4","name":"","active":true,"tosidebar":false,"console":true,"tostatus":false,"complete":"payload","x":350,"y":480,"wires":[]},{"id":"762cecef.af00d4","type":"inject","z":"41f61d2.fbe09e4","name":"","topic":"","payload":"26","payloadType":"num","repeat":"","crontab":"","once":true,"onceDelay":"2","x":90,"y":260,"wires":[["eabf2bd7.f4e0c8"]]},{"id":"f76b15b1.dd27a8","type":"ui_worldmap","z":"41f61d2.fbe09e4","group":"c75ad4f0.0cede8","order":1,"width":"6","height":"7","name":"","lat":"","lon":"","zoom":"","layer":"","cluster":"","maxage":"","usermenu":"hide","layers":"hide","panit":"false","panlock":"false","zoomlock":"false","hiderightclick":"true","coords":"none","showgrid":"false","path":"/worldmap","x":440,"y":400,"wires":[]}] \ No newline at end of file +[{"id":"41f61d2.fbe09e4","type":"tab","label":"Flow 1"},{"id":"52a903f3.ad56fc","type":"ui_tab","z":"41f61d2.fbe09e4","name":"Home","icon":"dashboard"},{"id":"30e652f.d9de3ae","type":"ui_group","z":"41f61d2.fbe09e4","name":"Panel 2","tab":"52a903f3.ad56fc","order":5,"disp":true,"width":"6"},{"id":"a8ecb9.c60f4348","type":"ui_group","z":"41f61d2.fbe09e4","name":"Introduction","tab":"52a903f3.ad56fc","order":1,"disp":false,"width":"4","collapse":false},{"id":"bbdf3e02.e8fee","type":"ui_group","z":"41f61d2.fbe09e4","name":"Panel 1","tab":"52a903f3.ad56fc","order":2,"disp":true,"width":"6"},{"id":"d9ba26fa.6d2b18","type":"ui_base","theme":{"name":"theme-light","lightTheme":{"default":"#0094CE","baseColor":"#8e0d17","baseFont":"Gill Sans,Geneva,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#097479","baseFont":"Helvetica Neue","edited":false},"customTheme":{"name":"Untitled Theme 1","default":"#4B7930","baseColor":"#4B7930","baseFont":"Helvetica Neue"},"themeState":{"base-color":{"default":"#0094CE","value":"#d80005","edited":true},"page-titlebar-backgroundColor":{"value":"#8e0d17","edited":false},"page-backgroundColor":{"value":"#fafafa","edited":false},"page-sidebar-backgroundColor":{"value":"#000000","edited":false},"group-textColor":{"value":"#d41322","edited":false},"group-borderColor":{"value":"#ffffff","edited":false},"group-backgroundColor":{"value":"#ffffff","edited":false},"widget-textColor":{"value":"#111111","edited":false},"widget-backgroundColor":{"value":"#8e0d17","edited":false},"widget-borderColor":{"value":"#ffffff","edited":false},"base-font":{"value":"Gill Sans,Geneva,sans-serif"}}},"site":{"name":"Node-RED Dashboard","hideToolbar":"false","allowSwipe":"false","dateFormat":"DD/MM/YYYY","sizes":{"sx":48,"sy":48,"gx":6,"gy":6,"cx":6,"cy":6,"px":0,"py":0}}},{"id":"87356b62.92e3d8","type":"ui_group","z":"","name":"Text to Speech","tab":"52a903f3.ad56fc","order":3,"disp":true,"width":"6"},{"id":"c75ad4f0.0cede8","type":"ui_group","z":"","name":"Map","tab":"52a903f3.ad56fc","order":4,"disp":true,"width":"6"},{"id":"189cf871.681118","type":"ui_template","z":"41f61d2.fbe09e4","group":"a8ecb9.c60f4348","name":"Welcome","order":1,"width":"4","height":"9","format":"

Welcome to the Node-RED Dashboard

\n

On the right you will see a graph and a gauge logging data from the sliders underneath.

\n

There is also an example of embedding a small map.

","storeOutMessages":false,"fwdInMessages":false,"templateScope":"local","x":93,"y":45,"wires":[[]]},{"id":"9f19ee5c.beaef","type":"ui_chart","z":"41f61d2.fbe09e4","name":"","group":"bbdf3e02.e8fee","order":1,"width":"0","height":"0","label":"","chartType":"line","xformat":"HH:mm:ss","interpolate":"basis","nodata":"No Data","dot":false,"ymin":"0","ymax":"100","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"60","cutout":"","colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":2,"x":270,"y":200,"wires":[[],[]]},{"id":"799d9318.fd385c","type":"ui_gauge","z":"41f61d2.fbe09e4","name":"","group":"30e652f.d9de3ae","order":2,"width":"","height":"","gtype":"gage","title":"Title","label":"gauge","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"x":270,"y":140,"wires":[]},{"id":"6f18b200.666a4","type":"ui_button","z":"41f61d2.fbe09e4","name":"","group":"87356b62.92e3d8","order":2,"width":0,"height":0,"label":"press to talk","color":"","bgcolor":"","icon":"fa-volume-up","payload":"Hello to Jason Isaacs","payloadType":"str","topic":"","x":110,"y":320,"wires":[["f897d7c2.467a58"]]},{"id":"f897d7c2.467a58","type":"ui_audio","z":"41f61d2.fbe09e4","name":"","group":"30e652f.d9de3ae","voice":"0","x":300,"y":320,"wires":[]},{"id":"da0f7e67.0d38a","type":"ui_slider","z":"41f61d2.fbe09e4","name":"","label":"slider","group":"30e652f.d9de3ae","order":4,"width":0,"height":0,"passthru":true,"topic":"","min":0,"max":"100","step":1,"x":90,"y":140,"wires":[["799d9318.fd385c","219da65f.e0b0da"]]},{"id":"eabf2bd7.f4e0c8","type":"ui_slider","z":"41f61d2.fbe09e4","name":"","label":"slider","group":"bbdf3e02.e8fee","order":4,"width":0,"height":0,"passthru":true,"topic":"","min":0,"max":"100","step":1,"x":130,"y":200,"wires":[["9f19ee5c.beaef","ccee40e3.c1618"]]},{"id":"45508d88.744a54","type":"function","z":"41f61d2.fbe09e4","name":"","func":"// create random position\nvar lat = 51 + Math.random() * 0.2;\nvar lon = -1.45 + Math.random() * 0.2;\nmsg.payload={lat:lat, lon:lon, name:\"Jason\", icon:\"male\", url:\"IBM link\"};\nreturn msg;","outputs":1,"noerr":0,"x":290,"y":400,"wires":[["f76b15b1.dd27a8"]]},{"id":"6ca8cfc2.e0bce","type":"ui_button","z":"41f61d2.fbe09e4","name":"","group":"c75ad4f0.0cede8","order":1,"width":0,"height":0,"passthru":false,"label":"Where's Jason ?","color":"","bgcolor":"#910000","icon":"fa-male","payload":"","payloadType":"str","topic":"","x":110,"y":400,"wires":[["45508d88.744a54"]]},{"id":"219da65f.e0b0da","type":"debug","z":"41f61d2.fbe09e4","name":"","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"payload","x":300,"y":100,"wires":[]},{"id":"ccee40e3.c1618","type":"debug","z":"41f61d2.fbe09e4","name":"","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"payload","targetType":"msg","x":300,"y":260,"wires":[]},{"id":"1c597308.3cfc0d","type":"worldmap in","z":"41f61d2.fbe09e4","name":"worldmap in","path":"","events":"","x":110,"y":480,"wires":[["7d6cb82c.3f3ea8"]]},{"id":"7d6cb82c.3f3ea8","type":"debug","z":"41f61d2.fbe09e4","name":"","active":true,"tosidebar":false,"console":true,"tostatus":false,"complete":"payload","x":350,"y":480,"wires":[]},{"id":"762cecef.af00d4","type":"inject","z":"41f61d2.fbe09e4","name":"","topic":"","payload":"26","payloadType":"num","repeat":"","crontab":"","once":true,"onceDelay":"2","x":90,"y":260,"wires":[["eabf2bd7.f4e0c8"]]},{"id":"f76b15b1.dd27a8","type":"ui_worldmap","z":"41f61d2.fbe09e4","group":"c75ad4f0.0cede8","order":1,"width":"6","height":"7","name":"","lat":"51.17","lon":"-1.4","zoom":"","layer":"","cluster":"","maxage":"","usermenu":"hide","layers":"hide","panit":"false","panlock":"false","zoomlock":"false","hiderightclick":"true","coords":"none","showgrid":"false","path":"/worldmap","x":440,"y":400,"wires":[]}] \ No newline at end of file diff --git a/main.js b/main.js index 4df8e2c..e3b27cc 100755 --- a/main.js +++ b/main.js @@ -6,6 +6,7 @@ const editable = true; // Set this to false to create a run only application - no editor/no console const allowLoadSave = false; // set to true to allow import and export of flow file const showMap = false; // set to true to add Worldmap to the menu +const kioskMode = false; // set to true to start in kiosk mode let flowfile = 'electronflow.json'; // default Flows file name - loaded at start const urldash = "/ui/#/0"; // Start on the dashboard page @@ -215,9 +216,11 @@ if (process.platform !== 'darwin') { template[tempNum].submenu.push({ type: "separator" }); template[tempNum].submenu.push({ role: 'togglefullscreen' }); template[tempNum].submenu.push({ role: 'quit' }); + if (!showMap) { template[tempNum].submenu.splice(8,1); } +} +else { + if (!showMap) { template[tempNum].submenu.splice(6,1); } } - -if (!showMap) { template[tempNum].submenu.splice(8,1); } if (!editable) { template[tempNum].submenu.splice(3,1); @@ -251,8 +254,7 @@ function saveFlow() { function openFlow() { dialog.showOpenDialog({ filters:[{ name:'JSON', extensions:['json']} ]}, function (fileNames) { - if (fileNames) { - //console.log(fileNames[0]); + if (fileNames && fileNames.length > 0) { fs.readFile(fileNames[0], 'utf-8', function (err, data) { try { var flo = JSON.parse(data); @@ -305,11 +307,11 @@ function createConsole() { function createWindow() { mainWindow = new BrowserWindow({ title: "Node-RED", - //titleBarStyle: "hidden", width: 1024, height: 768, icon: path.join(__dirname, nrIcon), fullscreenable: true, + kiosk: kioskMode, autoHideMenuBar: true, webPreferences: { nodeIntegration: false @@ -327,8 +329,8 @@ function createWindow() { } }); - // mainWindow.webContents.on('did-finish-load', () => { - // console.log("LOADED DASHBOARD"); + // mainWindow.webContents.on('did-finish-load', (a) => { + // console.log("FINISHED LOAD",a); // }); mainWindow.webContents.on("new-window", function(e, url, frameName, disposition, options) {