diff --git a/vzdv-site/src/endpoints/homepage.rs b/vzdv-site/src/endpoints/homepage.rs index 8ac3658..447ef67 100644 --- a/vzdv-site/src/endpoints/homepage.rs +++ b/vzdv-site/src/endpoints/homepage.rs @@ -17,7 +17,7 @@ use vatsim_utils::live_api::Vatsim; use vzdv::{ aviation::parse_metar, sql::{self, Activity}, - vatsim::get_online_facility_controllers, + vatsim::{get_online_facility_controllers, OnlineController}, PermissionsGroup, GENERAL_HTTP_CLIENT, }; @@ -45,6 +45,13 @@ async fn page_home( async fn snippet_online_controllers( State(state): State>, ) -> Result, AppError> { + #[derive(Debug, Serialize)] + struct OnlineControllerDisplay<'a> { + c: &'a OnlineController, + badge_color: &'static str, + badge_content: &'static str, + } + // cache this endpoint's returned data for 30 seconds let cache_key = "ONLINE_CONTROLLERS".to_string(); if let Some(cached) = state.cache.get(&cache_key) { @@ -58,6 +65,27 @@ async fn snippet_online_controllers( let online = get_online_facility_controllers(&state.db, &state.config) .await .map_err(|error| AppError::GenericFallback("getting online controllers", error))?; + let online: Vec = online + .iter() + .map(|c| { + let (badge_color, badge_content) = if c.callsign.ends_with("_CTR") { + ("blue", "CTR") + } else if c.callsign.ends_with("_APP") { + ("orange", "APP") + } else if c.callsign.ends_with("_TWR") { + ("red", "TWR") + } else if c.callsign.ends_with("_GND") { + ("green", "GND") + } else { + ("", "?") + }; + OnlineControllerDisplay { + c, + badge_color, + badge_content, + } + }) + .collect(); let template = state .templates .get_template("homepage/online_controllers.jinja")?; diff --git a/vzdv-site/templates/changelog.jinja b/vzdv-site/templates/changelog.jinja index 1421507..3d746e7 100644 --- a/vzdv-site/templates/changelog.jinja +++ b/vzdv-site/templates/changelog.jinja @@ -14,6 +14,17 @@
+
+
+
2025-01-19
+
+
    +
  • Online controllers card on homepage moved and expanded
  • +
+
+
+
+
2025-01-17
diff --git a/vzdv-site/templates/homepage/home.jinja b/vzdv-site/templates/homepage/home.jinja index fcae7c3..2755c02 100644 --- a/vzdv-site/templates/homepage/home.jinja +++ b/vzdv-site/templates/homepage/home.jinja @@ -4,15 +4,47 @@ {% block body %} + + + +

Welcome to the Denver ARTCC

- The Denver ARTCC covers approximately 285,000 square miles of airspace - over all or part of the states of Colorado, Arizona, New Mexico, Utah, + The Denver ARTCC covers approximately 285,000 square miles of airspace over all or part of the states of Colorado, Arizona, New Mexico, Utah, Kansas, Nebraska, South Dakota, Wyoming, and Montana.

+
+
+
+
+
{% include 'events/upcoming_events_snippet.jinja' %} @@ -21,21 +53,11 @@
-
-
-
-
-
+ hx-trigger="load, every 5m">
@@ -43,8 +65,7 @@
+ hx-trigger="load, every 1m">
diff --git a/vzdv-site/templates/homepage/online_controllers.jinja b/vzdv-site/templates/homepage/online_controllers.jinja index da37487..7cffc8e 100644 --- a/vzdv-site/templates/homepage/online_controllers.jinja +++ b/vzdv-site/templates/homepage/online_controllers.jinja @@ -1,13 +1,30 @@ {% if online|length > 0 %} -

Online controllers

-
    - {% for controller in online %} -
  • - {{ controller.name }} on {{ controller.callsign }} for - {{ controller.online_for }} -
  • - {% endfor %} -
+

+ Online controllers + +

+ + + + {% for controller in online %} + + + + + + + + {% endfor %} + +
{{ controller.badge_content }}{{ controller.c.callsign }} + {{ controller.c.name }} + + + + {{ controller.c.online_for }}{{ controller.c.frequency }}
{% else %} -

No controllers online

+
No controllers online
{% endif %} diff --git a/vzdv/src/vatsim.rs b/vzdv/src/vatsim.rs index 89f1dc8..d7287f8 100644 --- a/vzdv/src/vatsim.rs +++ b/vzdv/src/vatsim.rs @@ -29,6 +29,7 @@ pub struct OnlineController { pub callsign: String, pub name: String, pub online_for: String, + pub frequency: String, } /// Get facility controllers currently online. @@ -67,6 +68,7 @@ pub async fn get_online_facility_controllers( .map(|s| format!("{} {}", s.0, s.1)) .unwrap_or(String::from("?")), online_for: format!("{}h{}m", seconds / 3600, (seconds / 60) % 60), + frequency: controller.frequency.clone(), } }) .collect();