Compare commits
20
Commits
No files matched your search
Generated
+15
@@ -1697,6 +1697,7 @@ dependencies = [
|
|||||||
"tokio",
|
"tokio",
|
||||||
"tower",
|
"tower",
|
||||||
"tower-http",
|
"tower-http",
|
||||||
|
"tower-livereload",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
]
|
]
|
||||||
@@ -1824,6 +1825,20 @@ version = "0.3.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e"
|
checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tower-livereload"
|
||||||
|
version = "0.10.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7df210bd982165dee3c20e31deed79a3585ee6b255c070d9c73ae015cc40d2f3"
|
||||||
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
|
"http",
|
||||||
|
"http-body",
|
||||||
|
"pin-project-lite",
|
||||||
|
"tokio",
|
||||||
|
"tower",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tower-service"
|
name = "tower-service"
|
||||||
version = "0.3.3"
|
version = "0.3.3"
|
||||||
|
|||||||
@@ -15,9 +15,14 @@ sqlx = { version = "0.8", default-features = false, features = ["runtime-tokio",
|
|||||||
thiserror = "2.0.21"
|
thiserror = "2.0.21"
|
||||||
tokio = { version = "1.54.1", features = ["full"] }
|
tokio = { version = "1.54.1", features = ["full"] }
|
||||||
tower-http = { version = "0.7.1", features = ["trace"] }
|
tower-http = { version = "0.7.1", features = ["trace"] }
|
||||||
|
tower-livereload = { version = "0.10.3", optional = true }
|
||||||
tracing = "0.1.44"
|
tracing = "0.1.44"
|
||||||
tracing-subscriber = { version = "0.3.23", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3.23", features = ["env-filter"] }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
# Recharge le navigateur au redémarrage du serveur (dev uniquement).
|
||||||
|
livereload = ["dep:tower-livereload"]
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
http-body-util = "0.1.5"
|
http-body-util = "0.1.5"
|
||||||
tower = { version = "0.5.3", features = ["util"] }
|
tower = { version = "0.5.3", features = ["util"] }
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
DEPLOY_DIR ?= /var/www/tempus
|
||||||
|
SERVICE ?= tempus
|
||||||
|
HOST ?= tempus.loc
|
||||||
|
ADDR ?= 127.0.0.1:3110
|
||||||
|
UNIT := $(HOME)/.config/systemd/user/$(SERVICE).service
|
||||||
|
SUBST := sed -e 's|@HOST@|$(HOST)|g' -e 's|@ADDR@|$(ADDR)|g' -e 's|@DEPLOY_DIR@|$(DEPLOY_DIR)|g'
|
||||||
|
|
||||||
|
.PHONY: build setup deploy backup status logs dev
|
||||||
|
|
||||||
|
## Compile le binaire (templates, CSS/JS et migrations sont embarqués).
|
||||||
|
build:
|
||||||
|
cargo build --release
|
||||||
|
|
||||||
|
## Une seule fois : dossier, vhost Apache et /etc/hosts (sudo), service systemd utilisateur.
|
||||||
|
setup:
|
||||||
|
sudo install -d -o $(USER) -g www-data -m 755 $(DEPLOY_DIR)
|
||||||
|
$(SUBST) deploy/vh_tempus.conf | sudo tee /etc/apache2/sites-available/vh_tempus.conf >/dev/null
|
||||||
|
sudo a2ensite -q vh_tempus
|
||||||
|
sudo systemctl reload apache2
|
||||||
|
grep -qw '$(HOST)' /etc/hosts || printf '127.0.0.1\t$(HOST)\n' | sudo tee -a /etc/hosts >/dev/null
|
||||||
|
install -d $(dir $(UNIT))
|
||||||
|
$(SUBST) deploy/tempus.service > $(UNIT)
|
||||||
|
systemctl --user daemon-reload
|
||||||
|
systemctl --user enable $(SERVICE)
|
||||||
|
|
||||||
|
## Sauvegarde la base, installe le nouveau binaire et redémarre le service.
|
||||||
|
deploy: build
|
||||||
|
systemctl --user stop $(SERVICE)
|
||||||
|
$(MAKE) --no-print-directory backup
|
||||||
|
install -m 755 target/release/tempus $(DEPLOY_DIR)/tempus
|
||||||
|
systemctl --user start $(SERVICE)
|
||||||
|
@for i in $$(seq 1 50); do \
|
||||||
|
curl -sf -o /dev/null http://$(ADDR)/health && echo "Déployé : http://$(HOST)" && exit 0; \
|
||||||
|
sleep 0.1; \
|
||||||
|
done; echo "Le service ne répond pas : make logs" >&2; exit 1
|
||||||
|
|
||||||
|
## Copie la base (service arrêté) dans $(DEPLOY_DIR)/backups, garde les 10 dernières.
|
||||||
|
backup:
|
||||||
|
@if [ -f $(DEPLOY_DIR)/tempus.db ]; then \
|
||||||
|
d=$(DEPLOY_DIR)/backups/$$(date +%Y%m%d-%H%M%S); mkdir -p $$d; \
|
||||||
|
cp $(DEPLOY_DIR)/tempus.db* $$d/ && echo "Sauvegarde : $$d"; \
|
||||||
|
ls -1dt $(DEPLOY_DIR)/backups/*/ | tail -n +11 | xargs -r rm -r; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
status:
|
||||||
|
systemctl --user status $(SERVICE) --no-pager
|
||||||
|
|
||||||
|
logs:
|
||||||
|
journalctl --user -u $(SERVICE) -f
|
||||||
|
|
||||||
|
## Dev : recompile, redémarre et recharge le navigateur à chaque modif.
|
||||||
|
dev:
|
||||||
|
watchexec -r -e rs,html,css,js,sql -- cargo run --features livereload
|
||||||
@@ -31,8 +31,8 @@ Aucune authentification : le service est prévu pour tourner en local.
|
|||||||
|--------------|----------------------------------------------------|
|
|--------------|----------------------------------------------------|
|
||||||
| GET, POST | `/clients` (`?archived=true` pour inclure les archivés) — `{"name", "color"?}` |
|
| GET, POST | `/clients` (`?archived=true` pour inclure les archivés) — `{"name", "color"?}` |
|
||||||
| PATCH, DELETE| `/clients/{id}` — `{"name"?, "archived"?, "color"?}` |
|
| PATCH, DELETE| `/clients/{id}` — `{"name"?, "archived"?, "color"?}` |
|
||||||
| GET, POST | `/clients/{id}/projects` — `{"name", "color"?}` |
|
| GET, POST | `/clients/{id}/projects` — `{"name", "color"?, "repo_url"?}` |
|
||||||
| PATCH, DELETE| `/projects/{id}` — `"color": null` pour reprendre celle du client |
|
| PATCH, DELETE| `/projects/{id}` — `"color": null` pour reprendre celle du client, `"repo_url": ""` pour l'effacer |
|
||||||
| GET | `/timer` — entrée en cours ou `null` |
|
| GET | `/timer` — entrée en cours ou `null` |
|
||||||
| POST | `/timer/start` `{"project_id", "note"?}` · `/timer/stop` |
|
| POST | `/timer/start` `{"project_id", "note"?}` · `/timer/stop` |
|
||||||
| GET, POST | `/entries` (`?from&to&client_id&project_id`) |
|
| GET, POST | `/entries` (`?from&to&client_id&project_id`) |
|
||||||
@@ -51,8 +51,33 @@ curl -XPOST localhost:7878/api/clients -H 'content-type: application/json' -d '{
|
|||||||
curl -XPOST localhost:7878/api/timer/start -H 'content-type: application/json' -d '{"project_id":1}'
|
curl -XPOST localhost:7878/api/timer/start -H 'content-type: application/json' -d '{"project_id":1}'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Production locale
|
||||||
|
|
||||||
|
Binaire dans `/var/www/tempus`, service systemd utilisateur, vhost Apache
|
||||||
|
(reverse proxy) sur http://tempus.loc → `127.0.0.1:3110`.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
make setup # une fois (sudo) : dossier, vhost, /etc/hosts, service
|
||||||
|
make deploy # compile, sauvegarde la base, installe, redémarre
|
||||||
|
make status # / make logs
|
||||||
|
```
|
||||||
|
|
||||||
|
La base de prod est `/var/www/tempus/tempus.db` ; chaque `make deploy` la copie
|
||||||
|
dans `/var/www/tempus/backups/` (10 dernières conservées). Variables
|
||||||
|
surchargeables : `DEPLOY_DIR`, `HOST`, `ADDR`, `SERVICE`.
|
||||||
|
|
||||||
## Développement
|
## Développement
|
||||||
|
|
||||||
|
Rechargement automatique (recompile, redémarre et rafraîchit le navigateur) :
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cargo install watchexec-cli # une fois
|
||||||
|
make dev
|
||||||
|
```
|
||||||
|
|
||||||
|
La feature `livereload` injecte un script dans les pages (pas dans les fragments
|
||||||
|
htmx) et désactive le cache des assets ; elle n'est jamais active par défaut.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cargo test
|
cargo test
|
||||||
cargo clippy --all-targets -- -D warnings
|
cargo clippy --all-targets -- -D warnings
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Tempus (suivi du temps)
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
WorkingDirectory=@DEPLOY_DIR@
|
||||||
|
Environment=TEMPUS_DB=@DEPLOY_DIR@/tempus.db
|
||||||
|
Environment=TEMPUS_ADDR=@ADDR@
|
||||||
|
ExecStart=@DEPLOY_DIR@/tempus
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=3
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<VirtualHost *:80>
|
||||||
|
ServerName @HOST@
|
||||||
|
ProxyPreserveHost On
|
||||||
|
ProxyPass / http://@ADDR@/
|
||||||
|
ProxyPassReverse / http://@ADDR@/
|
||||||
|
ErrorLog /var/log/apache2/error.@HOST@.log
|
||||||
|
CustomLog /var/log/apache2/access.@HOST@.log combined
|
||||||
|
</VirtualHost>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
-- Optional link to the project's source repository (http(s) URL).
|
||||||
|
ALTER TABLE projects ADD COLUMN repo_url TEXT;
|
||||||
+9
-1
@@ -20,7 +20,15 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
.await
|
.await
|
||||||
.with_context(|| format!("cannot listen on {}", config.addr))?;
|
.with_context(|| format!("cannot listen on {}", config.addr))?;
|
||||||
tracing::info!(db = %config.database_url, "Tempus disponible sur http://{}", config.addr);
|
tracing::info!(db = %config.database_url, "Tempus disponible sur http://{}", config.addr);
|
||||||
axum::serve(listener, routes::app(pool))
|
let app = routes::app(pool);
|
||||||
|
#[cfg(feature = "livereload")]
|
||||||
|
let app = app.layer(
|
||||||
|
// Les fragments htmx ne doivent pas recevoir le script injecté.
|
||||||
|
tower_livereload::LiveReloadLayer::new().request_predicate(
|
||||||
|
|req: &axum::http::Request<axum::body::Body>| !req.headers().contains_key("hx-request"),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
axum::serve(listener, app)
|
||||||
.with_graceful_shutdown(async {
|
.with_graceful_shutdown(async {
|
||||||
let _ = tokio::signal::ctrl_c().await;
|
let _ = tokio::signal::ctrl_c().await;
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ pub struct Project {
|
|||||||
pub color: Option<String>,
|
pub color: Option<String>,
|
||||||
/// `color`, or the client's color.
|
/// `color`, or the client's color.
|
||||||
pub effective_color: String,
|
pub effective_color: String,
|
||||||
|
/// Link to the source repository.
|
||||||
|
pub repo_url: Option<String>,
|
||||||
pub archived: bool,
|
pub archived: bool,
|
||||||
pub created_at: DateTime<Utc>,
|
pub created_at: DateTime<Utc>,
|
||||||
}
|
}
|
||||||
@@ -97,6 +99,9 @@ pub struct NameInput {
|
|||||||
/// `#rrggbb`. Clients get one from the palette, projects inherit their client's.
|
/// `#rrggbb`. Clients get one from the palette, projects inherit their client's.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub color: Option<String>,
|
pub color: Option<String>,
|
||||||
|
/// Projects only: `http(s)://` link to the source repository.
|
||||||
|
#[serde(default)]
|
||||||
|
pub repo_url: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Deserialize)]
|
#[derive(Debug, Default, Deserialize)]
|
||||||
@@ -106,6 +111,9 @@ pub struct UpdateInput {
|
|||||||
/// Absent: unchanged. `null`: reset to the client's color (projects only).
|
/// Absent: unchanged. `null`: reset to the client's color (projects only).
|
||||||
#[serde(default, deserialize_with = "present")]
|
#[serde(default, deserialize_with = "present")]
|
||||||
pub color: Option<Option<String>>,
|
pub color: Option<Option<String>>,
|
||||||
|
/// Projects only. Absent: unchanged. `null` or `""`: removed.
|
||||||
|
#[serde(default, deserialize_with = "present")]
|
||||||
|
pub repo_url: Option<Option<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
|
|||||||
@@ -47,6 +47,17 @@ pub async fn list(
|
|||||||
.await?)
|
.await?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The `limit` most recent entries, whatever their date.
|
||||||
|
pub async fn recent(pool: &SqlitePool, limit: i64, now: DateTime<Utc>) -> AppResult<Vec<Entry>> {
|
||||||
|
Ok(
|
||||||
|
sqlx::query_as(&format!("{SELECT} ORDER BY e.started_at DESC LIMIT ?2"))
|
||||||
|
.bind(clock::ts(&now))
|
||||||
|
.bind(limit)
|
||||||
|
.fetch_all(pool)
|
||||||
|
.await?,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn get(pool: &SqlitePool, id: i64) -> AppResult<Entry> {
|
pub async fn get(pool: &SqlitePool, id: i64) -> AppResult<Entry> {
|
||||||
Ok(sqlx::query_as(&format!("{SELECT} WHERE e.id = ?2"))
|
Ok(sqlx::query_as(&format!("{SELECT} WHERE e.id = ?2"))
|
||||||
.bind(clock::ts(&clock::now()))
|
.bind(clock::ts(&clock::now()))
|
||||||
|
|||||||
@@ -33,6 +33,22 @@ fn clean_color(color: &str) -> AppResult<String> {
|
|||||||
Ok(color.to_ascii_lowercase())
|
Ok(color.to_ascii_lowercase())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Validates an optional repository URL; blank means none.
|
||||||
|
fn clean_repo_url(url: &str) -> AppResult<Option<String>> {
|
||||||
|
let url = url.trim();
|
||||||
|
if url.is_empty() {
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
|
let valid = (url.starts_with("https://") || url.starts_with("http://"))
|
||||||
|
&& !url.contains(char::is_whitespace);
|
||||||
|
if !valid {
|
||||||
|
return Err(AppError::Validation(format!(
|
||||||
|
"URL du repo invalide « {url} » (doit commencer par http:// ou https://)"
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
Ok(Some(url.to_owned()))
|
||||||
|
}
|
||||||
|
|
||||||
/// Maps "zero rows affected" to `NotFound`.
|
/// Maps "zero rows affected" to `NotFound`.
|
||||||
fn affected(result: sqlx::sqlite::SqliteQueryResult) -> AppResult<()> {
|
fn affected(result: sqlx::sqlite::SqliteQueryResult) -> AppResult<()> {
|
||||||
if result.rows_affected() == 0 {
|
if result.rows_affected() == 0 {
|
||||||
|
|||||||
+16
-4
@@ -1,12 +1,13 @@
|
|||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
|
|
||||||
use super::{affected, clean_color, clean_name};
|
use super::{affected, clean_color, clean_name, clean_repo_url};
|
||||||
use crate::clock;
|
use crate::clock;
|
||||||
use crate::error::{AppError, AppResult};
|
use crate::error::{AppError, AppResult};
|
||||||
use crate::models::{Project, UpdateInput};
|
use crate::models::{Project, UpdateInput};
|
||||||
|
|
||||||
const SELECT: &str = "SELECT p.id, p.client_id, c.name AS client_name, p.name,
|
const SELECT: &str = "SELECT p.id, p.client_id, c.name AS client_name, p.name,
|
||||||
p.color, COALESCE(p.color, c.color) AS effective_color, p.archived, p.created_at
|
p.color, COALESCE(p.color, c.color) AS effective_color, p.repo_url, p.archived,
|
||||||
|
p.created_at
|
||||||
FROM projects p JOIN clients c ON c.id = p.client_id";
|
FROM projects p JOIN clients c ON c.id = p.client_id";
|
||||||
|
|
||||||
/// Lists projects, optionally for one client. Archived projects (or projects of
|
/// Lists projects, optionally for one client. Archived projects (or projects of
|
||||||
@@ -40,17 +41,21 @@ pub async fn create(
|
|||||||
client_id: i64,
|
client_id: i64,
|
||||||
name: &str,
|
name: &str,
|
||||||
color: Option<&str>,
|
color: Option<&str>,
|
||||||
|
repo_url: Option<&str>,
|
||||||
) -> AppResult<Project> {
|
) -> AppResult<Project> {
|
||||||
let name = clean_name(name)?;
|
let name = clean_name(name)?;
|
||||||
let color = color.map(clean_color).transpose()?;
|
let color = color.map(clean_color).transpose()?;
|
||||||
|
let repo_url = repo_url.map(clean_repo_url).transpose()?.flatten();
|
||||||
// Surface a missing client as 404 rather than a foreign key error.
|
// Surface a missing client as 404 rather than a foreign key error.
|
||||||
super::clients::get(pool, client_id).await?;
|
super::clients::get(pool, client_id).await?;
|
||||||
let id = sqlx::query(
|
let id = sqlx::query(
|
||||||
"INSERT INTO projects (client_id, name, color, created_at) VALUES (?1, ?2, ?3, ?4)",
|
"INSERT INTO projects (client_id, name, color, repo_url, created_at)
|
||||||
|
VALUES (?1, ?2, ?3, ?4, ?5)",
|
||||||
)
|
)
|
||||||
.bind(client_id)
|
.bind(client_id)
|
||||||
.bind(name)
|
.bind(name)
|
||||||
.bind(color)
|
.bind(color)
|
||||||
|
.bind(repo_url)
|
||||||
.bind(clock::ts(&clock::now()))
|
.bind(clock::ts(&clock::now()))
|
||||||
.execute(pool)
|
.execute(pool)
|
||||||
.await?
|
.await?
|
||||||
@@ -64,10 +69,15 @@ pub async fn update(pool: &SqlitePool, id: i64, input: &UpdateInput) -> AppResul
|
|||||||
Some(Some(c)) => Some(clean_color(c)?),
|
Some(Some(c)) => Some(clean_color(c)?),
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
|
let repo_url = match &input.repo_url {
|
||||||
|
Some(Some(u)) => clean_repo_url(u)?,
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
affected(
|
affected(
|
||||||
sqlx::query(
|
sqlx::query(
|
||||||
"UPDATE projects SET name = COALESCE(?2, name), archived = COALESCE(?3, archived),
|
"UPDATE projects SET name = COALESCE(?2, name), archived = COALESCE(?3, archived),
|
||||||
color = CASE WHEN ?4 THEN ?5 ELSE color END
|
color = CASE WHEN ?4 THEN ?5 ELSE color END,
|
||||||
|
repo_url = CASE WHEN ?6 THEN ?7 ELSE repo_url END
|
||||||
WHERE id = ?1",
|
WHERE id = ?1",
|
||||||
)
|
)
|
||||||
.bind(id)
|
.bind(id)
|
||||||
@@ -75,6 +85,8 @@ pub async fn update(pool: &SqlitePool, id: i64, input: &UpdateInput) -> AppResul
|
|||||||
.bind(input.archived)
|
.bind(input.archived)
|
||||||
.bind(input.color.is_some())
|
.bind(input.color.is_some())
|
||||||
.bind(color)
|
.bind(color)
|
||||||
|
.bind(input.repo_url.is_some())
|
||||||
|
.bind(repo_url)
|
||||||
.execute(pool)
|
.execute(pool)
|
||||||
.await?,
|
.await?,
|
||||||
)?;
|
)?;
|
||||||
|
|||||||
+10
-1
@@ -90,7 +90,16 @@ async fn create_project(
|
|||||||
) -> AppResult<(StatusCode, Json<Project>)> {
|
) -> AppResult<(StatusCode, Json<Project>)> {
|
||||||
Ok((
|
Ok((
|
||||||
StatusCode::CREATED,
|
StatusCode::CREATED,
|
||||||
Json(projects::create(&pool, client_id, &input.name, input.color.as_deref()).await?),
|
Json(
|
||||||
|
projects::create(
|
||||||
|
&pool,
|
||||||
|
client_id,
|
||||||
|
&input.name,
|
||||||
|
input.color.as_deref(),
|
||||||
|
input.repo_url.as_deref(),
|
||||||
|
)
|
||||||
|
.await?,
|
||||||
|
),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+52
-5
@@ -18,22 +18,69 @@ pub fn app(pool: SqlitePool) -> Router {
|
|||||||
get(|| asset("text/javascript", include_str!("../../static/htmx.min.js"))),
|
get(|| asset("text/javascript", include_str!("../../static/htmx.min.js"))),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/static/app.js",
|
"/static/flatpickr/flatpickr.min.js",
|
||||||
get(|| asset("text/javascript", include_str!("../../static/app.js"))),
|
get(|| {
|
||||||
|
asset(
|
||||||
|
"text/javascript",
|
||||||
|
include_str!("../../static/flatpickr/flatpickr.min.js"),
|
||||||
|
)
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/static/app.css",
|
"/static/flatpickr/fr.min.js",
|
||||||
get(|| asset("text/css", include_str!("../../static/app.css"))),
|
get(|| {
|
||||||
|
asset(
|
||||||
|
"text/javascript",
|
||||||
|
include_str!("../../static/flatpickr/fr.min.js"),
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.route(
|
||||||
|
"/static/flatpickr/flatpickr.min.css",
|
||||||
|
get(|| {
|
||||||
|
asset(
|
||||||
|
"text/css",
|
||||||
|
include_str!("../../static/flatpickr/flatpickr.min.css"),
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.route("/static/app.js", get(|| asset("text/javascript", APP_JS)))
|
||||||
|
.route("/static/app.css", get(|| asset("text/css", APP_CSS)))
|
||||||
|
.route(
|
||||||
|
"/static/favicon.svg",
|
||||||
|
get(|| asset("image/svg+xml", include_str!("../../static/favicon.svg"))),
|
||||||
)
|
)
|
||||||
.layer(TraceLayer::new_for_http())
|
.layer(TraceLayer::new_for_http())
|
||||||
.with_state(pool)
|
.with_state(pool)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const APP_CSS: &str = include_str!("../../static/app.css");
|
||||||
|
const APP_JS: &str = include_str!("../../static/app.js");
|
||||||
|
|
||||||
|
/// Hash of app.css + app.js, appended as `?v=` to their URLs so a deploy
|
||||||
|
/// bypasses the browser cache.
|
||||||
|
pub fn asset_version() -> &'static str {
|
||||||
|
static VERSION: std::sync::LazyLock<String> = std::sync::LazyLock::new(|| {
|
||||||
|
use std::hash::{Hash, Hasher};
|
||||||
|
let mut h = std::collections::hash_map::DefaultHasher::new();
|
||||||
|
(APP_CSS, APP_JS).hash(&mut h);
|
||||||
|
format!("{:x}", h.finish())
|
||||||
|
});
|
||||||
|
&VERSION
|
||||||
|
}
|
||||||
|
|
||||||
|
// En livereload, le CSS/JS doit être relu à chaque rechargement.
|
||||||
|
const CACHE_CONTROL: &str = if cfg!(feature = "livereload") {
|
||||||
|
"no-cache"
|
||||||
|
} else {
|
||||||
|
"public, max-age=3600"
|
||||||
|
};
|
||||||
|
|
||||||
async fn asset(content_type: &'static str, body: &'static str) -> impl IntoResponse {
|
async fn asset(content_type: &'static str, body: &'static str) -> impl IntoResponse {
|
||||||
(
|
(
|
||||||
[
|
[
|
||||||
(header::CONTENT_TYPE, content_type),
|
(header::CONTENT_TYPE, content_type),
|
||||||
(header::CACHE_CONTROL, "public, max-age=3600"),
|
(header::CACHE_CONTROL, CACHE_CONTROL),
|
||||||
],
|
],
|
||||||
body,
|
body,
|
||||||
)
|
)
|
||||||
|
|||||||
+135
-3
@@ -26,8 +26,10 @@ pub fn router() -> Router<SqlitePool> {
|
|||||||
.route("/entries", get(entries_page))
|
.route("/entries", get(entries_page))
|
||||||
.route("/reports", get(reports_page))
|
.route("/reports", get(reports_page))
|
||||||
.route("/ui/today", get(today_fragment))
|
.route("/ui/today", get(today_fragment))
|
||||||
|
.route("/ui/dernieres-entrees", get(recent_fragment))
|
||||||
.route("/ui/timer/start", post(start_timer))
|
.route("/ui/timer/start", post(start_timer))
|
||||||
.route("/ui/timer/stop", post(stop_timer))
|
.route("/ui/timer/stop", post(stop_timer))
|
||||||
|
.route("/ui/timer/debut", post(set_timer_start))
|
||||||
.route("/ui/clients", post(create_client))
|
.route("/ui/clients", post(create_client))
|
||||||
.route("/ui/clients/{id}", post(save_client))
|
.route("/ui/clients/{id}", post(save_client))
|
||||||
.route("/ui/clients/{id}/archive", post(archive_client))
|
.route("/ui/clients/{id}/archive", post(archive_client))
|
||||||
@@ -42,6 +44,10 @@ pub fn router() -> Router<SqlitePool> {
|
|||||||
get(entry_row).put(update_entry).delete(delete_entry),
|
get(entry_row).put(update_entry).delete(delete_entry),
|
||||||
)
|
)
|
||||||
.route("/ui/entries/{id}/edit", get(entry_edit))
|
.route("/ui/entries/{id}/edit", get(entry_edit))
|
||||||
|
.route(
|
||||||
|
"/ui/entries/{id}/dupliquer",
|
||||||
|
get(entry_duplicate).post(duplicate_entry),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Plumbing ---------------------------------------------------------------
|
// --- Plumbing ---------------------------------------------------------------
|
||||||
@@ -206,6 +212,7 @@ struct DashboardTpl {
|
|||||||
groups: Vec<ProjectGroup>,
|
groups: Vec<ProjectGroup>,
|
||||||
today_entries: Vec<Entry>,
|
today_entries: Vec<Entry>,
|
||||||
today_total: String,
|
today_total: String,
|
||||||
|
recent_days: Vec<DayGroup>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
@@ -222,6 +229,44 @@ struct TodayTpl {
|
|||||||
today_total: String,
|
today_total: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Template)]
|
||||||
|
#[template(path = "_recent.html")]
|
||||||
|
struct RecentTpl {
|
||||||
|
recent_days: Vec<DayGroup>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Entries started on the same local day, with their total.
|
||||||
|
struct DayGroup {
|
||||||
|
day: String,
|
||||||
|
total: String,
|
||||||
|
entries: Vec<Entry>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Groups a list sorted by start time into consecutive days.
|
||||||
|
fn group_by_day(list: Vec<Entry>) -> Vec<DayGroup> {
|
||||||
|
let mut days: Vec<(NaiveDate, i64, Vec<Entry>)> = Vec::new();
|
||||||
|
for e in list {
|
||||||
|
let date = clock::local_date(&e.started_at);
|
||||||
|
match days.last_mut() {
|
||||||
|
Some((d, secs, entries)) if *d == date => {
|
||||||
|
*secs += e.seconds;
|
||||||
|
entries.push(e);
|
||||||
|
}
|
||||||
|
_ => days.push((date, e.seconds, vec![e])),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
days.into_iter()
|
||||||
|
.map(|(date, secs, entries)| DayGroup {
|
||||||
|
day: clock::fmt_day(date),
|
||||||
|
total: clock::hhmm(secs),
|
||||||
|
entries,
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// How many entries the dashboard lists under "Dernières entrées".
|
||||||
|
const RECENT_LIMIT: i64 = 20;
|
||||||
|
|
||||||
async fn timer_state(pool: &SqlitePool) -> PageResult<TimerTpl> {
|
async fn timer_state(pool: &SqlitePool) -> PageResult<TimerTpl> {
|
||||||
let running = entries::running(pool).await?;
|
let running = entries::running(pool).await?;
|
||||||
// Preselect the running project, else the most recently tracked one.
|
// Preselect the running project, else the most recently tracked one.
|
||||||
@@ -249,18 +294,27 @@ async fn today_state(pool: &SqlitePool) -> PageResult<TodayTpl> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn recent_state(pool: &SqlitePool) -> PageResult<RecentTpl> {
|
||||||
|
let recent = entries::recent(pool, RECENT_LIMIT, clock::now()).await?;
|
||||||
|
Ok(RecentTpl {
|
||||||
|
recent_days: group_by_day(recent),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
async fn dashboard(State(pool): State<SqlitePool>) -> PageResult {
|
async fn dashboard(State(pool): State<SqlitePool>) -> PageResult {
|
||||||
let TimerTpl { running, groups } = timer_state(&pool).await?;
|
let TimerTpl { running, groups } = timer_state(&pool).await?;
|
||||||
let TodayTpl {
|
let TodayTpl {
|
||||||
today_entries,
|
today_entries,
|
||||||
today_total,
|
today_total,
|
||||||
} = today_state(&pool).await?;
|
} = today_state(&pool).await?;
|
||||||
|
let RecentTpl { recent_days } = recent_state(&pool).await?;
|
||||||
render(DashboardTpl {
|
render(DashboardTpl {
|
||||||
nav: "dashboard",
|
nav: "dashboard",
|
||||||
running,
|
running,
|
||||||
groups,
|
groups,
|
||||||
today_entries,
|
today_entries,
|
||||||
today_total,
|
today_total,
|
||||||
|
recent_days,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,6 +322,10 @@ async fn today_fragment(State(pool): State<SqlitePool>) -> PageResult {
|
|||||||
render(today_state(&pool).await?)
|
render(today_state(&pool).await?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn recent_fragment(State(pool): State<SqlitePool>) -> PageResult {
|
||||||
|
render(recent_state(&pool).await?)
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct StartForm {
|
struct StartForm {
|
||||||
project_id: i64,
|
project_id: i64,
|
||||||
@@ -289,6 +347,32 @@ async fn stop_timer(State(pool): State<SqlitePool>) -> PageResult {
|
|||||||
Ok(with_entries_changed(render(timer_state(&pool).await?)?))
|
Ok(with_entries_changed(render(timer_state(&pool).await?)?))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct TimerStartForm {
|
||||||
|
started_at: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Moves the start of the running timer (e.g. started a bit late).
|
||||||
|
async fn set_timer_start(
|
||||||
|
State(pool): State<SqlitePool>,
|
||||||
|
Form(f): Form<TimerStartForm>,
|
||||||
|
) -> PageResult {
|
||||||
|
let started = parse_datetime(&f.started_at, "début")?;
|
||||||
|
let running = entries::running(&pool)
|
||||||
|
.await?
|
||||||
|
.ok_or_else(|| AppError::Conflict("aucun timer en cours".into()))?;
|
||||||
|
entries::update(
|
||||||
|
&pool,
|
||||||
|
running.id,
|
||||||
|
&UpdateEntry {
|
||||||
|
started_at: Some(started.fixed_offset()),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
Ok(with_entries_changed(render(timer_state(&pool).await?)?))
|
||||||
|
}
|
||||||
|
|
||||||
// --- Clients & projects -----------------------------------------------------
|
// --- Clients & projects -----------------------------------------------------
|
||||||
|
|
||||||
struct ClientCard {
|
struct ClientCard {
|
||||||
@@ -333,6 +417,9 @@ struct ItemForm {
|
|||||||
/// Projects only: go back to the client's color.
|
/// Projects only: go back to the client's color.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
inherit: bool,
|
inherit: bool,
|
||||||
|
/// Projects only; blank removes it.
|
||||||
|
#[serde(default)]
|
||||||
|
repo_url: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
@@ -392,7 +479,14 @@ async fn create_project(
|
|||||||
// The color picker is prefilled with the client's color: keeping it means inheriting.
|
// The color picker is prefilled with the client's color: keeping it means inheriting.
|
||||||
let client = clients::get(&pool, client_id).await?;
|
let client = clients::get(&pool, client_id).await?;
|
||||||
let color = f.color.filter(|c| !c.eq_ignore_ascii_case(&client.color));
|
let color = f.color.filter(|c| !c.eq_ignore_ascii_case(&client.color));
|
||||||
projects::create(&pool, client_id, &f.name, color.as_deref()).await?;
|
projects::create(
|
||||||
|
&pool,
|
||||||
|
client_id,
|
||||||
|
&f.name,
|
||||||
|
color.as_deref(),
|
||||||
|
f.repo_url.as_deref(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
back_to_clients()
|
back_to_clients()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,6 +507,7 @@ async fn save_project(
|
|||||||
let input = UpdateInput {
|
let input = UpdateInput {
|
||||||
name: Some(f.name),
|
name: Some(f.name),
|
||||||
color,
|
color,
|
||||||
|
repo_url: f.repo_url.map(Some),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
projects::update(&pool, id, &input).await?;
|
projects::update(&pool, id, &input).await?;
|
||||||
@@ -446,7 +541,7 @@ struct EntriesTpl {
|
|||||||
clients: Vec<ClientOption>,
|
clients: Vec<ClientOption>,
|
||||||
filter_groups: Vec<ProjectGroup>,
|
filter_groups: Vec<ProjectGroup>,
|
||||||
groups: Vec<ProjectGroup>,
|
groups: Vec<ProjectGroup>,
|
||||||
entries: Vec<Entry>,
|
days: Vec<DayGroup>,
|
||||||
total: String,
|
total: String,
|
||||||
default_start: String,
|
default_start: String,
|
||||||
default_end: String,
|
default_end: String,
|
||||||
@@ -465,6 +560,15 @@ struct EntryEditTpl {
|
|||||||
groups: Vec<ProjectGroup>,
|
groups: Vec<ProjectGroup>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Template)]
|
||||||
|
#[template(path = "_entry_duplicate.html")]
|
||||||
|
struct EntryDuplicateTpl {
|
||||||
|
e: Entry,
|
||||||
|
/// A running entry has no end yet: offer "now".
|
||||||
|
end: String,
|
||||||
|
groups: Vec<ProjectGroup>,
|
||||||
|
}
|
||||||
|
|
||||||
async fn entries_page(
|
async fn entries_page(
|
||||||
State(pool): State<SqlitePool>,
|
State(pool): State<SqlitePool>,
|
||||||
Query(filter): Query<EntryFilter>,
|
Query(filter): Query<EntryFilter>,
|
||||||
@@ -490,7 +594,7 @@ async fn entries_page(
|
|||||||
clients: client_options(clients::list(&pool, true).await?, filter.client_id),
|
clients: client_options(clients::list(&pool, true).await?, filter.client_id),
|
||||||
filter_groups: group_projects(projects::list(&pool, None, true).await?, filter.project_id),
|
filter_groups: group_projects(projects::list(&pool, None, true).await?, filter.project_id),
|
||||||
groups: group_projects(projects::list(&pool, None, false).await?, last_project),
|
groups: group_projects(projects::list(&pool, None, false).await?, last_project),
|
||||||
entries: list,
|
days: group_by_day(list),
|
||||||
total,
|
total,
|
||||||
default_start: format!("{today}T09:00"),
|
default_start: format!("{today}T09:00"),
|
||||||
default_end: format!("{today}T10:00"),
|
default_end: format!("{today}T10:00"),
|
||||||
@@ -546,6 +650,34 @@ async fn entry_edit(State(pool): State<SqlitePool>, Path(id): Path<i64>) -> Page
|
|||||||
render(EntryEditTpl { e, groups })
|
render(EntryEditTpl { e, groups })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Form to create a copy of an entry, prefilled with its values.
|
||||||
|
async fn entry_duplicate(State(pool): State<SqlitePool>, Path(id): Path<i64>) -> PageResult {
|
||||||
|
let e = entries::get(&pool, id).await?;
|
||||||
|
let end = clock::input_value(&e.ended_at.unwrap_or_else(clock::now));
|
||||||
|
let groups = group_projects(
|
||||||
|
projects::list(&pool, None, false).await?,
|
||||||
|
Some(e.project_id),
|
||||||
|
);
|
||||||
|
render(EntryDuplicateTpl { e, end, groups })
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates the copy and swaps the form for its row.
|
||||||
|
async fn duplicate_entry(State(pool): State<SqlitePool>, Form(f): Form<EntryForm>) -> PageResult {
|
||||||
|
let started = parse_datetime(&f.started_at, "début")?;
|
||||||
|
let ended = parse_datetime(&f.ended_at, "fin")?;
|
||||||
|
let e = entries::create(
|
||||||
|
&pool,
|
||||||
|
&NewEntry {
|
||||||
|
project_id: f.project_id,
|
||||||
|
started_at: started.fixed_offset(),
|
||||||
|
ended_at: ended.fixed_offset(),
|
||||||
|
note: f.note,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
Ok(with_entries_changed(render(EntryRowTpl { e })?))
|
||||||
|
}
|
||||||
|
|
||||||
async fn update_entry(
|
async fn update_entry(
|
||||||
State(pool): State<SqlitePool>,
|
State(pool): State<SqlitePool>,
|
||||||
Path(id): Path<i64>,
|
Path(id): Path<i64>,
|
||||||
|
|||||||
+47
-3
@@ -1,4 +1,7 @@
|
|||||||
:root {
|
:root {
|
||||||
|
/* Hauteur commune des champs, pastilles de couleur et boutons-icônes. */
|
||||||
|
--control: 2.5rem;
|
||||||
|
--control-sm: 1.9rem;
|
||||||
--bg: #f6f5f2;
|
--bg: #f6f5f2;
|
||||||
--surface: #ffffff;
|
--surface: #ffffff;
|
||||||
--text: #1d1d1f;
|
--text: #1d1d1f;
|
||||||
@@ -64,7 +67,8 @@ main { max-width: 960px; margin: 1.5rem auto; padding: 0 16px; display: grid; ga
|
|||||||
.row { display: flex; gap: .5rem; align-items: center; }
|
.row { display: flex; gap: .5rem; align-items: center; }
|
||||||
.row.wrap { flex-wrap: wrap; }
|
.row.wrap { flex-wrap: wrap; }
|
||||||
.grow { flex: 1; min-width: 0; }
|
.grow { flex: 1; min-width: 0; }
|
||||||
.row.grow input { flex: 1; min-width: 0; }
|
.row.grow input:not([type="color"]) { flex: 1; min-width: 0; }
|
||||||
|
.row input, .row select { height: var(--control); }
|
||||||
.stack { display: grid; gap: .35rem; }
|
.stack { display: grid; gap: .35rem; }
|
||||||
.muted, .empty { color: var(--muted); }
|
.muted, .empty { color: var(--muted); }
|
||||||
.empty { margin: .25rem 0; }
|
.empty { margin: .25rem 0; }
|
||||||
@@ -83,10 +87,23 @@ label { display: flex; align-items: center; gap: .35rem; color: var(--muted); }
|
|||||||
border: 1px solid var(--border); background: var(--surface); border-radius: 8px;
|
border: 1px solid var(--border); background: var(--surface); border-radius: 8px;
|
||||||
padding: .45rem .9rem; cursor: pointer; white-space: nowrap;
|
padding: .45rem .9rem; cursor: pointer; white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
a.btn { color: var(--text); text-decoration: none; }
|
||||||
.btn:hover { border-color: var(--muted); }
|
.btn:hover { border-color: var(--muted); }
|
||||||
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
|
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
|
||||||
.btn.danger { color: var(--danger); }
|
.btn.danger { color: var(--danger); }
|
||||||
.btn.small { padding: .2rem .55rem; font-size: .85rem; }
|
.btn.small { padding: .2rem .55rem; font-size: .85rem; }
|
||||||
|
.btn.icon {
|
||||||
|
display: inline-flex; align-items: center; justify-content: center; flex: none;
|
||||||
|
width: var(--control); height: var(--control); padding: 0; line-height: 0;
|
||||||
|
}
|
||||||
|
.btn.small.icon { width: var(--control-sm); height: var(--control-sm); }
|
||||||
|
.btn.icon svg { display: block; }
|
||||||
|
.btn-group { display: inline-flex; }
|
||||||
|
.btn-group > .btn { border-radius: 0; }
|
||||||
|
.btn-group > .btn + .btn { margin-left: -1px; }
|
||||||
|
.btn-group > .btn:first-child { border-top-left-radius: 8px; border-bottom-left-radius: 8px; }
|
||||||
|
.btn-group > .btn:last-child { border-top-right-radius: 8px; border-bottom-right-radius: 8px; }
|
||||||
|
.btn-group > .btn:hover { position: relative; z-index: 1; }
|
||||||
.htmx-request .btn, .btn.htmx-request { opacity: .6; }
|
.htmx-request .btn, .btn.htmx-request { opacity: .6; }
|
||||||
|
|
||||||
.badge { font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: var(--bg); color: var(--muted); }
|
.badge { font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: var(--bg); color: var(--muted); }
|
||||||
@@ -95,6 +112,8 @@ label { display: flex; align-items: center; gap: .35rem; color: var(--muted); }
|
|||||||
.timer.is-running { background: var(--running); border-color: var(--color, var(--accent)); border-left-width: 6px; }
|
.timer.is-running { background: var(--running); border-color: var(--color, var(--accent)); border-left-width: 6px; }
|
||||||
.current { display: grid; grid-template-columns: 1fr auto auto; gap: 1rem; align-items: center; margin-bottom: 1rem; }
|
.current { display: grid; grid-template-columns: 1fr auto auto; gap: 1rem; align-items: center; margin-bottom: 1rem; }
|
||||||
.current-project { font-size: 1.3rem; font-weight: 600; }
|
.current-project { font-size: 1.3rem; font-weight: 600; }
|
||||||
|
.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; }
|
.clock { font-size: 2rem; font-weight: 600; font-variant-numeric: tabular-nums; }
|
||||||
.start { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) auto; gap: .5rem; }
|
.start { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) auto; gap: .5rem; }
|
||||||
.note { color: var(--muted); font-size: .9rem; }
|
.note { color: var(--muted); font-size: .9rem; }
|
||||||
@@ -109,6 +128,8 @@ tr:last-child td { border-bottom: 0; }
|
|||||||
.time { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
|
.time { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
|
||||||
.client { color: var(--muted); }
|
.client { color: var(--muted); }
|
||||||
tr.running { background: var(--running); }
|
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; }
|
||||||
tr.editing td { background: var(--bg); }
|
tr.editing td { background: var(--bg); }
|
||||||
tr.editing input, tr.editing select { width: 100%; }
|
tr.editing input, tr.editing select { width: 100%; }
|
||||||
td.actions { text-align: right; white-space: nowrap; }
|
td.actions { text-align: right; white-space: nowrap; }
|
||||||
@@ -121,9 +142,10 @@ td.actions { text-align: right; white-space: nowrap; }
|
|||||||
}
|
}
|
||||||
.client-card { border-left: 6px solid var(--color); }
|
.client-card { border-left: 6px solid var(--color); }
|
||||||
input[type="color"] {
|
input[type="color"] {
|
||||||
width: 2.2rem; height: 2.2rem; padding: .15rem; flex: none; cursor: pointer;
|
width: var(--control); height: var(--control); padding: .15rem; flex: none; cursor: pointer;
|
||||||
}
|
}
|
||||||
.projects input[type="color"] { width: 1.8rem; height: 1.8rem; }
|
.projects input { height: var(--control-sm); padding-block: 0; }
|
||||||
|
.projects input[type="color"] { width: var(--control-sm); padding: .1rem; }
|
||||||
|
|
||||||
/* Projects list */
|
/* Projects list */
|
||||||
.projects { list-style: none; margin: 0 0 1rem; padding: 0; }
|
.projects { list-style: none; margin: 0 0 1rem; padding: 0; }
|
||||||
@@ -132,6 +154,8 @@ input[type="color"] {
|
|||||||
padding: .4rem 0; border-bottom: 1px solid var(--border);
|
padding: .4rem 0; border-bottom: 1px solid var(--border);
|
||||||
}
|
}
|
||||||
.projects li.archived { opacity: .6; }
|
.projects li.archived { opacity: .6; }
|
||||||
|
.row.grow input.repo-url { flex: 1.3; }
|
||||||
|
.projects li > form::before { content: "-"; color: var(--muted); flex: none; }
|
||||||
|
|
||||||
/* Periods & reports */
|
/* Periods & reports */
|
||||||
.presets { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .75rem; }
|
.presets { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .75rem; }
|
||||||
@@ -159,3 +183,23 @@ input[type="color"] {
|
|||||||
.report .label { width: auto; }
|
.report .label { width: auto; }
|
||||||
.bar-cell { width: 30%; }
|
.bar-cell { width: 30%; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Date pickers (flatpickr), themed with the app tokens */
|
||||||
|
.flatpickr-calendar { background: var(--surface); border: 1px solid var(--border); box-shadow: 0 6px 24px rgb(0 0 0 / .15); }
|
||||||
|
.flatpickr-calendar.arrowTop:before, .flatpickr-calendar.arrowTop:after { border-bottom-color: var(--border); }
|
||||||
|
.flatpickr-calendar.arrowBottom:before, .flatpickr-calendar.arrowBottom:after { border-top-color: var(--border); }
|
||||||
|
.flatpickr-months .flatpickr-month, .flatpickr-months .flatpickr-prev-month, .flatpickr-months .flatpickr-next-month,
|
||||||
|
.flatpickr-current-month .flatpickr-monthDropdown-months, .flatpickr-current-month input.cur-year,
|
||||||
|
span.flatpickr-weekday, .flatpickr-day, .flatpickr-time input, .flatpickr-time .flatpickr-time-separator {
|
||||||
|
color: var(--text); fill: var(--text); background: transparent;
|
||||||
|
}
|
||||||
|
.flatpickr-current-month .flatpickr-monthDropdown-months option { background: var(--surface); }
|
||||||
|
.flatpickr-months .flatpickr-prev-month:hover svg, .flatpickr-months .flatpickr-next-month:hover svg { fill: var(--accent); }
|
||||||
|
.flatpickr-day.prevMonthDay, .flatpickr-day.nextMonthDay, .flatpickr-day.flatpickr-disabled { color: var(--muted); }
|
||||||
|
.flatpickr-day:hover, .flatpickr-day:focus, .flatpickr-time input:hover, .flatpickr-time input:focus,
|
||||||
|
.flatpickr-time .numInputWrapper:hover { background: var(--bg); border-color: var(--bg); }
|
||||||
|
.flatpickr-day.today { border-color: var(--accent); }
|
||||||
|
.flatpickr-day.selected, .flatpickr-day.selected:hover, .flatpickr-day.selected:focus {
|
||||||
|
background: var(--accent); border-color: var(--accent); color: var(--accent-text);
|
||||||
|
}
|
||||||
|
.flatpickr-calendar.hasTime .flatpickr-time { border-top-color: var(--border); }
|
||||||
@@ -31,3 +31,74 @@ document.addEventListener("submit", (event) => {
|
|||||||
const message = event.target.dataset.confirm;
|
const message = event.target.dataset.confirm;
|
||||||
if (message && !confirm(message)) event.preventDefault();
|
if (message && !confirm(message)) event.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Date/time pickers on entry fields, including rows swapped in by htmx.
|
||||||
|
// The original input keeps the `YYYY-MM-DDTHH:MM` value sent to the server.
|
||||||
|
htmx.onLoad((root) => {
|
||||||
|
for (const input of root.querySelectorAll('input[type="datetime-local"]')) {
|
||||||
|
flatpickr(input, {
|
||||||
|
locale: "fr",
|
||||||
|
enableTime: true,
|
||||||
|
time_24hr: true,
|
||||||
|
dateFormat: "Y-m-d\\TH:i",
|
||||||
|
altInput: true,
|
||||||
|
altFormat: "d/m/Y H:i",
|
||||||
|
allowInput: true,
|
||||||
|
onReady: (_dates, _str, fp) =>
|
||||||
|
fp.altInput.setAttribute("aria-label", input.getAttribute("aria-label")),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// The calendars live in <body>: drop them with the inputs htmx removes.
|
||||||
|
document.body.addEventListener("htmx:beforeCleanupElement", (event) => {
|
||||||
|
event.target._flatpickr?.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Removes a row without a request (e.g. cancelling a duplicate).
|
||||||
|
function removeRow(button) {
|
||||||
|
const row = button.closest("tr");
|
||||||
|
for (const input of row.querySelectorAll("input")) input._flatpickr?.destroy();
|
||||||
|
row.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Favicon : point rouge clignotant tant qu'un enregistrement est en cours,
|
||||||
|
// sur toutes les pages (état lu sur /api/timer).
|
||||||
|
const favicon = document.getElementById("favicon");
|
||||||
|
const IDLE_ICON = favicon.href;
|
||||||
|
const recIcon = (opacity) =>
|
||||||
|
"data:image/svg+xml," +
|
||||||
|
encodeURIComponent(
|
||||||
|
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><circle cx="16" cy="16" r="13" fill="#e5322d" fill-opacity="${opacity}"/></svg>`,
|
||||||
|
);
|
||||||
|
const REC_ON = recIcon(1);
|
||||||
|
const REC_OFF = recIcon(0.2);
|
||||||
|
let recording = false;
|
||||||
|
let blinkOn = false;
|
||||||
|
|
||||||
|
function setRecording(value) {
|
||||||
|
if (value === recording) return;
|
||||||
|
recording = value;
|
||||||
|
blinkOn = true;
|
||||||
|
favicon.href = recording ? REC_ON : IDLE_ICON;
|
||||||
|
}
|
||||||
|
setInterval(() => {
|
||||||
|
if (!recording) return;
|
||||||
|
blinkOn = !blinkOn;
|
||||||
|
favicon.href = blinkOn ? REC_ON : REC_OFF;
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
async function refreshRecording() {
|
||||||
|
try {
|
||||||
|
const res = await fetch("/api/timer", { headers: { accept: "application/json" } });
|
||||||
|
if (res.ok) setRecording((await res.json()) !== null);
|
||||||
|
} catch {
|
||||||
|
// Serveur injoignable : on garde l'état connu.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
refreshRecording();
|
||||||
|
setInterval(refreshRecording, 20000);
|
||||||
|
document.addEventListener("visibilitychange", () => {
|
||||||
|
if (!document.hidden) refreshRecording();
|
||||||
|
});
|
||||||
|
document.body.addEventListener("htmx:afterRequest", refreshRecording);
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><circle cx="16" cy="16" r="12" fill="none" stroke="#2f6f5e" stroke-width="4"/><path d="M16 9v7l4 3" fill="none" stroke="#2f6f5e" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
||||||
|
After Width: | Height: | Size: 261 B |
Vendored
+13
@@ -0,0 +1,13 @@
|
|||||||
|
.flatpickr-calendar{background:transparent;opacity:0;display:none;text-align:center;visibility:hidden;padding:0;-webkit-animation:none;animation:none;direction:ltr;border:0;font-size:14px;line-height:24px;border-radius:5px;position:absolute;width:307.875px;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-touch-action:manipulation;touch-action:manipulation;background:#fff;-webkit-box-shadow:1px 0 0 #e6e6e6,-1px 0 0 #e6e6e6,0 1px 0 #e6e6e6,0 -1px 0 #e6e6e6,0 3px 13px rgba(0,0,0,0.08);box-shadow:1px 0 0 #e6e6e6,-1px 0 0 #e6e6e6,0 1px 0 #e6e6e6,0 -1px 0 #e6e6e6,0 3px 13px rgba(0,0,0,0.08)}.flatpickr-calendar.open,.flatpickr-calendar.inline{opacity:1;max-height:640px;visibility:visible}.flatpickr-calendar.open{display:inline-block;z-index:99999}.flatpickr-calendar.animate.open{-webkit-animation:fpFadeInDown 300ms cubic-bezier(.23,1,.32,1);animation:fpFadeInDown 300ms cubic-bezier(.23,1,.32,1)}.flatpickr-calendar.inline{display:block;position:relative;top:2px}.flatpickr-calendar.static{position:absolute;top:calc(100% + 2px)}.flatpickr-calendar.static.open{z-index:999;display:block}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+1) .flatpickr-day.inRange:nth-child(7n+7){-webkit-box-shadow:none !important;box-shadow:none !important}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+2) .flatpickr-day.inRange:nth-child(7n+1){-webkit-box-shadow:-2px 0 0 #e6e6e6,5px 0 0 #e6e6e6;box-shadow:-2px 0 0 #e6e6e6,5px 0 0 #e6e6e6}.flatpickr-calendar .hasWeeks .dayContainer,.flatpickr-calendar .hasTime .dayContainer{border-bottom:0;border-bottom-right-radius:0;border-bottom-left-radius:0}.flatpickr-calendar .hasWeeks .dayContainer{border-left:0}.flatpickr-calendar.hasTime .flatpickr-time{height:40px;border-top:1px solid #e6e6e6}.flatpickr-calendar.noCalendar.hasTime .flatpickr-time{height:auto}.flatpickr-calendar:before,.flatpickr-calendar:after{position:absolute;display:block;pointer-events:none;border:solid transparent;content:'';height:0;width:0;left:22px}.flatpickr-calendar.rightMost:before,.flatpickr-calendar.arrowRight:before,.flatpickr-calendar.rightMost:after,.flatpickr-calendar.arrowRight:after{left:auto;right:22px}.flatpickr-calendar.arrowCenter:before,.flatpickr-calendar.arrowCenter:after{left:50%;right:50%}.flatpickr-calendar:before{border-width:5px;margin:0 -5px}.flatpickr-calendar:after{border-width:4px;margin:0 -4px}.flatpickr-calendar.arrowTop:before,.flatpickr-calendar.arrowTop:after{bottom:100%}.flatpickr-calendar.arrowTop:before{border-bottom-color:#e6e6e6}.flatpickr-calendar.arrowTop:after{border-bottom-color:#fff}.flatpickr-calendar.arrowBottom:before,.flatpickr-calendar.arrowBottom:after{top:100%}.flatpickr-calendar.arrowBottom:before{border-top-color:#e6e6e6}.flatpickr-calendar.arrowBottom:after{border-top-color:#fff}.flatpickr-calendar:focus{outline:0}.flatpickr-wrapper{position:relative;display:inline-block}.flatpickr-months{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}.flatpickr-months .flatpickr-month{background:transparent;color:rgba(0,0,0,0.9);fill:rgba(0,0,0,0.9);height:34px;line-height:1;text-align:center;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;overflow:hidden;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}.flatpickr-months .flatpickr-prev-month,.flatpickr-months .flatpickr-next-month{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;text-decoration:none;cursor:pointer;position:absolute;top:0;height:34px;padding:10px;z-index:3;color:rgba(0,0,0,0.9);fill:rgba(0,0,0,0.9)}.flatpickr-months .flatpickr-prev-month.flatpickr-disabled,.flatpickr-months .flatpickr-next-month.flatpickr-disabled{display:none}.flatpickr-months .flatpickr-prev-month i,.flatpickr-months .flatpickr-next-month i{position:relative}.flatpickr-months .flatpickr-prev-month.flatpickr-prev-month,.flatpickr-months .flatpickr-next-month.flatpickr-prev-month{/*
|
||||||
|
/*rtl:begin:ignore*/left:0/*
|
||||||
|
/*rtl:end:ignore*/}/*
|
||||||
|
/*rtl:begin:ignore*/
|
||||||
|
/*
|
||||||
|
/*rtl:end:ignore*/
|
||||||
|
.flatpickr-months .flatpickr-prev-month.flatpickr-next-month,.flatpickr-months .flatpickr-next-month.flatpickr-next-month{/*
|
||||||
|
/*rtl:begin:ignore*/right:0/*
|
||||||
|
/*rtl:end:ignore*/}/*
|
||||||
|
/*rtl:begin:ignore*/
|
||||||
|
/*
|
||||||
|
/*rtl:end:ignore*/
|
||||||
|
.flatpickr-months .flatpickr-prev-month:hover,.flatpickr-months .flatpickr-next-month:hover{color:#959ea9}.flatpickr-months .flatpickr-prev-month:hover svg,.flatpickr-months .flatpickr-next-month:hover svg{fill:#f64747}.flatpickr-months .flatpickr-prev-month svg,.flatpickr-months .flatpickr-next-month svg{width:14px;height:14px}.flatpickr-months .flatpickr-prev-month svg path,.flatpickr-months .flatpickr-next-month svg path{-webkit-transition:fill .1s;transition:fill .1s;fill:inherit}.numInputWrapper{position:relative;height:auto}.numInputWrapper input,.numInputWrapper span{display:inline-block}.numInputWrapper input{width:100%}.numInputWrapper input::-ms-clear{display:none}.numInputWrapper input::-webkit-outer-spin-button,.numInputWrapper input::-webkit-inner-spin-button{margin:0;-webkit-appearance:none}.numInputWrapper span{position:absolute;right:0;width:14px;padding:0 4px 0 2px;height:50%;line-height:50%;opacity:0;cursor:pointer;border:1px solid rgba(57,57,57,0.15);-webkit-box-sizing:border-box;box-sizing:border-box}.numInputWrapper span:hover{background:rgba(0,0,0,0.1)}.numInputWrapper span:active{background:rgba(0,0,0,0.2)}.numInputWrapper span:after{display:block;content:"";position:absolute}.numInputWrapper span.arrowUp{top:0;border-bottom:0}.numInputWrapper span.arrowUp:after{border-left:4px solid transparent;border-right:4px solid transparent;border-bottom:4px solid rgba(57,57,57,0.6);top:26%}.numInputWrapper span.arrowDown{top:50%}.numInputWrapper span.arrowDown:after{border-left:4px solid transparent;border-right:4px solid transparent;border-top:4px solid rgba(57,57,57,0.6);top:40%}.numInputWrapper span svg{width:inherit;height:auto}.numInputWrapper span svg path{fill:rgba(0,0,0,0.5)}.numInputWrapper:hover{background:rgba(0,0,0,0.05)}.numInputWrapper:hover span{opacity:1}.flatpickr-current-month{font-size:135%;line-height:inherit;font-weight:300;color:inherit;position:absolute;width:75%;left:12.5%;padding:7.48px 0 0 0;line-height:1;height:34px;display:inline-block;text-align:center;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}.flatpickr-current-month span.cur-month{font-family:inherit;font-weight:700;color:inherit;display:inline-block;margin-left:.5ch;padding:0}.flatpickr-current-month span.cur-month:hover{background:rgba(0,0,0,0.05)}.flatpickr-current-month .numInputWrapper{width:6ch;width:7ch\0;display:inline-block}.flatpickr-current-month .numInputWrapper span.arrowUp:after{border-bottom-color:rgba(0,0,0,0.9)}.flatpickr-current-month .numInputWrapper span.arrowDown:after{border-top-color:rgba(0,0,0,0.9)}.flatpickr-current-month input.cur-year{background:transparent;-webkit-box-sizing:border-box;box-sizing:border-box;color:inherit;cursor:text;padding:0 0 0 .5ch;margin:0;display:inline-block;font-size:inherit;font-family:inherit;font-weight:300;line-height:inherit;height:auto;border:0;border-radius:0;vertical-align:initial;-webkit-appearance:textfield;-moz-appearance:textfield;appearance:textfield}.flatpickr-current-month input.cur-year:focus{outline:0}.flatpickr-current-month input.cur-year[disabled],.flatpickr-current-month input.cur-year[disabled]:hover{font-size:100%;color:rgba(0,0,0,0.5);background:transparent;pointer-events:none}.flatpickr-current-month .flatpickr-monthDropdown-months{appearance:menulist;background:transparent;border:none;border-radius:0;box-sizing:border-box;color:inherit;cursor:pointer;font-size:inherit;font-family:inherit;font-weight:300;height:auto;line-height:inherit;margin:-1px 0 0 0;outline:none;padding:0 0 0 .5ch;position:relative;vertical-align:initial;-webkit-box-sizing:border-box;-webkit-appearance:menulist;-moz-appearance:menulist;width:auto}.flatpickr-current-month .flatpickr-monthDropdown-months:focus,.flatpickr-current-month .flatpickr-monthDropdown-months:active{outline:none}.flatpickr-current-month .flatpickr-monthDropdown-months:hover{background:rgba(0,0,0,0.05)}.flatpickr-current-month .flatpickr-monthDropdown-months .flatpickr-monthDropdown-month{background-color:transparent;outline:none;padding:0}.flatpickr-weekdays{background:transparent;text-align:center;overflow:hidden;width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;height:28px}.flatpickr-weekdays .flatpickr-weekdaycontainer{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}span.flatpickr-weekday{cursor:default;font-size:90%;background:transparent;color:rgba(0,0,0,0.54);line-height:1;margin:0;text-align:center;display:block;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;font-weight:bolder}.dayContainer,.flatpickr-weeks{padding:1px 0 0 0}.flatpickr-days{position:relative;overflow:hidden;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:start;-webkit-align-items:flex-start;-ms-flex-align:start;align-items:flex-start;width:307.875pLine truncated
|
||||||
Vendored
+2
@@ -0,0 +1,2 @@
|
|||||||
|
/* flatpickr v4.6.13,, @license MIT */
|
||||||
|
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).flatpickr=n()}(this,(function(){"use strict";var e=function(){return(e=Object.assign||function(e){for(var n,t=1,a=arguments.length;t<a;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e}).apply(this,arguments)};function n(){for(var e=0,n=0,t=arguments.length;n<t;n++)e+=arguments[n].length;var a=Array(e),i=0;for(n=0;n<t;n++)for(var o=arguments[n],r=0,l=o.length;r<l;r++,i++)a[i]=o[r];return a}var t=["onChange","onClose","onDayCreate","onDestroy","onKeyDown","onMonthChange","onOpen","onParseConfig","onReady","onValueUpdate","onYearChange","onPreCalendarPosition"],a={_disable:[],allowInput:!1,allowInvalidPreload:!1,altFormat:"F j, Y",altInput:!1,altInputClass:"form-control input",animate:"object"==typeof window&&-1===window.navigator.userAgent.indexOf("MSIE"),ariaDateFormat:"F j, Y",autoFillDefaultTime:!0,clickOpens:!0,closeOnSelect:!0,conjunction:", ",dateFormat:"Y-m-d",defaultHour:12,defaultMinute:0,defaultSeconds:0,disable:[],disableMobile:!1,enableSeconds:!1,enableTime:!1,errorHandler:function(e){return"undefined"!=typeof console&&console.warn(e)},getWeek:function(e){var n=new Date(e.getTime());n.setHours(0,0,0,0),n.setDate(n.getDate()+3-(n.getDay()+6)%7);var t=new Date(n.getFullYear(),0,4);return 1+Math.round(((n.getTime()-t.getTime())/864e5-3+(t.getDay()+6)%7)/7)},hourIncrement:1,ignoredFocusElements:[],inline:!1,locale:"default",minuteIncrement:5,mode:"single",monthSelectorType:"dropdown",nextArrow:"<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M13.207 8.472l-7.854 7.854-0.707-0.707 7.146-7.146-7.146-7.148 0.707-0.707 7.854 7.854z' /></svg>",noCalendar:!1,now:new Date,onChange:[],onClose:[],onDayCreate:[],onDestroy:[],onKeyDown:[],onMonthChange:[],onOpen:[],onParseConfig:[],onReady:[],onValueUpdate:[],onYearChange:[],onPreCalendarPosition:[],plugins:[],position:"auto",positionElement:void 0,prevArrow:"<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M5.207 8.471l7.146 7.147-0.707 0.707-7.853-7.854 7.854-7.853 0.707 0.707-7.147 7.146z' /></svg>",shorthandCurrentMonth:!1,showMonths:1,static:!1,time_24hr:!1,weekNumbers:!1,wrap:!1},i={weekdays:{shorthand:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],longhand:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},months:{shorthand:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],longhand:["January","February","March","April","May","June","July","August","September","October","November","December"]},daysInMonth:[31,28,31,30,31,30,31,31,30,31,30,31],firstDayOfWeek:0,ordinal:function(e){var n=e%100;if(n>3&&n<21)return"th";switch(n%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}},rangeSeparator:" to ",weekAbbreviation:"Wk",scrollTitle:"Scroll to increment",toggleTitle:"Click to toggle",amPM:["AM","PM"],yearAriaLabel:"Year",monthAriaLabel:"Month",hourAriaLabel:"Hour",minuteAriaLabel:"Minute",time_24hr:!1},o=function(e,n){return void 0===n&&(n=2),("000"+e).slice(-1*n)},r=function(e){return!0===e?1:0};function l(e,n){var t;return function(){var a=this,i=arguments;clearTimeout(t),t=setTimeout((function(){return e.apply(a,i)}),n)}}var c=function(e){return e instanceof Array?e:[e]};function s(e,n,t){if(!0===t)return e.classList.add(n);e.classList.remove(n)}function d(e,n,t){var a=window.document.createElement(e);return n=n||"",t=t||"",a.className=n,void 0!==t&&(a.textContent=t),a}function u(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function f(e,n){return n(e)?e:e.parentNode?f(e.parentNode,n):void 0}function m(e,n){var t=d("div","numInputWrapper"),a=d("input","numInput "+e),i=d("span","arrowUp"),o=d("span","arrowDown");if(-1===navigator.userAgent.indexOf("MSIE 9.0")?a.type="number":(a.type="text",a.pattern="\\d*"),void 0!==n)for(var r in n)a.setAttribute(r,n[r]);return t.appendChild(a),t.appendChild(i),t.appendChild(o),t}function g(e){try{return"function"==typeof e.composedPath?e.composedPath()[0]:e.target}catch(n){return e.target}}var p=function(){},h=function(e,n,t){return t.months[n?"shorthand":"longhand"][e]},v={D:p,F:function(e,n,t){e.setMonth(t.months.longhand.indexOf(n))},G:function(e,n){e.setHours((e.getHours()>=12?12:0)+parseFloat(n))},H:function(e,n){e.setHours(parseFloat(n))},J:function(e,n){e.setDate(parseFloat(n))},K:function(e,n,t){e.setHours(e.getHours()%12+12*r(new RegExp(t.amPM[1],"i").test(n)))},M:function(e,n,t){e.setMonth(t.months.shorthand.indexOf(n))},S:function(e,n){e.setSeconds(parseFloat(n))},U:function(e,n){return new Date(1e3*parseFloat(n))},W:function(e,n,t){var a=parseInt(n),i=new Date(e.getFullYear(),0,2+7*(a-1),0,0,0,0);return i.setDate(i.getDate()-i.getDay()+t.fLine truncated
|
||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).fr={})}(this,function(e){"use strict";var r="undefined"!=typeof window&&void 0!==window.flatpickr?window.flatpickr:{l10ns:{}},n={firstDayOfWeek:1,weekdays:{shorthand:["dim","lun","mar","mer","jeu","ven","sam"],longhand:["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"]},months:{shorthand:["janv","févr","mars","avr","mai","juin","juil","août","sept","oct","nov","déc"],longhand:["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"]},ordinal:function(e){return 1<e?"":"er"},rangeSeparator:" au ",weekAbbreviation:"Sem",scrollTitle:"Défiler pour augmenter la valeur",toggleTitle:"Cliquer pour basculer",time_24hr:!0};r.l10ns.fr=n;r=r.l10ns;e.French=n,e.default=r,Object.defineProperty(e,"__esModule",{value:!0})});
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{% for d in days %}
|
||||||
|
<tbody>
|
||||||
|
<tr class="day-head"><th colspan="3">{{ d.day }}</th><th class="num">{{ d.total }}</th><th></th></tr>
|
||||||
|
{% for e in d.entries %}{% include "_entry_row.html" %}{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
{% endfor %}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<tr class="editing">
|
||||||
|
<td>
|
||||||
|
<div class="stack">
|
||||||
|
<input type="datetime-local" name="started_at" value="{{ e.start_input() }}" required aria-label="Début">
|
||||||
|
<input type="datetime-local" name="ended_at" value="{{ end }}" required aria-label="Fin">
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td><select name="project_id" aria-label="Projet">{% include "_project_select.html" %}</select></td>
|
||||||
|
<td><input name="note" value="{{ e.note }}" aria-label="Note"></td>
|
||||||
|
<td></td>
|
||||||
|
<td class="actions">
|
||||||
|
<button class="btn small primary" hx-post="/ui/entries/{{ e.id }}/dupliquer" hx-include="closest tr" hx-target="closest tr" hx-swap="outerHTML">Créer</button>
|
||||||
|
<button class="btn small" hx-on:click="removeRow(this)">Annuler</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<tr id="entry-{{ e.id }}" class="editing">
|
<tr id="entry-{{ e.id }}" class="editing">
|
||||||
<td colspan="2">
|
<td>
|
||||||
<div class="stack">
|
<div class="stack">
|
||||||
<input type="datetime-local" name="started_at" value="{{ e.start_input() }}" required aria-label="Début">
|
<input type="datetime-local" name="started_at" value="{{ e.start_input() }}" required aria-label="Début">
|
||||||
{% if e.running() %}
|
{% if e.running() %}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
{% import "_icons.html" as icons %}
|
||||||
<tr id="entry-{{ e.id }}"{% if e.running() %} class="running"{% endif %}>
|
<tr id="entry-{{ e.id }}"{% if e.running() %} class="running"{% endif %}>
|
||||||
<td class="nowrap">{{ e.day() }}</td>
|
|
||||||
<td class="time">
|
<td class="time">
|
||||||
{{ e.start_time() }} – {{ e.end_time() }}
|
{{ e.start_time() }} – {{ e.end_time() }}
|
||||||
{% if e.overlaps %}<span class="warn" title="Chevauche une autre entrée">⚠</span>{% endif %}
|
{% if e.overlaps %}<span class="warn" title="Chevauche une autre entrée">⚠</span>{% endif %}
|
||||||
@@ -8,7 +8,10 @@
|
|||||||
<td class="note">{{ e.note }}</td>
|
<td class="note">{{ e.note }}</td>
|
||||||
<td class="num">{{ e.duration() }}</td>
|
<td class="num">{{ e.duration() }}</td>
|
||||||
<td class="actions">
|
<td class="actions">
|
||||||
<button class="btn small" hx-get="/ui/entries/{{ e.id }}/edit" hx-target="closest tr" hx-swap="outerHTML">Modifier</button>
|
<div class="btn-group">
|
||||||
<button class="btn small danger" hx-delete="/ui/entries/{{ e.id }}" hx-target="closest tr" hx-swap="outerHTML" hx-confirm="Supprimer cette entrée ?">Suppr.</button>
|
<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>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{# Icônes SVG (tracés Lucide), en couleur du texte. #}
|
||||||
|
{% macro icon(name) %}<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||||||
|
{%- if name == "edit" -%}<path d="M12 20h9"/><path d="M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z"/>
|
||||||
|
{%- else if name == "copy" -%}<rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
|
||||||
|
{%- else if name == "trash" -%}<path d="M3 6h18"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><path d="M10 11v6"/><path d="M14 11v6"/>
|
||||||
|
{%- 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 == "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"/>
|
||||||
|
{%- endif -%}
|
||||||
|
</svg>{% endmacro %}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<section id="recent" class="card" hx-get="/ui/dernieres-entrees" hx-trigger="entries-changed from:body" hx-swap="outerHTML">
|
||||||
|
<div class="card-head">
|
||||||
|
<h2>Dernières entrées</h2>
|
||||||
|
<a href="/entries">Tout voir</a>
|
||||||
|
</div>
|
||||||
|
{% if recent_days.is_empty() %}
|
||||||
|
<p class="empty">Aucune entrée pour l'instant.</p>
|
||||||
|
{% else %}
|
||||||
|
<div class="table-wrap">
|
||||||
|
<table class="entries">
|
||||||
|
<thead><tr><th>Horaire</th><th>Projet</th><th>Note</th><th class="num">Durée</th><th></th></tr></thead>
|
||||||
|
{% let days = recent_days %}{% include "_entry_days.html" %}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</section>
|
||||||
@@ -5,6 +5,10 @@
|
|||||||
<div class="muted"><span class="dot" style="--color: {{ e.client_color }}"></span>{{ e.client_name }}</div>
|
<div class="muted"><span class="dot" style="--color: {{ e.client_color }}"></span>{{ e.client_name }}</div>
|
||||||
<div class="current-project">{{ e.project_name }}</div>
|
<div class="current-project">{{ e.project_name }}</div>
|
||||||
{% if !e.note.is_empty() %}<div class="note">{{ e.note }}</div>{% endif %}
|
{% if !e.note.is_empty() %}<div class="note">{{ e.note }}</div>{% endif %}
|
||||||
|
<form class="row timer-start" hx-post="/ui/timer/debut" hx-target="#timer" hx-swap="outerHTML">
|
||||||
|
<label>Début <input type="datetime-local" name="started_at" value="{{ e.start_input() }}" required aria-label="Heure de début"></label>
|
||||||
|
<button class="btn small">Modifier</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="clock" data-started="{{ e.started_rfc3339() }}">{{ e.duration() }}</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 danger" hx-post="/ui/timer/stop" hx-target="#timer" hx-swap="outerHTML">Arrêter</button>
|
||||||
|
|||||||
+8
-14
@@ -6,19 +6,13 @@
|
|||||||
{% if today_entries.is_empty() %}
|
{% if today_entries.is_empty() %}
|
||||||
<p class="empty">Rien de saisi pour l'instant.</p>
|
<p class="empty">Rien de saisi pour l'instant.</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
<table class="entries">
|
<div class="table-wrap">
|
||||||
<tbody>
|
<table class="entries">
|
||||||
{% for e in today_entries %}
|
<thead><tr><th>Horaire</th><th>Projet</th><th>Note</th><th class="num">Durée</th><th></th></tr></thead>
|
||||||
<tr{% if e.running() %} class="running"{% endif %}>
|
<tbody>
|
||||||
<td class="time">{{ e.start_time() }} – {{ e.end_time() }}</td>
|
{% for e in today_entries %}{% include "_entry_row.html" %}{% endfor %}
|
||||||
<td>
|
</tbody>
|
||||||
<span class="dot" style="--color: {{ e.color }}"></span><span class="client">{{ e.client_name }}</span> / {{ e.project_name }}
|
</table>
|
||||||
{% if !e.note.is_empty() %}<div class="note">{{ e.note }}</div>{% endif %}
|
</div>
|
||||||
</td>
|
|
||||||
<td class="num">{{ e.duration() }}</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</section>
|
</section>
|
||||||
+6
-2
@@ -4,9 +4,13 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>{% block title %}Tempus{% endblock %} · Tempus</title>
|
<title>{% block title %}Tempus{% endblock %} · Tempus</title>
|
||||||
<link rel="stylesheet" href="/static/app.css">
|
<link rel="icon" id="favicon" type="image/svg+xml" href="/static/favicon.svg">
|
||||||
|
<link rel="stylesheet" href="/static/flatpickr/flatpickr.min.css">
|
||||||
|
<link rel="stylesheet" href="/static/app.css?v={{ crate::routes::asset_version() }}">
|
||||||
<script src="/static/htmx.min.js" defer></script>
|
<script src="/static/htmx.min.js" defer></script>
|
||||||
<script src="/static/app.js" defer></script>
|
<script src="/static/flatpickr/flatpickr.min.js" defer></script>
|
||||||
|
<script src="/static/flatpickr/fr.min.js" defer></script>
|
||||||
|
<script src="/static/app.js?v={{ crate::routes::asset_version() }}" defer></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header class="topbar">
|
<header class="topbar">
|
||||||
|
|||||||
+35
-17
@@ -1,4 +1,5 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
{% import "_icons.html" as icons %}
|
||||||
{% block title %}Clients{% endblock %}
|
{% block title %}Clients{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<section class="card">
|
<section class="card">
|
||||||
@@ -6,7 +7,7 @@
|
|||||||
<form method="post" action="/ui/clients" class="row">
|
<form method="post" action="/ui/clients" class="row">
|
||||||
<input type="color" name="color" value="{{ next_color }}" aria-label="Couleur du client">
|
<input type="color" name="color" value="{{ next_color }}" aria-label="Couleur du client">
|
||||||
<input name="name" required placeholder="Nom du client" aria-label="Nom du client" class="grow">
|
<input name="name" required placeholder="Nom du client" aria-label="Nom du client" class="grow">
|
||||||
<button class="btn primary">Ajouter</button>
|
<button class="btn icon primary" title="Ajouter le client" aria-label="Ajouter le client">{% call icons::icon("plus") %}{% endcall %}</button>
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
@@ -20,17 +21,22 @@
|
|||||||
<form method="post" action="/ui/clients/{{ c.client.id }}" class="row grow">
|
<form method="post" action="/ui/clients/{{ c.client.id }}" class="row grow">
|
||||||
<input type="color" name="color" value="{{ c.client.color }}" aria-label="Couleur du client">
|
<input type="color" name="color" value="{{ c.client.color }}" aria-label="Couleur du client">
|
||||||
<input name="name" value="{{ c.client.name }}" required aria-label="Nom du client" class="title-input">
|
<input name="name" value="{{ c.client.name }}" required aria-label="Nom du client" class="title-input">
|
||||||
<button class="btn">Enregistrer</button>
|
<button class="btn icon primary" title="Enregistrer" aria-label="Enregistrer">{% call icons::icon("check") %}{% endcall %}</button>
|
||||||
</form>
|
</form>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{% if c.client.archived %}<span class="badge">archivé</span>{% endif %}
|
{% if c.client.archived %}<span class="badge">archivé</span>{% endif %}
|
||||||
<form method="post" action="/ui/clients/{{ c.client.id }}/archive">
|
<form id="archive-client-{{ c.client.id }}" method="post" action="/ui/clients/{{ c.client.id }}/archive" hidden>
|
||||||
<input type="hidden" name="archived" value="{{ !c.client.archived }}">
|
<input type="hidden" name="archived" value="{{ !c.client.archived }}">
|
||||||
<button class="btn">{% if c.client.archived %}Réactiver{% else %}Archiver{% endif %}</button>
|
|
||||||
</form>
|
|
||||||
<form method="post" action="/ui/clients/{{ c.client.id }}/delete" data-confirm="Supprimer ce client, ses projets et tout le temps saisi ?">
|
|
||||||
<button class="btn danger">Supprimer</button>
|
|
||||||
</form>
|
</form>
|
||||||
|
<form id="delete-client-{{ c.client.id }}" method="post" action="/ui/clients/{{ c.client.id }}/delete" data-confirm="Supprimer ce client, ses projets et tout le temps saisi ?" hidden></form>
|
||||||
|
<div class="btn-group">
|
||||||
|
{% if c.client.archived %}
|
||||||
|
<button class="btn icon" form="archive-client-{{ c.client.id }}" title="Réactiver" aria-label="Réactiver">{% call icons::icon("unarchive") %}{% endcall %}</button>
|
||||||
|
{% else %}
|
||||||
|
<button class="btn icon" form="archive-client-{{ c.client.id }}" title="Archiver" aria-label="Archiver">{% call icons::icon("archive") %}{% endcall %}</button>
|
||||||
|
{% endif %}
|
||||||
|
<button class="btn icon danger" form="delete-client-{{ c.client.id }}" title="Supprimer" aria-label="Supprimer">{% call icons::icon("trash") %}{% endcall %}</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -41,20 +47,31 @@
|
|||||||
<input type="color" name="color" value="{{ p.effective_color }}" aria-label="Couleur du projet"
|
<input type="color" name="color" value="{{ p.effective_color }}" aria-label="Couleur du projet"
|
||||||
title="{% if p.color.is_some() %}Couleur propre au projet{% else %}Couleur du client{% endif %}">
|
title="{% if p.color.is_some() %}Couleur propre au projet{% else %}Couleur du client{% endif %}">
|
||||||
<input name="name" value="{{ p.name }}" required aria-label="Nom du projet">
|
<input name="name" value="{{ p.name }}" required aria-label="Nom du projet">
|
||||||
<button class="btn small">Enregistrer</button>
|
<input type="url" name="repo_url" value="{% if let Some(u) = p.repo_url %}{{ u }}{% endif %}" placeholder="URL du repo" aria-label="URL du repo" class="repo-url">
|
||||||
{% if p.color.is_some() %}
|
<div class="btn-group">
|
||||||
<button class="btn small" name="inherit" value="true" title="Reprendre la couleur du client">↺</button>
|
<button class="btn small icon primary" title="Enregistrer" aria-label="Enregistrer">{% call icons::icon("check") %}{% endcall %}</button>
|
||||||
{% endif %}
|
{% if p.color.is_some() %}
|
||||||
|
<button class="btn small icon" name="inherit" value="true" title="Reprendre la couleur du client" aria-label="Reprendre la couleur du client">{% call icons::icon("reset") %}{% endcall %}</button>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{% if p.archived %}<span class="badge">archivé</span>{% endif %}
|
{% if p.archived %}<span class="badge">archivé</span>{% endif %}
|
||||||
<form method="post" action="/ui/projects/{{ p.id }}/archive">
|
<form id="archive-project-{{ p.id }}" method="post" action="/ui/projects/{{ p.id }}/archive" hidden>
|
||||||
<input type="hidden" name="archived" value="{{ !p.archived }}">
|
<input type="hidden" name="archived" value="{{ !p.archived }}">
|
||||||
<button class="btn small">{% if p.archived %}Réactiver{% else %}Archiver{% endif %}</button>
|
|
||||||
</form>
|
|
||||||
<form method="post" action="/ui/projects/{{ p.id }}/delete" data-confirm="Supprimer ce projet et tout le temps saisi dessus ?">
|
|
||||||
<button class="btn small danger">Supprimer</button>
|
|
||||||
</form>
|
</form>
|
||||||
|
<form id="delete-project-{{ p.id }}" method="post" action="/ui/projects/{{ p.id }}/delete" data-confirm="Supprimer ce projet et tout le temps saisi dessus ?" hidden></form>
|
||||||
|
<div class="btn-group">
|
||||||
|
{% if let Some(u) = p.repo_url %}
|
||||||
|
<a class="btn small icon" href="{{ u }}" target="_blank" rel="noopener noreferrer" title="Ouvrir le repo" aria-label="Ouvrir le repo">{% call icons::icon("link") %}{% endcall %}</a>
|
||||||
|
{% endif %}
|
||||||
|
{% if p.archived %}
|
||||||
|
<button class="btn small icon" form="archive-project-{{ p.id }}" title="Réactiver" aria-label="Réactiver">{% call icons::icon("unarchive") %}{% endcall %}</button>
|
||||||
|
{% else %}
|
||||||
|
<button class="btn small icon" form="archive-project-{{ p.id }}" title="Archiver" aria-label="Archiver">{% call icons::icon("archive") %}{% endcall %}</button>
|
||||||
|
{% endif %}
|
||||||
|
<button class="btn small icon danger" form="delete-project-{{ p.id }}" title="Supprimer" aria-label="Supprimer">{% call icons::icon("trash") %}{% endcall %}</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@@ -63,7 +80,8 @@
|
|||||||
<form method="post" action="/ui/clients/{{ c.client.id }}/projects" class="row">
|
<form method="post" action="/ui/clients/{{ c.client.id }}/projects" class="row">
|
||||||
<input type="color" name="color" value="{{ c.client.color }}" aria-label="Couleur du projet" title="Garder la couleur du client ou en choisir une autre">
|
<input type="color" name="color" value="{{ c.client.color }}" aria-label="Couleur du projet" title="Garder la couleur du client ou en choisir une autre">
|
||||||
<input name="name" required placeholder="Nouveau projet" aria-label="Nouveau projet" class="grow">
|
<input name="name" required placeholder="Nouveau projet" aria-label="Nouveau projet" class="grow">
|
||||||
<button class="btn">Ajouter le projet</button>
|
<input type="url" name="repo_url" placeholder="URL du repo (facultatif)" aria-label="URL du repo" class="grow">
|
||||||
|
<button class="btn icon primary" title="Ajouter le projet" aria-label="Ajouter le projet">{% call icons::icon("plus") %}{% endcall %}</button>
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
@@ -3,4 +3,5 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
{% include "_timer.html" %}
|
{% include "_timer.html" %}
|
||||||
{% include "_today.html" %}
|
{% include "_today.html" %}
|
||||||
|
{% include "_recent.html" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="card">
|
<section id="entries-list" class="card" hx-get="/entries?from={{ from }}&to={{ to }}{{ extra_query }}" hx-select="#entries-list" hx-trigger="entries-changed from:body" hx-swap="outerHTML">
|
||||||
<div class="card-head">
|
<div class="card-head">
|
||||||
<h2>Entrées</h2>
|
<h2>Entrées</h2>
|
||||||
<span class="total">{{ total }}</span>
|
<span class="total">{{ total }}</span>
|
||||||
@@ -40,15 +40,13 @@
|
|||||||
<button class="btn">Filtrer</button>
|
<button class="btn">Filtrer</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{% if entries.is_empty() %}
|
{% if days.is_empty() %}
|
||||||
<p class="empty">Aucune entrée sur cette période.</p>
|
<p class="empty">Aucune entrée sur cette période.</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="table-wrap">
|
<div class="table-wrap">
|
||||||
<table class="entries">
|
<table class="entries">
|
||||||
<thead><tr><th>Jour</th><th>Horaire</th><th>Projet</th><th>Note</th><th class="num">Durée</th><th></th></tr></thead>
|
<thead><tr><th>Horaire</th><th>Projet</th><th>Note</th><th class="num">Durée</th><th></th></tr></thead>
|
||||||
<tbody>
|
{% include "_entry_days.html" %}
|
||||||
{% for e in entries %}{% include "_entry_row.html" %}{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
+167
@@ -444,6 +444,32 @@ async fn html_pages() {
|
|||||||
get_html(&app, "/reports?from=2026-03-01&to=2026-03-31&group_by=day").await;
|
get_html(&app, "/reports?from=2026-03-01&to=2026-03-31&group_by=day").await;
|
||||||
assert_eq!(status, StatusCode::OK);
|
assert_eq!(status, StatusCode::OK);
|
||||||
assert!(html.contains("1:15") && html.contains("mar. 10/03/2026"));
|
assert!(html.contains("1:15") && html.contains("mar. 10/03/2026"));
|
||||||
|
|
||||||
|
let (status, html) = get_html(&app, "/").await;
|
||||||
|
assert_eq!(status, StatusCode::OK);
|
||||||
|
assert!(html.contains("Dernières entrées") && html.contains("mar. 10/03/2026"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn dashboard_lists_20_most_recent_entries() {
|
||||||
|
let app = app().await;
|
||||||
|
let p = project(&app, "Acme", "Site web").await;
|
||||||
|
for day in 1..=25 {
|
||||||
|
let (status, _) = add_entry(
|
||||||
|
&app,
|
||||||
|
p,
|
||||||
|
local(2026, 3, day, 9, 0),
|
||||||
|
local(2026, 3, day, 10, 0),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
assert_eq!(status, StatusCode::CREATED);
|
||||||
|
}
|
||||||
|
|
||||||
|
let (status, html) = get_html(&app, "/ui/dernieres-entrees").await;
|
||||||
|
assert_eq!(status, StatusCode::OK);
|
||||||
|
assert_eq!(html.matches("<tr id=\"entry-").count(), 20);
|
||||||
|
assert!(html.contains("25/03/2026") && html.contains("06/03/2026"));
|
||||||
|
assert!(!html.contains("05/03/2026"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -592,3 +618,144 @@ async fn colors() {
|
|||||||
assert_eq!(status, StatusCode::OK);
|
assert_eq!(status, StatusCode::OK);
|
||||||
assert!(html.contains("--color: #000000"));
|
assert!(html.contains("--color: #000000"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn duplicate_entry() {
|
||||||
|
let app = app().await;
|
||||||
|
let p = project(&app, "Acme", "Site web").await;
|
||||||
|
let (status, _) = send(
|
||||||
|
&app,
|
||||||
|
"POST",
|
||||||
|
"/api/entries",
|
||||||
|
Some(json!({
|
||||||
|
"project_id": p,
|
||||||
|
"started_at": local(2026, 3, 10, 9, 0),
|
||||||
|
"ended_at": local(2026, 3, 10, 10, 15),
|
||||||
|
"note": "réunion",
|
||||||
|
})),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
assert_eq!(status, StatusCode::CREATED);
|
||||||
|
|
||||||
|
let (status, html) = get_html(&app, "/ui/entries/1/dupliquer").await;
|
||||||
|
assert_eq!(status, StatusCode::OK);
|
||||||
|
assert!(html.contains("2026-03-10T09:00") && html.contains("2026-03-10T10:15"));
|
||||||
|
assert!(html.contains("réunion"));
|
||||||
|
|
||||||
|
let (status, html) = send_form(
|
||||||
|
&app,
|
||||||
|
"/ui/entries/1/dupliquer",
|
||||||
|
&format!("project_id={p}&started_at=2026-03-11T09%3A00&ended_at=2026-03-11T10%3A15¬e=r%C3%A9union"),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
assert_eq!(status, StatusCode::OK);
|
||||||
|
assert!(html.contains("id=\"entry-2\"") && html.contains("09:00 – 10:15"));
|
||||||
|
|
||||||
|
// /entries groups rows under one header per day, with the day total.
|
||||||
|
let (_, html) = get_html(&app, "/entries?from=2026-03-09&to=2026-03-15").await;
|
||||||
|
assert_eq!(html.matches("class=\"day-head\"").count(), 2);
|
||||||
|
assert!(html.contains("mer. 11/03/2026") && html.contains("mar. 10/03/2026"));
|
||||||
|
|
||||||
|
let (_, list) = send(
|
||||||
|
&app,
|
||||||
|
"GET",
|
||||||
|
"/api/entries?from=2026-03-09&to=2026-03-15",
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
let list = list.as_array().unwrap();
|
||||||
|
assert_eq!(list.len(), 2);
|
||||||
|
assert!(list.iter().all(|e| e["note"] == "réunion"));
|
||||||
|
|
||||||
|
let (status, _) = get_html(&app, "/ui/entries/99/dupliquer").await;
|
||||||
|
assert_eq!(status, StatusCode::NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn move_timer_start() {
|
||||||
|
let app = app().await;
|
||||||
|
let p = project(&app, "Acme", "Site web").await;
|
||||||
|
|
||||||
|
let (status, _) = send_form(&app, "/ui/timer/debut", "started_at=2026-03-10T09%3A00").await;
|
||||||
|
assert_eq!(status, StatusCode::CONFLICT, "no running timer");
|
||||||
|
|
||||||
|
let (status, _) = send_form(&app, "/ui/timer/start", &format!("project_id={p}")).await;
|
||||||
|
assert_eq!(status, StatusCode::OK);
|
||||||
|
|
||||||
|
let earlier = (Local::now() - chrono::Duration::minutes(90))
|
||||||
|
.format("%Y-%m-%dT%H:%M")
|
||||||
|
.to_string();
|
||||||
|
let (status, html) = send_form(&app, "/ui/timer/debut", &format!("started_at={earlier}")).await;
|
||||||
|
assert_eq!(status, StatusCode::OK);
|
||||||
|
assert!(html.contains(&earlier) && html.contains("Arrêter"));
|
||||||
|
|
||||||
|
let (_, timer) = send(&app, "GET", "/api/timer", None).await;
|
||||||
|
let started =
|
||||||
|
chrono::DateTime::parse_from_rfc3339(timer["started_at"].as_str().unwrap()).unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
started
|
||||||
|
.with_timezone(&Local)
|
||||||
|
.format("%Y-%m-%dT%H:%M")
|
||||||
|
.to_string(),
|
||||||
|
earlier
|
||||||
|
);
|
||||||
|
assert!(timer["ended_at"].is_null(), "still running");
|
||||||
|
|
||||||
|
let future = (Local::now() + chrono::Duration::hours(1))
|
||||||
|
.format("%Y-%m-%dT%H:%M")
|
||||||
|
.to_string();
|
||||||
|
let (status, _) = send_form(&app, "/ui/timer/debut", &format!("started_at={future}")).await;
|
||||||
|
assert_eq!(status, StatusCode::UNPROCESSABLE_ENTITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn project_repo_url() {
|
||||||
|
let app = app().await;
|
||||||
|
let (_, c) = send(
|
||||||
|
&app,
|
||||||
|
"POST",
|
||||||
|
"/api/clients",
|
||||||
|
Some(json!({ "name": "Acme" })),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
let uri = format!("/api/clients/{}/projects", c["id"]);
|
||||||
|
|
||||||
|
let (status, p) = send(
|
||||||
|
&app,
|
||||||
|
"POST",
|
||||||
|
&uri,
|
||||||
|
Some(json!({ "name": "Site", "repo_url": " https://git.example.com/acme/site " })),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
assert_eq!(status, StatusCode::CREATED);
|
||||||
|
assert_eq!(p["repo_url"], "https://git.example.com/acme/site");
|
||||||
|
|
||||||
|
let (status, _) = send(
|
||||||
|
&app,
|
||||||
|
"POST",
|
||||||
|
&uri,
|
||||||
|
Some(json!({ "name": "Bad", "repo_url": "git@example.com:acme/site.git" })),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
assert_eq!(status, StatusCode::UNPROCESSABLE_ENTITY);
|
||||||
|
|
||||||
|
// Absent: unchanged; "" clears it.
|
||||||
|
let project = format!("/api/projects/{}", p["id"]);
|
||||||
|
let (_, p) = send(&app, "PATCH", &project, Some(json!({ "name": "Site web" }))).await;
|
||||||
|
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\""));
|
||||||
|
let (_, p) = send(&app, "PATCH", &project, Some(json!({ "repo_url": "" }))).await;
|
||||||
|
assert!(p["repo_url"].is_null());
|
||||||
|
|
||||||
|
// HTML form: the URL field is saved with the project.
|
||||||
|
let (status, _) = send_form(
|
||||||
|
&app,
|
||||||
|
&project.replace("/api/", "/ui/"),
|
||||||
|
"name=Site+web&repo_url=https%3A%2F%2Fgit.example.com%2Fx",
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
assert_eq!(status, StatusCode::SEE_OTHER);
|
||||||
|
let (_, p) = send(&app, "GET", &format!("{uri}?archived=true"), None).await;
|
||||||
|
assert_eq!(p[0]["repo_url"], "https://git.example.com/x");
|
||||||
|
}
|
||||||
Reference in new issue
Block a user