barcode-host/Server/wwwroot/js/notification.js
2023-07-27 12:37:24 -07:00

57 lines
1.8 KiB
JavaScript

"use strict";
var connection = new signalR.HubConnectionBuilder()
.withUrl("/NotificationHub")
.build();
connection.on("NotifyAll", function (data) {
if (!data.keyPressEvent || !data.lastScanServiceResultValue) {
if (!data.httpContentBody) {
document.getElementById("lastScanServiceResultValue").innerText = "";
}
} else {
var innerText = `${data.keyPressEvent.dateTime} - [${data.lastScanServiceResultValue}]`;
document.getElementById("lastScanServiceResultValue").innerText = innerText;
}
if (!data.httpContentBody) {
if (!data.keyPressEvent || !data.lastScanServiceResultValue) {
document.getElementById("httpContentBody").innerText = data;
document.getElementById("mId").innerText = "";
document.getElementById("recipe").innerText = "";
}
} else {
document.getElementById("httpContentBody").innerText = data.httpContentBody;
var postResult = JSON.parse(data.httpContentBody);
if (!postResult.MId) {
document.getElementById("mId").innerText = "";
} else {
document.getElementById(
"mId",
).innerText = `Use ${postResult.MId} for the wafer and input id`;
}
if (!postResult.Recipe) {
document.getElementById("recipe").innerText = "";
} else {
if (postResult.Recipe != "Recipe") {
document.getElementById("recipe").innerText = postResult.Recipe;
} else {
$.getJSON(
"https://oi-prod-ec-api.mes.infineon.com/api/oiWizard/materials/rds/" +
postResult.LotName,
function (data) {
document.getElementById("recipe").innerText =
data.rds.rdsLayers.length;
},
);
}
}
}
});
connection
.start()
.then(function () {})
.catch(function (err) {
return console.error(err.toString());
});