initial commit

This commit is contained in:
Jon Vanvik 2026-05-26 11:16:18 +02:00
commit 0eb9b55717
11 changed files with 3969 additions and 0 deletions

69
preload.js Normal file
View file

@ -0,0 +1,69 @@
// 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),
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);
},
});