add proper window open/close dates

This commit is contained in:
insects 2025-02-07 15:02:36 +01:00
parent f6c315d985
commit c761a9ef26
4 changed files with 65 additions and 3 deletions

View file

@ -512,7 +512,7 @@ impl Filters {
pub fn filter<'a>(
&'a self,
fish: Vec<&'a CombinedFish>,
caught_fish_ids: &Vec<i32>,
caught_fish_ids: &[i32],
) -> Vec<&'a CombinedFish> {
fish.into_iter()
.filter(|fish| {

View file

@ -77,12 +77,27 @@ pub fn main_page(
}
.when {
@if let Some(window) = fish.windows.first() {
@if fish.is_up || fish.is_always_up {
@if fish.is_up {
"closes " (window.display_end_time())
} @else {
"opens " (window.display_start_time())
}
br;
@if fish.is_up {
.date data-ts=(clock::to_earth_time(window.start_time + window.duration).timestamp_millis()) {
.inner id=(format!("date-{}", fish.entry.id)) hx-preserve {
(clock::to_earth_time(window.start_time + window.duration).format("%c %Z"))
}
}
} @else {
.date data-ts=(clock::to_earth_time(window.start_time).timestamp_millis()) {
.inner id=(format!("date-{}", fish.entry.id)) hx-preserve {
(clock::to_earth_time(window.start_time).format("%c %Z"))
}
}
}
}
}
.how {
@for item_id in &fish.entry.best_catch_path {
@ -127,6 +142,8 @@ pub fn main_page(
}
}
}
script src="/static/scripts/dates.js" type="text/javascript" {}
};
let template = html! {
@ -173,7 +190,7 @@ pub fn main_page(
}
}
}
div hx-get="" hx-trigger="every 10s" hx-swap="innerHTML" hx-target="this" {
div id="list" hx-get="" hx-trigger="every 10s" hx-swap="innerHTML" hx-target="this" hx-on="changeDates" {
(list)
}
};