mirror of
https://github.com/AlexxIT/go2rtc.git
synced 2025-12-24 12:57:56 +08:00
75 lines
2.1 KiB
HTML
75 lines
2.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>net - go2rtc</title>
|
|
<script src="https://unpkg.com/vis-network@9.1.9/standalone/umd/vis-network.min.js"></script>
|
|
<style>
|
|
html, body, #network {
|
|
height: 100%;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<script src="main.js"></script>
|
|
|
|
<div id="network"></div>
|
|
|
|
<script>
|
|
/* global vis */
|
|
window.addEventListener('load', () => {
|
|
const url = new URL('api/streams.dot' + location.search, location.href);
|
|
|
|
const container = document.getElementById('network');
|
|
const options = {
|
|
edges: {
|
|
font: {align: 'middle'},
|
|
smooth: false,
|
|
},
|
|
nodes: {shape: 'box'},
|
|
physics: false,
|
|
};
|
|
|
|
let network;
|
|
|
|
async function update() {
|
|
try {
|
|
const response = await fetch(url, {cache: 'no-cache'});
|
|
const dotData = await response.text();
|
|
const data = vis.parseDOTNetwork(dotData);
|
|
|
|
if (!network) {
|
|
network = new vis.Network(container, data, options);
|
|
network.storePositions();
|
|
} else {
|
|
const positions = network.getPositions();
|
|
const viewPosition = network.getViewPosition();
|
|
const scale = network.getScale();
|
|
const selectedNodes = network.getSelectedNodes();
|
|
|
|
network.setData(data);
|
|
|
|
for (const nodeId in positions) {
|
|
network.moveNode(nodeId, positions[nodeId].x, positions[nodeId].y);
|
|
}
|
|
|
|
network.moveTo({position: viewPosition, scale: scale});
|
|
|
|
network.selectNodes(selectedNodes);
|
|
}
|
|
} catch (error) {
|
|
console.error('Error fetching or updating network data:', error);
|
|
}
|
|
|
|
setTimeout(update, 5000);
|
|
}
|
|
|
|
update();
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|