fix(ui): sync role select to live role; mark RF chip unavailable on poll failure

This commit is contained in:
2026-08-22 19:26:39 -06:00
parent a1b449c9be
commit 107cf17611
3 changed files with 18 additions and 7 deletions
@@ -269,7 +269,7 @@
<script src="js/xterm-addon-fit.min.js"></script> <script src="js/xterm-addon-fit.min.js"></script>
<script src="js/terminal.js?v=20260820-4"></script> <script src="js/terminal.js?v=20260820-4"></script>
<script src="js/pager.js?v=20260820-4"></script> <script src="js/pager.js?v=20260820-4"></script>
<script src="js/views.js?v=20260822-2"></script> <script src="js/views.js?v=20260822-3"></script>
<script src="js/app.js?v=20260822-1"></script> <script src="js/app.js?v=20260822-3"></script>
</body> </body>
</html> </html>
@@ -527,11 +527,21 @@ const Live = (() => {
} }
} }
function pollRfplan() { function pollRfplan() {
fetch(App.apiBase + '/api/rfplan', { credentials: 'include' }).then((r) => r.json()) fetch(App.apiBase + '/api/rfplan', { credentials: 'include' }).then((r) => {
.then((d) => { if (!r.ok) throw new Error('http ' + r.status);
rfState = d && typeof d.role === 'string' ? d : null; return r.json();
renderRfChip(); }).then((d) => {
}).catch(() => {}); rfState = d && typeof d.role === 'string' ? d : null;
renderRfChip();
}).catch(() => {
rfState = null;
const el = document.getElementById('rf-chip');
if (el) {
el.textContent = 'PHY1: ?';
el.title = 'RF plan unavailable';
el.className = 'health-chip warn';
}
});
} }
function renderRfChip() { function renderRfChip() {
const el = document.getElementById('rf-chip'); const el = document.getElementById('rf-chip');
@@ -482,6 +482,7 @@ views.pineap = (root) => {
const rfResult = h('div', { class: 'mk8-rf-result', text: '' }); const rfResult = h('div', { class: 'mk8-rf-result', text: '' });
function renderRfStatus(d) { function renderRfStatus(d) {
const role = d.role || 'idle'; const role = d.role || 'idle';
if (document.activeElement !== rfSel) rfSel.value = role;
rfStatusBadge.textContent = role.toUpperCase(); rfStatusBadge.textContent = role.toUpperCase();
rfStatusBadge.className = 'badge ' + rfStatusBadge.className = 'badge ' +
(role === 'uplink' ? (d.assoc ? 'on' : 'warn') : role === 'attack' ? 'warn' : 'off'); (role === 'uplink' ? (d.assoc ? 'on' : 'warn') : role === 'attack' ? 'warn' : 'off');