Commit 16dd6417 authored by Donald Chen's avatar Donald Chen
Browse files

wip: add node red url

parent e151c112
...@@ -252,7 +252,15 @@ ...@@ -252,7 +252,15 @@
<div class="submit_section"> <div class="submit_section">
<input class="submit_button" type="submit" value="Submit"> <input class="submit_button" type="submit" value="Submit">
</div> </div>
<div class="warning">
<div class="section" align="center">
This IoT Gateway includes Node-RED, a web-based tool for building Node.js applications.
<br>
The Node-RED web application is accessible at:
<a href="http://params_hostname:80">http://params_hostname:80</a>
</div>
<div class="warning">
<body> <body>
This application does not require or manage Passwords and you are responsible for securing your Gateway. This application does not require or manage Passwords and you are responsible for securing your Gateway.
<br> <br>
......
...@@ -234,9 +234,12 @@ function submitForm(params, res, req) { ...@@ -234,9 +234,12 @@ function submitForm(params, res, req) {
} }
} }
var nameobj;
// no errors occurred. Do success response. // no errors occurred. Do success response.
exec (BIN_DIR+'/configure_gateway --showNames', function (error, stdout, stderr) { exec (BIN_DIR+'/configure_gateway --showNames', function (error, stdout, stderr) {
var nameobj = {hostname: "unknown", ssid: "unknown", default_ssid: "unknown"}; nameobj = {hostname: "unknown", ssid: "unknown", default_ssid: "unknown"};
try { try {
nameobj = JSON.parse(stdout); nameobj = JSON.parse(stdout);
} catch (ex) { } catch (ex) {
...@@ -327,7 +330,7 @@ function requestHandler(req, res) { ...@@ -327,7 +330,7 @@ function requestHandler(req, res) {
if ((result.code != 0) || ((typeof result.output !== 'undefined') && (result.output.trim() != "Master"))) { if ((result.code != 0) || ((typeof result.output !== 'undefined') && (result.output.trim() != "Master"))) {
var res_str = fs.readFileSync(site + '/status.html', {encoding: 'utf8'}); var res_str = fs.readFileSync(site + '/status.html', {encoding: 'utf8'});
var myhostname, myipaddr; var myipaddr;
exec(BIN_DIR+'/configure_gateway --showWiFiIP', function (error, stdout, stderr) { exec(BIN_DIR+'/configure_gateway --showWiFiIP', function (error, stdout, stderr) {
if (error) { if (error) {
console.log("Error occurred:"); console.log("Error occurred:");
...@@ -338,7 +341,9 @@ function requestHandler(req, res) { ...@@ -338,7 +341,9 @@ function requestHandler(req, res) {
} }
}); });
} else { } else {
res.end(getStateBasedIndexPage()); var res_str = getStateBasedIndexPage();
res_str.replace(/params_hostname/g, nameobj.hostname + ".local");
res.end(res_str);
} }
} else if (urlobj.pathname === '/wifiNetworks') { } else if (urlobj.pathname === '/wifiNetworks') {
if (fs.existsSync(NETWORKS_FILE)) { if (fs.existsSync(NETWORKS_FILE)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment