From 975ecf842b5065cf137006505ceb6a845096bfe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20H=C3=B6rstrup?= Date: Tue, 20 Aug 2024 14:59:59 +0200 Subject: [PATCH] Rename pfdl message field from order_id to order_uuid --- application.py | 12 ++++++------ static/js/petri_net_helper.js | 4 ++-- templates/index.html | 20 ++++++++++---------- templates/log.html | 2 +- templates/order_history.html | 4 ++-- templates/order_state.html | 6 +++--- templates/view_petri_net.html | 2 +- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/application.py b/application.py index 2be49b6..6943a2b 100644 --- a/application.py +++ b/application.py @@ -158,8 +158,8 @@ def new_order(): # global order_dict pfdl_order = json.loads(request.data) - if pfdl_order["order_id"] in order_dict: - po = order_dict[pfdl_order["order_id"]] + if pfdl_order["order_uuid"] in order_dict: + po = order_dict[pfdl_order["order_uuid"]] po.starting_date = pfdl_order["starting_date"] po.last_update = pfdl_order["last_update"] po.status = pfdl_order["status"] @@ -182,7 +182,7 @@ def new_order(): socketio.emit("remove_pfdl_order", {"pfdl_order": pfdl_order}, namespace="/pfdl") else: po = PfdlOrder( - pfdl_order["order_id"], + pfdl_order["order_uuid"], pfdl_order["starting_date"], pfdl_order["last_update"], pfdl_order["status"], @@ -227,7 +227,7 @@ def get_pfdl_order_by_id(order_id): def update_petri_net(): record = json.loads(request.data) - order_id = record["order_id"] + order_id = record["order_uuid"] pn = PetriNet(order_id, record["content"], record["type_pn"]) if order_id in order_dict: @@ -246,9 +246,9 @@ def update_petri_net(): @app.route("/log_event/", methods=["POST"]) def new_log_entry(): log_event = json.loads(request.data) - order_id = log_event["order_id"] + order_id = log_event["order_uuid"] l_e = LogEvent( - log_event["order_id"], + log_event["order_uuid"], log_event["log_date"], log_event["log_message"], log_event["log_level"], diff --git a/static/js/petri_net_helper.js b/static/js/petri_net_helper.js index 5824750..623728e 100644 --- a/static/js/petri_net_helper.js +++ b/static/js/petri_net_helper.js @@ -128,7 +128,7 @@ const fitGraphAsImage = async function () { }; const createPetriNet = async function (msg, petriNetInfos) { - if (msg["order_id"] != petriNetInfos.orderId) { + if (msg["order_uuid"] != petriNetInfos.orderId) { return; } // enable the graph creation code to access the dotstring and tree structure @@ -155,7 +155,7 @@ const onPetriNetDrawn = async function (petriNetInfos) { }; const onUpdateMessageReceived = function (msg, petriNetInfos) { - if (msg["order_id"] != petriNetInfos.orderId) { + if (msg["order_uuid"] != petriNetInfos.orderId) { return; } // check if another petri net is currently drawn diff --git a/templates/index.html b/templates/index.html index 969249f..99146c8 100644 --- a/templates/index.html +++ b/templates/index.html @@ -26,27 +26,27 @@ //receive details from server socket.on("pfdl_order", function (msg) { - if (document.getElementById(msg.pfdl_order["order_id"])) { - document.getElementById(msg.pfdl_order["order_id"]).remove(); + if (document.getElementById(msg.pfdl_order["order_uuid"])) { + document.getElementById(msg.pfdl_order["order_uuid"]).remove(); } new_item = '
'; new_item += '
'; new_item += createHtmlStatus(msg.pfdl_order["status"]); new_item += " Order: " + - msg.pfdl_order["order_id"] + + msg.pfdl_order["order_uuid"] + " | Status: " + statusToText(msg.pfdl_order["status"]); new_item += "
"; new_item += '
'; new_item += '

Latest Log Messages:

'; new_item += - '
    '; + '
      '; msg.last_messages.forEach((item, index) => { new_item += '
    • '; @@ -65,7 +65,7 @@ "

      "; new_item += '

      Details'; new_item += "

"; new_item += "

"; @@ -89,17 +89,17 @@ "
"; }); document.getElementById( - "latest_messages_" + msg.log_event["order_id"] + "latest_messages_" + msg.log_event["order_uuid"] ).innerHTML = new_item; }); socket.on("remove_pfdl_order", function (msg) { - if (document.getElementById(msg.pfdl_order["order_id"])) { - document.getElementById(msg.pfdl_order["order_id"]).remove(); + if (document.getElementById(msg.pfdl_order["order_uuid"])) { + document.getElementById(msg.pfdl_order["order_uuid"]).remove(); new_item = '