Skip to content

Commit

Permalink
[custom] added custom file for localhost devs..
Browse files Browse the repository at this point in the history
  • Loading branch information
Grovkillen committed Feb 21, 2020
1 parent 8946d74 commit 41c1e78
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 15 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@

# Grunt dep *********
node_modules
package-lock.json
package-lock.json

# private ***********
src/custom.js
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,22 @@ 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:

```
grunt
```

The script will output something like this:
The script will output something like this (but much more text):

```
Running "buildGuiEasy" task
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "gui-easy",
"timestamp": 1582313902799,
"version": "0.0.1",
"versionName": "0.0.nightly.1",
"author": "Jimmy 'Grovkillen' Westberg <jimmy@grovkillen.com> (https://grovkillen.com)",
"description": "Front End for ESP Easy",
"main": {
Expand Down Expand Up @@ -40,6 +41,5 @@
"CSS framework",
"GUI",
"Frontend"
],
"versionName": "0.0.nightly.1"
]
}
4 changes: 4 additions & 0 deletions src/custom-template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"ip":"192.168.82.66",
"type":"queen"
}
4 changes: 4 additions & 0 deletions src/custom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"ip":"192.168.43.21",
"type":"queen"
}
15 changes: 11 additions & 4 deletions src/gui_easy_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand All @@ -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) {
Expand Down
15 changes: 13 additions & 2 deletions src/gui_easy_pitcher.js
Original file line number Diff line number Diff line change
@@ -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"});
}
Expand Down

0 comments on commit 41c1e78

Please sign in to comment.