save website from rpi

This commit is contained in:
Sietse Jonker
2024-02-16 11:56:11 +01:00
parent 16105122dd
commit 44b1317e33
3 changed files with 275 additions and 168 deletions

View File

@@ -5,26 +5,26 @@
<script src="https://cdn.plot.ly/plotly-latest.min.js" charset="utf-8"></script> <script src="https://cdn.plot.ly/plotly-latest.min.js" charset="utf-8"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css"> <link rel="stylesheet" href="styles.css">
<title>Climate-Measuring-Box</title> <title>Node dev page</title>
<link rel="icon" type="image/x-icon" href="favicon.ico"> <link rel="icon" type="image/x-icon" href="favicon.ico">
</head> </head>a
<body> <body>
<!-- Make a new header with a navigation bar --> <!-- Make a new header with a navigation bar -->
<header> <header>
<nav class="navbar"> <nav class="navbar">
<ul> <ul>
<li><a href="climate-monitor.html">Monitoring</a></li> <li><a href="climate-monitor.html">Monitoring deez</a></li>
<li><a href="Map.html">Map</a></li> <li><a href="Map.html">Map</a></li>
<li><a onclick="serialConnect()" class="navRight">Connect to port</a></li>
<li><a onclick="disconnect()" class="navRight">Disconnect from port</a></li>
</li> </li>
</ul> </ul>
</nav> </nav>
</header> </header>
<!-- Make a new flex container for the live data --> <!-- Make a new flex container for the live data -->
<div class="nodeData">
<div class="flex-NodeData">
<div class="flex-LiveData"> <div class="flex-LiveData">
<div> <div>
<div>Temperatuur: <p id="temperature">Not connected</p> <div>Temperatuur: <p id="temperature">Not connected</p>
@@ -55,14 +55,110 @@
<p>Live graph:</p> <p>Live graph:</p>
<div id="liveGraph"></div> <div id="liveGraph"></div>
</div> </div>
</div>
</div>
<div class="flex-NodeData">
<div class="flex-LiveData">
<div> <div>
<div>Time until POST request to API:<p id="cnt">Connect to port</p></div> <div>Temperatuur: <p id="temperature">Not connected</p>
</div>
<div class="statusElement">
<p class="statusText" id="tempStatus">Not connected</p>
</div>
</div> </div>
<div> <div>
<p>API data:</p> <div>Luchtvochtigheid: <p id="humidity">Not connected</p>
<div id="apiGraph"></div> </div>
<div class="statusElement">
<p class="statusText" id="humidStatus">Not connected</p>
</div> </div>
</div> </div>
<div>
<div>Lichtintensiteit: <p id="lightIntensity">Not connected</p>
</div>
<div class="statusElement">
<p class="statusText" id="lightIntensityStatus">Not connected</p>
</div>
</div>
</div>
<!-- Make a new flexcontainer for the graphs and API request time -->
<div class="flex-graph">
<div>
<p>Live graph:</p>
<div id="liveGraph"></div>
</div>
</div>
</div>
</div> <!-- class="nodeData" -->
<div class="nodeData">
<div class="flex-NodeData">
<div class="flex-LiveData">
<div>
<div>Temperatuur: <p id="temperature">Not connected</p>
</div>
<div class="statusElement">
<p class="statusText" id="tempStatus">Not connected</p>
</div>
</div>
<div>
<div>Luchtvochtigheid: <p id="humidity">Not connected</p>
</div>
<div class="statusElement">
<p class="statusText" id="humidStatus">Not connected</p>
</div>
</div>
<div>
<div>Lichtintensiteit: <p id="lightIntensity">Not connected</p>
</div>
<div class="statusElement">
<p class="statusText" id="lightIntensityStatus">Not connected</p>
</div>
</div>
</div>
<!-- Make a new flexcontainer for the graphs and API request time -->
<div class="flex-graph">
<div>
<p>Live graph:</p>
<div id="liveGraph"></div>
</div>
</div>
</div> <div class="flex-NodeData">
<div class="flex-LiveData">
<div>
<div>Temperatuur: <p id="temperature">Not connected</p>
</div>
<div class="statusElement">
<p class="statusText" id="tempStatus">Not connected</p>
</div>
</div>
<div>
<div>Luchtvochtigheid: <p id="humidity">Not connected</p>
</div>
<div class="statusElement">
<p class="statusText" id="humidStatus">Not connected</p>
</div>
</div>
<div>
<div>Lichtintensiteit: <p id="lightIntensity">Not connected</p>
</div>
<div class="statusElement">
<p class="statusText" id="lightIntensityStatus">Not connected</p>
</div>
</div>
</div>
<!-- Make a new flexcontainer for the graphs and API request time -->
<div class="flex-graph">
<div>
<p>Live graph:</p>
<div id="liveGraph"></div>
</div>
</div>
</div>
</div> <!-- class="nodeData" -->
<!-- Include the js file --> <!-- Include the js file -->
<script src="main.js"></script> <script src="main.js"></script>

