diff --git a/src/routes/ws/websocketRoute.ts b/src/routes/ws/websocketRoute.ts
index 6aefd82..1e4c1a2 100644
--- a/src/routes/ws/websocketRoute.ts
+++ b/src/routes/ws/websocketRoute.ts
@@ -50,12 +50,22 @@ router.ws('/', async (ws, req, next) => {
switch (msg.event) {
case WebSocketEvent.CONTAINERS: {
- let data = msg.data as { pumpPin: number; sensorType: SensorType; sensor1: number; sensor2: number; useProxy: boolean }[];
- await Container.deleteMany({}); // V2: Remove this and check every container based on id if changes occurs
+ let data = msg.data as { id?: string, pumpPin: number; sensorType: SensorType; sensor1: number; sensor2: number; useProxy: boolean }[];
+ // await Container.deleteMany({}); // V2: Remove this and check every container based on id if changes occurs
let i = 0;
for (let c of data) {
- let container = new Container();
+ let container : IContainer | null = null;
+
+ if( c.id )
+ {
+ container = await Container.findOne( {_id: c.id } );
+ }
+
+ if( !container )
+ container = new Container();
+
+
container.slot = i;
//container.volume = c.volume; // V2: Removed
container.pumpPin = c.pumpPin;
diff --git a/src/web/Setup.ts b/src/web/Setup.ts
index 428c8b8..505035a 100644
--- a/src/web/Setup.ts
+++ b/src/web/Setup.ts
@@ -12,13 +12,11 @@ import {RequestType} from "../RequestType";
export class Setup {
+ public static arduinoProxyCheckboxes: HTMLInputElement[] = [];
private static usingProxy = false;
-
private static pins_pi = [3, 7, 8, 10, 11, 12, 13, 15, 16, 18, 19, 21, 22, 23, 24, 26, 29, 31, 32, 33, 35, 36, 37, 38];
private static pins_arduino = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53];
- public static arduinoProxyCheckboxes: HTMLInputElement[] = [];
-
public static onConfigUpdate(payload: WebSocketPayload) {
// Setup containers updated
const ledGPIO = document.getElementById("ledGPIO") as HTMLInputElement;
@@ -34,8 +32,7 @@ export class Setup {
this.usingProxy = proxyCheckbox.checked;
for (let checkbox of this.arduinoProxyCheckboxes) {
checkbox.disabled = !proxyCheckbox.checked;
- if( !proxyCheckbox.checked )
- {
+ if (!proxyCheckbox.checked) {
checkbox.checked = false;
let event = new Event('change', {bubbles: true});
checkbox.dispatchEvent(event); // Trigger virtual onChange event
@@ -162,8 +159,6 @@ Dort werden die Behälter definiert, welche in den iTender gestellt werden.
D
}
-
-
const ledCheckbox = document.getElementById("ledCheckbox") as HTMLInputElement;
const ledGPIO = document.getElementById("ledGPIO") as HTMLInputElement;
const ambientColor = document.getElementById("ambientColor") as HTMLInputElement;
@@ -173,7 +168,7 @@ Dort werden die Behälter definiert, welche in den iTender gestellt werden.
D
// Containers
- let cons: { pumpPin: number; sensorType: SensorType; sensor1: number; sensor2: number; useProxy: boolean }[] = [];
+ let cons: { id: string, pumpPin: number; sensorType: SensorType; sensor1: number; sensor2: number; useProxy: boolean }[] = [];
for (let c of (document.getElementById("setupContainers") as HTMLDivElement).getElementsByTagName("div")) {
let sensorType = c.getElementsByTagName("select")[1].value;
let type;
@@ -189,7 +184,8 @@ Dort werden die Behälter definiert, welche in den iTender gestellt werden.
D
"pumpPin": parseInt(c.getElementsByTagName("select")[0].value),
"sensorType": type,
"sensor1": parseInt(c.getElementsByTagName("select")[2].value),
- "sensor2": parseInt(c.getElementsByTagName("select")[3].value)
+ "sensor2": parseInt(c.getElementsByTagName("select")[3].value),
+ "id": c.id,
});
}
let newConf = {
@@ -231,7 +227,6 @@ Dort werden die Behälter definiert, welche in den iTender gestellt werden.
D
setTimeout(() => {
saveModal.close();
-
this.startTare();
}, 1000);
@@ -255,7 +250,7 @@ Dort werden die Behälter definiert, welche in den iTender gestellt werden.
D
// Needs to be after selectPin.append because noSel-Pin should always be at pos 0
let event = new Event('click', {bubbles: true});
let btn = document.getElementById("setup_cancelBtn");
- if(btn )
+ if (btn)
btn.dispatchEvent(event);
});
@@ -299,7 +294,7 @@ Alle Sensoren wurden erfolgreich kalibriert.
`;
clearInterval(tareInterval);
let event = new Event('click', {bubbles: true});
let btn = document.getElementById("setup_cancelBtn");
- if(btn )
+ if (btn)
btn.dispatchEvent(event);
};
} else {