commit ccc9c80d0aee41390521b8177b2d9019999fea44
parent f1a01faa3ee04338e26f007e91e5c88770bb65d6
Author: LennartSchroot <[email protected]>
Date: Sun, 18 Jun 2023 18:13:33 +0200
xml en meuk
Diffstat:
7 files changed, 45 insertions(+), 20 deletions(-)
diff --git a/.DS_Store b/.DS_Store
Binary files differ.
diff --git a/Controller/hdata/hdata.php b/Controller/hdata/hdata.php
@@ -2,8 +2,28 @@
function make_table(){
$key = new Key();
if (isset($_GET['downloadXml'])) {
- return $key->retrieveHData('3jvl/yb?sRr80s6lTdeOyxV9VTQZkCPRp/bKOWKFWxfL2vhsU4Hhpgcmz9qe0zEk', true);
- } else {
+ $combinedXml = new SimpleXMLElement('<data></data>');
+
+ $humidityXml = $key->retrieveHumidityTable('ae9c50dc5cd58c538a0d6aedb17fffedcaffd568d22381dab3ae72baaeb24684', true);
+ $hDataXml = $key->retrieveHData('ae9c50dc5cd58c538a0d6aedb17fffedcaffd568d22381dab3ae72baaeb24684', true);
+
+ // Load humidity XML into combined XML
+ $humidityDataNode = $combinedXml->addChild('humidityData');
+ $humidityDataNode->addChild('data')->addChild('humidityData', $humidityXml->asXML());
+
+ // Load HData XML into combined XML
+ $hDataNode = $combinedXml->addChild('hData');
+ $hDataNode->addChild('data')->addChild('hData', $hDataXml->asXML());
+
+ $xmlString = $combinedXml->asXML();
+
+ header('Content-Type: application/xml');
+ header('Content-Disposition: attachment; filename="combined_data.xml"');
+
+ echo $xmlString;
+ exit();
+ }
+ else{
return $key->retrieveHData('3jvl/yb?sRr80s6lTdeOyxV9VTQZkCPRp/bKOWKFWxfL2vhsU4Hhpgcmz9qe0zEk');
}
}
diff --git a/Model/Key.php b/Model/Key.php
@@ -79,11 +79,9 @@ Class Key{
}
- function retrieveHumidityTable($key, $generateXml = false)
- {
+ function retrieveHumidityTable($key, $generateXml = false){
$html = '<table>';
$db = new mysqli("86.92.67.21", "friedel", "hailiwa", "wap2");
- $weather_data = [];
$query = "SELECT distinct temperature, dew_point, nl.name as city, date_time
FROM weather_data wd
JOIN station s ON wd.station_name = s.name
@@ -134,10 +132,23 @@ Class Key{
}
$html .= $table1 . $table2;
- return $html;
+ if ($generateXml) {
+ // Generate XML
+ $xml = new SimpleXMLElement('<data></data>');
+ foreach ($results as $city => $entries) {
+ foreach ($entries as $entry) {
+ $locationElement = $xml->addChild('location');
+ $locationElement->addChild('city', $city);
+ $locationElement->addChild('date', $entry['date']);
+ $locationElement->addChild('humidity', $entry['humidity']);
+ }
+ }
+ return $xml; // Return SimpleXMLElement object
}
+ return $html;
+ }
function retrieveHData($key, $generateXml = false) {
$html = '';
@@ -185,7 +196,7 @@ Class Key{
}
$html .= $this->retrieveHumidityTable('ae9c50dc5cd58c538a0d6aedb17fffedcaffd568d22381dab3ae72baaeb24684');
- $html .= '<table>';
+ $html .= '<table id="htmlTable">';
$html .= '<div class="space"></div>';
$html .= '<div class="content-title"><h2>Windchill corrected temperature per day</h2></div>';
@@ -204,6 +215,7 @@ Class Key{
$html .= '</table>';
if ($generateXml) {
+ // Generate XML
$xml = new SimpleXMLElement('<data></data>');
foreach ($results as $date => $entries) {
@@ -213,16 +225,11 @@ Class Key{
$locationElement = $dateElement->addChild('location');
$locationElement->addChild('city', $entry['city']);
$locationElement->addChild('windchill', $entry['windchill']);
+ $locationElement->addChild('humidity', $entry['humidity']);
}
}
- $xmlString = $xml->asXML();
-
- header('Content-Type: application/xml');
- header('Content-Disposition: attachment; filename="data.xml"');
-
- echo $xmlString;
- exit();
+ return $xml; // Return SimpleXMLElement object
}
$html .= '<a href="?downloadXml=true" class="download-button">Download XML</a>';
diff --git a/css/dashboard.css b/css/dashboard.css
@@ -126,7 +126,7 @@ h1 {
table {
width: 100%;
border-collapse: collapse;
-
+ color: white;
}
th, td {
diff --git a/css/hdata.css b/css/hdata.css
@@ -79,10 +79,9 @@ h1 {
display: flex;
width: 90vw;
height: auto;
- padding-top: 20px;
margin: 5vw auto 5vw;
justify-content: space-between;
- background-color: #333333;
+ background-color: #BCCFB0;
color: white;
border-radius: 4px;
@@ -132,6 +131,7 @@ table {
}
th, td {
+ background-color: #333333;
padding: 8px;
text-align: left;
border-bottom: 1px solid #ddd;
@@ -157,7 +157,7 @@ tr:hover {
}
.space{
- background-color: #BCCFB0;
+ background-color: transparent;
box-shadow: none;
padding-bottom: 100px
}
diff --git a/index.php b/index.php
@@ -37,7 +37,6 @@ if(isset($_SESSION['user_permissions']) && in_array(1,$_SESSION['user_permission
//dashboard
$router->addRoute(["GET"], "/dashboard", function(&$vars){
- session_start();
foreach($_SESSION as $key => $data){
$vars[$key] = $data;
}
diff --git a/js/panda.js b/js/panda.js
@@ -212,6 +212,5 @@ function getLatestDate(entry1, entry2) {
}
}
-
fetchDataAndUpdateChart();
setInterval(fetchDataAndUpdateChart, 3000);
\ No newline at end of file