Author SHA1 Message Date
Romulus21andClaude Opus 5.5 13bbba1053 Merge branch 'feat/entrees-relancer'
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 19:17:11 +01:00
Romulus21andClaude Opus 5.5 2ff27b2a65 Ajoute un bouton play sur les entrées
En tête du groupe d'actions : ▶ arrête le timer en cours et en relance
un sur le même projet et la même note (POST /ui/entries/{id}/relancer) ;
sur l'entrée en cours, ■ l'arrête. Les deux émettent timer-changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 19:15:06 +01:00
Romulus21andClaude Opus 5.5 f612dbd764 Remplace « Arrêter » par un picto stop dans le timer
Bouton rond avec l'icône stop ; en mobile, l'horloge et le stop passent
sous la description, côte à côte, sans déborder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 19:15:06 +01:00
Romulus21andClaude Opus 5.5 262ab07b03 Merge branch 'feat/header-timer-lien-repo'
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 19:07:55 +01:00
Romulus21andClaude Opus 5.5 1de02ade1e Retire les heures à zéro du chrono
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 <noreply@anthropic.com>
2026-11-13 19:07:54 +01:00
Romulus21andClaude Opus 5.5 ef69462e06 Affiche le timer en cours dans le header
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 <noreply@anthropic.com>
2026-11-13 19:07:54 +01:00
Romulus21andClaude Opus 5.5 cbc8ba8ce0 Lie le nom du projet à son repo dans les listes d'entrées
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 <noreply@anthropic.com>
2026-11-13 19:07:43 +01:00
Romulus21andClaude Opus 5.5 46d2596813 Merge branch 'feat/projets-url-repo'
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 18:59:20 +01:00
11 changed files with 167 additions and 8 deletions

No files matched your search

