From 67a9fc19ec1496045d5acdecbcc3e3cc7e198569 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Tue, 14 Nov 2023 18:06:09 -0500 Subject: [PATCH] new&renamed buttons, fixed quit button --- modules/_server.js | 22 +++++++++++++++++----- modules/functions.js | 4 ++-- www/public/main.css | 4 ++++ www/views/index.html | 10 +++++++--- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/modules/_server.js b/modules/_server.js index 4910c08..900ceac 100644 --- a/modules/_server.js +++ b/modules/_server.js @@ -10,6 +10,7 @@ // Modules const express = require('express'); const http = require('http'); +const fs = require('fs'); const fn = require('./functions.js').functions; const { dbfn } = require('./functions.js'); @@ -39,21 +40,23 @@ app.get('/', (req, res) => { // A POST form submission to the root page app.post('/', (req, response) => { - if (req.body.start != undefined) { - fn.commands.startup(); + if (req.body.augerOn != undefined) { + fn.commands.augerOn(); fn.commands.refreshConfig().then(res => { config = res.config; response.render('index', { config: JSON.stringify(config) }); return; }); + return; } - if (req.body.shutdown != undefined) { - fn.commands.shutdown(); + if (req.body.augerOff != undefined) { + fn.commands.augerOff(); fn.commands.refreshConfig().then(res => { config = res.config; response.render('index', { config: JSON.stringify(config) }); return; }); + return; } if (req.body.reload != undefined) { const updateAugerOffIntervalQuery = `UPDATE intervals SET value = '${2000 - req.body.feedRate}' WHERE key = 'auger_off'`; @@ -69,15 +72,24 @@ app.post('/', (req, response) => { }); }).catch(err => console.log(`E: ${err}`)); }).catch(err => console.log(`E: ${err}`)); + return; } if (req.body.quit != undefined) { - fn.commands.quit(); + fs.appendFile('quit', ".", err => { + if (err) console.error(err); + }); fn.commands.refreshConfig().then(res => { config = res.config; response.render('index', { config: JSON.stringify(config) }); return; }); + return; } + fn.commands.refreshConfig().then(res => { + config = res.config; + response.render('index', { config: JSON.stringify(config) }); + return; + }); }); module.exports = { diff --git a/modules/functions.js b/modules/functions.js index 642acc7..1ec8ec1 100644 --- a/modules/functions.js +++ b/modules/functions.js @@ -86,7 +86,7 @@ const functions = { }, commands: { // Prepare the stove for starting - startup() { + augerOn() { // FKA startup() // Basic startup just enables the auger const enableAugerQuery = "UPDATE status SET value = 1 WHERE key = 'auger'"; dbfn.run(enableAugerQuery).then(res => { @@ -94,7 +94,7 @@ const functions = { return; }).catch(err => console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] E: ${err}`)); }, - shutdown() { + augerOff() { // FKA shutdown() // Basic shutdown only needs to disable the auger const disableAugerQuery = "UPDATE status SET value = 0 WHERE key = 'auger'"; dbfn.run(disableAugerQuery).then(res => { diff --git a/www/public/main.css b/www/public/main.css index e97fdc8..050b923 100644 --- a/www/public/main.css +++ b/www/public/main.css @@ -99,4 +99,8 @@ table, th, td { th, td { width: 50%; +} + +#quit { + /* visibility: hidden; */ } \ No newline at end of file diff --git a/www/views/index.html b/www/views/index.html index 349a169..ef500ee 100644 --- a/www/views/index.html +++ b/www/views/index.html @@ -43,8 +43,12 @@
- - + + + + + +
@@ -67,7 +71,7 @@
-->
- +