diff --git a/src/api.rs b/src/api.rs index 0bd2d2a..7b84c3f 100644 --- a/src/api.rs +++ b/src/api.rs @@ -26,6 +26,7 @@ struct ApiStatus { ntp_active: bool, interfaces: Vec, hardware_offset_ms: i64, + clock_delta_history: Vec, } // AppState to hold shared data @@ -76,6 +77,8 @@ async fn get_status(data: web::Data) -> impl Responder { .map(|ifa| ifa.ip().to_string()) .collect(); + let clock_delta_history: Vec = state.clock_delta_history.iter().cloned().collect(); + HttpResponse::Ok().json(ApiStatus { ltc_status, ltc_timecode, @@ -89,6 +92,7 @@ async fn get_status(data: web::Data) -> impl Responder { ntp_active, interfaces, hardware_offset_ms: hw_offset_ms, + clock_delta_history, }) } @@ -215,6 +219,7 @@ mod tests { assert_eq!(resp.ltc_timecode, "01:02:03:04"); assert_eq!(resp.frame_rate, "25.00fps"); assert_eq!(resp.hardware_offset_ms, 10); + assert_eq!(resp.clock_delta_history, vec![4, 5, 6]); } #[actix_web::test] diff --git a/static/index.html b/static/index.html index 6b4c64a..1aa7110 100644 --- a/static/index.html +++ b/static/index.html @@ -32,6 +32,7 @@

Clock Offset

Delta: -- ms (-- frames)

Jitter: --

+

History (ms): --

diff --git a/static/script.js b/static/script.js index 2195bfd..1a7385c 100644 --- a/static/script.js +++ b/static/script.js @@ -10,6 +10,7 @@ document.addEventListener('DOMContentLoaded', () => { deltaMs: document.getElementById('delta-ms'), deltaFrames: document.getElementById('delta-frames'), jitterStatus: document.getElementById('jitter-status'), + deltaHistory: document.getElementById('delta-history'), interfaces: document.getElementById('interfaces'), }; @@ -43,6 +44,8 @@ document.addEventListener('DOMContentLoaded', () => { statusElements.jitterStatus.textContent = data.jitter_status; statusElements.jitterStatus.className = data.jitter_status.toLowerCase(); + statusElements.deltaHistory.textContent = data.clock_delta_history.join(', '); + statusElements.interfaces.innerHTML = ''; if (data.interfaces.length > 0) { data.interfaces.forEach(ip => {