diff --git a/gui/preload-chat.js b/gui/preload-chat.js index 313311f9..4c600cf7 100644 --- a/gui/preload-chat.js +++ b/gui/preload-chat.js @@ -1022,6 +1022,28 @@ update_chat = function (obj) { var attempt = obj.attempt; } +// add percent and bytes per minute if not existing +console.log(obj.percent) +if (typeof obj.percent == "undefined") { + obj.percent = 0; + obj.bytesperminute = 0; + } + + // check if wrong status message +if (obj.status == "transmit" && obj.percent == 0) { +var TimeDifference = (new Date().getTime()/1000) - obj.timestamp + if (TimeDifference > 3600){ + db.upsert(obj._id, function (doc) { + if (!doc.status) { + doc.status = "failed"; + } + return doc; + }); + obj.status = "failed"; + + } +} + if (typeof config.max_retry_attempts == "undefined") { var max_retry_attempts = 3; } else { @@ -1382,6 +1404,8 @@ update_chat = function (obj) { //console.log("Low graphics enabled for chat module"); } + + var new_message = `
${controlarea_transmit} @@ -1415,7 +1439,7 @@ update_chat = function (obj) { }%;" aria-valuenow="${ obj.percent }" aria-valuemin="0" aria-valuemax="100">
-

${percent_value} % - ${ obj.bytesperminute @@ -1436,6 +1460,12 @@ update_chat = function (obj) { console.log("element already exists......"); console.log(obj); + console.log(obj.status) + console.log(obj.attempt) + + + + if ( !obj.status == "broadcast_transmit" || !obj.status == "broadcast_received" @@ -1456,6 +1486,44 @@ update_chat = function (obj) { document.getElementById("msg-" + obj._id + "-attempts").innerHTML = obj.attempt + "/" + max_retry_attempts; } + + + if (obj.status == "transmit") { + + document.getElementById("msg-" + obj._id + "-status").innerHTML = + get_icon_for_state(obj.status); + +if (typeof obj.percent !== "undefined") { + document + .getElementById("msg-" + obj._id + "-progress") + .setAttribute("aria-valuenow", obj.percent); + document + .getElementById("msg-" + obj._id + "-progress") + .setAttribute("style", "width:" + obj.percent + "%;"); + document.getElementById( + "msg-" + obj._id + "-progress-information" + ).innerHTML = obj.percent + "% - " + obj.bytesperminute + " Bpm"; + + } else { + document + .getElementById("msg-" + obj._id + "-progress") + .setAttribute("aria-valuenow", 0); + document + .getElementById("msg-" + obj._id + "-progress") + .setAttribute("style", "width:0%;"); + document.getElementById( + "msg-" + obj._id + "-progress-information" + ).innerHTML = "0% - 0 Bpm"; + + } + + + + + document.getElementById("msg-" + obj._id + "-attempts").innerHTML = + obj.attempt + "/" + max_retry_attempts; + } + if (obj.status == "transmitted") { //document.getElementById('msg-' + obj._id + '-progress').classList.remove("progress-bar-striped"); document @@ -1496,9 +1564,15 @@ update_chat = function (obj) { .getElementById("msg-" + obj._id + "-progress") .classList.add("bg-danger"); + console.log(document + .getElementById("msg-" + obj._id + "-progress") + .classList) + document.getElementById( "msg-" + obj._id + "-progress-information" ).innerHTML = "TRANSMISSION FAILED - " + obj.bytesperminute + " Bpm"; + + } //document.getElementById(id).className = message_class;