new&renamed buttons, fixed quit button
This commit is contained in:
parent
db763223c6
commit
67a9fc19ec
@ -10,6 +10,7 @@
|
|||||||
// Modules
|
// Modules
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
|
const fs = require('fs');
|
||||||
const fn = require('./functions.js').functions;
|
const fn = require('./functions.js').functions;
|
||||||
const { dbfn } = require('./functions.js');
|
const { dbfn } = require('./functions.js');
|
||||||
|
|
||||||
@ -39,21 +40,23 @@ app.get('/', (req, res) => {
|
|||||||
|
|
||||||
// A POST form submission to the root page
|
// A POST form submission to the root page
|
||||||
app.post('/', (req, response) => {
|
app.post('/', (req, response) => {
|
||||||
if (req.body.start != undefined) {
|
if (req.body.augerOn != undefined) {
|
||||||
fn.commands.startup();
|
fn.commands.augerOn();
|
||||||
fn.commands.refreshConfig().then(res => {
|
fn.commands.refreshConfig().then(res => {
|
||||||
config = res.config;
|
config = res.config;
|
||||||
response.render('index', { config: JSON.stringify(config) });
|
response.render('index', { config: JSON.stringify(config) });
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (req.body.shutdown != undefined) {
|
if (req.body.augerOff != undefined) {
|
||||||
fn.commands.shutdown();
|
fn.commands.augerOff();
|
||||||
fn.commands.refreshConfig().then(res => {
|
fn.commands.refreshConfig().then(res => {
|
||||||
config = res.config;
|
config = res.config;
|
||||||
response.render('index', { config: JSON.stringify(config) });
|
response.render('index', { config: JSON.stringify(config) });
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (req.body.reload != undefined) {
|
if (req.body.reload != undefined) {
|
||||||
const updateAugerOffIntervalQuery = `UPDATE intervals SET value = '${2000 - req.body.feedRate}' WHERE key = 'auger_off'`;
|
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}`));
|
||||||
}).catch(err => console.log(`E: ${err}`));
|
}).catch(err => console.log(`E: ${err}`));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (req.body.quit != undefined) {
|
if (req.body.quit != undefined) {
|
||||||
fn.commands.quit();
|
fs.appendFile('quit', ".", err => {
|
||||||
|
if (err) console.error(err);
|
||||||
|
});
|
||||||
fn.commands.refreshConfig().then(res => {
|
fn.commands.refreshConfig().then(res => {
|
||||||
config = res.config;
|
config = res.config;
|
||||||
response.render('index', { config: JSON.stringify(config) });
|
response.render('index', { config: JSON.stringify(config) });
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
fn.commands.refreshConfig().then(res => {
|
||||||
|
config = res.config;
|
||||||
|
response.render('index', { config: JSON.stringify(config) });
|
||||||
|
return;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -86,7 +86,7 @@ const functions = {
|
|||||||
},
|
},
|
||||||
commands: {
|
commands: {
|
||||||
// Prepare the stove for starting
|
// Prepare the stove for starting
|
||||||
startup() {
|
augerOn() { // FKA startup()
|
||||||
// Basic startup just enables the auger
|
// Basic startup just enables the auger
|
||||||
const enableAugerQuery = "UPDATE status SET value = 1 WHERE key = 'auger'";
|
const enableAugerQuery = "UPDATE status SET value = 1 WHERE key = 'auger'";
|
||||||
dbfn.run(enableAugerQuery).then(res => {
|
dbfn.run(enableAugerQuery).then(res => {
|
||||||
@ -94,7 +94,7 @@ const functions = {
|
|||||||
return;
|
return;
|
||||||
}).catch(err => console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] E: ${err}`));
|
}).catch(err => console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] E: ${err}`));
|
||||||
},
|
},
|
||||||
shutdown() {
|
augerOff() { // FKA shutdown()
|
||||||
// Basic shutdown only needs to disable the auger
|
// Basic shutdown only needs to disable the auger
|
||||||
const disableAugerQuery = "UPDATE status SET value = 0 WHERE key = 'auger'";
|
const disableAugerQuery = "UPDATE status SET value = 0 WHERE key = 'auger'";
|
||||||
dbfn.run(disableAugerQuery).then(res => {
|
dbfn.run(disableAugerQuery).then(res => {
|
||||||
|
@ -99,4 +99,8 @@ table, th, td {
|
|||||||
|
|
||||||
th, td {
|
th, td {
|
||||||
width: 50%;
|
width: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#quit {
|
||||||
|
/* visibility: hidden; */
|
||||||
}
|
}
|
@ -43,8 +43,12 @@
|
|||||||
<form action="/" method="post">
|
<form action="/" method="post">
|
||||||
<!-- Start | Shutdown | Reload Settings -->
|
<!-- Start | Shutdown | Reload Settings -->
|
||||||
<div class="button-container d-flex justify-content-between">
|
<div class="button-container d-flex justify-content-between">
|
||||||
<input class="btn btn-outline-secondary" type="submit" id="ignite" value="Enable Auger" name="start">
|
<input class="btn btn-outline-secondary" type="submit" id="auger-on" value="Enable Auger" name="augerOn">
|
||||||
<input class="btn btn-outline-secondary" type="submit" id="shutdown" value="Disable Auger" name="shutdown">
|
<input class="btn btn-outline-secondary" type="submit" id="auger-off" value="Disable Auger" name="augerOff">
|
||||||
|
<input class="btn btn-outline-secondary" type="submit" id="igniter-on" value="Enable Igniter" name="igniterOn">
|
||||||
|
<input class="btn btn-outline-secondary" type="submit" id="igniter-off" value="Disable Igniter" name="igniterOff">
|
||||||
|
<input class="btn btn-outline-secondary" type="submit" id="exhaust-on" value="Enable Exhaust" name="exhaustOn">
|
||||||
|
<input class="btn btn-outline-secondary" type="submit" id="exhaust-off" value="Disable Exhaust" name="exhaustOff">
|
||||||
</div>
|
</div>
|
||||||
<!-- Set feed rates -->
|
<!-- Set feed rates -->
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@ -67,7 +71,7 @@
|
|||||||
</div> -->
|
</div> -->
|
||||||
<div class="controls-container">
|
<div class="controls-container">
|
||||||
<form action="/" method="POST">
|
<form action="/" method="POST">
|
||||||
<input class="btn btn-danger" type="submit" id="quit" value="Quit!!" name="quit" style="visibility: hidden;">
|
<input class="btn btn-danger" type="submit" id="quit" value="Quit!!" name="quit">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<!-- <script src="./main.js"></script> -->
|
<!-- <script src="./main.js"></script> -->
|
||||||
|
Loading…
Reference in New Issue
Block a user