barcode-host/Server/wwwroot/js/notification.js
2023-08-02 15:35:28 -07:00

62 lines
2.2 KiB
JavaScript

"use strict";
console.log(appSettings.OpenInsightApplicationProgrammingInterface);
document.getElementById("equipmentName").innerText = appSettings.EquipmentName;
var connection = new signalR.HubConnectionBuilder()
.withUrl("/NotificationHub")
.build();
connection.on("NotifyAll", function (data) {
document.getElementById("error").innerHTML = "";
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 {
var mId = postResult.MId.replace(/\r\n/g, ' ');
if (mId.length == postResult.MId) {
document.getElementById("mId").innerText = `Use ${mId} for the wafer and input id`;
}
else {
document.getElementById("mId").innerText = "";
document.getElementById("error").innerHTML = mId;
}
}
if (!postResult.QaMetTests) {
document.getElementById("qaMetTests").innerText = data.httpContentBody;
} else {
var properties = [];
var qaMetTests = "";
for (const property in postResult.QaMetTests)
properties.push(property);
for (var i = 0; i < properties.length; i++) {
for (var j = 0; j < postResult.QaMetTests[properties[i]].length; j++) {
qaMetTests += properties[i] + " - [" + postResult.QaMetTests[properties[i]][j].Recipe + "] - [" + postResult.QaMetTests[properties[i]][j].RecipePattern + "]<br />";
}
}
document.getElementById("qaMetTests").innerHTML = qaMetTests;
}
}
});
connection
.start()
.then(function () { })
.catch(function (err) {
return console.error(err.toString());
});