79 lines
2.5 KiB
PHP
79 lines
2.5 KiB
PHP
<?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">
|
|
<button onclick="window.location.reload();" class="title-button"><h1>SSD Health Dashboard</h1></button><p>
|
|
This lists every disk ever scanned by this device.<br>
|
|
|
|
<?php
|
|
echo "For a live dashboard, please visit <a href=http://{$_SERVER['HTTP_HOST']}:3000/>this link</a>.<p>";
|
|
$ssdData = fetchSSDData(); // Fetch data from the API
|
|
// Start the table
|
|
echo '<table class="ssd-list" style="border-collapse:collapse;width:100%;">';
|
|
// Table header (optional but handy)
|
|
echo '<thead>
|
|
<tr>
|
|
<th>Disk ID</th>
|
|
<th>Model String</th>
|
|
<th>Serial Number</th>
|
|
<th>TB Written</th>
|
|
<th>Disk Capacity</th>
|
|
<th>Disk Flavor</th>
|
|
<th>SMART Result</th>
|
|
</tr>
|
|
</thead>';
|
|
// Table body - one row per SSD
|
|
echo '<tbody>';
|
|
foreach ($ssdData as $ssd) {
|
|
// Escape the values so the page stays safe
|
|
$id = htmlspecialchars($ssd['id']);
|
|
$model = htmlspecialchars($ssd['model']);
|
|
$serial = htmlspecialchars($ssd['serial']);
|
|
$tbw = htmlspecialchars($ssd['TBW']);
|
|
$cap = htmlspecialchars($ssd['capacity']);
|
|
$flavor = htmlspecialchars($ssd['flavor']);
|
|
$smart = htmlspecialchars($ssd['smart']);
|
|
|
|
echo "<tr>
|
|
<td>{$id}</td>
|
|
<td>{$model}</td>
|
|
<td>{$serial}</td>
|
|
<td>{$tbw}</td>
|
|
<td>{$cap}</td>
|
|
<td>{$flavor}</td>
|
|
<td>{$smart}</td>
|
|
</tr>";
|
|
}
|
|
echo '</tbody></table>';
|
|
?>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|