parent
053fd3e260
commit
00a53c05fb
@ -62,26 +62,28 @@ export class WebSocketHandler {
|
||||
return new Promise(async resolve => {
|
||||
|
||||
let counts: any[] = [];
|
||||
for (let drink of (await Drink.find())) {
|
||||
// @ts-ignore
|
||||
let drinks = await Drink.find();
|
||||
for (let drink of drinks) {
|
||||
console.log(drink._id);
|
||||
console.log( (await Job.countDocuments( )) );
|
||||
let count = await Job.countDocuments({drink: drink._id});
|
||||
console.log(count);
|
||||
|
||||
counts.push([drink, count]);
|
||||
}
|
||||
|
||||
|
||||
counts.sort((a, b) => {
|
||||
// @ts-ignore
|
||||
if (a[1] < b[1])
|
||||
counts = counts.sort((a, b) => {
|
||||
if (a[1] > b[1])
|
||||
return -1;
|
||||
// @ts-ignore
|
||||
else if (a[1] > b[1])
|
||||
else if (a[1] < b[1])
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
});
|
||||
|
||||
|
||||
console.debug(counts);
|
||||
|
||||
let stats = {
|
||||
"drinks_finished": (await Job.countDocuments({successful: true})),
|
||||
"drink_most": (counts.length == 0) ? "Keiner" : counts[0][0].name,
|
||||
|
@ -306,18 +306,18 @@ router.ws('/', async (ws, req, next) => {
|
||||
let result = await exec(path.join(global.appRoot, "/../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 ) {
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
let error = e as {code: number, killed: boolean, cmd: string};
|
||||
let error = e as { code: number, killed: boolean, cmd: string };
|
||||
|
||||
let msg = "";
|
||||
if(error.code == 127 )
|
||||
if (error.code == 127)
|
||||
msg = "Beim Ausführen ist ein unbekanntes Problem aufgetreten.";
|
||||
else if ( error.code == 1 )
|
||||
else if (error.code == 1)
|
||||
msg = "Die Internetverbindung ist nicht ausreichend, um iTender zu aktualisieren.";
|
||||
|
||||
await WebSocketHandler.send(new WebSocketPayload(WebSocketEvent.ERROR, "Der iTender konnte das Update nicht installieren.<br><br>" + msg ));
|
||||
log("Could not execute update.sh" );
|
||||
await WebSocketHandler.send(new WebSocketPayload(WebSocketEvent.ERROR, "Der iTender konnte das Update nicht installieren.<br><br>" + msg));
|
||||
log("Could not execute update.sh");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -328,6 +328,7 @@ router.ws('/', async (ws, req, next) => {
|
||||
if (!net)
|
||||
net = nets["wlp0s20f3"];
|
||||
let ipAddr: string = "";
|
||||
|
||||
if (net)
|
||||
for (let addr of net) {
|
||||
if (addr.family == "IPv4" && addr.address && addr.address !== "127.0.0.1")
|
||||
@ -336,12 +337,11 @@ router.ws('/', async (ws, req, next) => {
|
||||
|
||||
let packageJson = require('../../../package.json');
|
||||
let wifi = (await exec("iwgetid")).stdout
|
||||
if( !wifi || wifi.length == 0 )
|
||||
{
|
||||
if (!wifi || wifi.length == 0) {
|
||||
wifi = ":Kein WiFi:";
|
||||
}
|
||||
|
||||
wifi.substring(wifi.indexOf('"') + 1, wifi.length - 2);
|
||||
wifi = wifi.substring(wifi.indexOf('"') + 1, wifi.length - 2);
|
||||
|
||||
let data = {
|
||||
"internet": iTender.internetConnection,
|
||||
|
@ -106,7 +106,6 @@ function setupOnClickEvents() {
|
||||
|
||||
|
||||
menuStatsBtn.onclick = async () => {
|
||||
|
||||
let modal = new Modal("stats", "Statistiken");
|
||||
|
||||
let table = document.createElement("table");
|
||||
|
Loading…
x
Reference in New Issue
Block a user