Init commit
This commit is contained in:
87
files/dashboard/index.php
Normal file
87
files/dashboard/index.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
// Function to fetch SSD information from the API
|
||||
function fetchSSDData() {
|
||||
$url = 'http://172.17.0.1:5000/drives';
|
||||
$options = [
|
||||
'http' => [
|
||||
'header' => "Content-type: application/json\r\n",
|
||||
'method' => 'GET',
|
||||
],
|
||||
];
|
||||
|
||||
$context = stream_context_create($options);
|
||||
$result = file_get_contents($url, false, $context);
|
||||
|
||||
if ($result === FALSE) {
|
||||
die('Error Fetching data');
|
||||
}
|
||||
|
||||
return json_decode($result, true); // Decode JSON as an associative array
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>SSD Health Dashboard</title>
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>SSD Health Dashboard</h1>
|
||||
<?php
|
||||
$i=0;
|
||||
$ssdData = fetchSSDData(); // Fetch data from the API
|
||||
echo '<div class="group-columns">';
|
||||
foreach ($ssdData as $ssd):
|
||||
if ($i % 2 == 0) {
|
||||
echo '</div><div class="group-columns">';
|
||||
}
|
||||
echo <<<EOL
|
||||
<div class="meter">
|
||||
<table>
|
||||
<tr><td align ="right">
|
||||
Disk ID:
|
||||
</td><td align ="left">
|
||||
{$ssd['id']}
|
||||
</td></tr><tr>
|
||||
<tr><td align ="right">
|
||||
Model String:
|
||||
</td><td align ="left">
|
||||
{$ssd['model']}
|
||||
</td></tr><tr>
|
||||
<tr><td align ="right">
|
||||
Serial Number:
|
||||
</td><td align ="left">
|
||||
{$ssd['serial']}
|
||||
</td></tr><tr>
|
||||
<tr><td align ="right">
|
||||
TB Written:
|
||||
</td><td align ="left">
|
||||
{$ssd['TBW']}
|
||||
</td></tr><tr>
|
||||
<tr><td align ="right">
|
||||
Disk Capacity:
|
||||
</td><td align ="left">
|
||||
{$ssd['capacity']}
|
||||
</td></tr><tr>
|
||||
<tr><td align ="right">
|
||||
Disk Flavor:
|
||||
</td><td align ="left">
|
||||
{$ssd['flavor']}
|
||||
</td></tr><tr>
|
||||
<tr><td align ="right">
|
||||
SMART Result:
|
||||
</td><td align ="left">
|
||||
{$ssd['smart']}
|
||||
</td></tr>
|
||||
</table>
|
||||
</div>
|
||||
EOL;
|
||||
$i++;
|
||||
endforeach;
|
||||
echo '</div>';
|
||||
?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user