From b9455a56a82a0f38c6c35e7497502c373a96258b Mon Sep 17 00:00:00 2001 From: Dano van den Bosch Date: Tue, 2 Apr 2024 13:05:31 +0200 Subject: [PATCH] change node name functionalitijd --- web/newWebsite/index.html | 18 ++++- web/newWebsite/styles/dashboard-styles.css | 36 +++++++++ web/newWebsite/text.html | 27 +++++++ web/newWebsite/text.js | 91 ++++++++++++++++++++++ web/styles.css | 2 - 5 files changed, 170 insertions(+), 4 deletions(-) create mode 100644 web/newWebsite/text.html create mode 100644 web/newWebsite/text.js diff --git a/web/newWebsite/index.html b/web/newWebsite/index.html index 52122e5..819f549 100644 --- a/web/newWebsite/index.html +++ b/web/newWebsite/index.html @@ -8,7 +8,9 @@ Gauges - + - + + + \ No newline at end of file diff --git a/web/newWebsite/styles/dashboard-styles.css b/web/newWebsite/styles/dashboard-styles.css index 2985720..28bc043 100644 --- a/web/newWebsite/styles/dashboard-styles.css +++ b/web/newWebsite/styles/dashboard-styles.css @@ -5,6 +5,42 @@ } +/* +.editNodeInformation{ + margin-bottom: 60%; + display: flex; + justify-content: left; +} */ + +#editNode{ + display: flex; + justify-content: center; + /* align-items: center; */ + /* flex-direction: column; */ + /* border-radius: 5%; */ + /* border: 20px solid orange; */ + } + + /* #editNode { + width: 98vw; + height: 20vh; + display: flex; + justify-content: center; + /* flex-direction: column; Keep as column + /* justify-content: ; + align-items: center; + + background-color: #333; + color: #fff; + padding: 10px; + border-radius: 50px; + border: 2px solid #333; + clear: both; + margin-bottom: 10px; + position: relative; + float: top; +} */ + body { padding-top: 5vw; display: flex; diff --git a/web/newWebsite/text.html b/web/newWebsite/text.html new file mode 100644 index 0000000..e3d1ae5 --- /dev/null +++ b/web/newWebsite/text.html @@ -0,0 +1,27 @@ + + + + + + + Document + + + + + + + +
+

Status updating

+ + + + +
+ +
+ +
+ + \ No newline at end of file diff --git a/web/newWebsite/text.js b/web/newWebsite/text.js new file mode 100644 index 0000000..63e3853 --- /dev/null +++ b/web/newWebsite/text.js @@ -0,0 +1,91 @@ +apiGetAllNode = "http://145.92.8.114/getNodeInfo?macAdress=*" + +nodeDataArray = {}; + +var updateNode = document.getElementById('editNode'); +var locationInput = document.getElementById("inputLocation"); +var nameInput = document.getElementById("inputName"); +var select = document.getElementById('mySelect'); + +document.getElementById("inputName").placeholder = "Type new name here.."; +document.getElementById("inputLocation").placeholder = "Type new location here.."; + +updateNode.style.display = "none"; + +function settings() { + if (updateNode.style.display === "none") { + updateNode.style.display = "block"; + locationInput.value = ""; + nameInput.value = ""; + + fetch(apiGetAllNode) + .then(response => { + if (!response.ok) { + document.getElementById('text').innerHTML = "Error: Network response was not ok"; + throw new Error('Network response was not ok'); + } + document.getElementById('text').innerHTML = "Fetching data"; + return response.json(); + }) + .then(data => { + document.getElementById('text').innerHTML = "Data fetched"; + handleData(data); + }) + + } else { + updateNode.style.display = "none"; + } + +} +function handleData(JSONdata) { + var i, L = select.options.length - 1; + for (i = L; i >= 0; i--) { + select.remove(i); + } + + for (var i = 0; i < JSONdata.length; i++) { + var node = JSONdata[i].NodeID; + var name = JSONdata[i].Name; + var location = JSONdata[i].Location; + nodeDataArray[node] = { name: name, location: location }; + // Create new option element + var option = document.createElement('option'); + + // Set the value of the option + option.value = node; + + // Set the text of the option + option.text = name; + + // Add the option to the select + select.add(option); + } +} + +function changeText() { + var nodeName = encodeURIComponent(document.getElementById('inputName').value); + var nodeLocation = encodeURIComponent(document.getElementById('inputLocation').value); + + updateNodeInfo(select.value, nodeName, nodeLocation); + + var text = document.getElementById('text'); + + text.innerHTML = "Changes made" +} + +function updateNodeInfo(node, newNodeName, newNodeLocation) { + apiUrl = "http://145.92.8.114/updateData?node=" + node + "&name=" + newNodeName + "&location=" + newNodeLocation; + fetch(apiUrl) + .then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); + }) + .catch(error => { + console.error('Error:', error); + }); +} + + + diff --git a/web/styles.css b/web/styles.css index 06cb22f..33ece6c 100644 --- a/web/styles.css +++ b/web/styles.css @@ -72,8 +72,6 @@ p1 { } - - .nodeData { display: flex; justify-content: left;