Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix updated pfdl messages #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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"],
Expand Down Expand Up @@ -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:
Expand All @@ -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"],
Expand Down
4 changes: 2 additions & 2 deletions static/js/petri_net_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
20 changes: 10 additions & 10 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
'<div class = "col-12 col-md-12 col-lg-4 col-xl-4" data-sort="' +
msg.pfdl_order["last_update"] +
'" id="' +
msg.pfdl_order["order_id"] +
msg.pfdl_order["order_uuid"] +
'"">';
new_item += '<div class="card">';
new_item += createHtmlStatus(msg.pfdl_order["status"]);
new_item +=
" <strong>Order: " +
msg.pfdl_order["order_id"] +
msg.pfdl_order["order_uuid"] +
"</strong> | Status: " +
statusToText(msg.pfdl_order["status"]);
new_item += " </div>";
new_item += ' <div class="card-body">';
new_item += ' <p class="card-text">Latest Log Messages:</p>';
new_item +=
' <ul id="latest_messages_' + msg.pfdl_order["order_id"] + '">';
' <ul id="latest_messages_' + msg.pfdl_order["order_uuid"] + '">';
msg.last_messages.forEach((item, index) => {
new_item +=
'<small class="text-muted "> <li class="add-read-more show-less-content">';
Expand All @@ -65,7 +65,7 @@
"</small></p>";
new_item +=
' <p class="card-text"><small class="text-muted"><a href="/order_state/' +
msg.pfdl_order["order_id"] +
msg.pfdl_order["order_uuid"] +
'"">Details</a></small</p>';
new_item += " </div>";
new_item += "</div> <br />";
Expand All @@ -89,17 +89,17 @@
"</li></small>";
});
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 =
'<div class="alert alert-success alert-dismissible fade show" role="alert">';
new_item += "Order " + msg.pfdl_order["order_id"] + " is finished!";
new_item += "Order " + msg.pfdl_order["order_uuid"] + " is finished!";
new_item +=
'<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">';
new_item += "</button>";
Expand Down
2 changes: 1 addition & 1 deletion templates/log.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
.DataTable()
.row.add([
date,
msg["log_event"]["order_id"],
msg["log_event"]["order_uuid"],
msg["log_event"]["log_message"],
logLevelToText(msg["log_event"]["log_level"])
])
Expand Down
4 changes: 2 additions & 2 deletions templates/order_history.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
);
link =
'<a href="/order_history/' +
msg.pfdl_order["order_id"] +
msg.pfdl_order["order_uuid"] +
'">Details</a>';
$("#order-history-table")
.DataTable()
.row.add([msg.pfdl_order["order_id"], date, link])
.row.add([msg.pfdl_order["order_uuid"], date, link])
.draw(false);
});
});
Expand Down
6 changes: 3 additions & 3 deletions templates/order_state.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

//receive details from server
socket.on("new_log_event", function (msg) {
if (msg["log_event"]["order_id"] == "{{order.order_id}}") {
if (msg["log_event"]["order_uuid"] == "{{order.order_id}}") {
var date = new Date(msg["log_event"]["log_date"] * 1000).toLocaleString(
"en-GB"
);
Expand All @@ -49,7 +49,7 @@
});

socket.on("remove_pfdl_order", function (msg) {
if (msg.pfdl_order["order_id"] == "{{order.order_id}}") {
if (msg.pfdl_order["order_uuid"] == "{{order.order_id}}") {
document.getElementById("petriNetLink").href =
"/order_history/{{order.order_id}}/petri_net";

Expand All @@ -68,7 +68,7 @@
if (currentDotContent.includes("digraph")) {
// trigger the creation of the current Petri Net by sending a mock message containing the Petri Net content
const mockMessage = {
order_id: "{{order.order_id}}",
order_uuid: "{{order.order_id}}",
content: currentDotContent,
type_pn: "dot"
};
Expand Down
2 changes: 1 addition & 1 deletion templates/view_petri_net.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
});

socket.on("remove_pfdl_order", function (msg) {
if (msg.pfdl_order["order_id"] == "{{order.order_id}}") {
if (msg.pfdl_order["order_uuid"] == "{{order.order_id}}") {
document.getElementById("backLink").href =
"/order_history/{{order.order_id}}";

Expand Down