Commit b86b4940 authored by David Mondou's avatar David Mondou
Browse files

Merge branch 'feature/add_demo_url' into 'master'

Feature/add demo url

See merge request !4
parents e151c112 4ba58747
......@@ -252,7 +252,15 @@
<div class="submit_section">
<input class="submit_button" type="submit" value="Submit">
</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:params_node_red_http_port">http://params_hostname:params_node_red_http_port</a>
</div>
<div class="warning">
<body>
This application does not require or manage Passwords and you are responsible for securing your Gateway.
<br>
......
......@@ -28,6 +28,7 @@ var supportedExtensions = {
"png" : "image/png"
};
var PORT = 8000;
var NODE_RED_PORT = 80;
var STATE_DIR = '/var/lib/gateway_config_tools';
var BIN_DIR = './bin';
var NETWORKS_FILE = STATE_DIR + '/networks.txt';
......@@ -234,6 +235,7 @@ function submitForm(params, res, req) {
}
}
// no errors occurred. Do success response.
exec (BIN_DIR+'/configure_gateway --showNames', function (error, stdout, stderr) {
var nameobj = {hostname: "unknown", ssid: "unknown", default_ssid: "unknown"};
......@@ -327,7 +329,7 @@ function requestHandler(req, res) {
if ((result.code != 0) || ((typeof result.output !== 'undefined') && (result.output.trim() != "Master"))) {
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) {
if (error) {
console.log("Error occurred:");
......@@ -338,7 +340,21 @@ function requestHandler(req, res) {
}
});
} else {
res.end(getStateBasedIndexPage());
exec ('/usr/bin/unit_serial_number', function (error, stdout, stderr) {
var sn = stdout.trim();
if(error || !sn ) {
console.log("error getting serial number!", error);
sn = "unknown"
}
var res_str = getStateBasedIndexPage();
var host_url = sn + ".local";
var host_port = NODE_RED_PORT.toString().trim();
res_str = res_str.replace(/params_hostname/g, host_url);
res_str = res_str.replace(/params_node_red_http_port/g, host_port);
res.end(res_str);
});
}
} else if (urlobj.pathname === '/wifiNetworks') {
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