This commit is contained in:
Bruno Eckhardt committed 2026-05-22 09:48:44 +02:00
1 parent 59eba3ef2b
commit d7cb5084ef
5 files changed
+194 -5

No files matched your search

+11 -4
View File
@@ -9,6 +9,7 @@ try {
$router->add('abgas', \MVC\Controller\AbgasController::class, 'abgas');
$router->add('vorlauf', \MVC\Controller\VorlaufController::class, 'vorlauf');
$router->add('puffer', \MVC\Controller\PufferController::class, 'puffer');
$router->add('aussentemp', \MVC\Controller\AussentempController::class, 'aussentemp');
$layout = new \MVC\Layout\Layout('main');
$layout->setBlock('title', 'MVC Starter');
@@ -17,12 +18,18 @@ try {
// Sidebar Block
ob_start();
$navItems = [
'home' => '🏠 Home',
'abgas' => '🔥 Abgas',
'vorlauf' => '🏃‍♂️‍➡️ Vorlauf',
'puffer' => '♨️ Puffer',
'aussentemp' => '🌡️ Außentemperatur'
];
?>
<nav>
<a href="?service=home">🏠 Home</a>
<a href="?service=abgas">🔥 Abgas</a>
<a href="?service=vorlauf">🏃‍♂️‍➡️ Vorlauf</a>
<a href="?service=puffer">♨️ Puffer</a>
<?php foreach ($navItems as $navKey => $navLabel): ?>
<a href="?service=<?= $navKey ?>" class="<?= $service === $navKey ? 'active' : '' ?>"><?= $navLabel ?></a>
<?php endforeach; ?>
</nav>
<?php
$layout->setBlock('sidebar', ob_get_clean());
@@ -0,0 +1,46 @@
<?php
namespace MVC\Controller;
use MVC\Core\Controller;
use MVC\Model\Messungen;
class AussentempController extends Controller {
public function aussentemp() {
$day = $_GET['day'] ?? date('Y-m-d');
$datum = \DateTime::createFromFormat('Y-m-d', $day);
if (!$datum) {
$day = date('Y-m-d');
}
$array = Messungen::getAussentempByDay($day);
$labels = [];
$aussentemp = [];
foreach ($array as $row) {
$labels[] = date('H:i:s', strtotime($row['ts']));
$aussentemp[] = (float)$row['aussentemp'];
}
$prevDay = date('Y-m-d', strtotime($day . ' -1 day'));
$nextDay = date('Y-m-d', strtotime($day . ' +1 day'));
return $this->render('aussentemp', [
'title' => 'Aussentemperatur Modul',
'xtitle' => 'Zeit',
'ytitle' => 'Temperatur',
'array' => $array,
'labels' => $labels,
'aussentemp' => $aussentemp,
'day' => $day,
'prevDay' => $prevDay,
'nextDay' => $nextDay,
]);
}
}
@@ -4,7 +4,11 @@
<meta charset="UTF-8">
<title><?= $this->getBlock('title') ?></title>
<style>
:root { --bg: #ffffff; --text: #333; --sidebar: #f4f4f4; --header: #007bff; --accent: #007bff; --border: #ddd; }
:root {
--bg: #ffffff;
--text: #333;
--sidebar: #f4f4f4;
--header: #007bff; --accent: #007bff; --border: #ddd; }
.dark-mode { --bg: #1a1a1a; --text: #f4f4f4; --sidebar: #252525; --header: #111; --accent: #3498db; --border: #333; }
body { font-family: 'Segoe UI', sans-serif; margin: 0; background: var(--bg); color: var(--text); transition: 0.3s; height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.main-header { height: 60px; background: var(--header); color: white; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); z-index: 10; }
@@ -15,6 +19,7 @@
.btn-toggle:hover { background: rgba(255,255,255,0.1); }
nav a { display: block; padding: 12px; text-decoration: none; color: inherit; border-radius: 5px; margin-bottom: 5px; }
nav a:hover { background: rgba(0,0,0,0.05); }
nav a.active { background: rgba(0,0,0,0.25); }
.logo { font-size: 1.4rem; font-weight: bold; }
</style>
</head>
@@ -34,4 +34,9 @@ class Messungen extends Model {
$sql = "SELECT ts, kessel_oben, kessel_unten FROM " . self::$table . " WHERE ts LIKE '$day%' ORDER BY ts ASC";
return self::query($sql)->fetch_all(MYSQLI_ASSOC);
}
public static function getAussentempByDay($day) {
$sql = "SELECT ts, aussentemp FROM " . self::$table . " WHERE ts LIKE '$day%' ORDER BY ts ASC";
return self::query($sql)->fetch_all(MYSQLI_ASSOC);
}
}
+126
View File
@@ -0,0 +1,126 @@
<?php
/**
* @var array $array
* @var string $prevDay
* @var string $nextDay
* @var string $day
* @var string $title
* @var string $xtitle
* @var string $ytitle
* @var string $labels
* @var string $aussentemp
*/
?>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-zoom"></script>
<div style="height:800px;">
<canvas id="logChart"></canvas>
</div>
<script>
const ctx = document.getElementById('logChart').getContext('2d');
const logChart = new Chart(ctx, {
type: 'line',
data: {
labels: <?php echo json_encode($labels); ?>,
datasets: [{
label: 'Aussentemperatur',
data: <?php echo json_encode($aussentemp); ?>,
borderColor: 'rgba(75, 192, 192, 1)',
backgroundColor: 'rgba(75, 192, 192, 0.2)',
fill: true,
tension: 0.1
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
title: {
display: true,
text: '<?= $title ?>'
},
legend: {
display: true,
position: 'top'
},
zoom: {
pan: {
enabled: true,
mode: 'x'
},
zoom: {
wheel: {
enabled: true
},
pinch: {
enabled: true
},
mode: 'x'
}
}
},
interaction: {
mode: 'index',
intersect: false
},
scales: {
x: {
title: {
display: true,
text: '<?= $xtitle ?>'
}
},
y: {
min: 0,
max: 50,
title: {
display: true,
text: '<?= $ytitle ?>'
},
ticks: {
stepSize: 20
},
beginAtZero: true
}
}
}
});
</script>
<div style="margin-bottom:20px;">
<a href="?service=aussentemp&day=<?php echo $prevDay; ?>">
← Vorheriger Tag
</a>
<strong style="margin:0 20px;">
<?php echo $day; ?>
</strong>
<a href="?service=aussentemp&day=<?php echo $nextDay; ?>">
Nächster Tag →
</a>
</div>