-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.php
More file actions
88 lines (82 loc) · 2.97 KB
/
Copy pathindex.php
File metadata and controls
88 lines (82 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
$page = 'dashboard';
include 'header.php';
include 'functions.php';
$gateway_config = parse_ini_file($config['gateway_config_file'], true);
$txfreq = number_format($gateway_config['Radio']['TXFrequency']/1000000,3);
$rxfreq = number_format($gateway_config['Radio']['RXFrequency']/1000000,3);
?>
<div class="cards">
<section class="card"><h2>Transceiver info</h2>
<p>RX frequency <strong><?php echo $rxfreq; ?> MHz</strong></p>
<p>TX frequency <strong><?php echo $txfreq; ?> MHz</strong></p>
<p>Power <strong>0 dBm</strong></p>
</section>
<section class="card"><h2>Gateway status</h2>
<p>Callsign <strong id="gw_callsign"><?php echo $gateway_config['General']['Callsign'] ?? 'N/A'; ?></strong></p>
<p>Gateway <strong id="gw_status" class="status-good"></strong></p>
<p>Reflector <strong id="gw_ref"></strong></p>
<p>Module <strong id="gw_mod"></strong></p>
<p>Radio state <strong id="gw_radio" class="status-good"></strong></p>
</section></div>
<h2>Recent activity</h2>
<div class="table-card"><table id="lastheard">
<thead><tr>
<th>Time</th><th>Source</th><th>Destination</th><th>Interface</th>
<th>Type</th><th>CAN</th><th>MER</th><th>Duration</th>
</tr></thead><tbody></tbody></table></div>
<script>
function updateStatus(){fetch('get_status.php').then(r=>r.json()).then(d=>{
if(!d)return;
let g=document.getElementById('gw_status');
let r=document.getElementById('gw_radio');
document.getElementById('gw_ref').textContent=d.connected_ref||'-';
document.getElementById('gw_mod').textContent=d.connected_mod||'-';
r.textContent=d.radio_status||'unknown';
g.textContent=d.gateway_status||'unknown';
g.className=(g.textContent.toLowerCase()==='running')?'status-good':'status-bad';
r.className=(r.textContent.toLowerCase()==='listening')?'status-good':'status-bad';
});}
function updateDashboard(){
$.getJSON('get_lastheard.php',data=>{
let b=$('#lastheard tbody');b.empty();
if(!Array.isArray(data))return;
data.forEach(e=>{
let rc = e.src ? e.src.replace(/[^A-Za-z0-9].*$/, '') : '';
let iface = e.type === 'RF' ? 'RF' : 'Internet';
let mer = '<td></td>';
if (iface === 'RF' && Number.isFinite(parseFloat(e.mer))) {
let v = parseFloat(e.mer);
let c = v < 5 ? 'mer-good' : v < 10 ? 'mer-warn' : 'mer-bad';
mer = `<td class="${c}">${v.toFixed(1)} %</td>`;
}
if (e.subtype === 'Packet') {
b.append(`<tr class="packet">
<td>${e.time || ''}</td>
<td><a href="https://www.qrz.com/db/${rc}" target="_blank">${e.src || ''}</a></td>
<td>${e.dst || ''}</td>
<td>${iface}</td>
<td>Packet</td>
<td>${e.can ?? ''}</td>
${mer}
<td></td>
</tr>`);
return;
}
b.append(`<tr>
<td>${e.time || ''}</td>
<td><a href="https://www.qrz.com/db/${rc}" target="_blank">${e.src || ''}</a></td>
<td>${e.dst || ''}</td>
<td>${iface}</td>
<td>${e.subtype || ''}</td>
<td>${e.can ?? ''}</td>
${mer}
<td>${e.duration || ''}</td>
</tr>`);
});
});}
$(function(){updateStatus();updateDashboard();
setInterval(updateStatus,2000);
setInterval(updateDashboard,2000);});
</script>
<?php include 'footer.php'; ?>