mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-16 12:45:04 +01:00
add channel open support
This commit is contained in:
parent
dc8efd4e4e
commit
46cccab748
10 changed files with 1950 additions and 1462 deletions
3
amqp_dashboard/assets/.prettierrc.json
Normal file
3
amqp_dashboard/assets/.prettierrc.json
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"singleQuote": true
|
||||
}
|
||||
|
|
@ -1,19 +1,20 @@
|
|||
<!doctype html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
|
||||
/>
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
||||
<title>AMQP Data</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>AMQP Data</h1>
|
||||
<h2>Connections</h2>
|
||||
<div id="connection-wrapper"></div>
|
||||
|
||||
<h1>AMQP Data</h1>
|
||||
<h2>Connections</h2>
|
||||
<div id="connection-wrapper">
|
||||
</div>
|
||||
|
||||
<script src="script.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
<script src="script.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,41 +1,48 @@
|
|||
const renderTable = (colNames, rows) => {
|
||||
const table = document.createElement("table");
|
||||
const table = document.createElement('table');
|
||||
|
||||
const headerRow = document.createElement("tr");
|
||||
const headerRow = document.createElement('tr');
|
||||
|
||||
colNames.forEach((name) => {
|
||||
const th = document.createElement("th");
|
||||
th.innerText = name;
|
||||
colNames.forEach((name) => {
|
||||
const th = document.createElement('th');
|
||||
th.innerText = name;
|
||||
|
||||
headerRow.append(th);
|
||||
headerRow.append(th);
|
||||
});
|
||||
table.append(headerRow);
|
||||
|
||||
rows.forEach((row) => {
|
||||
const contentRow = document.createElement('tr');
|
||||
row.forEach((cell) => {
|
||||
const td = document.createElement('td');
|
||||
td.innerText = cell;
|
||||
contentRow.append(td);
|
||||
});
|
||||
table.append(headerRow);
|
||||
table.append(contentRow);
|
||||
});
|
||||
|
||||
rows.forEach((row) => {
|
||||
const contentRow = document.createElement("tr");
|
||||
row.forEach((cell) => {
|
||||
const td = document.createElement("td");
|
||||
td.innerText = cell;
|
||||
contentRow.append(td);
|
||||
});
|
||||
table.append(contentRow);
|
||||
})
|
||||
|
||||
return table;
|
||||
}
|
||||
return table;
|
||||
};
|
||||
|
||||
const renderConnections = (connections) => {
|
||||
const wrapper = document.getElementById("connection-wrapper");
|
||||
const wrapper = document.getElementById('connection-wrapper');
|
||||
|
||||
const table = renderTable(['Connection ID', 'Client Address'], connections.map((conn) =>
|
||||
[conn.id, conn.peer_addr]));
|
||||
wrapper.replaceChildren(table)
|
||||
}
|
||||
const table = renderTable(
|
||||
['Connection ID', 'Client Address', 'Channels'],
|
||||
connections.map((conn) => {
|
||||
const channels = conn.channels
|
||||
.map((chan) => `${chan.number} - ${chan.id}`)
|
||||
.join('\n');
|
||||
return [conn.id, conn.peer_addr, channels];
|
||||
})
|
||||
);
|
||||
wrapper.replaceChildren(table);
|
||||
};
|
||||
|
||||
const refresh = async () => {
|
||||
const fetched = await fetch('http://localhost:3000/api/data');
|
||||
const data = await fetched.json();
|
||||
renderConnections(data.connections);
|
||||
}
|
||||
const fetched = await fetch('http://localhost:3000/api/data');
|
||||
const data = await fetched.json();
|
||||
renderConnections(data.connections);
|
||||
};
|
||||
|
||||
setInterval(refresh, 1000);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
html {
|
||||
font-family: arial, sans-serif;
|
||||
margin: 10px;
|
||||
font-family: arial, sans-serif;
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
table, th, td {
|
||||
border: 1px solid black;
|
||||
border-collapse: collapse;
|
||||
padding: 10px;
|
||||
}
|
||||
table,
|
||||
th,
|
||||
td {
|
||||
border: 1px solid black;
|
||||
border-collapse: collapse;
|
||||
padding: 10px;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue