From cbc8ba8ce001a2ff40d309f8acd804a2146467e4 Mon Sep 17 00:00:00 2001 From: Romulus21 Date: Fri, 13 Nov 2026 19:07:43 +0100 Subject: [PATCH 1/3] =?UTF-8?q?Lie=20le=20nom=20du=20projet=20=C3=A0=20son?= =?UTF-8?q?=20repo=20dans=20les=20listes=20d'entr=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Les entrées exposent repo_url ; sur /entries et l'accueil, le nom du projet ouvre le repo dans un nouvel onglet (soulignement pointillé). Co-Authored-By: Claude Opus 5.5 --- src/models.rs | 2 ++ src/repo/entries.rs | 2 +- static/app.css | 2 ++ templates/_entry_row.html | 2 +- tests/api.rs | 11 +++++++++++ 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/models.rs b/src/models.rs index 740b8be..33e9851 100644 --- a/src/models.rs +++ b/src/models.rs @@ -41,6 +41,8 @@ pub struct Entry { /// The project's effective color. pub color: String, pub client_color: String, + /// The project's repository link. + pub repo_url: Option, pub started_at: DateTime, /// `None` while the timer is running. pub ended_at: Option>, diff --git a/src/repo/entries.rs b/src/repo/entries.rs index d20a88c..339d730 100644 --- a/src/repo/entries.rs +++ b/src/repo/entries.rs @@ -9,7 +9,7 @@ use crate::models::{Entry, EntryFilter, NewEntry, UpdateEntry}; /// `?1` is always "now", used to measure running entries. const SELECT: &str = "SELECT e.id, e.project_id, p.name AS project_name, p.client_id, c.name AS client_name, - COALESCE(p.color, c.color) AS color, c.color AS client_color, + COALESCE(p.color, c.color) AS color, c.color AS client_color, p.repo_url, e.started_at, e.ended_at, e.note, strftime('%s', COALESCE(e.ended_at, ?1)) - strftime('%s', e.started_at) AS seconds, EXISTS (SELECT 1 FROM time_entries o diff --git a/static/app.css b/static/app.css index 900d2cd..f3d2665 100644 --- a/static/app.css +++ b/static/app.css @@ -127,6 +127,8 @@ tr:last-child td { border-bottom: 0; } .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; } .time { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); } .client { color: var(--muted); } +.project-link { color: inherit; text-decoration: underline dotted var(--muted); text-underline-offset: 3px; } +.project-link:hover { color: var(--accent); text-decoration-color: currentColor; } tr.running { background: var(--running); } tr.day-head th { color: var(--text); font-weight: 600; font-size: .9rem; padding-top: 1.1rem; } tbody:first-of-type tr.day-head th { padding-top: .6rem; } diff --git a/templates/_entry_row.html b/templates/_entry_row.html index 22e1e7a..52efb75 100644 --- a/templates/_entry_row.html +++ b/templates/_entry_row.html @@ -4,7 +4,7 @@ {{ e.start_time() }} – {{ e.end_time() }} {% if e.overlaps %}⚠{% endif %} - {{ e.client_name }} / {{ e.project_name }} + {{ e.client_name }} / {% if let Some(u) = e.repo_url %}{{ e.project_name }}{% else %}{{ e.project_name }}{% endif %} {{ e.note }} {{ e.duration() }} diff --git a/tests/api.rs b/tests/api.rs index 8f58bb0..2fcd9e9 100644 --- a/tests/api.rs +++ b/tests/api.rs @@ -745,6 +745,17 @@ async fn project_repo_url() { assert_eq!(p["repo_url"], "https://git.example.com/acme/site"); let (_, html) = get_html(&app, "/clients").await; assert!(html.contains("href=\"https://git.example.com/acme/site\"")); + // Entry lists link the project name to its repository. + let (status, _) = add_entry( + &app, + p["id"].as_i64().unwrap(), + local(2026, 3, 10, 9, 0), + local(2026, 3, 10, 10, 0), + ) + .await; + assert_eq!(status, StatusCode::CREATED); + let (_, html) = get_html(&app, "/entries?from=2026-03-09&to=2026-03-15").await; + assert!(html.contains("class=\"project-link\" href=\"https://git.example.com/acme/site\"")); let (_, p) = send(&app, "PATCH", &project, Some(json!({ "repo_url": "" }))).await; assert!(p["repo_url"].is_null()); From ef69462e06e6f276adf5c32ffec94cde590dd804 Mon Sep 17 00:00:00 2001 From: Romulus21 Date: Fri, 13 Nov 2026 19:07:54 +0100 Subject: [PATCH 2/3] Affiche le timer en cours dans le header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pastille à droite du header sur toutes les pages (fragment /ui/timer/entete) : description ou projet, chrono et bouton stop, bordée à la couleur du projet. L'arrêt émet timer-changed pour rafraîchir le timer de l'accueil (GET /ui/timer). Co-Authored-By: Claude Opus 5.5 --- src/routes/pages.rs | 27 ++++++++++++++++++++++++++- static/app.css | 8 ++++++++ templates/_icons.html | 1 + templates/_mini_timer.html | 10 ++++++++++ templates/_timer.html | 2 +- templates/base.html | 1 + tests/api.rs | 32 ++++++++++++++++++++++++++++++++ 7 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 templates/_mini_timer.html diff --git a/src/routes/pages.rs b/src/routes/pages.rs index 9a36139..fd39c3e 100644 --- a/src/routes/pages.rs +++ b/src/routes/pages.rs @@ -27,6 +27,8 @@ pub fn router() -> Router { .route("/reports", get(reports_page)) .route("/ui/today", get(today_fragment)) .route("/ui/dernieres-entrees", get(recent_fragment)) + .route("/ui/timer", get(timer_fragment)) + .route("/ui/timer/entete", get(mini_timer)) .route("/ui/timer/start", post(start_timer)) .route("/ui/timer/stop", post(stop_timer)) .route("/ui/timer/debut", post(set_timer_start)) @@ -222,6 +224,13 @@ struct TimerTpl { groups: Vec, } +/// Compact running timer shown in the header of every page. +#[derive(Template)] +#[template(path = "_mini_timer.html")] +struct MiniTimerTpl { + running: Option, +} + #[derive(Template)] #[template(path = "_today.html")] struct TodayTpl { @@ -318,6 +327,16 @@ async fn dashboard(State(pool): State) -> PageResult { }) } +async fn timer_fragment(State(pool): State) -> PageResult { + render(timer_state(&pool).await?) +} + +async fn mini_timer(State(pool): State) -> PageResult { + render(MiniTimerTpl { + running: entries::running(&pool).await?, + }) +} + async fn today_fragment(State(pool): State) -> PageResult { render(today_state(&pool).await?) } @@ -344,7 +363,13 @@ async fn stop_timer(State(pool): State) -> PageResult { Ok(_) | Err(AppError::Conflict(_)) => {} Err(e) => return Err(e.into()), } - Ok(with_entries_changed(render(timer_state(&pool).await?)?)) + // `timer-changed` refreshes the dashboard timer when stopped from the header. + let resp = render(timer_state(&pool).await?)?; + Ok(( + AppendHeaders([("HX-Trigger", "entries-changed, timer-changed")]), + resp, + ) + .into_response()) } #[derive(Deserialize)] diff --git a/static/app.css b/static/app.css index f3d2665..bad72d6 100644 --- a/static/app.css +++ b/static/app.css @@ -52,6 +52,14 @@ h2 { font-size: 1.1rem; } padding: .35rem .75rem; border-radius: 999px; color: var(--muted); text-decoration: none; } .topbar nav a[aria-current="page"] { background: var(--bg); color: var(--text); font-weight: 600; } +#mini-timer { margin-left: auto; } +.mini-timer { + display: flex; align-items: center; gap: .6rem; min-width: 0; + border: 2px solid var(--color); border-radius: 999px; padding: .2rem .25rem .2rem .85rem; +} +.mini-timer-label { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); } +.mini-timer .clock { font-size: 1rem; } +.mini-timer .btn { border-radius: 50%; } main { max-width: 960px; margin: 1.5rem auto; padding: 0 16px; display: grid; gap: 1rem; } diff --git a/templates/_icons.html b/templates/_icons.html index 948adfe..e6251d3 100644 --- a/templates/_icons.html +++ b/templates/_icons.html @@ -6,6 +6,7 @@ {%- else if name == "check" -%} {%- else if name == "plus" -%} {%- else if name == "reset" -%} +{%- else if name == "stop" -%} {%- else if name == "link" -%} {%- else if name == "archive" -%} {%- else if name == "unarchive" -%} diff --git a/templates/_mini_timer.html b/templates/_mini_timer.html new file mode 100644 index 0000000..6e437dd --- /dev/null +++ b/templates/_mini_timer.html @@ -0,0 +1,10 @@ +{% import "_icons.html" as icons %} +
+ {% if let Some(e) = running %} +
+ {% if e.note.is_empty() %}{{ e.project_name }}{% else %}{{ e.note }}{% endif %} + {{ e.duration() }} + +
+ {% endif %} +
diff --git a/templates/_timer.html b/templates/_timer.html index e515f69..80a043d 100644 --- a/templates/_timer.html +++ b/templates/_timer.html @@ -1,4 +1,4 @@ -
+
{% if let Some(e) = running %}
diff --git a/templates/base.html b/templates/base.html index 35c4e35..a142563 100644 --- a/templates/base.html +++ b/templates/base.html @@ -21,6 +21,7 @@ Rapports Clients +
{% block content %}{% endblock %} diff --git a/tests/api.rs b/tests/api.rs index 2fcd9e9..d205765 100644 --- a/tests/api.rs +++ b/tests/api.rs @@ -770,3 +770,35 @@ async fn project_repo_url() { let (_, p) = send(&app, "GET", &format!("{uri}?archived=true"), None).await; assert_eq!(p[0]["repo_url"], "https://git.example.com/x"); } + +#[tokio::test] +async fn header_mini_timer() { + let app = app().await; + let p = project(&app, "Acme", "Site web").await; + + let (status, html) = get_html(&app, "/ui/timer/entete").await; + assert_eq!(status, StatusCode::OK); + assert!(!html.contains("mini-timer-label")); + + send( + &app, + "POST", + "/api/timer/start", + Some(json!({ "project_id": p, "note": "Refonte" })), + ) + .await; + let (_, html) = get_html(&app, "/ui/timer/entete").await; + assert!(html.contains("Refonte") && html.contains("data-started")); + assert!(html.contains("hx-post=\"/ui/timer/stop\"")); + + // Without a note, the project name is shown. + send( + &app, + "POST", + "/api/timer/start", + Some(json!({ "project_id": p })), + ) + .await; + let (_, html) = get_html(&app, "/ui/timer/entete").await; + assert!(html.contains("Site web")); +} From 1de02ade1eb8e02c0c50b4776072833ab2248264 Mon Sep 17 00:00:00 2001 From: Romulus21 Date: Fri, 13 Nov 2026 19:07:54 +0100 Subject: [PATCH 3/3] =?UTF-8?q?Retire=20les=20heures=20=C3=A0=20z=C3=A9ro?= =?UTF-8?q?=20du=20chrono?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 0:02, 4:07 puis 1:04:07 ; les horloges chargées par htmx sont mises à jour dès leur arrivée. Co-Authored-By: Claude Opus 5.5 --- static/app.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/static/app.js b/static/app.js index c46ebfc..fd6445e 100644 --- a/static/app.js +++ b/static/app.js @@ -3,13 +3,15 @@ function tick() { for (const el of document.querySelectorAll(".clock[data-started]")) { const secs = Math.max(0, Math.floor((Date.now() - Date.parse(el.dataset.started)) / 1000)); const h = Math.floor(secs / 3600); - const m = String(Math.floor((secs % 3600) / 60)).padStart(2, "0"); + const m = Math.floor((secs % 3600) / 60); const s = String(secs % 60).padStart(2, "0"); - el.textContent = `${h}:${m}:${s}`; + // Pas d'heures à zéro : 4:07, puis 1:04:07. + el.textContent = h ? `${h}:${String(m).padStart(2, "0")}:${s}` : `${m}:${s}`; } } tick(); setInterval(tick, 1000); +htmx.onLoad(tick); // horloges arrivées par htmx (ex. header) // Show server errors from htmx requests in a toast. let toastTimer;