move outdated data warning into connected list for csv page

This commit is contained in:
Ziad-I
2024-08-08 13:35:08 +03:00
parent 27ef2b5d49
commit d142fa5e62
2 changed files with 26 additions and 14 deletions
@@ -105,11 +105,9 @@ nav ul li a.active {
color: var(--blender-selected-object, var(--nav-link-hover-color)); color: var(--blender-selected-object, var(--nav-link-hover-color));
} }
.warning { .warning,
.warning-icon {
color: var(--blender-info-warning, var(--warning-color)); color: var(--blender-info-warning, var(--warning-color));
margin-bottom: var(--margin-small);
padding: var(--padding-tiny);
display: none;
} }
#toggle-theme { #toggle-theme {
@@ -1,5 +1,5 @@
// keeps track of blenders connected in form of // keeps track of blenders connected in form of
// {shown:bool, filename:string, headers:array} // {shown:bool, filename:string, headers:array, warning: false}
const connectedClients = {}; const connectedClients = {};
let socket; let socket;
@@ -37,6 +37,7 @@ function handleBlenderConnect(blenderId) {
if (!connectedClients.hasOwnProperty(blenderId)) { if (!connectedClients.hasOwnProperty(blenderId)) {
connectedClients[blenderId] = { shown: false, ifc_file: "" }; connectedClients[blenderId] = { shown: false, ifc_file: "" };
} }
$("#blender-count").text(function (i, text) { $("#blender-count").text(function (i, text) {
return parseInt(text, 10) + 1; return parseInt(text, 10) + 1;
}); });
@@ -108,16 +109,19 @@ function handleCsvData(data) {
shown: true, shown: true,
ifc_file: filename, ifc_file: filename,
headers: [], headers: [],
warning: false,
}; };
addTableElement(blenderId, csvData, filename); addTableElement(blenderId, csvData, filename);
} else { } else {
updateTableElement(blenderId, csvData, filename); updateTableElement(blenderId, csvData, filename);
connectedClients[blenderId].warning = false;
} }
} else { } else {
connectedClients[blenderId] = { connectedClients[blenderId] = {
shown: true, shown: true,
ifc_file: filename, ifc_file: filename,
headers: [], headers: [],
warning: false,
}; };
addTableElement(blenderId, csvData, filename); addTableElement(blenderId, csvData, filename);
} }
@@ -147,19 +151,11 @@ function addTableElement(blenderId, csvData, filename) {
.text(filename) .text(filename)
.css("margin-bottom", "10px"); .css("margin-bottom", "10px");
const warning = $("<div></div>")
.attr("id", "warning-" + blenderId)
.html(
"&#9888; Warning: This table may contain outdated data due to recent changes in Blender."
)
.addClass("warning");
const tableDiv = $("<div></div>") const tableDiv = $("<div></div>")
.addClass("csv-table") .addClass("csv-table")
.attr("id", "table-" + blenderId); .attr("id", "table-" + blenderId);
tableContainer.append(tableTitle); tableContainer.append(tableTitle);
tableContainer.append(warning);
tableContainer.append(tableDiv); tableContainer.append(tableDiv);
$("#container").append(tableContainer); $("#container").append(tableContainer);
@@ -282,7 +278,7 @@ function removeTableElement(blenderId) {
} }
function showWarning(blenderId, isDirty) { function showWarning(blenderId, isDirty) {
$("#warning-" + blenderId).css("display", "block"); connectedClients[blenderId].warning = true;
} }
// Utility function to compare two csv header // Utility function to compare two csv header
@@ -349,12 +345,29 @@ function toggleClientList() {
const clientDiv = $("<div>") const clientDiv = $("<div>")
.addClass("client") .addClass("client")
.addClass(`client-${id}`)
.text(client.ifc_file || "Blender " + counter); .text(client.ifc_file || "Blender " + counter);
if (client.warning) {
warningIcon = $("<i>")
.addClass("fas fa-triangle-exclamation warning")
.css("margin-left", "0.5rem");
clientDiv.append(warningIcon);
}
clientDiv.append(dropdownIcon); clientDiv.append(dropdownIcon);
const clientDetailsDiv = $("<div>").addClass("client-details"); const clientDetailsDiv = $("<div>").addClass("client-details");
if (client.warning) {
warningIcon = $("<i>").addClass("fa-solid fa-triangle-exclamation");
const clientWarning = $("<div>")
.addClass("client-detail warning")
.text(" Might have outdated data due to recent changes in Blender.");
clientWarning.prepend(warningIcon);
clientDetailsDiv.append(clientWarning);
}
if (id) { if (id) {
const clientId = $("<div>") const clientId = $("<div>")
.addClass("client-detail") .addClass("client-detail")
@@ -397,5 +410,6 @@ function toggleClientList() {
clientList.append(clientDiv); clientList.append(clientDiv);
}); });
clientList.addClass("show"); clientList.addClass("show");
} }