diff --git a/.gitignore b/.gitignore index 28bb8df..abab0d2 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,7 @@ # Grunt dep ********* node_modules -package-lock.json \ No newline at end of file +package-lock.json + +# private *********** +src/custom.js \ No newline at end of file diff --git a/README.md b/README.md index 14442ed..85548fc 100644 --- a/README.md +++ b/README.md @@ -32,16 +32,14 @@ order to bug test as close as release conditions as possible. What you need to d 1. Install [Node.js](https://nodejs.org/en/download/), this will include [npm](https://www.npmjs.com/get-npm) which is what we use to compile the project. -2. Install [Grunt.js](https://gruntjs.com/) (use the command line once ``npm`` is installed) -3. Install Grunt dependencies ([package.json](/package.json), run ``npm install``) - -Install Grunt using your command line interface, and thanks to npm it's this easy: +2. Install [Grunt.js](https://gruntjs.com/) + dependencies ([package.json](/package.json), run ``npm install`` from the project root level) +3. Install Grunt Command Line Interface using your terminal/cmd, and thanks to npm it's this easy: ``` npm install -g grunt-cli ``` -The compile is then done using your command line once again, make sure you're in the same +The compile is then done using your terminal/cmd, make sure you're in the same directory as the **Gruntfile.js** (this is the root of the project). Run the compile script using this command: @@ -49,7 +47,7 @@ using this command: grunt ``` -The script will output something like this: +The script will output something like this (but much more text): ``` Running "buildGuiEasy" task @@ -86,6 +84,13 @@ Done. Congrats, you just compiled your build from source! +### Run as localhost + +In the folder ``src`` you find (currently) three html files. The ``index.html`` is the main +file we use when developing. ``index-minimal.html`` is the frontend for units that do not +have the full frontend installed. If you develop you might want to connect to an existing unit +in your local network. Point to this unit inside the + ### Source Code Ideology As you will find out the source code is composed by several individual JavaScript files. diff --git a/package.json b/package.json index f0b720a..40b745a 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "gui-easy", "timestamp": 1582313902799, "version": "0.0.1", + "versionName": "0.0.nightly.1", "author": "Jimmy 'Grovkillen' Westberg (https://grovkillen.com)", "description": "Front End for ESP Easy", "main": { @@ -40,6 +41,5 @@ "CSS framework", "GUI", "Frontend" - ], - "versionName": "0.0.nightly.1" + ] } \ No newline at end of file diff --git a/src/custom-template.js b/src/custom-template.js new file mode 100644 index 0000000..611efce --- /dev/null +++ b/src/custom-template.js @@ -0,0 +1,4 @@ +{ + "ip":"192.168.82.66", + "type":"queen" +} \ No newline at end of file diff --git a/src/custom.js b/src/custom.js new file mode 100644 index 0000000..b2d8ca7 --- /dev/null +++ b/src/custom.js @@ -0,0 +1,4 @@ +{ + "ip":"192.168.43.21", + "type":"queen" +} \ No newline at end of file diff --git a/src/gui_easy_helper.js b/src/gui_easy_helper.js index fa5fb02..91258a6 100644 --- a/src/gui_easy_helper.js +++ b/src/gui_easy_helper.js @@ -90,24 +90,26 @@ const helpEasy = { "wpa" ]; let reformat = [ - "BMP085/180","BH1750", + "BMP085/180","BMx280","BH1750", + "CO2", "DS18b20","DHT11/12/22", "GitHub", "HC-SR04", "LCD2004", - "MCP23017", + "MCP23017","MH-Z19", "OpenHAB", "PCF8591","phpBB", "RCW-0001", - "SI7021/HTU21D","SSD1306/SH1106", + "SI7021/HTU21D","SSD1306/SH1106","SDS011/018/198", "TSL2561" ]; - let reformatCheck = [[],[],[],[]]; + let reformatCheck = [[],[],[],[],[]]; for (let i = 0; i < reformat.length; i++) { reformatCheck[0].push(reformat[i].toLowerCase()); reformatCheck[1].push("(" + reformat[i].toLowerCase()); reformatCheck[2].push(reformat[i].toLowerCase() + ")"); reformatCheck[3].push("(" + reformat[i].toLowerCase() + ")"); + reformatCheck[4].push(reformat[i].toLowerCase() + ","); } let words = str.toLowerCase().split(" "); for (let i = 0; i < words.length; i++) { @@ -131,6 +133,11 @@ const helpEasy = { words[i] = reformat[index] + ")"; continue; } + index = helpEasy.findInArray(words[i], reformatCheck[4]); + if (index > -1) { + words[i] = reformat[index] + ","; + continue; + } //if the string is found in the allCaps it will be all caps. index = helpEasy.findInArray(words[i], allCaps); if (index > -1) { diff --git a/src/gui_easy_pitcher.js b/src/gui_easy_pitcher.js index 6cfea06..a81e3ba 100644 --- a/src/gui_easy_pitcher.js +++ b/src/gui_easy_pitcher.js @@ -1,13 +1,24 @@ /* GUIEasy Copyright (C) 2019-2020 Jimmy "Grovkillen" Westberg */ //HERE WE ADD THINGS THAT THE CLIENT WANTS TO DO -guiEasy.pitcher = function (processID, processType) { +guiEasy.pitcher = async function (processID, processType) { let maxTimeout = 20 * 1000; let urlParams = helpEasy.urlParams(); helpEasy.getGuiInFields(); helpEasy.setCurrentIndex(-1); if (window.location.hostname === "localhost") { + let path = window.location.origin + window.location.pathname; + path = path.replace("index.html", "custom.js"); + await fetch(path) + .then(res => res.json()) + .then((jsonData) => { + guiEasy.nodes.push(jsonData); //THIS ONE IS USED TO RUN THE GUI FROM LOCALHOST + }) + .catch(error => { + helpEasy.addToLogDOM('Error fetching (custom.js): ' + error, 0, "error"); + helpEasy.addToLogDOM('You should create a "custom.js", please refer to the "custom-template.js".', 0, "info"); + helpEasy.addToLogDOM('With this file you can specify what unit you want to connect to during development...', 0, "info"); + }); //guiEasy.nodes.push({"ip":"192.168.73.164", "type":"queen"}); //THIS ONE IS USED TO RUN THE GUI FROM LOCALHOST - guiEasy.nodes.push({"ip":"192.168.43.21", "type":"queen"}); //THIS ONE IS USED TO RUN THE GUI FROM LOCALHOST } else { guiEasy.nodes.push({"ip": window.location.hostname, "type":"queen"}); }