Commit b2d1d395 authored by Léo-Paul Géneau's avatar Léo-Paul Géneau 👾

software/js-drone/web-gui: Update state management

parent adf5debf
......@@ -42,7 +42,7 @@ md5sum = 34a02101a607e60f4e422375beaf7fc2
[script-js]
_update_hash_filename_ = web-gui/script.js.jinja2
md5sum = c3858b5ec7373a0932fcda911a8177b5
md5sum = 3bbb0f80b644d86784aab99b03e88c2f
[worker]
_update_hash_filename_ = drone-scripts/worker.js.jinja2
......
......@@ -23,12 +23,13 @@
socket;
function updateConnexionClass(element, status) {
element.classList.remove(
status ? DISCONNECTED_CLASS_NAME : CONNECTED_CLASS_NAME
);
element.classList.add(
status ? CONNECTED_CLASS_NAME : DISCONNECTED_CLASS_NAME
);
var class_name = status ? CONNECTED_CLASS_NAME : DISCONNECTED_CLASS_NAME;
if (!element.classList.contains(class_name)) {
element.classList.remove(
status ? DISCONNECTED_CLASS_NAME : CONNECTED_CLASS_NAME
);
element.classList.add(class_name);
}
}
function setWebSocketStatus(connected, status) {
......@@ -87,10 +88,10 @@
log_textarea.value += drone["log"];
{% endif -%}
});
} else if (message.hasOwnProperty("state") && message.hasOwnProperty("id")) {
} else if (message.hasOwnProperty("id")) {
flight_state_cell = document.getElementById(FLIGHT_STATUS_BASE_ID + message['id']);
flight_state_cell.innerHTML = message['state'];
updateConnexionClass(flight_state_cell, message['inAir']);
updateConnexionClass(flight_state_cell, message['okState']);
} else {
console.info(message);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment