meetup-golang-2024-demo/index.html

44 lines
1.4 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Meetup Go</title>
<link href="/style.css" type="text/css" rel="stylesheet">
</head>
<body>
<h1>Meetup Go&nbsp;!</h1>
<table>
<thead>
<tr>
<th>CONTAINER ID</th>
<th>IMAGE</th>
<th>COMMAND</th>
<th>CREATED</th>
<th>STATUS</th>
<th>PORTS</th>
<th>NAMES</th>
</tr>
</thead>
<tbody id="containers">
</tbody>
</table>
<div style="text-align: center">
<button type="button" id="create-btn">Create container</button>
</div>
<script>
document.getElementById('create-btn').addEventListener("click", () => fetch('/containers', {method: 'POST'}));
fetch('/containers').then(
(res) => res.json()
).then(
(containers) => {
document.getElementById('containers').innerHTML = '';
for (const container of containers) {
let div = document.createElement('tr');
div.innerHTML = `<td>${container.Id.substring(0, 8)}</td><td>${container.Image}</td><td>${container.Command}</td><td>${container.Created}</td><td>${container.Status}</td><td>${container.Ports.map((port) => port.PrivatePort + '/' + port.Type).join(" ")}</td><td>${container.Names.join(" ")}</td>`;
document.getElementById('containers').appendChild(div);
}
})
</script>
</body>
</html>