From c4d3dad63967302e9e465c122ce0fb5030f119a7 Mon Sep 17 00:00:00 2001 From: Ziad-I <68874104+Ziad-I@users.noreply.github.com> Date: Thu, 25 Jul 2024 15:35:08 +0300 Subject: [PATCH] add page setup functions --- .../bim/data/webui/static/js/drawings.js | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/src/blenderbim/blenderbim/bim/data/webui/static/js/drawings.js b/src/blenderbim/blenderbim/bim/data/webui/static/js/drawings.js index ae254501a2..151086de96 100644 --- a/src/blenderbim/blenderbim/bim/data/webui/static/js/drawings.js +++ b/src/blenderbim/blenderbim/bim/data/webui/static/js/drawings.js @@ -26,3 +26,94 @@ function connectSocket() { // socket.on("csv_data", handleCsvData); // socket.on("default_data", handleDefaultData); } + +function setTheme(theme) { + var stylesheet = $("#tabulator-stylesheet"); + if (theme === "light") { + stylesheet.attr( + "href", + "https://unpkg.com/tabulator-tables/dist/css/tabulator_site.min.css" + ); + $("html").removeClass("dark").addClass("light"); + $("#toggle-theme").html(''); + } else { + stylesheet.attr( + "href", + "https://unpkg.com/tabulator-tables/dist/css/tabulator_site_dark.min.css" + ); + $("html").removeClass("light").addClass("dark"); + $("#toggle-theme").html(''); + } + localStorage.setItem("theme", theme); +} + +function toggleTheme() { + if ($("html").hasClass("dark")) { + setTheme("light"); + } else { + setTheme("dark"); + } +} + +function toggleClientList() { + var clientList = $("#client-list"); + + if (clientList.hasClass("show")) { + clientList.removeClass("show"); + return; + } + + clientList.empty(); + + $.each(connectedClients, function (id, client) { + if (!client.shown) return; + + const dropdownIcon = $("") + .addClass("fas fa-chevron-down") + .css("margin-left", "0.5rem"); + + const clientDiv = $("
").addClass("client").text(client.ifc_file); + + clientDiv.append(dropdownIcon); + + const clientDetailsDiv = $("
").addClass("client-details"); + + if (id) { + const clientId = $("
") + .addClass("client-detail") + .text(`Blender ID: ${id}`); + clientDetailsDiv.append(clientId); + } + + if (client.headers && client.headers.length) { + const clientHeaders = $("
") + .addClass("client-detail") + .text(`Table Headers: ${client.headers.join(", ")}`); + + const scrollButton = $("