/** * com_bridge.js - COM Bridge (Windows EXE client). * * Informational version: every user has FIXED 2 CI-V ports. The section in * the web UI is informational only (no per-user configuration). This * module only handles: * - Status badge (how many clients online) * - Admin: connected-client stats (/api/com/stats) */ (function () { 'use strict'; async function load() { _applyRoleVisibility(); _checkAdmin(); if (window.AppState?.role === 'admin') { loadStats(); } } function _applyRoleVisibility() { // Viewer has NO access to the bridges (COM Bridge) - web UI only. // Hide both COM Bridge sections (Configuration + Settings) for viewers. // Operator and admin can see them. const role = window.AppState?.role || 'viewer'; const isViewer = (role === 'viewer'); ['com-bridge-config-section', 'com-bridge-settings-card'].forEach(id => { const el = document.getElementById(id); if (el) el.style.display = isViewer ? 'none' : ''; }); } function _checkAdmin() { const isAdmin = (window.AppState?.role === 'admin'); const box = document.getElementById('cb-admin-stats-box'); if (box) box.style.display = isAdmin ? '' : 'none'; } async function loadStats() { const list = document.getElementById('cb-stats-list'); if (!list) return; list.innerHTML = `
| IP klienta | Użytkownik | COM porty | Przypisania | Ruch (B/s) | Uptime |
|---|---|---|---|---|---|
| ${c.peer || '?'} | ${c.user_id || '?'} | ${(c.ports || []).join(', ') || '—'} | ${(c.assignments || []).map(a => `${a.com || '?'}=${a.service}` ).join(' ') || '—'} | ${c.rate_bytes || 0} | ${_formatUptime(c.connected_s || 0)} |