Enhance: Implement Phase 4 Device Heartbeat and Room Refresh

- Fully implemented run_device_heartbeat with OS/Network telemetry.
- Added refresh_location_config to keep room metadata synchronized.
- Finalized background loop initialization in onMount.
- Integrated telemetry gathered via the Electron get_device_info bridge.
This commit is contained in:
Scott Idem
2026-01-23 17:40:39 -05:00
parent 10f7c1b776
commit 54a2cfa59f

View File

@@ -122,6 +122,65 @@
is_syncing = false;
}
}
/**
* Device Heartbeat & Telemetry
* Gathers OS info and updates the device record in the cloud.
*/
async function run_device_heartbeat() {
const device_id = $ae_loc.native_device?.event_device_id || $ae_loc.native_device?.id;
if (!device_id) return;
try {
const info = await native.get_device_info();
if (!info) return;
const update_payload = {
heartbeat: new Date().toISOString(),
info_hostname: info.hostname,
info_ip_list: info.ip_addresses.join(', '),
meta_json: {
platform: info.platform,
release: info.release,
arch: info.arch,
cpus: info.cpus,
total_mem: Math.round(info.total_mem / (1024 * 1024)) + 'MB',
free_mem: Math.round(info.free_mem / (1024 * 1024)) + 'MB'
}
};
await events_func.update_ae_obj__event_device({
api_cfg: $ae_api,
event_device_id: device_id,
data_kv: update_payload,
log_lvl: 0
});
if (log_lvl > 1) console.log('Sync: Device heartbeat SUCCESS.');
} catch (err) {
console.error('Sync: Device heartbeat FAILED:', err);
}
}
/**
* Location Config Refresh
* Ensures we have latest room settings.
*/
async function refresh_location_config() {
const location_id = $events_slct.event_location_id;
if (!location_id) return;
try {
await events_func.load_ae_obj_id__event_location({
api_cfg: $ae_api,
event_location_id: location_id,
try_cache: true,
log_lvl: 0
});
} catch (err) {
console.error('Sync: Location refresh FAILED:', err);
}
}
</script>
<!-- Monitor Overlay (Hidden by default, triggered by config modal or secret gesture) -->