add and close #12

Took 1 hour 46 minutes
This commit is contained in:
2023-02-02 14:28:09 +01:00
parent a021d25332
commit 937f825e82
13 changed files with 135 additions and 89 deletions

View File

@ -77,6 +77,17 @@ router.ws('/', async (ws, req, next) => {
await container.save();
i++;
}
let containers : IContainer[] = await Container.find();
for( let c of containers )
{
let find = data.find( (e) => {
return c._id == e.id;
} );
if( !find )
await Container.deleteOne({_id: c._id });
}
break;
}
@ -211,7 +222,7 @@ router.ws('/', async (ws, req, next) => {
} catch (e) {
log("Checkup failed");
content.success = false;
content.msg = "Bei der Kommunikation mit dem Arduino Proxy ist ein Fehler aufgetreten.<br>Technische Details: " + e;
content.msg = "Bei der Kommunikation mit dem Arduino Proxy ist ein Fehler aufgetreten.<br><br><em>Technische Details: " + e + "</em>";
return WebSocketHandler.answerRequest(msg.data["type"] as RequestType, content);
}
}
@ -288,13 +299,20 @@ router.ws('/', async (ws, req, next) => {
}
case RequestType.UPDATE: {
/*
- git pull
- yarn install
- yarn run compile
- (arduino update?)
- reboot
*/
if( !iTender.internetConnection )
return WebSocketHandler.answerRequest(msg.data["type"] as RequestType, false);
WebSocketHandler.answerRequest(msg.data["type"] as RequestType, true);
try {
let result = await exec("/home/itender/itender/update.sh");
if( result.stderr )
await WebSocketHandler.send(new WebSocketPayload(WebSocketEvent.ERROR, "Der iTender konnte das Update nicht installieren.<br>Möglicherweise ist die Internetverbindung nicht ausreichend oder das Update enthält Fehler.<br>"));
} catch( e )
{
await WebSocketHandler.send(new WebSocketPayload(WebSocketEvent.ERROR, "Der iTender konnte das Update nicht installieren.<br>Möglicherweise ist die Internetverbindung nicht ausreichend oder das Update enthält Fehler.<br>"));
}
break;
}
@ -321,7 +339,9 @@ router.ws('/', async (ws, req, next) => {
"ip": ipAddr,
"network": wifi.substring(wifi.indexOf('"')+1,wifi.length-2),
"uptime": (await exec("uptime -p")).stdout.substring(3),
"version": packageJson.version
"version": packageJson.version,
"author": "Tobias Hopp",
"contact": "tobi@gaminggeneration.de"
}
return WebSocketHandler.answerRequest(msg.data["type"] as RequestType, data);