Select Git revision
list.html 2.02 KiB
<!-- //This file was written by chatGPT (3.5) with many iterations and manual corrections. -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Device List</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
h1 {
color: #333;
}
.device-list {
width: 50%;
margin-top: 20px;
border-collapse: collapse;
}
.device-list th, .device-list td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
.device-list th {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<h1>Device List</h1>
<table class="device-list">
<thead>
<tr>
<th>ID</th>
<th>State</th>
<th>Count</th>
</tr>
</thead>
<tbody id="deviceTableBody">
<!-- Device entries will be added dynamically here -->
</tbody>
</table>
<script>
async function populateDeviceList() {
try {
const response = await fetch('/get-devices');
const data = await response.json();
const deviceTableBody = document.getElementById('deviceTableBody');
deviceTableBody.innerHTML = '';
data.forEach(device => {
const row = document.createElement('tr');
const idCell = document.createElement('td');
const stateCell = document.createElement('td');
const currentCntCell = document.createElement('td');
idCell.textContent = device.id;
stateCell.textContent = device.state;
// Display current_cnt if available, otherwise display a placeholder
currentCntCell.textContent = device.current_cnt || 'N/A';