diff --git a/data/config.db b/data/config.db index 4cf319b..2ddcf9d 100644 Binary files a/data/config.db and b/data/config.db differ diff --git a/hestia.sh b/hestia.sh index f1a0c91..8576743 100755 --- a/hestia.sh +++ b/hestia.sh @@ -55,7 +55,6 @@ case "$opt" in clear echo "Launching Hestia Web Portal" nohup node main.js > log.txt & - nohup node modules/_server.js & ;; 2) # Quit Hestia Web Portal diff --git a/main.js b/main.js index 184f5bf..5cc9179 100644 --- a/main.js +++ b/main.js @@ -3,6 +3,9 @@ const fn = require('./modules/functions.js').functions; var config = require('./templates/config.json'); // Database Functions const dbfn = require('./modules/database.js'); +// Web Portal +const portal = require('./modules/_server.js'); +portal.start(); dbfn.run(`UPDATE timestamps SET value = ${Date.now()} WHERE key = 'process_start'`).catch(err => console.error(`Error setting process start time: ${err}`)); diff --git a/modules/_server.js b/modules/_server.js index 215fa7c..529146e 100644 --- a/modules/_server.js +++ b/modules/_server.js @@ -29,12 +29,13 @@ app.set('view engine', 'html'); // A normal load of the root page app.get('/', (req, res) => { - res.render('index', config); + if (process.env.DEBUG) console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] I: ${JSON.stringify(config)}`); + res.render('index', { config: JSON.stringify(config) }); }); // A POST form submission to the root page app.post('/', (req, res) => { - res.render('index', config); + res.render('index', { config }); if (req.body.start != undefined) { fn.commands.startup(); } @@ -57,4 +58,8 @@ app.post('/', (req, res) => { } }); -server.listen(8080, "0.0.0.0"); \ No newline at end of file +module.exports = { + start: () => { + server.listen(8080, "0.0.0.0"); + } +}; \ No newline at end of file diff --git a/www/public/config.db b/www/public/config.db new file mode 120000 index 0000000..8e6b047 --- /dev/null +++ b/www/public/config.db @@ -0,0 +1 @@ +./data/config.db \ No newline at end of file diff --git a/www/public/config.json b/www/public/config.json deleted file mode 120000 index 19d6015..0000000 --- a/www/public/config.json +++ /dev/null @@ -1 +0,0 @@ -../../config.json \ No newline at end of file diff --git a/www/public/log.txt b/www/public/log.txt deleted file mode 120000 index ffd7298..0000000 --- a/www/public/log.txt +++ /dev/null @@ -1 +0,0 @@ -../../log.txt \ No newline at end of file diff --git a/www/public/main.js b/www/public/main.js index da1453f..4997f38 100644 --- a/www/public/main.js +++ b/www/public/main.js @@ -41,9 +41,7 @@ function refreshData() { const augerOn = statusTable.rows[0].cells[3]; const augerOff = statusTable.rows[1].cells[3]; const feedRate = statusTable.rows[1].cells[1]; - - // Get the config file - const config = readJSON('./config.json'); + // console.log(config); augerStatus.innerHTML = parseStatus(config.status.auger); diff --git a/www/views/index.html b/www/views/index.html index 013b729..d7336e9 100644 --- a/www/views/index.html +++ b/www/views/index.html @@ -10,6 +10,11 @@ + <%- include('trial.html') -%>
Hestia Web Portal @@ -48,7 +53,7 @@
- @@ -67,7 +72,84 @@
- + +