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

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

parent 287c1316
......@@ -42,8 +42,8 @@ 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
md5sum = 4d6639424300a5f165730de6e267543a
md5sum = f4e21f22719347c8a22d6a82f0782eba
......@@ -276,12 +276,14 @@ import { evalScript, fdopen, loadFile, open } from "std";
while (parsed_message.timestamp !== last_message_timestamp_list[id]) {
if (user_me.hasOwnProperty("onGetMsg")
&& [-1, user_me.id].includes(parsed_message.dest_id)) {
console.log("running on getMsg");
user_me.onGetMsg(parsed_message.content);
}
last_message_timestamp_list[id] = parsed_message.timestamp;
parsed_message = JSON.parse(peer.message);
message = peer.message;
if (message.length > 0) {
parsed_message = JSON.parse(message);
}
}
}
});
......
......@@ -23,12 +23,13 @@
socket;
function updateConnexionClass(element, status) {
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(
status ? CONNECTED_CLASS_NAME : DISCONNECTED_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