View File

@@ -1,26 +1,29 @@
let data;
let measurements;
let date;
let value;
let newArrayTemp = [];
let newArrayHumid = [];
let newArrayLight = [];
let timeArray = []; // Array to store time values`
let dateArray = [1,2,3];
let valueArray = [1,2,3,4,5];
let newValueArray = [4,5,6];
let myValue = 1;
//const timeArray = [1,2,3,4];
//const dateArray = [5,6,7,8];
//const valueArray = [1,1,1,3];
// Make lines in the graph of the live data // Make lines in the graph of the live data
Plotly.plot("liveGraph", [ Plotly.plot("liveGraph", [
{ {
x: timeArray, // Use timeArray as x values x: timeArray, // Use timeArray as x values
y: newArrayTemp, y: valueArray,
mode: "lines", mode: "lines",
line: { color: "#80CAF6" }, line: { color: "#80CAF6" },
name: "Temperature", name: "Temperature",
}, },
{
x: timeArray, // Use timeArray as x values
y: newArrayHumid,
mode: "lines",
line: { color: "#FFA500" },
name: "Humidity",
},
{
x: timeArray, // Use timeArray as x values
y: newArrayLight,
mode: "lines",
line: { color: "#00FF00" },
name: "Light / 100",
},
]); ]);
let cnt = 0; let cnt = 0;
@@ -28,10 +31,13 @@ let cnt = 0;
// Update the graph every 1 ms // Update the graph every 1 ms
let interval = setInterval(function () { let interval = setInterval(function () {
var time = new Date(); var time = new Date();
timeArray.push(new Date());
valueArray.push(Math.random() * 10);
var update = { var update = {
x: [[time]], x: [[time]],
y: [[newArrayTemp], [newArrayHumid], [newArrayLight]], y: [[newValueArray]],
}; };
var olderTime = time.setMinutes(time.getMinutes() - 1); var olderTime = time.setMinutes(time.getMinutes() - 1);
@@ -45,19 +51,5 @@ let interval = setInterval(function () {
}; };
Plotly.relayout("liveGraph", minuteView); Plotly.relayout("liveGraph", minuteView);
apiGraph = document.getElementById("apiGraph");
Plotly.newPlot(
apiGraph,
[
{
x: dateArray,
y: valueArray,
},
],
{
margin: { t: 0 },
}
);
if (cnt === 100) clearInterval(interval); if (cnt === 100) clearInterval(interval);
}, 1); }, 1);

View File

@@ -8,7 +8,7 @@ body {
h1 { h1 {
opacity: 0.8; opacity: 0.8;
color: black; color: green;
margin: auto; margin: auto;
width: 50%; width: 50%;
} }
@@ -49,6 +49,23 @@ body {
font-size: 20px; font-size: 20px;
} }
.flex-NodeData {
display: flex;
margin-left: 10%;
margin-right: 10;
height: 40%;
flex-direction: column;
border: 1px solid red;
margin-bottom: 40px;
}
.nodeData {
display: flex;
justify-content: center;
flex-direction: row;
border: 2px solid red;
}
.flex-LiveData { .flex-LiveData {
display: flex; display: flex;
align-content: begin; align-content: begin;
@@ -59,7 +76,9 @@ body {
padding: 10px; padding: 10px;
} }
.flex-LiveData > div { .flex-LiveData > div {
border: solid #1f82d3 2px; border: solid #1f82d3 2px;
padding: 15px 0; padding: 15px 0;
font-size: 30px; font-size: 30px;