diff --git a/web/src/components/TableCategory.vue b/web/src/components/TableCategory.vue
index 4361b65..b327936 100644
--- a/web/src/components/TableCategory.vue
+++ b/web/src/components/TableCategory.vue
@@ -20,8 +20,14 @@
{{ node.status }}
-
{{ node.position.lat }} |
- {{ node.position.lng }} |
+ {{ node.position.lat }} |
+ {{ node.position.lng }} |
{{ calculateBatteryPercentage(node.batteryVoltage, node.minVoltage, node.maxVoltage) }}% |
{{ node.temperature }}°C |
{{ node.runtime }} |
@@ -121,6 +127,28 @@ export default {
} else {
return ((currentVoltage - minVoltage) / (maxVoltage - minVoltage) * 100).toFixed(2);
}
+ },
+ validateAndUpdateLatLng(node, field, event) {
+ const originalValue = node.position[field];
+ let newValue = event.target.innerText;
+
+ // normalize seperated values
+ newValue = newValue.replace(',', '.');
+
+ // check if float value
+ const validNumberRegex = /^-?\d+(\.\d+)?$/;
+
+ if (validNumberRegex.test(newValue)) {
+ const parsedValue = parseFloat(newValue);
+
+ // Update if valid
+ node.position[field] = parsedValue;
+ console.log(`Updated ${field} of ${node.name}: ${parsedValue}`);
+ } else {
+ // Reset to original value if invalid
+ event.target.innerText = originalValue;
+ console.log(`Failed to set ${field} of ${node.name}: Invalid input "${newValue}"`);
+ }
}
}
};