barcode-host/Server/wwwroot/js/notification.js
2023-08-02 11:41:17 -07:00

55 lines
1.8 KiB
JavaScript

"use strict";
console.log(appSettings.OpenInsightApplicationProgrammingInterface);
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("mId").innerText = "";
document.getElementById("qaMetTests").innerText = "";
}
} else {
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.QaMetTests) {
document.getElementById("qaMetTests").innerText = data.httpContentBody;
} else {
var properties = [];
var qaMetTests = "";
for (const property in postResult)
properties.push(property);
for (var i = 0; i < properties.length; i++) {
for (var j = 0; j < postResult[properties[i]].length; j++) {
qaMetTests += properties[i] + " - [" + postResult[properties[i]][j].recipe + "] - [" + postResult[properties[i]][j].recipePattern + "]<br />";
}
}
document.getElementById("qaMetTests").innerText = qaMetTests;
}
}
});
connection
.start()
.then(function () { })
.catch(function (err) {
return console.error(err.toString());
});