+2
View File
@@ -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<String>,
pub started_at: DateTime<Utc>,
/// `None` while the timer is running.
pub ended_at: Option<DateTime<Utc>>,
+1 -1
View File
@@ -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
+38 -1
View File
@@ -27,6 +27,8 @@ pub fn router() -> Router<SqlitePool> {
.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))
@@ -44,6 +46,7 @@ pub fn router() -> Router<SqlitePool> {
get(entry_row).put(update_entry).delete(delete_entry),
)
.route("/ui/entries/{id}/edit", get(entry_edit))
.route("/ui/entries/{id}/relancer", post(restart_entry))
.route(
"/ui/entries/{id}/dupliquer",
get(entry_duplicate).post(duplicate_entry),
@@ -97,6 +100,16 @@ fn with_entries_changed(resp: Response) -> Response {
(AppendHeaders([("HX-Trigger", "entries-changed")]), resp).into_response()
}
/// Same, plus `timer-changed` so the dashboard timer follows a start/stop
/// made elsewhere (header, entry lists).
fn with_timer_changed(resp: Response) -> Response {
(
AppendHeaders([("HX-Trigger", "entries-changed, timer-changed")]),
resp,
)
.into_response()
}
struct ProjectOption {
id: i64,
name: String,
@@ -222,6 +235,13 @@ struct TimerTpl {
groups: Vec<ProjectGroup>,
}
/// Compact running timer shown in the header of every page.
#[derive(Template)]
#[template(path = "_mini_timer.html")]
struct MiniTimerTpl {
running: Option<Entry>,
}
#[derive(Template)]
#[template(path = "_today.html")]
struct TodayTpl {
@@ -318,6 +338,16 @@ async fn dashboard(State(pool): State<SqlitePool>) -> PageResult {
})
}
async fn timer_fragment(State(pool): State<SqlitePool>) -> PageResult {
render(timer_state(&pool).await?)
}
async fn mini_timer(State(pool): State<SqlitePool>) -> PageResult {
render(MiniTimerTpl {
running: entries::running(&pool).await?,
})
}
async fn today_fragment(State(pool): State<SqlitePool>) -> PageResult {
render(today_state(&pool).await?)
}
@@ -344,7 +374,7 @@ async fn stop_timer(State(pool): State<SqlitePool>) -> PageResult {
Ok(_) | Err(AppError::Conflict(_)) => {}
Err(e) => return Err(e.into()),
}
Ok(with_entries_changed(render(timer_state(&pool).await?)?))
Ok(with_timer_changed(render(timer_state(&pool).await?)?))
}
#[derive(Deserialize)]
@@ -702,6 +732,13 @@ async fn update_entry(
Ok(with_entries_changed(render(EntryRowTpl { e })?))
}
/// Stops the running timer and starts a new one on this entry's project and note.
async fn restart_entry(State(pool): State<SqlitePool>, Path(id): Path<i64>) -> PageResult {
let e = entries::get(&pool, id).await?;
entries::start(&pool, e.project_id, &e.note).await?;
Ok(with_timer_changed(StatusCode::OK.into_response()))
}
async fn delete_entry(State(pool): State<SqlitePool>, Path(id): Path<i64>) -> PageResult {
entries::delete(&pool, id).await?;
// htmx swaps the row with this empty body, removing it.
+14 -1
View File
@@ -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; }
@@ -91,6 +99,7 @@ a.btn { color: var(--text); text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn.play { color: var(--accent); }
.btn.small { padding: .2rem .55rem; font-size: .85rem; }
.btn.icon {
display: inline-flex; align-items: center; justify-content: center; flex: none;
@@ -115,6 +124,8 @@ a.btn { color: var(--text); text-decoration: none; }
.timer-start { margin-top: .35rem; font-size: .9rem; }
.timer-start input { width: 11rem; }
.clock { font-size: 2rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.btn.icon.timer-stop { width: 3rem; height: 3rem; border-radius: 50%; }
.timer-stop svg { width: 20px; height: 20px; }
.start { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) auto; gap: .5rem; }
.note { color: var(--muted); font-size: .9rem; }
@@ -127,6 +138,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; }
@@ -178,7 +191,7 @@ input[type="color"] {
@media (max-width: 640px) {
.current { grid-template-columns: 1fr auto; }
.current .btn { grid-column: 1 / -1; }
.current-label { grid-column: 1 / -1; min-width: 0; }
.start { grid-template-columns: 1fr; }
.report .label { width: auto; }
.bar-cell { width: 30%; }
+4 -2
View File
@@ -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;
+6 -1
View File
@@ -4,11 +4,16 @@
{{ e.start_time() }} – {{ e.end_time() }}
{% if e.overlaps %}<span class="warn" title="Chevauche une autre entrée">⚠</span>{% endif %}
</td>
<td><span class="dot" style="--color: {{ e.color }}"></span><span class="client">{{ e.client_name }}</span> / {{ e.project_name }}</td>
<td><span class="dot" style="--color: {{ e.color }}"></span><span class="client">{{ e.client_name }}</span> / {% if let Some(u) = e.repo_url %}<a class="project-link" href="{{ u }}" target="_blank" rel="noopener noreferrer" title="Ouvrir le repo">{{ e.project_name }}</a>{% else %}{{ e.project_name }}{% endif %}</td>
<td class="note">{{ e.note }}</td>
<td class="num">{{ e.duration() }}</td>
<td class="actions">
<div class="btn-group">
{% if e.running() %}
<button class="btn small icon danger" title="Arrêter" aria-label="Arrêter le timer" hx-post="/ui/timer/stop" hx-swap="none">{% call icons::icon("stop") %}{% endcall %}</button>
{% else %}
<button class="btn small icon play" title="Relancer cette entrée" aria-label="Relancer cette entrée" hx-post="/ui/entries/{{ e.id }}/relancer" hx-swap="none">{% call icons::icon("play") %}{% endcall %}</button>
{% endif %}
<button class="btn small icon primary" title="Modifier" aria-label="Modifier" hx-get="/ui/entries/{{ e.id }}/edit" hx-target="closest tr" hx-swap="outerHTML">{% call icons::icon("edit") %}{% endcall %}</button>
<button class="btn small icon" title="Dupliquer" aria-label="Dupliquer" hx-get="/ui/entries/{{ e.id }}/dupliquer" hx-target="closest tr" hx-swap="afterend">{% call icons::icon("copy") %}{% endcall %}</button>
<button class="btn small icon danger" title="Supprimer" aria-label="Supprimer" hx-delete="/ui/entries/{{ e.id }}" hx-target="closest tr" hx-swap="outerHTML" hx-confirm="Supprimer cette entrée ?">{% call icons::icon("trash") %}{% endcall %}</button>
+2
View File
@@ -6,6 +6,8 @@
{%- else if name == "check" -%}<path d="M20 6 9 17l-5-5"/>
{%- else if name == "plus" -%}<path d="M5 12h14"/><path d="M12 5v14"/>
{%- else if name == "reset" -%}<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/>
{%- else if name == "play" -%}<path d="M7 4.5v15l12.5-7.5z" fill="currentColor"/>
{%- else if name == "stop" -%}<rect x="6" y="6" width="12" height="12" rx="1.5" fill="currentColor"/>
{%- else if name == "link" -%}<path d="M15 3h6v6"/><path d="M10 14 21 3"/><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>
{%- else if name == "archive" -%}<rect x="2" y="3" width="20" height="5" rx="1"/><path d="M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8"/><path d="M10 12h4"/>
{%- else if name == "unarchive" -%}<rect x="2" y="3" width="20" height="5" rx="1"/><path d="M4 8v11a2 2 0 0 0 2 2h2"/><path d="M20 8v11a2 2 0 0 1-2 2h-2"/><path d="m9 15 3-3 3 3"/><path d="M12 12v9"/>
+10
View File
@@ -0,0 +1,10 @@
{% import "_icons.html" as icons %}
<div id="mini-timer" hx-get="/ui/timer/entete" hx-trigger="entries-changed from:body, every 30s" hx-swap="outerHTML">
{% if let Some(e) = running %}
<div class="mini-timer" style="--color: {{ e.color }}" title="{{ e.client_name }} / {{ e.project_name }}">
<span class="mini-timer-label">{% if e.note.is_empty() %}{{ e.project_name }}{% else %}{{ e.note }}{% endif %}</span>
<span class="clock" data-started="{{ e.started_rfc3339() }}">{{ e.duration() }}</span>
<button class="btn small icon danger" hx-post="/ui/timer/stop" hx-swap="none" title="Arrêter" aria-label="Arrêter le timer">{% call icons::icon("stop") %}{% endcall %}</button>
</div>
{% endif %}
</div>
+3 -2
View File
@@ -1,4 +1,5 @@
<section id="timer" class="card timer{% if running.is_some() %} is-running{% endif %}"{% if let Some(e) = running %} style="--color: {{ e.color }}"{% endif %}>
{% import "_icons.html" as icons %}
<section id="timer" hx-get="/ui/timer" hx-trigger="timer-changed from:body" hx-swap="outerHTML" class="card timer{% if running.is_some() %} is-running{% endif %}"{% if let Some(e) = running %} style="--color: {{ e.color }}"{% endif %}>
{% if let Some(e) = running %}
<div class="current">
<div class="current-label">
@@ -11,7 +12,7 @@
</form>
</div>
<div class="clock" data-started="{{ e.started_rfc3339() }}">{{ e.duration() }}</div>
<button class="btn danger" hx-post="/ui/timer/stop" hx-target="#timer" hx-swap="outerHTML">Arrêter</button>
<button class="btn icon danger timer-stop" hx-post="/ui/timer/stop" hx-target="#timer" hx-swap="outerHTML" title="Arrêter" aria-label="Arrêter le timer">{% call icons::icon("stop") %}{% endcall %}</button>
</div>
{% endif %}
{% if groups.is_empty() %}
+1
View File
@@ -21,6 +21,7 @@
<a href="/reports" {% if nav == "reports" %}aria-current="page"{% endif %}>Rapports</a>
<a href="/clients" {% if nav == "clients" %}aria-current="page"{% endif %}>Clients</a>
</nav>
<div id="mini-timer" hx-get="/ui/timer/entete" hx-trigger="load" hx-swap="outerHTML"></div>
</header>
<main>
{% block content %}{% endblock %}
+86
View File
@@ -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());
@@ -759,3 +770,78 @@ 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("<span class=\"mini-timer-label\">Site web</span>"));
}
#[tokio::test]
async fn restart_entry_from_list() {
let app = app().await;
let a = project(&app, "Acme", "Site web").await;
let b = project(&app, "Globex", "API").await;
add_entry(&app, a, local(2026, 3, 10, 9, 0), local(2026, 3, 10, 10, 0)).await;
send(
&app,
"PATCH",
"/api/entries/1",
Some(json!({ "note": "réunion" })),
)
.await;
send(
&app,
"POST",
"/api/timer/start",
Some(json!({ "project_id": b })),
)
.await;
// ▶ on entry 1: the Globex timer stops, a new one runs on Acme / "réunion".
let (status, _) = send_form(&app, "/ui/entries/1/relancer", "").await;
assert_eq!(status, StatusCode::OK);
let (_, running) = send(&app, "GET", "/api/timer", None).await;
assert_eq!(running["project_id"], a);
assert_eq!(running["note"], "réunion");
let (_, list) = send(
&app,
"GET",
"/api/entries?from=2020-01-01&to=2100-01-01",
None,
)
.await;
let open = list
.as_array()
.unwrap()
.iter()
.filter(|e| e["ended_at"].is_null())
.count();
assert_eq!(open, 1);
}