first commit
This commit is contained in:
commit
403a19ac85
158 files changed
+25101
No files matched your search
@@ -0,0 +1,109 @@
|
||||
<style>
|
||||
body { margin: 0; overflow: hidden; font-family: Arial, sans-serif; color: #303742; }
|
||||
.devolo-topology { height: 100%; min-height: 250px; display: flex; flex-direction: column; }
|
||||
.devolo-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px; font-size: 12px; }
|
||||
.devolo-status { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.devolo-dot { width: 9px; height: 9px; border-radius: 50%; background: #9aa4b2; flex: 0 0 auto; }
|
||||
.devolo-dot.online { background: #2b9b69; box-shadow: 0 0 0 3px rgba(43, 155, 105, .16); }
|
||||
.devolo-dot.error { background: #c84c4c; box-shadow: 0 0 0 3px rgba(200, 76, 76, .16); }
|
||||
.devolo-refresh { border: 0; border-radius: 4px; padding: 4px 8px; background: #e7edf3; color: inherit; cursor: pointer; }
|
||||
.devolo-refresh:hover { background: #d5e1eb; }
|
||||
.devolo-canvas { flex: 1; min-height: 0; width: 100%; }
|
||||
.devolo-link { fill: none; stroke: #8ca1b3; stroke-width: 3; stroke-linecap: round; opacity: .72; }
|
||||
.devolo-link.active { stroke: #2a8ac5; stroke-dasharray: 10 8; animation: devolo-flow 2.4s linear infinite; }
|
||||
.devolo-rate { fill: #52616f; font-size: 11px; text-anchor: middle; paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round; }
|
||||
.devolo-node { cursor: default; }
|
||||
.devolo-node circle { fill: #f5f8fb; stroke: #7891a6; stroke-width: 2; }
|
||||
.devolo-node.local circle { fill: #e2f2fb; stroke: #217bb2; stroke-width: 3; }
|
||||
.devolo-node text { fill: #27313b; text-anchor: middle; pointer-events: none; }
|
||||
.devolo-name { font-size: 12px; font-weight: bold; }
|
||||
.devolo-product { font-size: 10px; fill: #617080 !important; }
|
||||
.devolo-empty { fill: #687584; text-anchor: middle; font-size: 14px; }
|
||||
@keyframes devolo-flow { to { stroke-dashoffset: -36; } }
|
||||
@media (prefers-reduced-motion: reduce) { .devolo-link.active { animation: none; } }
|
||||
@media (prefers-color-scheme: dark) {
|
||||
body { color: #e7eef5; background: #1d2730; }
|
||||
.devolo-refresh { background: #334552; color: #e7eef5; }
|
||||
.devolo-refresh:hover { background: #405663; }
|
||||
.devolo-rate { fill: #d3dde5; stroke: #1d2730; }
|
||||
.devolo-node circle { fill: #263541; stroke: #91a8ba; }
|
||||
.devolo-node.local circle { fill: #17425d; stroke: #58a9d9; }
|
||||
.devolo-node text { fill: #f1f6fa; }
|
||||
.devolo-node .devolo-product { fill: #bed0dd !important; }
|
||||
.devolo-empty { fill: #bed0dd; }
|
||||
}
|
||||
</style>
|
||||
<div class="devolo-topology">
|
||||
<div class="devolo-toolbar">
|
||||
<div class="devolo-status"><span id="devolo-dot" class="devolo-dot"></span><span id="devolo-status">Noch keine Netzwerkdaten</span></div>
|
||||
<button class="devolo-refresh" type="button" onclick="if (window.requestAction) { requestAction('Refresh', true); }">Aktualisieren</button>
|
||||
</div>
|
||||
<svg id="devolo-canvas" class="devolo-canvas" viewBox="0 0 600 310" preserveAspectRatio="xMidYMid meet" role="img" aria-label="Devolo Powerline-Netzwerktopologie">
|
||||
<defs><marker id="devolo-arrow" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="5" markerHeight="5" orient="auto-start-reverse"><path d="M 0 0 L 10 5 L 0 10 z" fill="#2a8ac5"></path></marker></defs>
|
||||
<g id="devolo-graph"></g>
|
||||
</svg>
|
||||
</div>
|
||||
<script>
|
||||
const devoloSvg = 'http://www.w3.org/2000/svg';
|
||||
function devoloElement(type, attributes, text) {
|
||||
const element = document.createElementNS(devoloSvg, type);
|
||||
Object.keys(attributes || {}).forEach(key => element.setAttribute(key, attributes[key]));
|
||||
if (text !== undefined) element.textContent = text;
|
||||
return element;
|
||||
}
|
||||
function devoloMac(value) { return String(value || '').replace(/[^a-f0-9]/ig, '').toLowerCase(); }
|
||||
function devoloShort(value, max) { value = String(value || 'Unbekannter Adapter'); return value.length > max ? value.slice(0, max - 1) + '…' : value; }
|
||||
function devoloRate(value) { return Number(value || 0).toLocaleString('de-DE', { maximumFractionDigits: 0 }); }
|
||||
function handleMessage(message) {
|
||||
let data = message;
|
||||
if (typeof message === 'string') {
|
||||
try { data = JSON.parse(message); } catch (_) { data = {}; }
|
||||
}
|
||||
const graph = document.getElementById('devolo-graph');
|
||||
const status = document.getElementById('devolo-status');
|
||||
const dot = document.getElementById('devolo-dot');
|
||||
if (!graph || !status || !dot) return;
|
||||
graph.replaceChildren();
|
||||
const devices = Array.isArray(data.devices) ? data.devices : [];
|
||||
const links = Array.isArray(data.links) ? data.links : [];
|
||||
const online = Boolean(data.online);
|
||||
dot.className = 'devolo-dot ' + (online ? 'online' : (data.error ? 'error' : ''));
|
||||
status.textContent = data.error || (devices.length ? (devices.length + ' Magic-Adapter · ' + (data.updated ? new Date(data.updated).toLocaleTimeString('de-DE') : 'aktuell')) : 'Noch keine Netzwerkdaten');
|
||||
if (!devices.length) {
|
||||
graph.appendChild(devoloElement('text', { x: 300, y: 155, class: 'devolo-empty' }, 'Beim nächsten Abruf erscheint hier die Powerline-Topologie.'));
|
||||
return;
|
||||
}
|
||||
const localMac = devoloMac(data.localMac);
|
||||
let localIndex = devices.findIndex(device => device.local || devoloMac(device.mac) === localMac);
|
||||
if (localIndex < 0) localIndex = 0;
|
||||
const positions = new Map();
|
||||
const remotes = devices.filter((_, index) => index !== localIndex);
|
||||
devices.forEach((device, index) => {
|
||||
if (index === localIndex) {
|
||||
positions.set(devoloMac(device.mac), { x: 300, y: 155 });
|
||||
return;
|
||||
}
|
||||
const remoteIndex = remotes.indexOf(device);
|
||||
const angle = -Math.PI / 2 + (Math.PI * 2 * remoteIndex / Math.max(remotes.length, 1));
|
||||
positions.set(devoloMac(device.mac), { x: 300 + 210 * Math.cos(angle), y: 155 + 105 * Math.sin(angle) });
|
||||
});
|
||||
links.forEach(link => {
|
||||
const from = positions.get(devoloMac(link.from));
|
||||
const to = positions.get(devoloMac(link.to));
|
||||
if (!from || !to) return;
|
||||
const tx = Number(link.tx || 0), rx = Number(link.rx || 0), active = tx > 0 || rx > 0;
|
||||
const path = devoloElement('line', { x1: from.x, y1: from.y, x2: to.x, y2: to.y, class: 'devolo-link' + (active ? ' active' : ''), 'marker-end': active ? 'url(#devolo-arrow)' : '' });
|
||||
if (active) path.style.animationDuration = Math.max(0.8, 3.8 - Math.min(2.7, Math.max(tx, rx) / 850)) + 's';
|
||||
graph.appendChild(path);
|
||||
graph.appendChild(devoloElement('text', { x: (from.x + to.x) / 2, y: (from.y + to.y) / 2 - 6, class: 'devolo-rate' }, devoloRate(tx) + ' ↔ ' + devoloRate(rx) + ' Mbit/s'));
|
||||
});
|
||||
devices.forEach((device, index) => {
|
||||
const pos = positions.get(devoloMac(device.mac));
|
||||
const group = devoloElement('g', { class: 'devolo-node' + (index === localIndex ? ' local' : '') });
|
||||
group.appendChild(devoloElement('circle', { cx: pos.x, cy: pos.y, r: index === localIndex ? 36 : 30 }));
|
||||
group.appendChild(devoloElement('text', { x: pos.x, y: pos.y - 3, class: 'devolo-name' }, devoloShort(device.userDeviceName || device.productName || device.mac, 18)));
|
||||
group.appendChild(devoloElement('text', { x: pos.x, y: pos.y + 13, class: 'devolo-product' }, devoloShort(device.productName || device.technology || 'Magic', 20)));
|
||||
graph.appendChild(group);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
Reference in new issue
Block a user