Restructure the UI behind top-level tabs (Dashboard / ONU / OLT) so more features have room to land. showView() now drives the active tab via a VIEW_TO_TAB map, so sub-views (campaign/verify) keep the ONU tab lit. Tabs appear on login (landing on Dashboard) and hide on logout. Dashboard: a read-only network telemetry view modeled on the PONGo iOS app's DashboardViewModel. New api:dashboardStats aggregates, all in main.js (renderer just formats): - counts: ONUs, OLTs, controllers (controllers best-effort via /v3/controllers/configs/) - aggregate traffic (OLT TX BW = downstream, RX BW = upstream) - health: OLTs with laser off; abnormal-Rx count (rx < -28 || > -10) - ONU registration-state breakdown (clicking a state deep-links to the ONU tab pre-filtered) - opt-in detailed scan: per-ONU optical + FEC-health distribution fmtBps is a port of the iOS Format.bps. Edge glow: #edge-glow draws a neon conic-gradient beam masked to a 3px border ring and spins an @property --beam-angle 0->360deg, so a glow travels around the screen edge. Honors prefers-reduced-motion. mcms-api: add listAllControllerConfigs. Docs: CLAUDE.md section 15 + README + IPC table. Verified: npm run check passes; rendered the Dashboard + tabs + edge beam offscreen (beam frozen on the right edge to confirm it follows the border). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
80 lines
3 KiB
JavaScript
80 lines
3 KiB
JavaScript
// Preload: the only bridge between renderer and main. Everything the UI
|
|
// can do is enumerated here — the renderer has no direct node access.
|
|
|
|
const { contextBridge, ipcRenderer } = require('electron');
|
|
|
|
function call(channel, args) {
|
|
return ipcRenderer.invoke(channel, args);
|
|
}
|
|
|
|
contextBridge.exposeInMainWorld('api', {
|
|
login: (opts) => call('api:login', opts),
|
|
logout: () => call('api:logout'),
|
|
|
|
listOnuConfigs: (opts) => call('api:listOnuConfigs', opts),
|
|
listFleet: (opts) => call('api:listFleet', opts),
|
|
fetchStates: (opts) => call('api:fetchStates', opts),
|
|
getOnuConfig: (opts) => call('api:getOnuConfig', opts),
|
|
listOnuFirmware: () => call('api:listOnuFirmware'),
|
|
uploadFirmware: () => call('api:uploadFirmware'),
|
|
|
|
planUpgrade: (opts) => call('api:planUpgrade', opts),
|
|
executePerOnu: (opts) => call('api:executePerOnu', opts),
|
|
executeBulkTask: (opts) => call('api:executeBulkTask', opts),
|
|
getTaskConfig: (opts) => call('api:getTaskConfig', opts),
|
|
getUpgradeStatus: (opts) => call('api:getUpgradeStatus', opts),
|
|
|
|
deleteOnus: (opts) => call('api:deleteOnus', opts),
|
|
|
|
dashboardStats: (opts) => call('api:dashboardStats', opts),
|
|
|
|
listOlts: (opts) => call('api:listOlts', opts),
|
|
executeFloodChange: (opts) => call('api:executeFloodChange', opts),
|
|
|
|
onFloodProgress: (handler) => {
|
|
const fn = (_ev, payload) => handler(payload);
|
|
ipcRenderer.on('olt-flood:progress', fn);
|
|
return () => ipcRenderer.removeListener('olt-flood:progress', fn);
|
|
},
|
|
|
|
fetchFecHealth: (opts) => call('api:fetchFecHealth', opts),
|
|
fetchOnuSnapshot: (opts) => call('api:fetchOnuSnapshot', opts),
|
|
savePlanCsv: (opts) => call('api:savePlanCsv', opts),
|
|
saveCsvFile: (opts) => call('api:saveCsvFile', opts),
|
|
openCsvFile: () => call('api:openCsvFile'),
|
|
|
|
// Streaming FEC pre-flight progress (one event per ONU resolved).
|
|
onFecProgress: (handler) => {
|
|
const fn = (_ev, payload) => handler(payload);
|
|
ipcRenderer.on('fec:progress', fn);
|
|
return () => ipcRenderer.removeListener('fec:progress', fn);
|
|
},
|
|
|
|
// Streaming verify-snapshot progress.
|
|
onVerifyProgress: (handler) => {
|
|
const fn = (_ev, payload) => handler(payload);
|
|
ipcRenderer.on('verify:progress', fn);
|
|
return () => ipcRenderer.removeListener('verify:progress', fn);
|
|
},
|
|
|
|
// Live progress events from the main process while executePerOnu runs.
|
|
onUpgradeProgress: (handler) => {
|
|
const fn = (_ev, payload) => handler(payload);
|
|
ipcRenderer.on('upgrade:progress', fn);
|
|
return () => ipcRenderer.removeListener('upgrade:progress', fn);
|
|
},
|
|
|
|
// Streaming state-fetch progress (Equipment ID population).
|
|
onStatesProgress: (handler) => {
|
|
const fn = (_ev, payload) => handler(payload);
|
|
ipcRenderer.on('states:progress', fn);
|
|
return () => ipcRenderer.removeListener('states:progress', fn);
|
|
},
|
|
|
|
// Streaming delete progress.
|
|
onDeleteProgress: (handler) => {
|
|
const fn = (_ev, payload) => handler(payload);
|
|
ipcRenderer.on('delete:progress', fn);
|
|
return () => ipcRenderer.removeListener('delete:progress', fn);
|
|
},
|
|
});
|