From dd6a7406452baf484c98f27ac44009c2d72c05a9 Mon Sep 17 00:00:00 2001 From: Romulus21 Date: Mon, 26 Oct 2026 13:21:14 +0100 Subject: [PATCH] first commit --- .gitignore | 4 + Cargo.lock | 2287 ++++++++++++++++++++++++++++++++ Cargo.toml | 23 + README.md | 63 + migrations/0001_init.sql | 33 + migrations/0002_colors.sql | 15 + src/clock.rs | 120 ++ src/config.rs | 33 + src/db.rs | 30 + src/error.rs | 64 + src/lib.rs | 7 + src/main.rs | 29 + src/models.rs | 225 ++++ src/repo/clients.rs | 87 ++ src/repo/entries.rs | 193 +++ src/repo/mod.rs | 43 + src/repo/projects.rs | 105 ++ src/repo/reports.rs | 130 ++ src/routes/api.rs | 184 +++ src/routes/mod.rs | 40 + src/routes/pages.rs | 620 +++++++++ static/app.css | 161 +++ static/app.js | 33 + static/htmx.min.js | 1 + templates/_entry_edit.html | 19 + templates/_entry_row.html | 14 + templates/_presets.html | 5 + templates/_project_select.html | 5 + templates/_timer.html | 22 + templates/_today.html | 24 + templates/base.html | 26 + templates/clients.html | 70 + templates/dashboard.html | 6 + templates/entries.html | 56 + templates/error.html | 9 + templates/reports.html | 44 + tests/api.rs | 594 +++++++++ 37 files changed, 5424 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 README.md create mode 100644 migrations/0001_init.sql create mode 100644 migrations/0002_colors.sql create mode 100644 src/clock.rs create mode 100644 src/config.rs create mode 100644 src/db.rs create mode 100644 src/error.rs create mode 100644 src/lib.rs create mode 100644 src/main.rs create mode 100644 src/models.rs create mode 100644 src/repo/clients.rs create mode 100644 src/repo/entries.rs create mode 100644 src/repo/mod.rs create mode 100644 src/repo/projects.rs create mode 100644 src/repo/reports.rs create mode 100644 src/routes/api.rs create mode 100644 src/routes/mod.rs create mode 100644 src/routes/pages.rs create mode 100644 static/app.css create mode 100644 static/app.js create mode 100644 static/htmx.min.js create mode 100644 templates/_entry_edit.html create mode 100644 templates/_entry_row.html create mode 100644 templates/_presets.html create mode 100644 templates/_project_select.html create mode 100644 templates/_timer.html create mode 100644 templates/_today.html create mode 100644 templates/base.html create mode 100644 templates/clients.html create mode 100644 templates/dashboard.html create mode 100644 templates/entries.html create mode 100644 templates/error.html create mode 100644 templates/reports.html create mode 100644 tests/api.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c536345 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/target +*.db +*.db-shm +*.db-wal diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..2536a0e --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,2287 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" +dependencies = [ + "memchr", +] + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "android_system_properties" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc" +dependencies = [ + "libc", +] + +[[package]] +name = "anyhow" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" + +[[package]] +name = "askama" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6024d73179f43f15ccd2b881bfea6fee7f3a46ec53f33b52210dea749ebebaa4" +dependencies = [ + "askama_macros", + "itoa", + "percent-encoding", + "serde", + "serde_json", +] + +[[package]] +name = "askama_derive" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071ee5ebf2138e3ad180e0aacf6940c2cab5e6d8333741d9925c7bee2b153f39" +dependencies = [ + "askama_parser", + "basic-toml", + "glob", + "memchr", + "proc-macro2", + "quote", + "rustc-hash", + "serde", + "serde_derive", + "syn 3.0.9", +] + +[[package]] +name = "askama_macros" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643e1c7cbb6aec1d920332fe51a7c0d8219e273dcb8602db03f5263e4d16487b" +dependencies = [ + "askama_derive", +] + +[[package]] +name = "askama_parser" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c5ae75772275d268b03ab8bdccdd12117b6169ee23256942b34e46c9f476583" +dependencies = [ + "rustc-hash", + "serde", + "serde_derive", + "unicode-ident", + "winnow", +] + +[[package]] +name = "atoi" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" +dependencies = [ + "num-traits", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "axum" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31b698c5f9a010f6573133b09e0de5408834d0c82f8d7475a89fc1867a71cd90" +dependencies = [ + "axum-core", + "bytes", + "form_urlencoded", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "serde_core", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-core" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c78f31d7b1291f7ee735c1c6780ccde7785daae9a9206026862dab7d8792d1" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "sync_wrapper", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64ct" +version = "1.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" + +[[package]] +name = "basic-toml" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba62675e8242a4c4e806d12f11d136e626e6c8361d6b829310732241652a178a" +dependencies = [ + "serde", +] + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" +dependencies = [ + "serde_core", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" + +[[package]] +name = "cc" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86e055fa6e3e40ad6187ba25b6855eeb635d5271f8e0f0e1e9a5826b8d75bea0" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "chrono" +version = "0.4.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crc" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eb8a2a1cd12ab0d987a5d5e825195d372001a4094a0376319d5a0ad71c1ba0d" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "217698eaf96b4a3f0bc4f3662aaa55bdf913cd54d7204591faa790070c6d0853" + +[[package]] +name = "crossbeam-queue" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03e8bd762f7479489c70ed6c768ddca99d7296857de437a68dcb2a94365b3fae" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "der" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" +dependencies = [ + "const-oid", + "pem-rfc7468", + "zeroize", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "const-oid", + "crypto-common", + "subtle", +] + +[[package]] +name = "directories" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16f5094c54661b38d03bd7e50df373292118db60b585c08a411c6d840017fe7d" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.61.2", +] + +[[package]] +name = "displaydoc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + +[[package]] +name = "either" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" +dependencies = [ + "serde", +] + +[[package]] +name = "equivalent" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "etcetera" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" +dependencies = [ + "cfg-if", + "home", + "windows-sys 0.48.0", +] + +[[package]] +name = "event-listener" +version = "5.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a23add41df1562121a9393cb065eab5146a1242410f23a644851e90cfd669d2" +dependencies = [ + "parking", + "pin-project-lite", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" + +[[package]] +name = "flume" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095" +dependencies = [ + "futures-core", + "futures-sink", + "spin", +] + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-executor" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-intrusive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" +dependencies = [ + "futures-core", + "lock_api", + "parking_lot", +] + +[[package]] +name = "futures-io" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" + +[[package]] +name = "futures-sink" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "glob" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b" + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "hashlink" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" +dependencies = [ + "hashbrown 0.15.5", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +dependencies = [ + "hmac", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "home" +version = "0.5.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "http" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2a8f2913ee65f60facd6a5905613afaa448497a0230cc41ce022d93290bc2c" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23169fe34a5fbcdd3f3862e78fb9b6fccd5f02a6dc6f732547005d45631ce71c" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c3e324da4c95177d6291d4c8730197c0d1822f8a9766814a4a44fa5ab797c9c" +dependencies = [ + "atomic-waker", + "bytes", + "futures-core", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", +] + +[[package]] +name = "hyper-util" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddc03d96684f9226b8a787cdb71488417b53ab5ea8fdb1dac946cb9431cc8bff" +dependencies = [ + "bytes", + "http", + "http-body", + "hyper", + "pin-project-lite", + "tokio", + "tower-service", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "icu_collections" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe090a42a0d3140fed8c63263ed1fecc02422cb2f4bfe55cd8de2de1b8e105dd" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25d29b57c17c6528d0dc4c2141cfa2d08200465acb537a3909c8b9b8a4a984c0" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "404a3b8c486f205c87fe7f23ab6894d84a4ad76d6e4671ae1981ba7def87c599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20f0088bfb7441f7a37fa0c9e20cb1e9cba1cac6b9ce8cd2a6dc44294f8e8cbc" + +[[package]] +name = "icu_properties" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ea83d991c56158f7cf898bf86436c1dfe7c07ee82fe88951f2695c9f37a379f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98f29af82d02b163fe50161388350e743bb3107cc8e8c2f7314cb505faddfcf" + +[[package]] +name = "icu_provider" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413099315636c588ee8f011190b329b971a09a8fae9d157e01dcae8379468514" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown 0.17.1", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "js-sys" +version = "0.3.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb" +dependencies = [ + "spin", +] + +[[package]] +name = "libc" +version = "0.2.191" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + +[[package]] +name = "libredox" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61ff90caf6077a803a240f62fdbe88645a890bbca49ef8174c3cb0404362171d" +dependencies = [ + "bitflags", + "libc", + "plain", + "redox_syscall 0.9.5", +] + +[[package]] +name = "libsqlite3-sys" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "litemap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" + +[[package]] +name = "matchers" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "matchit" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" + +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if", + "digest", +] + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mio" +version = "1.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1788edb87fdc09c7e26304471e2f5be8cdefb1b6930d6e3985fc02ff53bf86ee" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "num-bigint-dig" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e661dda6640fad38e827a6d4a310ff4763082116fe217f279885c97f511bb0b7" +dependencies = [ + "lazy_static", + "libm", + "num-integer", + "num-iter", + "num-traits", + "rand", + "smallvec", + "zeroize", +] + +[[package]] +name = "num-integer" +version = "0.1.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c92800bd69a1eac91786bcfe9da64a897eb72911b8dc3095decbd07429e8048b" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.5.18", + "smallvec", + "windows-link", +] + +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pkcs1" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +dependencies = [ + "der", + "pkcs8", + "spki", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "pkg-config" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" + +[[package]] +name = "plain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" + +[[package]] +name = "potential_utf" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" +dependencies = [ + "zerovec", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_syscall" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "580c875845b41ecb1564ad1ae4703044cef774145e3d7a94dc2b3fa7c97868fd" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_users" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60dc65c0ff1a7ae1294b0c67b9f14baf70b644404010370171787bfac1038fc0" +dependencies = [ + "libredox", + "thiserror", +] + +[[package]] +name = "regex-automata" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + +[[package]] +name = "rsa" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8573f03f5883dcaebdfcf4725caa1ecb9c15b2ef50c43a07b816e06799bb12d" +dependencies = [ + "const-oid", + "digest", + "num-bigint-dig", + "num-integer", + "num-traits", + "pkcs1", + "pkcs8", + "rand_core", + "signature", + "spki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustc-hash" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_path_to_error" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a9ff822e371bb5403e391ecd83e182e0e77ba7f6fe0160b795797109d1b457" +dependencies = [ + "itoa", + "serde", + "serde_core", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha1" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a978451301f4db1d02937a4ab3ccce137717b81826e79b7d49ffe3244a13c3b8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest", + "rand_core", +] + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.16.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0d5d4b1981b8bbbb7aed204cae5726d683d5d6ac7e74ec54122ea28f315e7c8" +dependencies = [ + "serde", +] + +[[package]] +name = "socket2" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "spin" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e" +dependencies = [ + "lock_api", +] + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "sqlx" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fefb893899429669dcdd979aff487bd78f4064e5e7907e4269081e0ef7d97dc" +dependencies = [ + "sqlx-core", + "sqlx-macros", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", +] + +[[package]] +name = "sqlx-core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee6798b1838b6a0f69c007c133b8df5866302197e404e8b6ee8ed3e3a5e68dc6" +dependencies = [ + "base64", + "bytes", + "chrono", + "crc", + "crossbeam-queue", + "either", + "event-listener", + "futures-core", + "futures-intrusive", + "futures-io", + "futures-util", + "hashbrown 0.15.5", + "hashlink", + "indexmap", + "log", + "memchr", + "once_cell", + "percent-encoding", + "serde", + "serde_json", + "sha2", + "smallvec", + "thiserror", + "tokio", + "tokio-stream", + "tracing", + "url", +] + +[[package]] +name = "sqlx-macros" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2d452988ccaacfbf5e0bdbc348fb91d7c8af5bee192173ac3636b5fb6e6715d" +dependencies = [ + "proc-macro2", + "quote", + "sqlx-core", + "sqlx-macros-core", + "syn 2.0.119", +] + +[[package]] +name = "sqlx-macros-core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19a9c1841124ac5a61741f96e1d9e2ec77424bf323962dd894bdb93f37d5219b" +dependencies = [ + "dotenvy", + "either", + "heck", + "hex", + "once_cell", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2", + "sqlx-core", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", + "syn 2.0.119", + "tokio", + "url", +] + +[[package]] +name = "sqlx-mysql" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa003f0038df784eb8fecbbac13affe3da23b45194bd57dba231c8f48199c526" +dependencies = [ + "atoi", + "base64", + "bitflags", + "byteorder", + "bytes", + "chrono", + "crc", + "digest", + "dotenvy", + "either", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "generic-array", + "hex", + "hkdf", + "hmac", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "percent-encoding", + "rand", + "rsa", + "serde", + "sha1", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "tracing", + "whoami", +] + +[[package]] +name = "sqlx-postgres" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db58fcd5a53cf07c184b154801ff91347e4c30d17a3562a635ff028ad5deda46" +dependencies = [ + "atoi", + "base64", + "bitflags", + "byteorder", + "chrono", + "crc", + "dotenvy", + "etcetera", + "futures-channel", + "futures-core", + "futures-util", + "hex", + "hkdf", + "hmac", + "home", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "rand", + "serde", + "serde_json", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "tracing", + "whoami", +] + +[[package]] +name = "sqlx-sqlite" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2d12fe70b2c1b4401038055f90f151b78208de1f9f89a7dbfd41587a10c3eea" +dependencies = [ + "atoi", + "chrono", + "flume", + "futures-channel", + "futures-core", + "futures-executor", + "futures-intrusive", + "futures-util", + "libsqlite3-sys", + "log", + "percent-encoding", + "serde", + "serde_urlencoded", + "sqlx-core", + "thiserror", + "tracing", + "url", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "stringprep" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1" +dependencies = [ + "unicode-bidi", + "unicode-normalization", + "unicode-properties", +] + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" + +[[package]] +name = "synstructure" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "tempus" +version = "0.1.0" +dependencies = [ + "anyhow", + "askama", + "axum", + "chrono", + "directories", + "http-body-util", + "serde", + "serde_json", + "sqlx", + "thiserror", + "tokio", + "tower", + "tower-http", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "thiserror" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "thread_local" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad99c4c6d32803332c548b1af0540b357b3f5fc0be8f6c6bfe8b2e6ae784070" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "tinystr" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee" + +[[package]] +name = "tokio" +version = "1.54.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" +dependencies = [ + "bytes", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "tokio-stream" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3d06f0b082ba57c26b79407372e57cf2a1e28124f78e9479fe80322cf53420b" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-http" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08a05a66a4fdd61cbbe0a1d755ffe0ca6aba159dd4820936a0ff8a8278245b9c" +dependencies = [ + "bitflags", + "bytes", + "http", + "http-body", + "percent-encoding", + "pin-project-lite", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex-automata", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "unicode-bidi" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "unicode-normalization" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75cd3fb03d5288b3ba9a1ee103ac7e9cbb59f0b03d64f8ddfcc04dd42758a85d" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-properties" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" + +[[package]] +name = "wasm-bindgen" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 3.0.9", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "whoami" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d4a4db5077702ca3015d3d02d74974948aba2ad9e12ab7df718ee64ccd7e97d" +dependencies = [ + "libredox", + "wasite", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "winnow" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" +dependencies = [ + "memchr", +] + +[[package]] +name = "writeable" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" + +[[package]] +name = "yoke" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5fe1f8f1b06191a00962174c61aa5005e0bb391a6d80d07e24d115c01a92ed8" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "863ad3ac83293fb4d740aedbfdc9240dd8d1a50c1099acd76ce80ce7c7230c7f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13084392c5e4bc371903e2935a5eaeed24905a7511356b883835e18a78f6879" + +[[package]] +name = "zerotrie" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..1118da7 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "tempus" +version = "0.1.0" +edition = "2024" + +[dependencies] +anyhow = "1.0.104" +askama = "0.16.1" +axum = "0.8" +chrono = { version = "0.4.45", features = ["serde"] } +directories = "6.0.0" +serde = { version = "1.0.229", features = ["derive"] } +serde_json = "1.0.154" +sqlx = { version = "0.8", default-features = false, features = ["runtime-tokio", "sqlite", "chrono", "migrate", "macros"] } +thiserror = "2.0.21" +tokio = { version = "1.54.1", features = ["full"] } +tower-http = { version = "0.7.1", features = ["trace"] } +tracing = "0.1.44" +tracing-subscriber = { version = "0.3.23", features = ["env-filter"] } + +[dev-dependencies] +http-body-util = "0.1.5" +tower = { version = "0.5.3", features = ["util"] } diff --git a/README.md b/README.md new file mode 100644 index 0000000..5a7154c --- /dev/null +++ b/README.md @@ -0,0 +1,63 @@ +# Tempus + +Time tracker local pour suivre le temps passé sur chaque projet de chaque client. +Un seul binaire Rust (axum + SQLite) qui sert une interface web et une API JSON. + +## Lancer + +```sh +cargo run --release +# → http://127.0.0.1:7878 +``` + +| Variable | Défaut | Rôle | +|---------------|------------------------------------------|------------------------------------| +| `TEMPUS_DB` | `~/.local/share/tempus/tempus.db` | Chemin (ou URL `sqlite:`) de la base | +| `TEMPUS_ADDR` | `127.0.0.1:7878` | Adresse d'écoute | +| `RUST_LOG` | `tempus=info,tower_http=info` | Niveau de logs | + +Aucune authentification : le service est prévu pour tourner en local. + +## Pages + +- `/` — timer (démarrer / basculer / arrêter) et entrées du jour +- `/entries` — liste filtrable, saisie manuelle, édition inline (⚠ = chevauchement) +- `/reports` — totaux par client, projet ou jour sur une période +- `/clients` — clients et projets (nom, couleur, archiver, supprimer) + +## API JSON (`/api`) + +| Méthode | Route | +|--------------|----------------------------------------------------| +| GET, POST | `/clients` (`?archived=true` pour inclure les archivés) — `{"name", "color"?}` | +| PATCH, DELETE| `/clients/{id}` — `{"name"?, "archived"?, "color"?}` | +| GET, POST | `/clients/{id}/projects` — `{"name", "color"?}` | +| PATCH, DELETE| `/projects/{id}` — `"color": null` pour reprendre celle du client | +| GET | `/timer` — entrée en cours ou `null` | +| POST | `/timer/start` `{"project_id", "note"?}` · `/timer/stop` | +| GET, POST | `/entries` (`?from&to&client_id&project_id`) | +| PATCH, DELETE| `/entries/{id}` | +| GET | `/reports?from&to&group_by=client\|project\|day&client_id&project_id` | + +Les couleurs sont au format `#rrggbb`. Un client reçoit automatiquement une couleur +de la palette s'il n'en précise pas ; un projet sans couleur utilise celle de son client +(`effective_color` dans les réponses). + +Les dates d'entrées sont en RFC 3339 (`2026-10-26T09:00:00+01:00`) ; les périodes +(`from`, `to`, inclusives) sont des dates `YYYY-MM-DD` dans le fuseau local. + +```sh +curl -XPOST localhost:7878/api/clients -H 'content-type: application/json' -d '{"name":"Acme"}' +curl -XPOST localhost:7878/api/timer/start -H 'content-type: application/json' -d '{"project_id":1}' +``` + +## Développement + +```sh +cargo test +cargo clippy --all-targets -- -D warnings +``` + +Le schéma est dans `migrations/` (appliqué automatiquement au démarrage). +Les horodatages sont stockés en UTC au format fixe `YYYY-MM-DDTHH:MM:SSZ` +(voir `src/clock.rs`) pour que les comparaisons SQL sur le texte restent valides. diff --git a/migrations/0001_init.sql b/migrations/0001_init.sql new file mode 100644 index 0000000..5b6ceb2 --- /dev/null +++ b/migrations/0001_init.sql @@ -0,0 +1,33 @@ +-- Timestamps are stored as UTC text, always formatted as "YYYY-MM-DDTHH:MM:SSZ" +-- so that lexicographic comparison matches chronological order. + +CREATE TABLE clients ( + id INTEGER PRIMARY KEY, + name TEXT NOT NULL UNIQUE, + archived INTEGER NOT NULL DEFAULT 0, + created_at TEXT NOT NULL +); + +CREATE TABLE projects ( + id INTEGER PRIMARY KEY, + client_id INTEGER NOT NULL REFERENCES clients (id) ON DELETE CASCADE, + name TEXT NOT NULL, + archived INTEGER NOT NULL DEFAULT 0, + created_at TEXT NOT NULL, + UNIQUE (client_id, name) +); + +CREATE TABLE time_entries ( + id INTEGER PRIMARY KEY, + project_id INTEGER NOT NULL REFERENCES projects (id) ON DELETE CASCADE, + started_at TEXT NOT NULL, + ended_at TEXT, + note TEXT NOT NULL DEFAULT '', + CHECK (ended_at IS NULL OR ended_at > started_at) +); + +-- At most one running timer: every running entry indexes the same value (1). +CREATE UNIQUE INDEX one_running_timer ON time_entries ((ended_at IS NULL)) WHERE ended_at IS NULL; +CREATE INDEX idx_entries_started ON time_entries (started_at); +CREATE INDEX idx_entries_project ON time_entries (project_id); +CREATE INDEX idx_projects_client ON projects (client_id); diff --git a/migrations/0002_colors.sql b/migrations/0002_colors.sql new file mode 100644 index 0000000..c2dded0 --- /dev/null +++ b/migrations/0002_colors.sql @@ -0,0 +1,15 @@ +-- Clients always have a color; projects inherit their client's color unless set. +ALTER TABLE clients ADD COLUMN color TEXT NOT NULL DEFAULT '#2f6f5e'; +ALTER TABLE projects ADD COLUMN color TEXT; + +-- Spread existing clients over the default palette (see repo::PALETTE). +UPDATE clients SET color = CASE (id - 1) % 8 + WHEN 0 THEN '#2f6f5e' + WHEN 1 THEN '#3b6fb6' + WHEN 2 THEN '#c2410c' + WHEN 3 THEN '#7c3aed' + WHEN 4 THEN '#be185d' + WHEN 5 THEN '#a16207' + WHEN 6 THEN '#0e7490' + ELSE '#4d7c0f' +END; diff --git a/src/clock.rs b/src/clock.rs new file mode 100644 index 0000000..2e60631 --- /dev/null +++ b/src/clock.rs @@ -0,0 +1,120 @@ +//! Time helpers. Storage is UTC; periods and display use the local timezone. + +use chrono::{ + DateTime, Datelike, Duration, Local, NaiveDate, NaiveDateTime, SubsecRound, TimeZone, Utc, +}; + +pub fn now() -> DateTime { + Utc::now().trunc_subsecs(0) +} + +pub fn today() -> NaiveDate { + Local::now().date_naive() +} + +/// Canonical storage format; must stay fixed-width for text comparisons in SQL. +pub fn ts(dt: &DateTime) -> String { + dt.format("%Y-%m-%dT%H:%M:%SZ").to_string() +} + +/// Converts a local wall-clock time to UTC, resolving DST gaps/folds to the earliest instant. +pub fn local_to_utc(naive: NaiveDateTime) -> DateTime { + let local = Local + .from_local_datetime(&naive) + .earliest() + // Inside a DST gap the wall-clock time does not exist: shift past it. + .or_else(|| { + Local + .from_local_datetime(&(naive + Duration::hours(1))) + .earliest() + }) + .unwrap_or_else(|| Utc.from_utc_datetime(&naive).with_timezone(&Local)); + local.with_timezone(&Utc).trunc_subsecs(0) +} + +pub fn local_midnight(date: NaiveDate) -> DateTime { + local_to_utc(date.and_hms_opt(0, 0, 0).expect("midnight is valid")) +} + +pub fn local_date(dt: &DateTime) -> NaiveDate { + dt.with_timezone(&Local).date_naive() +} + +pub fn week_start(date: NaiveDate) -> NaiveDate { + date - Duration::days(date.weekday().num_days_from_monday() as i64) +} + +pub fn month_start(date: NaiveDate) -> NaiveDate { + date.with_day(1).expect("day 1 is valid") +} + +/// Formats a duration as `h:mm`. +pub fn hhmm(seconds: i64) -> String { + let minutes = seconds.max(0) / 60; + format!("{}:{:02}", minutes / 60, minutes % 60) +} + +/// Value for an ``. +pub fn input_value(dt: &DateTime) -> String { + dt.with_timezone(&Local) + .format("%Y-%m-%dT%H:%M") + .to_string() +} + +/// Parses an `` value as local time. +pub fn parse_input(value: &str) -> Option> { + ["%Y-%m-%dT%H:%M", "%Y-%m-%dT%H:%M:%S"] + .iter() + .find_map(|fmt| NaiveDateTime::parse_from_str(value.trim(), fmt).ok()) + .map(local_to_utc) +} + +pub fn fmt_time(dt: &DateTime) -> String { + dt.with_timezone(&Local).format("%H:%M").to_string() +} + +pub fn fmt_day(date: NaiveDate) -> String { + const DAYS: [&str; 7] = ["lun.", "mar.", "mer.", "jeu.", "ven.", "sam.", "dim."]; + format!( + "{} {}", + DAYS[date.weekday().num_days_from_monday() as usize], + date.format("%d/%m/%Y") + ) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn hhmm_formats() { + assert_eq!(hhmm(0), "0:00"); + assert_eq!(hhmm(59), "0:00"); + assert_eq!(hhmm(3600 + 5 * 60), "1:05"); + assert_eq!(hhmm(-10), "0:00"); + } + + #[test] + fn month_bounds() { + let d = NaiveDate::from_ymd_opt(2026, 12, 15).unwrap(); + assert_eq!( + month_start(d), + NaiveDate::from_ymd_opt(2026, 12, 1).unwrap() + ); + } + + #[test] + fn week_starts_monday() { + let sunday = NaiveDate::from_ymd_opt(2026, 10, 25).unwrap(); + assert_eq!( + week_start(sunday), + NaiveDate::from_ymd_opt(2026, 10, 19).unwrap() + ); + } + + #[test] + fn input_roundtrip() { + let dt = parse_input("2026-10-26T09:30").unwrap(); + assert_eq!(input_value(&dt), "2026-10-26T09:30"); + } +} diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..0a6c4e1 --- /dev/null +++ b/src/config.rs @@ -0,0 +1,33 @@ +use std::net::SocketAddr; +use std::path::PathBuf; + +use anyhow::{Context, Result}; + +pub struct Config { + pub database_url: String, + pub addr: SocketAddr, +} + +impl Config { + /// Reads `TEMPUS_DB` (a file path or `sqlite:` URL) and `TEMPUS_ADDR`. + pub fn from_env() -> Result { + let database_url = match std::env::var("TEMPUS_DB") { + Ok(v) if v.starts_with("sqlite:") => v, + Ok(path) => format!("sqlite://{path}"), + Err(_) => format!("sqlite://{}", default_db_path()?.display()), + }; + let addr = std::env::var("TEMPUS_ADDR") + .unwrap_or_else(|_| "127.0.0.1:7878".into()) + .parse() + .context("invalid TEMPUS_ADDR")?; + Ok(Self { database_url, addr }) + } +} + +fn default_db_path() -> Result { + let dirs = directories::ProjectDirs::from("", "", "tempus") + .context("cannot determine a data directory; set TEMPUS_DB")?; + let dir = dirs.data_dir(); + std::fs::create_dir_all(dir).with_context(|| format!("cannot create {}", dir.display()))?; + Ok(dir.join("tempus.db")) +} diff --git a/src/db.rs b/src/db.rs new file mode 100644 index 0000000..4e196f6 --- /dev/null +++ b/src/db.rs @@ -0,0 +1,30 @@ +use std::str::FromStr; + +use sqlx::SqlitePool; +use sqlx::sqlite::{SqliteConnectOptions, SqliteJournalMode, SqlitePoolOptions}; + +/// Opens the database and applies pending migrations. +pub async fn connect(url: &str) -> Result { + let in_memory = url.contains(":memory:"); + let mut opts = SqliteConnectOptions::from_str(url)? + .create_if_missing(true) + .foreign_keys(true); + if !in_memory { + opts = opts.journal_mode(SqliteJournalMode::Wal); + } + + // Every connection to `:memory:` is a separate database, so keep exactly one alive. + let pool_opts = if in_memory { + SqlitePoolOptions::new() + .max_connections(1) + .min_connections(1) + .idle_timeout(None) + .max_lifetime(None) + } else { + SqlitePoolOptions::new().max_connections(5) + }; + + let pool = pool_opts.connect_with(opts).await?; + sqlx::migrate!().run(&pool).await?; + Ok(pool) +} diff --git a/src/error.rs b/src/error.rs new file mode 100644 index 0000000..0f84383 --- /dev/null +++ b/src/error.rs @@ -0,0 +1,64 @@ +use axum::Json; +use axum::http::StatusCode; +use axum::response::{IntoResponse, Response}; +use serde_json::json; + +#[derive(Debug, thiserror::Error)] +pub enum AppError { + #[error("ressource introuvable")] + NotFound, + #[error("{0}")] + Conflict(String), + #[error("{0}")] + Validation(String), + #[error("erreur de base de données")] + Db(#[source] sqlx::Error), + #[error("erreur interne")] + Internal(#[source] anyhow::Error), +} + +pub type AppResult = Result; + +impl AppError { + pub fn status(&self) -> StatusCode { + match self { + Self::NotFound => StatusCode::NOT_FOUND, + Self::Conflict(_) => StatusCode::CONFLICT, + Self::Validation(_) => StatusCode::UNPROCESSABLE_ENTITY, + Self::Db(_) | Self::Internal(_) => StatusCode::INTERNAL_SERVER_ERROR, + } + } + + pub fn log(&self) { + match self { + Self::Db(e) => tracing::error!(error = %e, "database error"), + Self::Internal(e) => tracing::error!(error = %e, "internal error"), + _ => {} + } + } +} + +impl From for AppError { + fn from(e: sqlx::Error) -> Self { + match &e { + sqlx::Error::RowNotFound => Self::NotFound, + sqlx::Error::Database(db) if db.is_unique_violation() => { + Self::Conflict("cet élément existe déjà".into()) + } + _ => Self::Db(e), + } + } +} + +impl From for AppError { + fn from(e: askama::Error) -> Self { + Self::Internal(e.into()) + } +} + +impl IntoResponse for AppError { + fn into_response(self) -> Response { + self.log(); + (self.status(), Json(json!({ "error": self.to_string() }))).into_response() + } +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..44b2e02 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,7 @@ +pub mod clock; +pub mod config; +pub mod db; +pub mod error; +pub mod models; +pub mod repo; +pub mod routes; diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..818fc32 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,29 @@ +use anyhow::Context; +use tempus::{config::Config, db, routes}; +use tracing_subscriber::EnvFilter; + +#[tokio::main] +async fn main() -> anyhow::Result<()> { + tracing_subscriber::fmt() + .with_env_filter( + EnvFilter::try_from_default_env() + .unwrap_or_else(|_| "tempus=info,tower_http=info".into()), + ) + .init(); + + let config = Config::from_env()?; + let pool = db::connect(&config.database_url) + .await + .with_context(|| format!("cannot open {}", config.database_url))?; + + let listener = tokio::net::TcpListener::bind(config.addr) + .await + .with_context(|| format!("cannot listen on {}", config.addr))?; + tracing::info!(db = %config.database_url, "Tempus disponible sur http://{}", config.addr); + axum::serve(listener, routes::app(pool)) + .with_graceful_shutdown(async { + let _ = tokio::signal::ctrl_c().await; + }) + .await?; + Ok(()) +} diff --git a/src/models.rs b/src/models.rs new file mode 100644 index 0000000..33ba53f --- /dev/null +++ b/src/models.rs @@ -0,0 +1,225 @@ +use std::fmt::Display; +use std::str::FromStr; + +use chrono::{DateTime, FixedOffset, NaiveDate, Utc}; +use serde::{Deserialize, Deserializer, Serialize}; + +use crate::clock; + +#[derive(Debug, Clone, Serialize, sqlx::FromRow)] +pub struct Client { + pub id: i64, + pub name: String, + pub color: String, + pub archived: bool, + pub created_at: DateTime, +} + +#[derive(Debug, Clone, Serialize, sqlx::FromRow)] +pub struct Project { + pub id: i64, + pub client_id: i64, + pub client_name: String, + pub name: String, + /// Own color; `None` means the client's color is used. + pub color: Option, + /// `color`, or the client's color. + pub effective_color: String, + pub archived: bool, + pub created_at: DateTime, +} + +#[derive(Debug, Clone, Serialize, sqlx::FromRow)] +pub struct Entry { + pub id: i64, + pub project_id: i64, + pub project_name: String, + pub client_id: i64, + pub client_name: String, + /// The project's effective color. + pub color: String, + pub client_color: String, + pub started_at: DateTime, + /// `None` while the timer is running. + pub ended_at: Option>, + pub note: String, + /// Elapsed seconds (up to now for a running entry). + pub seconds: i64, + /// True when another entry covers part of the same time span. + pub overlaps: bool, +} + +impl Entry { + pub fn running(&self) -> bool { + self.ended_at.is_none() + } + + pub fn duration(&self) -> String { + clock::hhmm(self.seconds) + } + + pub fn day(&self) -> String { + clock::fmt_day(clock::local_date(&self.started_at)) + } + + pub fn start_time(&self) -> String { + clock::fmt_time(&self.started_at) + } + + pub fn end_time(&self) -> String { + self.ended_at + .as_ref() + .map(clock::fmt_time) + .unwrap_or_else(|| "…".into()) + } + + pub fn start_input(&self) -> String { + clock::input_value(&self.started_at) + } + + pub fn end_input(&self) -> String { + self.ended_at + .as_ref() + .map(clock::input_value) + .unwrap_or_default() + } + + pub fn started_rfc3339(&self) -> String { + self.started_at.to_rfc3339() + } +} + +// --- API inputs ------------------------------------------------------------- + +#[derive(Debug, Deserialize)] +pub struct NameInput { + pub name: String, + /// `#rrggbb`. Clients get one from the palette, projects inherit their client's. + #[serde(default)] + pub color: Option, +} + +#[derive(Debug, Default, Deserialize)] +pub struct UpdateInput { + pub name: Option, + pub archived: Option, + /// Absent: unchanged. `null`: reset to the client's color (projects only). + #[serde(default, deserialize_with = "present")] + pub color: Option>, +} + +#[derive(Debug, Deserialize)] +pub struct StartTimer { + pub project_id: i64, + #[serde(default)] + pub note: String, +} + +#[derive(Debug, Deserialize)] +pub struct NewEntry { + pub project_id: i64, + pub started_at: DateTime, + pub ended_at: DateTime, + #[serde(default)] + pub note: String, +} + +#[derive(Debug, Default, Deserialize)] +pub struct UpdateEntry { + pub project_id: Option, + pub started_at: Option>, + pub ended_at: Option>, + pub note: Option, +} + +#[derive(Debug, Default, Clone, Deserialize)] +pub struct EntryFilter { + #[serde(default, deserialize_with = "empty_as_none")] + pub from: Option, + /// Inclusive. + #[serde(default, deserialize_with = "empty_as_none")] + pub to: Option, + #[serde(default, deserialize_with = "empty_as_none")] + pub client_id: Option, + #[serde(default, deserialize_with = "empty_as_none")] + pub project_id: Option, +} + +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum GroupBy { + Client, + #[default] + Project, + Day, +} + +#[derive(Debug, Default, Clone, Deserialize)] +pub struct ReportQuery { + #[serde(default, deserialize_with = "empty_as_none")] + pub from: Option, + #[serde(default, deserialize_with = "empty_as_none")] + pub to: Option, + #[serde(default)] + pub group_by: GroupBy, + #[serde(default, deserialize_with = "empty_as_none")] + pub client_id: Option, + #[serde(default, deserialize_with = "empty_as_none")] + pub project_id: Option, +} + +#[derive(Debug, Serialize)] +pub struct Report { + pub from: NaiveDate, + pub to: NaiveDate, + pub group_by: GroupBy, + pub rows: Vec, + pub total_seconds: i64, +} + +impl Report { + pub fn total(&self) -> String { + clock::hhmm(self.total_seconds) + } +} + +#[derive(Debug, Serialize)] +pub struct ReportRow { + pub key: String, + pub label: String, + pub seconds: i64, + /// Client or project color; `None` for days. + pub color: Option, + /// Share of the largest row, 0–100, for bar rendering. + pub percent: u32, +} + +impl ReportRow { + pub fn duration(&self) -> String { + clock::hhmm(self.seconds) + } +} + +/// Distinguishes an explicit `null` (`Some(None)`) from an absent field (`None`). +fn present<'de, D, T>(de: D) -> Result>, D::Error> +where + D: Deserializer<'de>, + T: Deserialize<'de>, +{ + Option::::deserialize(de).map(Some) +} + +/// HTML forms send empty strings for unset fields. +pub fn empty_as_none<'de, D, T>(de: D) -> Result, D::Error> +where + D: Deserializer<'de>, + T: FromStr, + T::Err: Display, +{ + match Option::::deserialize(de)? { + Some(s) if !s.trim().is_empty() => { + s.trim().parse().map(Some).map_err(serde::de::Error::custom) + } + _ => Ok(None), + } +} diff --git a/src/repo/clients.rs b/src/repo/clients.rs new file mode 100644 index 0000000..bd17e37 --- /dev/null +++ b/src/repo/clients.rs @@ -0,0 +1,87 @@ +use sqlx::SqlitePool; + +use super::{PALETTE, affected, clean_color, clean_name}; +use crate::clock; +use crate::error::{AppError, AppResult}; +use crate::models::{Client, UpdateInput}; + +pub async fn list(pool: &SqlitePool, include_archived: bool) -> AppResult> { + Ok(sqlx::query_as( + "SELECT id, name, color, archived, created_at FROM clients + WHERE ?1 OR archived = 0 + ORDER BY archived, name COLLATE NOCASE", + ) + .bind(include_archived) + .fetch_all(pool) + .await?) +} + +pub async fn get(pool: &SqlitePool, id: i64) -> AppResult { + Ok( + sqlx::query_as("SELECT id, name, color, archived, created_at FROM clients WHERE id = ?1") + .bind(id) + .fetch_one(pool) + .await?, + ) +} + +pub async fn create(pool: &SqlitePool, name: &str, color: Option<&str>) -> AppResult { + let name = clean_name(name)?; + let color = match color { + Some(c) => clean_color(c)?, + None => next_color(pool).await?, + }; + let id = sqlx::query("INSERT INTO clients (name, color, created_at) VALUES (?1, ?2, ?3)") + .bind(name) + .bind(color) + .bind(clock::ts(&clock::now())) + .execute(pool) + .await? + .last_insert_rowid(); + get(pool, id).await +} + +pub async fn update(pool: &SqlitePool, id: i64, input: &UpdateInput) -> AppResult { + let name = input.name.as_deref().map(clean_name).transpose()?; + let color = match &input.color { + None => None, + Some(Some(c)) => Some(clean_color(c)?), + Some(None) => { + return Err(AppError::Validation( + "un client doit avoir une couleur".into(), + )); + } + }; + affected( + sqlx::query( + "UPDATE clients SET name = COALESCE(?2, name), archived = COALESCE(?3, archived), + color = COALESCE(?4, color) + WHERE id = ?1", + ) + .bind(id) + .bind(name) + .bind(input.archived) + .bind(color) + .execute(pool) + .await?, + )?; + get(pool, id).await +} + +/// The palette color for the next client, cycling once all are used. +pub async fn next_color(pool: &SqlitePool) -> AppResult { + let count: i64 = sqlx::query_scalar("SELECT COUNT(*) FROM clients") + .fetch_one(pool) + .await?; + Ok(PALETTE[count as usize % PALETTE.len()].to_owned()) +} + +/// Deletes the client with all its projects and time entries. +pub async fn delete(pool: &SqlitePool, id: i64) -> AppResult<()> { + affected( + sqlx::query("DELETE FROM clients WHERE id = ?1") + .bind(id) + .execute(pool) + .await?, + ) +} diff --git a/src/repo/entries.rs b/src/repo/entries.rs new file mode 100644 index 0000000..2e04d2e --- /dev/null +++ b/src/repo/entries.rs @@ -0,0 +1,193 @@ +use chrono::{DateTime, Duration, Utc}; +use sqlx::SqlitePool; + +use super::affected; +use crate::clock; +use crate::error::{AppError, AppResult}; +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, + 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 + WHERE o.id <> e.id + AND o.started_at < COALESCE(e.ended_at, ?1) + AND COALESCE(o.ended_at, ?1) > e.started_at) AS overlaps + FROM time_entries e + JOIN projects p ON p.id = e.project_id + JOIN clients c ON c.id = p.client_id"; + +/// Entries intersecting the filter's period, most recent first. +pub async fn list( + pool: &SqlitePool, + filter: &EntryFilter, + now: DateTime, +) -> AppResult> { + let from = filter.from.map(|d| clock::ts(&clock::local_midnight(d))); + let to = filter + .to + .map(|d| clock::ts(&clock::local_midnight(d + Duration::days(1)))); + Ok(sqlx::query_as(&format!( + "{SELECT} + WHERE (?2 IS NULL OR COALESCE(e.ended_at, ?1) > ?2) + AND (?3 IS NULL OR e.started_at < ?3) + AND (?4 IS NULL OR p.client_id = ?4) + AND (?5 IS NULL OR e.project_id = ?5) + ORDER BY e.started_at DESC" + )) + .bind(clock::ts(&now)) + .bind(from) + .bind(to) + .bind(filter.client_id) + .bind(filter.project_id) + .fetch_all(pool) + .await?) +} + +pub async fn get(pool: &SqlitePool, id: i64) -> AppResult { + Ok(sqlx::query_as(&format!("{SELECT} WHERE e.id = ?2")) + .bind(clock::ts(&clock::now())) + .bind(id) + .fetch_one(pool) + .await?) +} + +/// The running timer, if any. +pub async fn running(pool: &SqlitePool) -> AppResult> { + Ok( + sqlx::query_as(&format!("{SELECT} WHERE e.ended_at IS NULL")) + .bind(clock::ts(&clock::now())) + .fetch_optional(pool) + .await?, + ) +} + +/// Starts a timer on `project_id`, stopping the running one first if needed. +pub async fn start(pool: &SqlitePool, project_id: i64, note: &str) -> AppResult { + super::projects::get_active(pool, project_id).await?; + let now = clock::now(); + let mut tx = pool.begin().await?; + // An entry started in this very second would end up empty: drop it instead. + sqlx::query("DELETE FROM time_entries WHERE ended_at IS NULL AND started_at >= ?1") + .bind(clock::ts(&now)) + .execute(&mut *tx) + .await?; + sqlx::query("UPDATE time_entries SET ended_at = ?1 WHERE ended_at IS NULL") + .bind(clock::ts(&now)) + .execute(&mut *tx) + .await?; + let id = + sqlx::query("INSERT INTO time_entries (project_id, started_at, note) VALUES (?1, ?2, ?3)") + .bind(project_id) + .bind(clock::ts(&now)) + .bind(note.trim()) + .execute(&mut *tx) + .await? + .last_insert_rowid(); + tx.commit().await?; + get(pool, id).await +} + +/// Stops the running timer. +pub async fn stop(pool: &SqlitePool) -> AppResult { + let entry = running(pool) + .await? + .ok_or_else(|| AppError::Conflict("aucun timer en cours".into()))?; + let now = clock::now(); + if now <= entry.started_at { + // Less than a second of work: nothing worth keeping. + delete(pool, entry.id).await?; + return Err(AppError::Conflict( + "timer arrêté sans durée, entrée supprimée".into(), + )); + } + sqlx::query("UPDATE time_entries SET ended_at = ?2 WHERE id = ?1") + .bind(entry.id) + .bind(clock::ts(&now)) + .execute(pool) + .await?; + get(pool, entry.id).await +} + +pub async fn create(pool: &SqlitePool, input: &NewEntry) -> AppResult { + super::projects::get_active(pool, input.project_id).await?; + let started = input.started_at.with_timezone(&Utc); + let ended = input.ended_at.with_timezone(&Utc); + validate_span(&started, Some(&ended))?; + let id = sqlx::query( + "INSERT INTO time_entries (project_id, started_at, ended_at, note) VALUES (?1, ?2, ?3, ?4)", + ) + .bind(input.project_id) + .bind(clock::ts(&started)) + .bind(clock::ts(&ended)) + .bind(input.note.trim()) + .execute(pool) + .await? + .last_insert_rowid(); + get(pool, id).await +} + +pub async fn update(pool: &SqlitePool, id: i64, input: &UpdateEntry) -> AppResult { + let current = get(pool, id).await?; + let project_id = input.project_id.unwrap_or(current.project_id); + if project_id != current.project_id { + super::projects::get_active(pool, project_id).await?; + } + let started = input + .started_at + .map(|d| d.with_timezone(&Utc)) + .unwrap_or(current.started_at); + let ended = input + .ended_at + .map(|d| d.with_timezone(&Utc)) + .or(current.ended_at); + validate_span(&started, ended.as_ref())?; + let note = input.note.as_deref().unwrap_or(¤t.note).trim(); + + sqlx::query( + "UPDATE time_entries SET project_id = ?2, started_at = ?3, ended_at = ?4, note = ?5 + WHERE id = ?1", + ) + .bind(id) + .bind(project_id) + .bind(clock::ts(&started)) + .bind(ended.as_ref().map(clock::ts)) + .bind(note) + .execute(pool) + .await?; + get(pool, id).await +} + +pub async fn delete(pool: &SqlitePool, id: i64) -> AppResult<()> { + affected( + sqlx::query("DELETE FROM time_entries WHERE id = ?1") + .bind(id) + .execute(pool) + .await?, + ) +} + +fn validate_span(started: &DateTime, ended: Option<&DateTime>) -> AppResult<()> { + match ended { + Some(ended) if ended <= started => Err(AppError::Validation( + "la fin doit être postérieure au début".into(), + )), + // A running entry cannot start in the future. + None if *started > clock::now() => Err(AppError::Validation( + "un timer en cours ne peut pas commencer dans le futur".into(), + )), + _ => Ok(()), + } +} + +/// The project of the most recently started entry. +pub async fn last_project_id(pool: &SqlitePool) -> AppResult> { + Ok( + sqlx::query_scalar("SELECT project_id FROM time_entries ORDER BY started_at DESC LIMIT 1") + .fetch_optional(pool) + .await?, + ) +} diff --git a/src/repo/mod.rs b/src/repo/mod.rs new file mode 100644 index 0000000..dd0e8ae --- /dev/null +++ b/src/repo/mod.rs @@ -0,0 +1,43 @@ +pub mod clients; +pub mod entries; +pub mod projects; +pub mod reports; + +use crate::error::{AppError, AppResult}; + +/// Trims a user-provided name and rejects empty ones. +fn clean_name(name: &str) -> AppResult { + let name = name.trim(); + if name.is_empty() { + return Err(AppError::Validation("le nom ne peut pas être vide".into())); + } + Ok(name.to_owned()) +} + +/// Colors handed out to new clients, in order. +pub const PALETTE: [&str; 8] = [ + "#2f6f5e", "#3b6fb6", "#c2410c", "#7c3aed", "#be185d", "#a16207", "#0e7490", "#4d7c0f", +]; + +/// Validates a `#rrggbb` color and normalizes it to lowercase. +fn clean_color(color: &str) -> AppResult { + let color = color.trim(); + let valid = color.len() == 7 + && color.starts_with('#') + && color[1..].chars().all(|c| c.is_ascii_hexdigit()); + if !valid { + return Err(AppError::Validation(format!( + "couleur invalide « {color} » (format attendu : #rrggbb)" + ))); + } + Ok(color.to_ascii_lowercase()) +} + +/// Maps "zero rows affected" to `NotFound`. +fn affected(result: sqlx::sqlite::SqliteQueryResult) -> AppResult<()> { + if result.rows_affected() == 0 { + Err(AppError::NotFound) + } else { + Ok(()) + } +} diff --git a/src/repo/projects.rs b/src/repo/projects.rs new file mode 100644 index 0000000..87d6648 --- /dev/null +++ b/src/repo/projects.rs @@ -0,0 +1,105 @@ +use sqlx::SqlitePool; + +use super::{affected, clean_color, clean_name}; +use crate::clock; +use crate::error::{AppError, AppResult}; +use crate::models::{Project, UpdateInput}; + +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 + FROM projects p JOIN clients c ON c.id = p.client_id"; + +/// Lists projects, optionally for one client. Archived projects (or projects of +/// archived clients) are only included on request. +pub async fn list( + pool: &SqlitePool, + client_id: Option, + include_archived: bool, +) -> AppResult> { + Ok(sqlx::query_as(&format!( + "{SELECT} + WHERE (?1 IS NULL OR p.client_id = ?1) + AND (?2 OR (p.archived = 0 AND c.archived = 0)) + ORDER BY c.name COLLATE NOCASE, p.archived, p.name COLLATE NOCASE" + )) + .bind(client_id) + .bind(include_archived) + .fetch_all(pool) + .await?) +} + +pub async fn get(pool: &SqlitePool, id: i64) -> AppResult { + Ok(sqlx::query_as(&format!("{SELECT} WHERE p.id = ?1")) + .bind(id) + .fetch_one(pool) + .await?) +} + +pub async fn create( + pool: &SqlitePool, + client_id: i64, + name: &str, + color: Option<&str>, +) -> AppResult { + let name = clean_name(name)?; + let color = color.map(clean_color).transpose()?; + // Surface a missing client as 404 rather than a foreign key error. + super::clients::get(pool, client_id).await?; + let id = sqlx::query( + "INSERT INTO projects (client_id, name, color, created_at) VALUES (?1, ?2, ?3, ?4)", + ) + .bind(client_id) + .bind(name) + .bind(color) + .bind(clock::ts(&clock::now())) + .execute(pool) + .await? + .last_insert_rowid(); + get(pool, id).await +} + +pub async fn update(pool: &SqlitePool, id: i64, input: &UpdateInput) -> AppResult { + let name = input.name.as_deref().map(clean_name).transpose()?; + let color = match &input.color { + Some(Some(c)) => Some(clean_color(c)?), + _ => None, + }; + affected( + sqlx::query( + "UPDATE projects SET name = COALESCE(?2, name), archived = COALESCE(?3, archived), + color = CASE WHEN ?4 THEN ?5 ELSE color END + WHERE id = ?1", + ) + .bind(id) + .bind(name) + .bind(input.archived) + .bind(input.color.is_some()) + .bind(color) + .execute(pool) + .await?, + )?; + get(pool, id).await +} + +/// Deletes the project with all its time entries. +pub async fn delete(pool: &SqlitePool, id: i64) -> AppResult<()> { + affected( + sqlx::query("DELETE FROM projects WHERE id = ?1") + .bind(id) + .execute(pool) + .await?, + ) +} + +/// Fetches a project that time can be tracked on. +pub async fn get_active(pool: &SqlitePool, id: i64) -> AppResult { + let project = get(pool, id).await.map_err(|e| match e { + AppError::NotFound => AppError::Validation("projet inconnu".into()), + e => e, + })?; + let client = super::clients::get(pool, project.client_id).await?; + if project.archived || client.archived { + return Err(AppError::Validation("ce projet est archivé".into())); + } + Ok(project) +} diff --git a/src/repo/reports.rs b/src/repo/reports.rs new file mode 100644 index 0000000..aca82d1 --- /dev/null +++ b/src/repo/reports.rs @@ -0,0 +1,130 @@ +use std::collections::HashMap; + +use chrono::{DateTime, Duration, NaiveDate, Utc}; +use sqlx::SqlitePool; + +use crate::clock; +use crate::error::{AppError, AppResult}; +use crate::models::{Entry, EntryFilter, GroupBy, Report, ReportRow}; + +/// Above this span, days without any time are not listed. +const MAX_FILLED_DAYS: i64 = 62; + +pub async fn build( + pool: &SqlitePool, + from: NaiveDate, + to: NaiveDate, + group_by: GroupBy, + client_id: Option, + project_id: Option, + now: DateTime, +) -> AppResult { + if to < from { + return Err(AppError::Validation( + "la date de fin précède la date de début".into(), + )); + } + let filter = EntryFilter { + from: Some(from), + to: Some(to), + client_id, + project_id, + }; + let entries = super::entries::list(pool, &filter, now).await?; + Ok(aggregate(&entries, from, to, group_by, now)) +} + +/// Sums entry durations clipped to `[from, to]` (local days, inclusive). +pub fn aggregate( + entries: &[Entry], + from: NaiveDate, + to: NaiveDate, + group_by: GroupBy, + now: DateTime, +) -> Report { + let start = clock::local_midnight(from); + let end = clock::local_midnight(to + Duration::days(1)); + let mut totals: HashMap, i64)> = HashMap::new(); + let mut add = |key: String, label: String, color: Option<&str>, seconds: i64| { + totals + .entry(key) + .or_insert((label, color.map(str::to_owned), 0)) + .2 += seconds; + }; + + for e in entries { + let s = e.started_at.max(start); + let t = e.ended_at.unwrap_or(now).min(end); + if t <= s { + continue; + } + match group_by { + GroupBy::Client => add( + e.client_id.to_string(), + e.client_name.clone(), + Some(&e.client_color), + secs(s, t), + ), + GroupBy::Project => add( + e.project_id.to_string(), + format!("{} / {}", e.client_name, e.project_name), + Some(&e.color), + secs(s, t), + ), + GroupBy::Day => { + // Split at local midnights so an entry spanning two days counts on both. + let mut cur = s; + while cur < t { + let day = clock::local_date(&cur); + let next = clock::local_midnight(day + Duration::days(1)).min(t); + add(day.to_string(), clock::fmt_day(day), None, secs(cur, next)); + cur = next; + } + } + } + } + + if group_by == GroupBy::Day && (to - from).num_days() < MAX_FILLED_DAYS { + for day in from.iter_days().take_while(|d| *d <= to) { + add(day.to_string(), clock::fmt_day(day), None, 0); + } + } + + let mut rows: Vec = totals + .into_iter() + .map(|(key, (label, color, seconds))| ReportRow { + key, + label, + seconds, + color, + percent: 0, + }) + .collect(); + match group_by { + // ISO dates sort chronologically. + GroupBy::Day => rows.sort_by(|a, b| a.key.cmp(&b.key)), + _ => rows.sort_by(|a, b| { + b.seconds + .cmp(&a.seconds) + .then_with(|| a.label.cmp(&b.label)) + }), + } + let max = rows.iter().map(|r| r.seconds).max().unwrap_or(0); + if max > 0 { + for r in &mut rows { + r.percent = (r.seconds * 100 / max) as u32; + } + } + + Report { + from, + to, + group_by, + total_seconds: rows.iter().map(|r| r.seconds).sum(), + rows, + } +} + +fn secs(from: DateTime, to: DateTime) -> i64 { + (to - from).num_seconds() +} diff --git a/src/routes/api.rs b/src/routes/api.rs new file mode 100644 index 0000000..6bfc89e --- /dev/null +++ b/src/routes/api.rs @@ -0,0 +1,184 @@ +use axum::extract::{Path, Query, State}; +use axum::http::StatusCode; +use axum::routing::{get, patch, post}; +use axum::{Json, Router}; +use serde::Deserialize; +use sqlx::SqlitePool; + +use crate::clock; +use crate::error::AppResult; +use crate::models::{ + Client, Entry, EntryFilter, NameInput, NewEntry, Project, Report, ReportQuery, StartTimer, + UpdateEntry, UpdateInput, +}; +use crate::repo::{clients, entries, projects, reports}; + +pub fn router() -> Router { + Router::new() + .route("/clients", get(list_clients).post(create_client)) + .route("/clients/{id}", patch(update_client).delete(delete_client)) + .route( + "/clients/{id}/projects", + get(list_projects).post(create_project), + ) + .route( + "/projects/{id}", + patch(update_project).delete(delete_project), + ) + .route("/timer", get(timer)) + .route("/timer/start", post(start_timer)) + .route("/timer/stop", post(stop_timer)) + .route("/entries", get(list_entries).post(create_entry)) + .route("/entries/{id}", patch(update_entry).delete(delete_entry)) + .route("/reports", get(report)) +} + +#[derive(Deserialize)] +struct ArchivedQuery { + #[serde(default)] + archived: bool, +} + +async fn list_clients( + State(pool): State, + Query(q): Query, +) -> AppResult>> { + Ok(Json(clients::list(&pool, q.archived).await?)) +} + +async fn create_client( + State(pool): State, + Json(input): Json, +) -> AppResult<(StatusCode, Json)> { + Ok(( + StatusCode::CREATED, + Json(clients::create(&pool, &input.name, input.color.as_deref()).await?), + )) +} + +async fn update_client( + State(pool): State, + Path(id): Path, + Json(input): Json, +) -> AppResult> { + Ok(Json(clients::update(&pool, id, &input).await?)) +} + +async fn delete_client( + State(pool): State, + Path(id): Path, +) -> AppResult { + clients::delete(&pool, id).await?; + Ok(StatusCode::NO_CONTENT) +} + +async fn list_projects( + State(pool): State, + Path(client_id): Path, + Query(q): Query, +) -> AppResult>> { + clients::get(&pool, client_id).await?; + Ok(Json( + projects::list(&pool, Some(client_id), q.archived).await?, + )) +} + +async fn create_project( + State(pool): State, + Path(client_id): Path, + Json(input): Json, +) -> AppResult<(StatusCode, Json)> { + Ok(( + StatusCode::CREATED, + Json(projects::create(&pool, client_id, &input.name, input.color.as_deref()).await?), + )) +} + +async fn update_project( + State(pool): State, + Path(id): Path, + Json(input): Json, +) -> AppResult> { + Ok(Json(projects::update(&pool, id, &input).await?)) +} + +async fn delete_project( + State(pool): State, + Path(id): Path, +) -> AppResult { + projects::delete(&pool, id).await?; + Ok(StatusCode::NO_CONTENT) +} + +async fn timer(State(pool): State) -> AppResult>> { + Ok(Json(entries::running(&pool).await?)) +} + +async fn start_timer( + State(pool): State, + Json(input): Json, +) -> AppResult<(StatusCode, Json)> { + Ok(( + StatusCode::CREATED, + Json(entries::start(&pool, input.project_id, &input.note).await?), + )) +} + +async fn stop_timer(State(pool): State) -> AppResult> { + Ok(Json(entries::stop(&pool).await?)) +} + +async fn list_entries( + State(pool): State, + Query(filter): Query, +) -> AppResult>> { + Ok(Json(entries::list(&pool, &filter, clock::now()).await?)) +} + +async fn create_entry( + State(pool): State, + Json(input): Json, +) -> AppResult<(StatusCode, Json)> { + Ok(( + StatusCode::CREATED, + Json(entries::create(&pool, &input).await?), + )) +} + +async fn update_entry( + State(pool): State, + Path(id): Path, + Json(input): Json, +) -> AppResult> { + Ok(Json(entries::update(&pool, id, &input).await?)) +} + +async fn delete_entry( + State(pool): State, + Path(id): Path, +) -> AppResult { + entries::delete(&pool, id).await?; + Ok(StatusCode::NO_CONTENT) +} + +/// Defaults to the current week. +async fn report( + State(pool): State, + Query(q): Query, +) -> AppResult> { + let today = clock::today(); + let from = q.from.unwrap_or_else(|| clock::week_start(today)); + let to = q.to.unwrap_or(today.max(from)); + Ok(Json( + reports::build( + &pool, + from, + to, + q.group_by, + q.client_id, + q.project_id, + clock::now(), + ) + .await?, + )) +} diff --git a/src/routes/mod.rs b/src/routes/mod.rs new file mode 100644 index 0000000..9078821 --- /dev/null +++ b/src/routes/mod.rs @@ -0,0 +1,40 @@ +mod api; +mod pages; + +use axum::Router; +use axum::http::header; +use axum::response::IntoResponse; +use axum::routing::get; +use sqlx::SqlitePool; +use tower_http::trace::TraceLayer; + +pub fn app(pool: SqlitePool) -> Router { + Router::new() + .merge(pages::router()) + .nest("/api", api::router()) + .route("/health", get(|| async { "ok" })) + .route( + "/static/htmx.min.js", + get(|| asset("text/javascript", include_str!("../../static/htmx.min.js"))), + ) + .route( + "/static/app.js", + get(|| asset("text/javascript", include_str!("../../static/app.js"))), + ) + .route( + "/static/app.css", + get(|| asset("text/css", include_str!("../../static/app.css"))), + ) + .layer(TraceLayer::new_for_http()) + .with_state(pool) +} + +async fn asset(content_type: &'static str, body: &'static str) -> impl IntoResponse { + ( + [ + (header::CONTENT_TYPE, content_type), + (header::CACHE_CONTROL, "public, max-age=3600"), + ], + body, + ) +} diff --git a/src/routes/pages.rs b/src/routes/pages.rs new file mode 100644 index 0000000..0e70d40 --- /dev/null +++ b/src/routes/pages.rs @@ -0,0 +1,620 @@ +//! Server-rendered pages and the htmx fragments they swap in. + +use askama::Template; +use axum::Form; +use axum::Router; +use axum::extract::{Path, Query, State}; +use axum::http::StatusCode; +use axum::response::{AppendHeaders, Html, IntoResponse, Redirect, Response}; +use axum::routing::{get, post}; +use chrono::{Duration, NaiveDate}; +use serde::Deserialize; +use sqlx::SqlitePool; + +use crate::clock; +use crate::error::AppError; +use crate::models::{ + Client, Entry, EntryFilter, GroupBy, NewEntry, Project, Report, ReportQuery, UpdateEntry, + UpdateInput, empty_as_none, +}; +use crate::repo::{clients, entries, projects, reports}; + +pub fn router() -> Router { + Router::new() + .route("/", get(dashboard)) + .route("/clients", get(clients_page)) + .route("/entries", get(entries_page)) + .route("/reports", get(reports_page)) + .route("/ui/today", get(today_fragment)) + .route("/ui/timer/start", post(start_timer)) + .route("/ui/timer/stop", post(stop_timer)) + .route("/ui/clients", post(create_client)) + .route("/ui/clients/{id}", post(save_client)) + .route("/ui/clients/{id}/archive", post(archive_client)) + .route("/ui/clients/{id}/delete", post(delete_client)) + .route("/ui/clients/{id}/projects", post(create_project)) + .route("/ui/projects/{id}", post(save_project)) + .route("/ui/projects/{id}/archive", post(archive_project)) + .route("/ui/projects/{id}/delete", post(delete_project)) + .route("/ui/entries", post(create_entry)) + .route( + "/ui/entries/{id}", + get(entry_row).put(update_entry).delete(delete_entry), + ) + .route("/ui/entries/{id}/edit", get(entry_edit)) +} + +// --- Plumbing --------------------------------------------------------------- + +/// Renders errors as an HTML page; `app.js` extracts the message for htmx requests. +pub struct PageError(AppError); + +impl From for PageError { + fn from(e: AppError) -> Self { + Self(e) + } +} + +impl From for PageError { + fn from(e: askama::Error) -> Self { + Self(e.into()) + } +} + +#[derive(Template)] +#[template(path = "error.html")] +struct ErrorTpl { + nav: &'static str, + message: String, +} + +impl IntoResponse for PageError { + fn into_response(self) -> Response { + self.0.log(); + let tpl = ErrorTpl { + nav: "", + message: self.0.to_string(), + }; + let body = tpl.render().unwrap_or_else(|_| self.0.to_string()); + (self.0.status(), Html(body)).into_response() + } +} + +type PageResult = Result; + +fn render(tpl: impl Template) -> PageResult { + Ok(Html(tpl.render()?).into_response()) +} + +/// Tells listeners on the page (e.g. today's list) that entries changed. +fn with_entries_changed(resp: Response) -> Response { + (AppendHeaders([("HX-Trigger", "entries-changed")]), resp).into_response() +} + +struct ProjectOption { + id: i64, + name: String, + selected: bool, +} + +struct ProjectGroup { + name: String, + projects: Vec, +} + +/// Groups projects (already sorted by client) for ``s. +fn group_projects(list: Vec, selected: Option) -> Vec { + let mut groups: Vec = Vec::new(); + for p in list { + if groups.last().is_none_or(|g| g.name != p.client_name) { + groups.push(ProjectGroup { + name: p.client_name.clone(), + projects: Vec::new(), + }); + } + let name = if p.archived { + format!("{} (archivé)", p.name) + } else { + p.name + }; + groups + .last_mut() + .expect("just pushed") + .projects + .push(ProjectOption { + id: p.id, + name, + selected: Some(p.id) == selected, + }); + } + groups +} + +struct ClientOption { + id: i64, + name: String, + selected: bool, +} + +fn client_options(list: Vec, selected: Option) -> Vec { + list.into_iter() + .map(|c| ClientOption { + selected: Some(c.id) == selected, + id: c.id, + name: c.name, + }) + .collect() +} + +struct Preset { + label: &'static str, + from: NaiveDate, + to: NaiveDate, + active: bool, +} + +fn presets(from: NaiveDate, to: NaiveDate) -> Vec { + let today = clock::today(); + let last_month = clock::month_start(today) - Duration::days(1); + [ + ("Aujourd'hui", today, today), + ("Cette semaine", clock::week_start(today), today), + ( + "Semaine dernière", + clock::week_start(today) - Duration::days(7), + clock::week_start(today) - Duration::days(1), + ), + ("Ce mois", clock::month_start(today), today), + ("Mois dernier", clock::month_start(last_month), last_month), + ] + .into_iter() + .map(|(label, f, t)| Preset { + label, + from: f, + to: t, + active: f == from && t == to, + }) + .collect() +} + +/// Query-string suffix that keeps the current filters when switching period. +fn id_params(client_id: Option, project_id: Option) -> String { + let mut s = String::new(); + if let Some(id) = client_id { + s.push_str(&format!("&client_id={id}")); + } + if let Some(id) = project_id { + s.push_str(&format!("&project_id={id}")); + } + s +} + +/// Resolves an optional period, defaulting to the current week. +fn period(from: Option, to: Option) -> (NaiveDate, NaiveDate) { + let today = clock::today(); + let from = from.unwrap_or_else(|| clock::week_start(today)); + (from, to.unwrap_or(today.max(from))) +} + +// --- Dashboard & timer ------------------------------------------------------ + +#[derive(Template)] +#[template(path = "dashboard.html")] +struct DashboardTpl { + nav: &'static str, + running: Option, + groups: Vec, + today_entries: Vec, + today_total: String, +} + +#[derive(Template)] +#[template(path = "_timer.html")] +struct TimerTpl { + running: Option, + groups: Vec, +} + +#[derive(Template)] +#[template(path = "_today.html")] +struct TodayTpl { + today_entries: Vec, + today_total: String, +} + +async fn timer_state(pool: &SqlitePool) -> PageResult { + let running = entries::running(pool).await?; + // Preselect the running project, else the most recently tracked one. + let selected = match &running { + Some(e) => Some(e.project_id), + None => entries::last_project_id(pool).await?, + }; + let groups = group_projects(projects::list(pool, None, false).await?, selected); + Ok(TimerTpl { running, groups }) +} + +async fn today_state(pool: &SqlitePool) -> PageResult { + let today = clock::today(); + let now = clock::now(); + let filter = EntryFilter { + from: Some(today), + to: Some(today), + ..Default::default() + }; + let today_entries = entries::list(pool, &filter, now).await?; + let total = reports::aggregate(&today_entries, today, today, GroupBy::Client, now); + Ok(TodayTpl { + today_entries, + today_total: total.total(), + }) +} + +async fn dashboard(State(pool): State) -> PageResult { + let TimerTpl { running, groups } = timer_state(&pool).await?; + let TodayTpl { + today_entries, + today_total, + } = today_state(&pool).await?; + render(DashboardTpl { + nav: "dashboard", + running, + groups, + today_entries, + today_total, + }) +} + +async fn today_fragment(State(pool): State) -> PageResult { + render(today_state(&pool).await?) +} + +#[derive(Deserialize)] +struct StartForm { + project_id: i64, + #[serde(default)] + note: String, +} + +async fn start_timer(State(pool): State, Form(form): Form) -> PageResult { + entries::start(&pool, form.project_id, &form.note).await?; + Ok(with_entries_changed(render(timer_state(&pool).await?)?)) +} + +async fn stop_timer(State(pool): State) -> PageResult { + match entries::stop(&pool).await { + // Already stopped (e.g. from another tab): just refresh the widget. + Ok(_) | Err(AppError::Conflict(_)) => {} + Err(e) => return Err(e.into()), + } + Ok(with_entries_changed(render(timer_state(&pool).await?)?)) +} + +// --- Clients & projects ----------------------------------------------------- + +struct ClientCard { + client: Client, + projects: Vec, +} + +#[derive(Template)] +#[template(path = "clients.html")] +struct ClientsTpl { + nav: &'static str, + clients: Vec, + next_color: String, +} + +async fn clients_page(State(pool): State) -> PageResult { + let all_projects = projects::list(&pool, None, true).await?; + let clients = clients::list(&pool, true) + .await? + .into_iter() + .map(|client| { + let projects = all_projects + .iter() + .filter(|p| p.client_id == client.id) + .cloned() + .collect(); + ClientCard { client, projects } + }) + .collect(); + render(ClientsTpl { + nav: "clients", + clients, + next_color: clients::next_color(&pool).await?, + }) +} + +#[derive(Deserialize)] +struct ItemForm { + name: String, + #[serde(default, deserialize_with = "empty_as_none")] + color: Option, + /// Projects only: go back to the client's color. + #[serde(default)] + inherit: bool, +} + +#[derive(Deserialize)] +struct ArchiveForm { + archived: bool, +} + +fn back_to_clients() -> PageResult { + Ok(Redirect::to("/clients").into_response()) +} + +fn archive_input(archived: bool) -> UpdateInput { + UpdateInput { + archived: Some(archived), + ..Default::default() + } +} + +async fn create_client(State(pool): State, Form(f): Form) -> PageResult { + clients::create(&pool, &f.name, f.color.as_deref()).await?; + back_to_clients() +} + +async fn save_client( + State(pool): State, + Path(id): Path, + Form(f): Form, +) -> PageResult { + let input = UpdateInput { + name: Some(f.name), + color: f.color.map(Some), + ..Default::default() + }; + clients::update(&pool, id, &input).await?; + back_to_clients() +} + +async fn archive_client( + State(pool): State, + Path(id): Path, + Form(f): Form, +) -> PageResult { + clients::update(&pool, id, &archive_input(f.archived)).await?; + back_to_clients() +} + +async fn delete_client(State(pool): State, Path(id): Path) -> PageResult { + clients::delete(&pool, id).await?; + back_to_clients() +} + +async fn create_project( + State(pool): State, + Path(client_id): Path, + Form(f): Form, +) -> PageResult { + // The color picker is prefilled with the client's color: keeping it means inheriting. + let client = clients::get(&pool, client_id).await?; + let color = f.color.filter(|c| !c.eq_ignore_ascii_case(&client.color)); + projects::create(&pool, client_id, &f.name, color.as_deref()).await?; + back_to_clients() +} + +async fn save_project( + State(pool): State, + Path(id): Path, + Form(f): Form, +) -> PageResult { + let current = projects::get(&pool, id).await?; + let color = if f.inherit { + Some(None) + } else { + // Untouched picker: leave the color (own or inherited) as it is. + f.color + .filter(|c| !c.eq_ignore_ascii_case(¤t.effective_color)) + .map(Some) + }; + let input = UpdateInput { + name: Some(f.name), + color, + ..Default::default() + }; + projects::update(&pool, id, &input).await?; + back_to_clients() +} + +async fn archive_project( + State(pool): State, + Path(id): Path, + Form(f): Form, +) -> PageResult { + projects::update(&pool, id, &archive_input(f.archived)).await?; + back_to_clients() +} + +async fn delete_project(State(pool): State, Path(id): Path) -> PageResult { + projects::delete(&pool, id).await?; + back_to_clients() +} + +// --- Entries ---------------------------------------------------------------- + +#[derive(Template)] +#[template(path = "entries.html")] +struct EntriesTpl { + nav: &'static str, + from: NaiveDate, + to: NaiveDate, + presets: Vec, + extra_query: String, + clients: Vec, + filter_groups: Vec, + groups: Vec, + entries: Vec, + total: String, + default_start: String, + default_end: String, +} + +#[derive(Template)] +#[template(path = "_entry_row.html")] +struct EntryRowTpl { + e: Entry, +} + +#[derive(Template)] +#[template(path = "_entry_edit.html")] +struct EntryEditTpl { + e: Entry, + groups: Vec, +} + +async fn entries_page( + State(pool): State, + Query(filter): Query, +) -> PageResult { + let (from, to) = period(filter.from, filter.to); + let filter = EntryFilter { + from: Some(from), + to: Some(to), + ..filter + }; + let now = clock::now(); + let list = entries::list(&pool, &filter, now).await?; + let total = reports::aggregate(&list, from, to, GroupBy::Client, now).total(); + + let last_project = list.first().map(|e| e.project_id); + let today = clock::today(); + render(EntriesTpl { + nav: "entries", + from, + to, + presets: presets(from, to), + extra_query: id_params(filter.client_id, filter.project_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), + groups: group_projects(projects::list(&pool, None, false).await?, last_project), + entries: list, + total, + default_start: format!("{today}T09:00"), + default_end: format!("{today}T10:00"), + }) +} + +#[derive(Deserialize)] +struct EntryForm { + project_id: i64, + started_at: String, + #[serde(default)] + ended_at: String, + #[serde(default)] + note: String, +} + +fn parse_datetime(value: &str, field: &str) -> Result, AppError> { + clock::parse_input(value).ok_or_else(|| AppError::Validation(format!("{field} invalide"))) +} + +async fn create_entry(State(pool): State, Form(f): Form) -> PageResult { + let started = parse_datetime(&f.started_at, "début")?; + let ended = parse_datetime(&f.ended_at, "fin")?; + let entry = entries::create( + &pool, + &NewEntry { + project_id: f.project_id, + started_at: started.fixed_offset(), + ended_at: ended.fixed_offset(), + note: f.note, + }, + ) + .await?; + // Land on the week containing the new entry so it is visible. + let day = clock::local_date(&entry.started_at); + let from = clock::week_start(day); + Ok(Redirect::to(&format!( + "/entries?from={from}&to={}", + from + Duration::days(6) + )) + .into_response()) +} + +async fn entry_row(State(pool): State, Path(id): Path) -> PageResult { + render(EntryRowTpl { + e: entries::get(&pool, id).await?, + }) +} + +async fn entry_edit(State(pool): State, Path(id): Path) -> PageResult { + let e = entries::get(&pool, id).await?; + let groups = group_projects(projects::list(&pool, None, true).await?, Some(e.project_id)); + render(EntryEditTpl { e, groups }) +} + +async fn update_entry( + State(pool): State, + Path(id): Path, + Form(f): Form, +) -> PageResult { + let started = parse_datetime(&f.started_at, "début")?; + let ended = match f.ended_at.trim() { + "" => None, + v => Some(parse_datetime(v, "fin")?), + }; + let e = entries::update( + &pool, + id, + &UpdateEntry { + project_id: Some(f.project_id), + started_at: Some(started.fixed_offset()), + ended_at: ended.map(|d| d.fixed_offset()), + note: Some(f.note), + }, + ) + .await?; + Ok(with_entries_changed(render(EntryRowTpl { e })?)) +} + +async fn delete_entry(State(pool): State, Path(id): Path) -> PageResult { + entries::delete(&pool, id).await?; + // htmx swaps the row with this empty body, removing it. + Ok(with_entries_changed((StatusCode::OK, "").into_response())) +} + +// --- Reports ---------------------------------------------------------------- + +#[derive(Template)] +#[template(path = "reports.html")] +struct ReportsTpl { + nav: &'static str, + report: Report, + presets: Vec, + extra_query: String, + clients: Vec, + group_by: &'static str, +} + +async fn reports_page(State(pool): State, Query(q): Query) -> PageResult { + let (from, to) = period(q.from, q.to); + let report = reports::build( + &pool, + from, + to, + q.group_by, + q.client_id, + q.project_id, + clock::now(), + ) + .await?; + let group_by = match q.group_by { + GroupBy::Client => "client", + GroupBy::Project => "project", + GroupBy::Day => "day", + }; + render(ReportsTpl { + nav: "reports", + presets: presets(from, to), + extra_query: format!( + "&group_by={group_by}{}", + id_params(q.client_id, q.project_id) + ), + clients: client_options(clients::list(&pool, true).await?, q.client_id), + group_by, + report, + }) +} diff --git a/static/app.css b/static/app.css new file mode 100644 index 0000000..3fc8eda --- /dev/null +++ b/static/app.css @@ -0,0 +1,161 @@ +:root { + --bg: #f6f5f2; + --surface: #ffffff; + --text: #1d1d1f; + --muted: #6b6b70; + --border: #e3e1dc; + --accent: #2f6f5e; + --accent-text: #ffffff; + --danger: #b3402f; + --running: #e8f3ef; + --warn: #b7791f; + --radius: 10px; + color-scheme: light dark; +} +@media (prefers-color-scheme: dark) { + :root { + --bg: #151517; + --surface: #1f1f22; + --text: #ececef; + --muted: #9a9aa2; + --border: #2f2f34; + --accent: #5fb39a; + --accent-text: #0d1f1a; + --danger: #e0705e; + --running: #1d2e29; + --warn: #e0a84a; + } +} + +* { box-sizing: border-box; } +body { + margin: 0; + background: var(--bg); + color: var(--text); + font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; +} +a { color: var(--accent); } +h1, h2 { margin: 0 0 .75rem; font-weight: 600; } +h2 { font-size: 1.1rem; } + +.topbar { + display: flex; align-items: center; gap: 2rem; flex-wrap: wrap; + padding: .75rem max(16px, calc((100vw - 960px) / 2)); + background: var(--surface); border-bottom: 1px solid var(--border); +} +.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; } +.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; } +.topbar nav a { + 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; } + +main { max-width: 960px; margin: 1.5rem auto; padding: 0 16px; display: grid; gap: 1rem; } + +.card { + background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); + padding: 1.25rem; min-width: 0; +} +.card.archived { opacity: .65; } +.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; } +.card-head h2 { margin: 0; } +.total { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 1.1rem; } + +.row { display: flex; gap: .5rem; align-items: center; } +.row.wrap { flex-wrap: wrap; } +.grow { flex: 1; min-width: 0; } +.row.grow input { flex: 1; min-width: 0; } +.stack { display: grid; gap: .35rem; } +.muted, .empty { color: var(--muted); } +.empty { margin: .25rem 0; } +.nowrap { white-space: nowrap; } + +input, select, button { font: inherit; color: inherit; } +input, select { + background: var(--bg); border: 1px solid var(--border); border-radius: 8px; + padding: .45rem .6rem; min-width: 0; max-width: 100%; +} +input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; } +.title-input { font-weight: 600; font-size: 1.05rem; } +label { display: flex; align-items: center; gap: .35rem; color: var(--muted); } + +.btn { + border: 1px solid var(--border); background: var(--surface); border-radius: 8px; + padding: .45rem .9rem; cursor: pointer; white-space: nowrap; +} +.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.small { padding: .2rem .55rem; font-size: .85rem; } +.htmx-request .btn, .btn.htmx-request { opacity: .6; } + +.badge { font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: var(--bg); color: var(--muted); } + +/* Timer */ +.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-project { font-size: 1.3rem; font-weight: 600; } +.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; } +.note { color: var(--muted); font-size: .9rem; } + +/* Tables */ +.table-wrap { overflow-x: auto; } +table { width: 100%; border-collapse: collapse; } +th { text-align: left; font-weight: 500; color: var(--muted); font-size: .85rem; } +th, td { padding: .5rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; } +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); } +tr.running { background: var(--running); } +tr.editing td { background: var(--bg); } +tr.editing input, tr.editing select { width: 100%; } +td.actions { text-align: right; white-space: nowrap; } +.warn { color: var(--warn); cursor: help; } + +/* Colors */ +.dot { + display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; + background: var(--color); margin-right: .4rem; vertical-align: baseline; flex: none; +} +.client-card { border-left: 6px solid var(--color); } +input[type="color"] { + width: 2.2rem; height: 2.2rem; padding: .15rem; flex: none; cursor: pointer; +} +.projects input[type="color"] { width: 1.8rem; height: 1.8rem; } + +/* Projects list */ +.projects { list-style: none; margin: 0 0 1rem; padding: 0; } +.projects li { + display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; + padding: .4rem 0; border-bottom: 1px solid var(--border); +} +.projects li.archived { opacity: .6; } + +/* Periods & reports */ +.presets { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .75rem; } +.presets a { + padding: .25rem .7rem; border-radius: 999px; border: 1px solid var(--border); + color: var(--muted); text-decoration: none; font-size: .9rem; +} +.presets a[aria-current="true"] { border-color: var(--accent); color: var(--accent); font-weight: 600; } +.filters { margin-bottom: 1rem; } +.report .label { width: 35%; } +.bar-cell { width: 50%; vertical-align: middle; } +.bar { height: .7rem; border-radius: 4px; background: var(--color, var(--accent)); min-width: 2px; } +.report tfoot td { font-weight: 600; border-top: 2px solid var(--border); } + +#toast { + position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); + background: var(--danger); color: #fff; padding: .6rem 1rem; border-radius: 8px; + max-width: calc(100vw - 32px); box-shadow: 0 4px 16px rgb(0 0 0 / .2); +} + +@media (max-width: 640px) { + .current { grid-template-columns: 1fr auto; } + .current .btn { grid-column: 1 / -1; } + .start { grid-template-columns: 1fr; } + .report .label { width: auto; } + .bar-cell { width: 30%; } +} diff --git a/static/app.js b/static/app.js new file mode 100644 index 0000000..feb4566 --- /dev/null +++ b/static/app.js @@ -0,0 +1,33 @@ +// Live clock for the running timer. +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 s = String(secs % 60).padStart(2, "0"); + el.textContent = `${h}:${m}:${s}`; + } +} +tick(); +setInterval(tick, 1000); + +// Show server errors from htmx requests in a toast. +let toastTimer; +function toast(message) { + const el = document.getElementById("toast"); + el.textContent = message; + el.hidden = false; + clearTimeout(toastTimer); + toastTimer = setTimeout(() => (el.hidden = true), 5000); +} +document.body.addEventListener("htmx:responseError", (event) => { + const html = new DOMParser().parseFromString(event.detail.xhr.responseText, "text/html"); + toast(html.getElementById("error-message")?.textContent || "Une erreur est survenue"); +}); +document.body.addEventListener("htmx:sendError", () => toast("Serveur injoignable")); + +// Confirmation for plain (non-htmx) destructive forms. +document.addEventListener("submit", (event) => { + const message = event.target.dataset.confirm; + if (message && !confirm(message)) event.preventDefault(); +}); diff --git a/static/htmx.min.js b/static/htmx.min.js new file mode 100644 index 0000000..59937d7 --- /dev/null +++ b/static/htmx.min.js @@ -0,0 +1 @@ +var htmx=function(){"use strict";const Q={onLoad:null,process:null,on:null,off:null,trigger:null,ajax:null,find:null,findAll:null,closest:null,values:function(e,t){const n=cn(e,t||"post");return n.values},remove:null,addClass:null,removeClass:null,toggleClass:null,takeClass:null,swap:null,defineExtension:null,removeExtension:null,logAll:null,logNone:null,logger:null,config:{historyEnabled:true,historyCacheSize:10,refreshOnHistoryMiss:false,defaultSwapStyle:"innerHTML",defaultSwapDelay:0,defaultSettleDelay:20,includeIndicatorStyles:true,indicatorClass:"htmx-indicator",requestClass:"htmx-request",addedClass:"htmx-added",settlingClass:"htmx-settling",swappingClass:"htmx-swapping",allowEval:true,allowScriptTags:true,inlineScriptNonce:"",inlineStyleNonce:"",attributesToSettle:["class","style","width","height"],withCredentials:false,timeout:0,wsReconnectDelay:"full-jitter",wsBinaryType:"blob",disableSelector:"[hx-disable], [data-hx-disable]",scrollBehavior:"instant",defaultFocusScroll:false,getCacheBusterParam:false,globalViewTransitions:false,methodsThatUseUrlParams:["get","delete"],selfRequestsOnly:true,ignoreTitle:false,scrollIntoViewOnBoost:true,triggerSpecsCache:null,disableInheritance:false,responseHandling:[{code:"204",swap:false},{code:"[23]..",swap:true},{code:"[45]..",swap:false,error:true}],allowNestedOobSwaps:true},parseInterval:null,_:null,version:"2.0.4"};Q.onLoad=j;Q.process=kt;Q.on=ye;Q.off=be;Q.trigger=he;Q.ajax=Rn;Q.find=u;Q.findAll=x;Q.closest=g;Q.remove=z;Q.addClass=K;Q.removeClass=G;Q.toggleClass=W;Q.takeClass=Z;Q.swap=$e;Q.defineExtension=Fn;Q.removeExtension=Bn;Q.logAll=V;Q.logNone=_;Q.parseInterval=d;Q._=e;const n={addTriggerHandler:St,bodyContains:le,canAccessLocalStorage:B,findThisElement:Se,filterValues:hn,swap:$e,hasAttribute:s,getAttributeValue:te,getClosestAttributeValue:re,getClosestMatch:o,getExpressionVars:En,getHeaders:fn,getInputValues:cn,getInternalData:ie,getSwapSpecification:gn,getTriggerSpecs:st,getTarget:Ee,makeFragment:P,mergeObjects:ce,makeSettleInfo:xn,oobSwap:He,querySelectorExt:ae,settleImmediately:Kt,shouldCancel:ht,triggerEvent:he,triggerErrorEvent:fe,withExtensions:Ft};const r=["get","post","put","delete","patch"];const H=r.map(function(e){return"[hx-"+e+"], [data-hx-"+e+"]"}).join(", ");function d(e){if(e==undefined){return undefined}let t=NaN;if(e.slice(-2)=="ms"){t=parseFloat(e.slice(0,-2))}else if(e.slice(-1)=="s"){t=parseFloat(e.slice(0,-1))*1e3}else if(e.slice(-1)=="m"){t=parseFloat(e.slice(0,-1))*1e3*60}else{t=parseFloat(e)}return isNaN(t)?undefined:t}function ee(e,t){return e instanceof Element&&e.getAttribute(t)}function s(e,t){return!!e.hasAttribute&&(e.hasAttribute(t)||e.hasAttribute("data-"+t))}function te(e,t){return ee(e,t)||ee(e,"data-"+t)}function c(e){const t=e.parentElement;if(!t&&e.parentNode instanceof ShadowRoot)return e.parentNode;return t}function ne(){return document}function m(e,t){return e.getRootNode?e.getRootNode({composed:t}):ne()}function o(e,t){while(e&&!t(e)){e=c(e)}return e||null}function i(e,t,n){const r=te(t,n);const o=te(t,"hx-disinherit");var i=te(t,"hx-inherit");if(e!==t){if(Q.config.disableInheritance){if(i&&(i==="*"||i.split(" ").indexOf(n)>=0)){return r}else{return null}}if(o&&(o==="*"||o.split(" ").indexOf(n)>=0)){return"unset"}}return r}function re(t,n){let r=null;o(t,function(e){return!!(r=i(t,ue(e),n))});if(r!=="unset"){return r}}function h(e,t){const n=e instanceof Element&&(e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector);return!!n&&n.call(e,t)}function T(e){const t=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i;const n=t.exec(e);if(n){return n[1].toLowerCase()}else{return""}}function q(e){const t=new DOMParser;return t.parseFromString(e,"text/html")}function L(e,t){while(t.childNodes.length>0){e.append(t.childNodes[0])}}function A(e){const t=ne().createElement("script");se(e.attributes,function(e){t.setAttribute(e.name,e.value)});t.textContent=e.textContent;t.async=false;if(Q.config.inlineScriptNonce){t.nonce=Q.config.inlineScriptNonce}return t}function N(e){return e.matches("script")&&(e.type==="text/javascript"||e.type==="module"||e.type==="")}function I(e){Array.from(e.querySelectorAll("script")).forEach(e=>{if(N(e)){const t=A(e);const n=e.parentNode;try{n.insertBefore(t,e)}catch(e){O(e)}finally{e.remove()}}})}function P(e){const t=e.replace(/]*)?>[\s\S]*?<\/head>/i,"");const n=T(t);let r;if(n==="html"){r=new DocumentFragment;const i=q(e);L(r,i.body);r.title=i.title}else if(n==="body"){r=new DocumentFragment;const i=q(t);L(r,i.body);r.title=i.title}else{const i=q('");r=i.querySelector("template").content;r.title=i.title;var o=r.querySelector("title");if(o&&o.parentNode===r){o.remove();r.title=o.innerText}}if(r){if(Q.config.allowScriptTags){I(r)}else{r.querySelectorAll("script").forEach(e=>e.remove())}}return r}function oe(e){if(e){e()}}function t(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function k(e){return typeof e==="function"}function D(e){return t(e,"Object")}function ie(e){const t="htmx-internal-data";let n=e[t];if(!n){n=e[t]={}}return n}function M(t){const n=[];if(t){for(let e=0;e=0}function le(e){return e.getRootNode({composed:true})===document}function F(e){return e.trim().split(/\s+/)}function ce(e,t){for(const n in t){if(t.hasOwnProperty(n)){e[n]=t[n]}}return e}function S(e){try{return JSON.parse(e)}catch(e){O(e);return null}}function B(){const e="htmx:localStorageTest";try{localStorage.setItem(e,e);localStorage.removeItem(e);return true}catch(e){return false}}function U(t){try{const e=new URL(t);if(e){t=e.pathname+e.search}if(!/^\/$/.test(t)){t=t.replace(/\/+$/,"")}return t}catch(e){return t}}function e(e){return vn(ne().body,function(){return eval(e)})}function j(t){const e=Q.on("htmx:load",function(e){t(e.detail.elt)});return e}function V(){Q.logger=function(e,t,n){if(console){console.log(t,e,n)}}}function _(){Q.logger=null}function u(e,t){if(typeof e!=="string"){return e.querySelector(t)}else{return u(ne(),e)}}function x(e,t){if(typeof e!=="string"){return e.querySelectorAll(t)}else{return x(ne(),e)}}function E(){return window}function z(e,t){e=y(e);if(t){E().setTimeout(function(){z(e);e=null},t)}else{c(e).removeChild(e)}}function ue(e){return e instanceof Element?e:null}function $(e){return e instanceof HTMLElement?e:null}function J(e){return typeof e==="string"?e:null}function f(e){return e instanceof Element||e instanceof Document||e instanceof DocumentFragment?e:null}function K(e,t,n){e=ue(y(e));if(!e){return}if(n){E().setTimeout(function(){K(e,t);e=null},n)}else{e.classList&&e.classList.add(t)}}function G(e,t,n){let r=ue(y(e));if(!r){return}if(n){E().setTimeout(function(){G(r,t);r=null},n)}else{if(r.classList){r.classList.remove(t);if(r.classList.length===0){r.removeAttribute("class")}}}}function W(e,t){e=y(e);e.classList.toggle(t)}function Z(e,t){e=y(e);se(e.parentElement.children,function(e){G(e,t)});K(ue(e),t)}function g(e,t){e=ue(y(e));if(e&&e.closest){return e.closest(t)}else{do{if(e==null||h(e,t)){return e}}while(e=e&&ue(c(e)));return null}}function l(e,t){return e.substring(0,t.length)===t}function Y(e,t){return e.substring(e.length-t.length)===t}function ge(e){const t=e.trim();if(l(t,"<")&&Y(t,"/>")){return t.substring(1,t.length-2)}else{return t}}function p(t,r,n){if(r.indexOf("global ")===0){return p(t,r.slice(7),true)}t=y(t);const o=[];{let t=0;let n=0;for(let e=0;e"){t--}}if(n0){const r=ge(o.shift());let e;if(r.indexOf("closest ")===0){e=g(ue(t),ge(r.substr(8)))}else if(r.indexOf("find ")===0){e=u(f(t),ge(r.substr(5)))}else if(r==="next"||r==="nextElementSibling"){e=ue(t).nextElementSibling}else if(r.indexOf("next ")===0){e=pe(t,ge(r.substr(5)),!!n)}else if(r==="previous"||r==="previousElementSibling"){e=ue(t).previousElementSibling}else if(r.indexOf("previous ")===0){e=me(t,ge(r.substr(9)),!!n)}else if(r==="document"){e=document}else if(r==="window"){e=window}else if(r==="body"){e=document.body}else if(r==="root"){e=m(t,!!n)}else if(r==="host"){e=t.getRootNode().host}else{s.push(r)}if(e){i.push(e)}}if(s.length>0){const e=s.join(",");const c=f(m(t,!!n));i.push(...M(c.querySelectorAll(e)))}return i}var pe=function(t,e,n){const r=f(m(t,n)).querySelectorAll(e);for(let e=0;e=0;e--){const o=r[e];if(o.compareDocumentPosition(t)===Node.DOCUMENT_POSITION_FOLLOWING){return o}}};function ae(e,t){if(typeof e!=="string"){return p(e,t)[0]}else{return p(ne().body,e)[0]}}function y(e,t){if(typeof e==="string"){return u(f(t)||document,e)}else{return e}}function xe(e,t,n,r){if(k(t)){return{target:ne().body,event:J(e),listener:t,options:n}}else{return{target:y(e),event:J(t),listener:n,options:r}}}function ye(t,n,r,o){Vn(function(){const e=xe(t,n,r,o);e.target.addEventListener(e.event,e.listener,e.options)});const e=k(n);return e?n:r}function be(t,n,r){Vn(function(){const e=xe(t,n,r);e.target.removeEventListener(e.event,e.listener)});return k(n)?n:r}const ve=ne().createElement("output");function we(e,t){const n=re(e,t);if(n){if(n==="this"){return[Se(e,t)]}else{const r=p(e,n);if(r.length===0){O('The selector "'+n+'" on '+t+" returned no matches!");return[ve]}else{return r}}}}function Se(e,t){return ue(o(e,function(e){return te(ue(e),t)!=null}))}function Ee(e){const t=re(e,"hx-target");if(t){if(t==="this"){return Se(e,"hx-target")}else{return ae(e,t)}}else{const n=ie(e);if(n.boosted){return ne().body}else{return e}}}function Ce(t){const n=Q.config.attributesToSettle;for(let e=0;e0){s=e.substring(0,e.indexOf(":"));n=e.substring(e.indexOf(":")+1)}else{s=e}o.removeAttribute("hx-swap-oob");o.removeAttribute("data-hx-swap-oob");const r=p(t,n,false);if(r){se(r,function(e){let t;const n=o.cloneNode(true);t=ne().createDocumentFragment();t.appendChild(n);if(!Re(s,e)){t=f(n)}const r={shouldSwap:true,target:e,fragment:t};if(!he(e,"htmx:oobBeforeSwap",r))return;e=r.target;if(r.shouldSwap){qe(t);_e(s,e,e,t,i);Te()}se(i.elts,function(e){he(e,"htmx:oobAfterSwap",r)})});o.parentNode.removeChild(o)}else{o.parentNode.removeChild(o);fe(ne().body,"htmx:oobErrorNoTarget",{content:o})}return e}function Te(){const e=u("#--htmx-preserve-pantry--");if(e){for(const t of[...e.children]){const n=u("#"+t.id);n.parentNode.moveBefore(t,n);n.remove()}e.remove()}}function qe(e){se(x(e,"[hx-preserve], [data-hx-preserve]"),function(e){const t=te(e,"id");const n=ne().getElementById(t);if(n!=null){if(e.moveBefore){let e=u("#--htmx-preserve-pantry--");if(e==null){ne().body.insertAdjacentHTML("afterend","
");e=u("#--htmx-preserve-pantry--")}e.moveBefore(n,null)}else{e.parentNode.replaceChild(n,e)}}})}function Le(l,e,c){se(e.querySelectorAll("[id]"),function(t){const n=ee(t,"id");if(n&&n.length>0){const r=n.replace("'","\\'");const o=t.tagName.replace(":","\\:");const e=f(l);const i=e&&e.querySelector(o+"[id='"+r+"']");if(i&&i!==e){const s=t.cloneNode();Oe(t,i);c.tasks.push(function(){Oe(t,s)})}}})}function Ae(e){return function(){G(e,Q.config.addedClass);kt(ue(e));Ne(f(e));he(e,"htmx:load")}}function Ne(e){const t="[autofocus]";const n=$(h(e,t)?e:e.querySelector(t));if(n!=null){n.focus()}}function a(e,t,n,r){Le(e,n,r);while(n.childNodes.length>0){const o=n.firstChild;K(ue(o),Q.config.addedClass);e.insertBefore(o,t);if(o.nodeType!==Node.TEXT_NODE&&o.nodeType!==Node.COMMENT_NODE){r.tasks.push(Ae(o))}}}function Ie(e,t){let n=0;while(n0}function $e(e,t,r,o){if(!o){o={}}e=y(e);const i=o.contextElement?m(o.contextElement,false):ne();const n=document.activeElement;let s={};try{s={elt:n,start:n?n.selectionStart:null,end:n?n.selectionEnd:null}}catch(e){}const l=xn(e);if(r.swapStyle==="textContent"){e.textContent=t}else{let n=P(t);l.title=n.title;if(o.selectOOB){const u=o.selectOOB.split(",");for(let t=0;t0){E().setTimeout(c,r.settleDelay)}else{c()}}function Je(e,t,n){const r=e.getResponseHeader(t);if(r.indexOf("{")===0){const o=S(r);for(const i in o){if(o.hasOwnProperty(i)){let e=o[i];if(D(e)){n=e.target!==undefined?e.target:n}else{e={value:e}}he(n,i,e)}}}else{const s=r.split(",");for(let e=0;e0){const s=o[0];if(s==="]"){e--;if(e===0){if(n===null){t=t+"true"}o.shift();t+=")})";try{const l=vn(r,function(){return Function(t)()},function(){return true});l.source=t;return l}catch(e){fe(ne().body,"htmx:syntax:error",{error:e,source:t});return null}}}else if(s==="["){e++}if(tt(s,n,i)){t+="(("+i+"."+s+") ? ("+i+"."+s+") : (window."+s+"))"}else{t=t+s}n=o.shift()}}}function C(e,t){let n="";while(e.length>0&&!t.test(e[0])){n+=e.shift()}return n}function rt(e){let t;if(e.length>0&&Ye.test(e[0])){e.shift();t=C(e,Qe).trim();e.shift()}else{t=C(e,v)}return t}const ot="input, textarea, select";function it(e,t,n){const r=[];const o=et(t);do{C(o,w);const l=o.length;const c=C(o,/[,\[\s]/);if(c!==""){if(c==="every"){const u={trigger:"every"};C(o,w);u.pollInterval=d(C(o,/[,\[\s]/));C(o,w);var i=nt(e,o,"event");if(i){u.eventFilter=i}r.push(u)}else{const a={trigger:c};var i=nt(e,o,"event");if(i){a.eventFilter=i}C(o,w);while(o.length>0&&o[0]!==","){const f=o.shift();if(f==="changed"){a.changed=true}else if(f==="once"){a.once=true}else if(f==="consume"){a.consume=true}else if(f==="delay"&&o[0]===":"){o.shift();a.delay=d(C(o,v))}else if(f==="from"&&o[0]===":"){o.shift();if(Ye.test(o[0])){var s=rt(o)}else{var s=C(o,v);if(s==="closest"||s==="find"||s==="next"||s==="previous"){o.shift();const h=rt(o);if(h.length>0){s+=" "+h}}}a.from=s}else if(f==="target"&&o[0]===":"){o.shift();a.target=rt(o)}else if(f==="throttle"&&o[0]===":"){o.shift();a.throttle=d(C(o,v))}else if(f==="queue"&&o[0]===":"){o.shift();a.queue=C(o,v)}else if(f==="root"&&o[0]===":"){o.shift();a[f]=rt(o)}else if(f==="threshold"&&o[0]===":"){o.shift();a[f]=C(o,v)}else{fe(e,"htmx:syntax:error",{token:o.shift()})}C(o,w)}r.push(a)}}if(o.length===l){fe(e,"htmx:syntax:error",{token:o.shift()})}C(o,w)}while(o[0]===","&&o.shift());if(n){n[t]=r}return r}function st(e){const t=te(e,"hx-trigger");let n=[];if(t){const r=Q.config.triggerSpecsCache;n=r&&r[t]||it(e,t,r)}if(n.length>0){return n}else if(h(e,"form")){return[{trigger:"submit"}]}else if(h(e,'input[type="button"], input[type="submit"]')){return[{trigger:"click"}]}else if(h(e,ot)){return[{trigger:"change"}]}else{return[{trigger:"click"}]}}function lt(e){ie(e).cancelled=true}function ct(e,t,n){const r=ie(e);r.timeout=E().setTimeout(function(){if(le(e)&&r.cancelled!==true){if(!gt(n,e,Mt("hx:poll:trigger",{triggerSpec:n,target:e}))){t(e)}ct(e,t,n)}},n.pollInterval)}function ut(e){return location.hostname===e.hostname&&ee(e,"href")&&ee(e,"href").indexOf("#")!==0}function at(e){return g(e,Q.config.disableSelector)}function ft(t,n,e){if(t instanceof HTMLAnchorElement&&ut(t)&&(t.target===""||t.target==="_self")||t.tagName==="FORM"&&String(ee(t,"method")).toLowerCase()!=="dialog"){n.boosted=true;let r,o;if(t.tagName==="A"){r="get";o=ee(t,"href")}else{const i=ee(t,"method");r=i?i.toLowerCase():"get";o=ee(t,"action");if(o==null||o===""){o=ne().location.href}if(r==="get"&&o.includes("?")){o=o.replace(/\?[^#]+/,"")}}e.forEach(function(e){pt(t,function(e,t){const n=ue(e);if(at(n)){b(n);return}de(r,o,n,t)},n,e,true)})}}function ht(e,t){const n=ue(t);if(!n){return false}if(e.type==="submit"||e.type==="click"){if(n.tagName==="FORM"){return true}if(h(n,'input[type="submit"], button')&&(h(n,"[form]")||g(n,"form")!==null)){return true}if(n instanceof HTMLAnchorElement&&n.href&&(n.getAttribute("href")==="#"||n.getAttribute("href").indexOf("#")!==0)){return true}}return false}function dt(e,t){return ie(e).boosted&&e instanceof HTMLAnchorElement&&t.type==="click"&&(t.ctrlKey||t.metaKey)}function gt(e,t,n){const r=e.eventFilter;if(r){try{return r.call(t,n)!==true}catch(e){const o=r.source;fe(ne().body,"htmx:eventFilter:error",{error:e,source:o});return true}}return false}function pt(l,c,e,u,a){const f=ie(l);let t;if(u.from){t=p(l,u.from)}else{t=[l]}if(u.changed){if(!("lastValue"in f)){f.lastValue=new WeakMap}t.forEach(function(e){if(!f.lastValue.has(u)){f.lastValue.set(u,new WeakMap)}f.lastValue.get(u).set(e,e.value)})}se(t,function(i){const s=function(e){if(!le(l)){i.removeEventListener(u.trigger,s);return}if(dt(l,e)){return}if(a||ht(e,l)){e.preventDefault()}if(gt(u,l,e)){return}const t=ie(e);t.triggerSpec=u;if(t.handledFor==null){t.handledFor=[]}if(t.handledFor.indexOf(l)<0){t.handledFor.push(l);if(u.consume){e.stopPropagation()}if(u.target&&e.target){if(!h(ue(e.target),u.target)){return}}if(u.once){if(f.triggeredOnce){return}else{f.triggeredOnce=true}}if(u.changed){const n=event.target;const r=n.value;const o=f.lastValue.get(u);if(o.has(n)&&o.get(n)===r){return}o.set(n,r)}if(f.delayed){clearTimeout(f.delayed)}if(f.throttle){return}if(u.throttle>0){if(!f.throttle){he(l,"htmx:trigger");c(l,e);f.throttle=E().setTimeout(function(){f.throttle=null},u.throttle)}}else if(u.delay>0){f.delayed=E().setTimeout(function(){he(l,"htmx:trigger");c(l,e)},u.delay)}else{he(l,"htmx:trigger");c(l,e)}}};if(e.listenerInfos==null){e.listenerInfos=[]}e.listenerInfos.push({trigger:u.trigger,listener:s,on:i});i.addEventListener(u.trigger,s)})}let mt=false;let xt=null;function yt(){if(!xt){xt=function(){mt=true};window.addEventListener("scroll",xt);window.addEventListener("resize",xt);setInterval(function(){if(mt){mt=false;se(ne().querySelectorAll("[hx-trigger*='revealed'],[data-hx-trigger*='revealed']"),function(e){bt(e)})}},200)}}function bt(e){if(!s(e,"data-hx-revealed")&&X(e)){e.setAttribute("data-hx-revealed","true");const t=ie(e);if(t.initHash){he(e,"revealed")}else{e.addEventListener("htmx:afterProcessNode",function(){he(e,"revealed")},{once:true})}}}function vt(e,t,n,r){const o=function(){if(!n.loaded){n.loaded=true;he(e,"htmx:trigger");t(e)}};if(r>0){E().setTimeout(o,r)}else{o()}}function wt(t,n,e){let i=false;se(r,function(r){if(s(t,"hx-"+r)){const o=te(t,"hx-"+r);i=true;n.path=o;n.verb=r;e.forEach(function(e){St(t,e,n,function(e,t){const n=ue(e);if(g(n,Q.config.disableSelector)){b(n);return}de(r,o,n,t)})})}});return i}function St(r,e,t,n){if(e.trigger==="revealed"){yt();pt(r,n,t,e);bt(ue(r))}else if(e.trigger==="intersect"){const o={};if(e.root){o.root=ae(r,e.root)}if(e.threshold){o.threshold=parseFloat(e.threshold)}const i=new IntersectionObserver(function(t){for(let e=0;e0){t.polling=true;ct(ue(r),n,e)}else{pt(r,n,t,e)}}function Et(e){const t=ue(e);if(!t){return false}const n=t.attributes;for(let e=0;e", "+e).join(""));return o}else{return[]}}function Tt(e){const t=g(ue(e.target),"button, input[type='submit']");const n=Lt(e);if(n){n.lastButtonClicked=t}}function qt(e){const t=Lt(e);if(t){t.lastButtonClicked=null}}function Lt(e){const t=g(ue(e.target),"button, input[type='submit']");if(!t){return}const n=y("#"+ee(t,"form"),t.getRootNode())||g(t,"form");if(!n){return}return ie(n)}function At(e){e.addEventListener("click",Tt);e.addEventListener("focusin",Tt);e.addEventListener("focusout",qt)}function Nt(t,e,n){const r=ie(t);if(!Array.isArray(r.onHandlers)){r.onHandlers=[]}let o;const i=function(e){vn(t,function(){if(at(t)){return}if(!o){o=new Function("event",n)}o.call(t,e)})};t.addEventListener(e,i);r.onHandlers.push({event:e,listener:i})}function It(t){ke(t);for(let e=0;eQ.config.historyCacheSize){i.shift()}while(i.length>0){try{localStorage.setItem("htmx-history-cache",JSON.stringify(i));break}catch(e){fe(ne().body,"htmx:historyCacheError",{cause:e,cache:i});i.shift()}}}function Vt(t){if(!B()){return null}t=U(t);const n=S(localStorage.getItem("htmx-history-cache"))||[];for(let e=0;e=200&&this.status<400){he(ne().body,"htmx:historyCacheMissLoad",i);const e=P(this.response);const t=e.querySelector("[hx-history-elt],[data-hx-history-elt]")||e;const n=Ut();const r=xn(n);kn(e.title);qe(e);Ve(n,t,r);Te();Kt(r.tasks);Bt=o;he(ne().body,"htmx:historyRestore",{path:o,cacheMiss:true,serverResponse:this.response})}else{fe(ne().body,"htmx:historyCacheMissLoadError",i)}};e.send()}function Wt(e){zt();e=e||location.pathname+location.search;const t=Vt(e);if(t){const n=P(t.content);const r=Ut();const o=xn(r);kn(t.title);qe(n);Ve(r,n,o);Te();Kt(o.tasks);E().setTimeout(function(){window.scrollTo(0,t.scroll)},0);Bt=e;he(ne().body,"htmx:historyRestore",{path:e,item:t})}else{if(Q.config.refreshOnHistoryMiss){window.location.reload(true)}else{Gt(e)}}}function Zt(e){let t=we(e,"hx-indicator");if(t==null){t=[e]}se(t,function(e){const t=ie(e);t.requestCount=(t.requestCount||0)+1;e.classList.add.call(e.classList,Q.config.requestClass)});return t}function Yt(e){let t=we(e,"hx-disabled-elt");if(t==null){t=[]}se(t,function(e){const t=ie(e);t.requestCount=(t.requestCount||0)+1;e.setAttribute("disabled","");e.setAttribute("data-disabled-by-htmx","")});return t}function Qt(e,t){se(e.concat(t),function(e){const t=ie(e);t.requestCount=(t.requestCount||1)-1});se(e,function(e){const t=ie(e);if(t.requestCount===0){e.classList.remove.call(e.classList,Q.config.requestClass)}});se(t,function(e){const t=ie(e);if(t.requestCount===0){e.removeAttribute("disabled");e.removeAttribute("data-disabled-by-htmx")}})}function en(t,n){for(let e=0;en.indexOf(e)<0)}else{e=e.filter(e=>e!==n)}r.delete(t);se(e,e=>r.append(t,e))}}function on(t,n,r,o,i){if(o==null||en(t,o)){return}else{t.push(o)}if(tn(o)){const s=ee(o,"name");let e=o.value;if(o instanceof HTMLSelectElement&&o.multiple){e=M(o.querySelectorAll("option:checked")).map(function(e){return e.value})}if(o instanceof HTMLInputElement&&o.files){e=M(o.files)}nn(s,e,n);if(i){sn(o,r)}}if(o instanceof HTMLFormElement){se(o.elements,function(e){if(t.indexOf(e)>=0){rn(e.name,e.value,n)}else{t.push(e)}if(i){sn(e,r)}});new FormData(o).forEach(function(e,t){if(e instanceof File&&e.name===""){return}nn(t,e,n)})}}function sn(e,t){const n=e;if(n.willValidate){he(n,"htmx:validation:validate");if(!n.checkValidity()){t.push({elt:n,message:n.validationMessage,validity:n.validity});he(n,"htmx:validation:failed",{message:n.validationMessage,validity:n.validity})}}}function ln(n,e){for(const t of e.keys()){n.delete(t)}e.forEach(function(e,t){n.append(t,e)});return n}function cn(e,t){const n=[];const r=new FormData;const o=new FormData;const i=[];const s=ie(e);if(s.lastButtonClicked&&!le(s.lastButtonClicked)){s.lastButtonClicked=null}let l=e instanceof HTMLFormElement&&e.noValidate!==true||te(e,"hx-validate")==="true";if(s.lastButtonClicked){l=l&&s.lastButtonClicked.formNoValidate!==true}if(t!=="get"){on(n,o,i,g(e,"form"),l)}on(n,r,i,e,l);if(s.lastButtonClicked||e.tagName==="BUTTON"||e.tagName==="INPUT"&&ee(e,"type")==="submit"){const u=s.lastButtonClicked||e;const a=ee(u,"name");nn(a,u.value,o)}const c=we(e,"hx-include");se(c,function(e){on(n,r,i,ue(e),l);if(!h(e,"form")){se(f(e).querySelectorAll(ot),function(e){on(n,r,i,e,l)})}});ln(r,o);return{errors:i,formData:r,values:An(r)}}function un(e,t,n){if(e!==""){e+="&"}if(String(n)==="[object Object]"){n=JSON.stringify(n)}const r=encodeURIComponent(n);e+=encodeURIComponent(t)+"="+r;return e}function an(e){e=qn(e);let n="";e.forEach(function(e,t){n=un(n,t,e)});return n}function fn(e,t,n){const r={"HX-Request":"true","HX-Trigger":ee(e,"id"),"HX-Trigger-Name":ee(e,"name"),"HX-Target":te(t,"id"),"HX-Current-URL":ne().location.href};bn(e,"hx-headers",false,r);if(n!==undefined){r["HX-Prompt"]=n}if(ie(e).boosted){r["HX-Boosted"]="true"}return r}function hn(n,e){const t=re(e,"hx-params");if(t){if(t==="none"){return new FormData}else if(t==="*"){return n}else if(t.indexOf("not ")===0){se(t.slice(4).split(","),function(e){e=e.trim();n.delete(e)});return n}else{const r=new FormData;se(t.split(","),function(t){t=t.trim();if(n.has(t)){n.getAll(t).forEach(function(e){r.append(t,e)})}});return r}}else{return n}}function dn(e){return!!ee(e,"href")&&ee(e,"href").indexOf("#")>=0}function gn(e,t){const n=t||re(e,"hx-swap");const r={swapStyle:ie(e).boosted?"innerHTML":Q.config.defaultSwapStyle,swapDelay:Q.config.defaultSwapDelay,settleDelay:Q.config.defaultSettleDelay};if(Q.config.scrollIntoViewOnBoost&&ie(e).boosted&&!dn(e)){r.show="top"}if(n){const s=F(n);if(s.length>0){for(let e=0;e0?o.join(":"):null;r.scroll=u;r.scrollTarget=i}else if(l.indexOf("show:")===0){const a=l.slice(5);var o=a.split(":");const f=o.pop();var i=o.length>0?o.join(":"):null;r.show=f;r.showTarget=i}else if(l.indexOf("focus-scroll:")===0){const h=l.slice("focus-scroll:".length);r.focusScroll=h=="true"}else if(e==0){r.swapStyle=l}else{O("Unknown modifier in hx-swap: "+l)}}}}return r}function pn(e){return re(e,"hx-encoding")==="multipart/form-data"||h(e,"form")&&ee(e,"enctype")==="multipart/form-data"}function mn(t,n,r){let o=null;Ft(n,function(e){if(o==null){o=e.encodeParameters(t,r,n)}});if(o!=null){return o}else{if(pn(n)){return ln(new FormData,qn(r))}else{return an(r)}}}function xn(e){return{tasks:[],elts:[e]}}function yn(e,t){const n=e[0];const r=e[e.length-1];if(t.scroll){var o=null;if(t.scrollTarget){o=ue(ae(n,t.scrollTarget))}if(t.scroll==="top"&&(n||o)){o=o||n;o.scrollTop=0}if(t.scroll==="bottom"&&(r||o)){o=o||r;o.scrollTop=o.scrollHeight}}if(t.show){var o=null;if(t.showTarget){let e=t.showTarget;if(t.showTarget==="window"){e="body"}o=ue(ae(n,e))}if(t.show==="top"&&(n||o)){o=o||n;o.scrollIntoView({block:"start",behavior:Q.config.scrollBehavior})}if(t.show==="bottom"&&(r||o)){o=o||r;o.scrollIntoView({block:"end",behavior:Q.config.scrollBehavior})}}}function bn(r,e,o,i){if(i==null){i={}}if(r==null){return i}const s=te(r,e);if(s){let e=s.trim();let t=o;if(e==="unset"){return null}if(e.indexOf("javascript:")===0){e=e.slice(11);t=true}else if(e.indexOf("js:")===0){e=e.slice(3);t=true}if(e.indexOf("{")!==0){e="{"+e+"}"}let n;if(t){n=vn(r,function(){return Function("return ("+e+")")()},{})}else{n=S(e)}for(const l in n){if(n.hasOwnProperty(l)){if(i[l]==null){i[l]=n[l]}}}}return bn(ue(c(r)),e,o,i)}function vn(e,t,n){if(Q.config.allowEval){return t()}else{fe(e,"htmx:evalDisallowedError");return n}}function wn(e,t){return bn(e,"hx-vars",true,t)}function Sn(e,t){return bn(e,"hx-vals",false,t)}function En(e){return ce(wn(e),Sn(e))}function Cn(t,n,r){if(r!==null){try{t.setRequestHeader(n,r)}catch(e){t.setRequestHeader(n,encodeURIComponent(r));t.setRequestHeader(n+"-URI-AutoEncoded","true")}}}function On(t){if(t.responseURL&&typeof URL!=="undefined"){try{const e=new URL(t.responseURL);return e.pathname+e.search}catch(e){fe(ne().body,"htmx:badResponseUrl",{url:t.responseURL})}}}function R(e,t){return t.test(e.getAllResponseHeaders())}function Rn(t,n,r){t=t.toLowerCase();if(r){if(r instanceof Element||typeof r==="string"){return de(t,n,null,null,{targetOverride:y(r)||ve,returnPromise:true})}else{let e=y(r.target);if(r.target&&!e||r.source&&!e&&!y(r.source)){e=ve}return de(t,n,y(r.source),r.event,{handler:r.handler,headers:r.headers,values:r.values,targetOverride:e,swapOverride:r.swap,select:r.select,returnPromise:true})}}else{return de(t,n,null,null,{returnPromise:true})}}function Hn(e){const t=[];while(e){t.push(e);e=e.parentElement}return t}function Tn(e,t,n){let r;let o;if(typeof URL==="function"){o=new URL(t,document.location.href);const i=document.location.origin;r=i===o.origin}else{o=t;r=l(t,document.location.origin)}if(Q.config.selfRequestsOnly){if(!r){return false}}return he(e,"htmx:validateUrl",ce({url:o,sameHost:r},n))}function qn(e){if(e instanceof FormData)return e;const t=new FormData;for(const n in e){if(e.hasOwnProperty(n)){if(e[n]&&typeof e[n].forEach==="function"){e[n].forEach(function(e){t.append(n,e)})}else if(typeof e[n]==="object"&&!(e[n]instanceof Blob)){t.append(n,JSON.stringify(e[n]))}else{t.append(n,e[n])}}}return t}function Ln(r,o,e){return new Proxy(e,{get:function(t,e){if(typeof e==="number")return t[e];if(e==="length")return t.length;if(e==="push"){return function(e){t.push(e);r.append(o,e)}}if(typeof t[e]==="function"){return function(){t[e].apply(t,arguments);r.delete(o);t.forEach(function(e){r.append(o,e)})}}if(t[e]&&t[e].length===1){return t[e][0]}else{return t[e]}},set:function(e,t,n){e[t]=n;r.delete(o);e.forEach(function(e){r.append(o,e)});return true}})}function An(o){return new Proxy(o,{get:function(e,t){if(typeof t==="symbol"){const r=Reflect.get(e,t);if(typeof r==="function"){return function(){return r.apply(o,arguments)}}else{return r}}if(t==="toJSON"){return()=>Object.fromEntries(o)}if(t in e){if(typeof e[t]==="function"){return function(){return o[t].apply(o,arguments)}}else{return e[t]}}const n=o.getAll(t);if(n.length===0){return undefined}else if(n.length===1){return n[0]}else{return Ln(e,t,n)}},set:function(t,n,e){if(typeof n!=="string"){return false}t.delete(n);if(e&&typeof e.forEach==="function"){e.forEach(function(e){t.append(n,e)})}else if(typeof e==="object"&&!(e instanceof Blob)){t.append(n,JSON.stringify(e))}else{t.append(n,e)}return true},deleteProperty:function(e,t){if(typeof t==="string"){e.delete(t)}return true},ownKeys:function(e){return Reflect.ownKeys(Object.fromEntries(e))},getOwnPropertyDescriptor:function(e,t){return Reflect.getOwnPropertyDescriptor(Object.fromEntries(e),t)}})}function de(t,n,r,o,i,D){let s=null;let l=null;i=i!=null?i:{};if(i.returnPromise&&typeof Promise!=="undefined"){var e=new Promise(function(e,t){s=e;l=t})}if(r==null){r=ne().body}const M=i.handler||Dn;const X=i.select||null;if(!le(r)){oe(s);return e}const c=i.targetOverride||ue(Ee(r));if(c==null||c==ve){fe(r,"htmx:targetError",{target:te(r,"hx-target")});oe(l);return e}let u=ie(r);const a=u.lastButtonClicked;if(a){const L=ee(a,"formaction");if(L!=null){n=L}const A=ee(a,"formmethod");if(A!=null){if(A.toLowerCase()!=="dialog"){t=A}}}const f=re(r,"hx-confirm");if(D===undefined){const K=function(e){return de(t,n,r,o,i,!!e)};const G={target:c,elt:r,path:n,verb:t,triggeringEvent:o,etc:i,issueRequest:K,question:f};if(he(r,"htmx:confirm",G)===false){oe(s);return e}}let h=r;let d=re(r,"hx-sync");let g=null;let F=false;if(d){const N=d.split(":");const I=N[0].trim();if(I==="this"){h=Se(r,"hx-sync")}else{h=ue(ae(r,I))}d=(N[1]||"drop").trim();u=ie(h);if(d==="drop"&&u.xhr&&u.abortable!==true){oe(s);return e}else if(d==="abort"){if(u.xhr){oe(s);return e}else{F=true}}else if(d==="replace"){he(h,"htmx:abort")}else if(d.indexOf("queue")===0){const W=d.split(" ");g=(W[1]||"last").trim()}}if(u.xhr){if(u.abortable){he(h,"htmx:abort")}else{if(g==null){if(o){const P=ie(o);if(P&&P.triggerSpec&&P.triggerSpec.queue){g=P.triggerSpec.queue}}if(g==null){g="last"}}if(u.queuedRequests==null){u.queuedRequests=[]}if(g==="first"&&u.queuedRequests.length===0){u.queuedRequests.push(function(){de(t,n,r,o,i)})}else if(g==="all"){u.queuedRequests.push(function(){de(t,n,r,o,i)})}else if(g==="last"){u.queuedRequests=[];u.queuedRequests.push(function(){de(t,n,r,o,i)})}oe(s);return e}}const p=new XMLHttpRequest;u.xhr=p;u.abortable=F;const m=function(){u.xhr=null;u.abortable=false;if(u.queuedRequests!=null&&u.queuedRequests.length>0){const e=u.queuedRequests.shift();e()}};const B=re(r,"hx-prompt");if(B){var x=prompt(B);if(x===null||!he(r,"htmx:prompt",{prompt:x,target:c})){oe(s);m();return e}}if(f&&!D){if(!confirm(f)){oe(s);m();return e}}let y=fn(r,c,x);if(t!=="get"&&!pn(r)){y["Content-Type"]="application/x-www-form-urlencoded"}if(i.headers){y=ce(y,i.headers)}const U=cn(r,t);let b=U.errors;const j=U.formData;if(i.values){ln(j,qn(i.values))}const V=qn(En(r));const v=ln(j,V);let w=hn(v,r);if(Q.config.getCacheBusterParam&&t==="get"){w.set("org.htmx.cache-buster",ee(c,"id")||"true")}if(n==null||n===""){n=ne().location.href}const S=bn(r,"hx-request");const _=ie(r).boosted;let E=Q.config.methodsThatUseUrlParams.indexOf(t)>=0;const C={boosted:_,useUrlParams:E,formData:w,parameters:An(w),unfilteredFormData:v,unfilteredParameters:An(v),headers:y,target:c,verb:t,errors:b,withCredentials:i.credentials||S.credentials||Q.config.withCredentials,timeout:i.timeout||S.timeout||Q.config.timeout,path:n,triggeringEvent:o};if(!he(r,"htmx:configRequest",C)){oe(s);m();return e}n=C.path;t=C.verb;y=C.headers;w=qn(C.parameters);b=C.errors;E=C.useUrlParams;if(b&&b.length>0){he(r,"htmx:validation:halted",C);oe(s);m();return e}const z=n.split("#");const $=z[0];const O=z[1];let R=n;if(E){R=$;const Z=!w.keys().next().done;if(Z){if(R.indexOf("?")<0){R+="?"}else{R+="&"}R+=an(w);if(O){R+="#"+O}}}if(!Tn(r,R,C)){fe(r,"htmx:invalidPath",C);oe(l);return e}p.open(t.toUpperCase(),R,true);p.overrideMimeType("text/html");p.withCredentials=C.withCredentials;p.timeout=C.timeout;if(S.noHeaders){}else{for(const k in y){if(y.hasOwnProperty(k)){const Y=y[k];Cn(p,k,Y)}}}const H={xhr:p,target:c,requestConfig:C,etc:i,boosted:_,select:X,pathInfo:{requestPath:n,finalRequestPath:R,responsePath:null,anchor:O}};p.onload=function(){try{const t=Hn(r);H.pathInfo.responsePath=On(p);M(r,H);if(H.keepIndicators!==true){Qt(T,q)}he(r,"htmx:afterRequest",H);he(r,"htmx:afterOnLoad",H);if(!le(r)){let e=null;while(t.length>0&&e==null){const n=t.shift();if(le(n)){e=n}}if(e){he(e,"htmx:afterRequest",H);he(e,"htmx:afterOnLoad",H)}}oe(s);m()}catch(e){fe(r,"htmx:onLoadError",ce({error:e},H));throw e}};p.onerror=function(){Qt(T,q);fe(r,"htmx:afterRequest",H);fe(r,"htmx:sendError",H);oe(l);m()};p.onabort=function(){Qt(T,q);fe(r,"htmx:afterRequest",H);fe(r,"htmx:sendAbort",H);oe(l);m()};p.ontimeout=function(){Qt(T,q);fe(r,"htmx:afterRequest",H);fe(r,"htmx:timeout",H);oe(l);m()};if(!he(r,"htmx:beforeRequest",H)){oe(s);m();return e}var T=Zt(r);var q=Yt(r);se(["loadstart","loadend","progress","abort"],function(t){se([p,p.upload],function(e){e.addEventListener(t,function(e){he(r,"htmx:xhr:"+t,{lengthComputable:e.lengthComputable,loaded:e.loaded,total:e.total})})})});he(r,"htmx:beforeSend",H);const J=E?null:mn(p,r,w);p.send(J);return e}function Nn(e,t){const n=t.xhr;let r=null;let o=null;if(R(n,/HX-Push:/i)){r=n.getResponseHeader("HX-Push");o="push"}else if(R(n,/HX-Push-Url:/i)){r=n.getResponseHeader("HX-Push-Url");o="push"}else if(R(n,/HX-Replace-Url:/i)){r=n.getResponseHeader("HX-Replace-Url");o="replace"}if(r){if(r==="false"){return{}}else{return{type:o,path:r}}}const i=t.pathInfo.finalRequestPath;const s=t.pathInfo.responsePath;const l=re(e,"hx-push-url");const c=re(e,"hx-replace-url");const u=ie(e).boosted;let a=null;let f=null;if(l){a="push";f=l}else if(c){a="replace";f=c}else if(u){a="push";f=s||i}if(f){if(f==="false"){return{}}if(f==="true"){f=s||i}if(t.pathInfo.anchor&&f.indexOf("#")===-1){f=f+"#"+t.pathInfo.anchor}return{type:a,path:f}}else{return{}}}function In(e,t){var n=new RegExp(e.code);return n.test(t.toString(10))}function Pn(e){for(var t=0;t0){E().setTimeout(e,x.swapDelay)}else{e()}}if(f){fe(o,"htmx:responseError",ce({error:"Response Status Error Code "+s.status+" from "+i.pathInfo.requestPath},i))}}const Mn={};function Xn(){return{init:function(e){return null},getSelectors:function(){return null},onEvent:function(e,t){return true},transformResponse:function(e,t,n){return e},isInlineSwap:function(e){return false},handleSwap:function(e,t,n,r){return false},encodeParameters:function(e,t,n){return null}}}function Fn(e,t){if(t.init){t.init(n)}Mn[e]=ce(Xn(),t)}function Bn(e){delete Mn[e]}function Un(e,n,r){if(n==undefined){n=[]}if(e==undefined){return n}if(r==undefined){r=[]}const t=te(e,"hx-ext");if(t){se(t.split(","),function(e){e=e.replace(/ /g,"");if(e.slice(0,7)=="ignore:"){r.push(e.slice(7));return}if(r.indexOf(e)<0){const t=Mn[e];if(t&&n.indexOf(t)<0){n.push(t)}}})}return Un(ue(c(e)),n,r)}var jn=false;ne().addEventListener("DOMContentLoaded",function(){jn=true});function Vn(e){if(jn||ne().readyState==="complete"){e()}else{ne().addEventListener("DOMContentLoaded",e)}}function _n(){if(Q.config.includeIndicatorStyles!==false){const e=Q.config.inlineStyleNonce?` nonce="${Q.config.inlineStyleNonce}"`:"";ne().head.insertAdjacentHTML("beforeend"," ."+Q.config.indicatorClass+"{opacity:0} ."+Q.config.requestClass+" ."+Q.config.indicatorClass+"{opacity:1; transition: opacity 200ms ease-in;} ."+Q.config.requestClass+"."+Q.config.indicatorClass+"{opacity:1; transition: opacity 200ms ease-in;} ")}}function zn(){const e=ne().querySelector('meta[name="htmx-config"]');if(e){return S(e.content)}else{return null}}function $n(){const e=zn();if(e){Q.config=ce(Q.config,e)}}Vn(function(){$n();_n();let e=ne().body;kt(e);const t=ne().querySelectorAll("[hx-trigger='restored'],[data-hx-trigger='restored']");e.addEventListener("htmx:abort",function(e){const t=e.target;const n=ie(t);if(n&&n.xhr){n.xhr.abort()}});const n=window.onpopstate?window.onpopstate.bind(window):null;window.onpopstate=function(e){if(e.state&&e.state.htmx){Wt();se(t,function(e){he(e,"htmx:restored",{document:ne(),triggerEvent:he})})}else{if(n){n(e)}}};E().setTimeout(function(){he(e,"htmx:load",{});e=null},0)});return Q}(); \ No newline at end of file diff --git a/templates/_entry_edit.html b/templates/_entry_edit.html new file mode 100644 index 0000000..7a5e5bb --- /dev/null +++ b/templates/_entry_edit.html @@ -0,0 +1,19 @@ + + +
+ + {% if e.running() %} + en cours + {% else %} + + {% endif %} +
+ + + + + + + + + diff --git a/templates/_entry_row.html b/templates/_entry_row.html new file mode 100644 index 0000000..11707a9 --- /dev/null +++ b/templates/_entry_row.html @@ -0,0 +1,14 @@ + + {{ e.day() }} + + {{ e.start_time() }} – {{ e.end_time() }} + {% if e.overlaps %}⚠{% endif %} + + {{ e.client_name }} / {{ e.project_name }} + {{ e.note }} + {{ e.duration() }} + + + + + diff --git a/templates/_presets.html b/templates/_presets.html new file mode 100644 index 0000000..2295321 --- /dev/null +++ b/templates/_presets.html @@ -0,0 +1,5 @@ +
+ {% for p in presets %} + {{ p.label }} + {% endfor %} +
diff --git a/templates/_project_select.html b/templates/_project_select.html new file mode 100644 index 0000000..850cb55 --- /dev/null +++ b/templates/_project_select.html @@ -0,0 +1,5 @@ +{% for g in groups %} + + {% for p in g.projects %}{% endfor %} + +{% endfor %} diff --git a/templates/_timer.html b/templates/_timer.html new file mode 100644 index 0000000..6d722b7 --- /dev/null +++ b/templates/_timer.html @@ -0,0 +1,22 @@ +
+ {% if let Some(e) = running %} +
+
+
{{ e.client_name }}
+
{{ e.project_name }}
+ {% if !e.note.is_empty() %}
{{ e.note }}
{% endif %} +
+
{{ e.duration() }}
+ +
+ {% endif %} + {% if groups.is_empty() %} +

Aucun projet actif. Crée un client et un projet pour commencer.

+ {% else %} +
+ + + +
+ {% endif %} +
diff --git a/templates/_today.html b/templates/_today.html new file mode 100644 index 0000000..287872e --- /dev/null +++ b/templates/_today.html @@ -0,0 +1,24 @@ +
+
+

Aujourd'hui

+ {{ today_total }} +
+ {% if today_entries.is_empty() %} +

Rien de saisi pour l'instant.

+ {% else %} + + + {% for e in today_entries %} + + + + + + {% endfor %} + +
{{ e.start_time() }} – {{ e.end_time() }} + {{ e.client_name }} / {{ e.project_name }} + {% if !e.note.is_empty() %}
{{ e.note }}
{% endif %} +
{{ e.duration() }}
+ {% endif %} +
diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..514faa0 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,26 @@ + + + + + + {% block title %}Tempus{% endblock %} · Tempus + + + + + +
+ Tempus + +
+
+ {% block content %}{% endblock %} +
+ + + diff --git a/templates/clients.html b/templates/clients.html new file mode 100644 index 0000000..f077d5e --- /dev/null +++ b/templates/clients.html @@ -0,0 +1,70 @@ +{% extends "base.html" %} +{% block title %}Clients{% endblock %} +{% block content %} +
+

Nouveau client

+
+ + + +
+
+ +{% if clients.is_empty() %} +

Aucun client pour l'instant.

+{% endif %} + +{% for c in clients %} +
+
+
+ + + +
+
+ {% if c.client.archived %}archivé{% endif %} +
+ + +
+
+ +
+
+
+ +
    + {% for p in c.projects %} + +
    + + + + {% if p.color.is_some() %} + + {% endif %} +
    +
    + {% if p.archived %}archivé{% endif %} +
    + + +
    +
    + +
    +
    + + {% endfor %} +
+ +
+ + + +
+
+{% endfor %} +{% endblock %} diff --git a/templates/dashboard.html b/templates/dashboard.html new file mode 100644 index 0000000..837555d --- /dev/null +++ b/templates/dashboard.html @@ -0,0 +1,6 @@ +{% extends "base.html" %} +{% block title %}Aujourd'hui{% endblock %} +{% block content %} +{% include "_timer.html" %} +{% include "_today.html" %} +{% endblock %} diff --git a/templates/entries.html b/templates/entries.html new file mode 100644 index 0000000..da90dcf --- /dev/null +++ b/templates/entries.html @@ -0,0 +1,56 @@ +{% extends "base.html" %} +{% block title %}Entrées{% endblock %} +{% block content %} +
+

Ajouter du temps

+ {% if groups.is_empty() %} +

Aucun projet actif. Crée un client et un projet d'abord.

+ {% else %} +
+ + + + + +
+ {% endif %} +
+ +
+
+

Entrées

+ {{ total }} +
+ {% include "_presets.html" %} +
+ + + + + +
+ + {% if entries.is_empty() %} +

Aucune entrée sur cette période.

+ {% else %} +
+ + + + {% for e in entries %}{% include "_entry_row.html" %}{% endfor %} + +
JourHoraireProjetNoteDurée
+
+ {% endif %} +
+{% endblock %} diff --git a/templates/error.html b/templates/error.html new file mode 100644 index 0000000..1f05fda --- /dev/null +++ b/templates/error.html @@ -0,0 +1,9 @@ +{% extends "base.html" %} +{% block title %}Erreur{% endblock %} +{% block content %} +
+

Oups

+

{{ message }}

+

← Retour

+
+{% endblock %} diff --git a/templates/reports.html b/templates/reports.html new file mode 100644 index 0000000..f28d298 --- /dev/null +++ b/templates/reports.html @@ -0,0 +1,44 @@ +{% extends "base.html" %} +{% block title %}Rapports{% endblock %} +{% block content %} +
+
+

Rapport

+ {{ report.total() }} +
+ {% include "_presets.html" %} +
+ + + + + +
+ + {% if report.rows.is_empty() %} +

Aucun temps sur cette période.

+ {% else %} + + + {% for r in report.rows %} + + + + + + {% endfor %} + + + + +
{% if let Some(c) = r.color %}{% endif %}{{ r.label }}
{{ r.duration() }}
Total{{ report.total() }}
+ {% endif %} +
+{% endblock %} diff --git a/tests/api.rs b/tests/api.rs new file mode 100644 index 0000000..185539d --- /dev/null +++ b/tests/api.rs @@ -0,0 +1,594 @@ +use axum::Router; +use axum::body::Body; +use axum::http::{Request, StatusCode, header}; +use chrono::{Local, NaiveDate, TimeZone}; +use http_body_util::BodyExt; +use serde_json::{Value, json}; +use tower::ServiceExt; + +async fn app() -> Router { + let pool = tempus::db::connect("sqlite::memory:").await.unwrap(); + tempus::routes::app(pool) +} + +async fn send(app: &Router, method: &str, uri: &str, body: Option) -> (StatusCode, Value) { + let mut req = Request::builder().method(method).uri(uri); + let body = match body { + Some(v) => { + req = req.header(header::CONTENT_TYPE, "application/json"); + Body::from(v.to_string()) + } + None => Body::empty(), + }; + let resp = app.clone().oneshot(req.body(body).unwrap()).await.unwrap(); + let status = resp.status(); + let bytes = resp.into_body().collect().await.unwrap().to_bytes(); + let value = serde_json::from_slice(&bytes).unwrap_or(Value::Null); + (status, value) +} + +async fn send_form(app: &Router, uri: &str, form: &str) -> (StatusCode, String) { + let req = Request::post(uri) + .header(header::CONTENT_TYPE, "application/x-www-form-urlencoded") + .body(Body::from(form.to_owned())) + .unwrap(); + let resp = app.clone().oneshot(req).await.unwrap(); + let status = resp.status(); + let bytes = resp.into_body().collect().await.unwrap().to_bytes(); + (status, String::from_utf8(bytes.to_vec()).unwrap()) +} + +async fn get_html(app: &Router, uri: &str) -> (StatusCode, String) { + let resp = app + .clone() + .oneshot(Request::get(uri).body(Body::empty()).unwrap()) + .await + .unwrap(); + let status = resp.status(); + let bytes = resp.into_body().collect().await.unwrap().to_bytes(); + (status, String::from_utf8(bytes.to_vec()).unwrap()) +} + +/// Local wall-clock time as RFC3339 with offset. +fn local(y: i32, m: u32, d: u32, h: u32, min: u32) -> String { + Local + .from_local_datetime( + &NaiveDate::from_ymd_opt(y, m, d) + .unwrap() + .and_hms_opt(h, min, 0) + .unwrap(), + ) + .earliest() + .unwrap() + .to_rfc3339() +} + +/// Creates a client with one project; returns the project id. +async fn project(app: &Router, client: &str, name: &str) -> i64 { + let (_, c) = send(app, "POST", "/api/clients", Some(json!({ "name": client }))).await; + let (status, p) = send( + app, + "POST", + &format!("/api/clients/{}/projects", c["id"]), + Some(json!({ "name": name })), + ) + .await; + assert_eq!(status, StatusCode::CREATED); + p["id"].as_i64().unwrap() +} + +async fn add_entry( + app: &Router, + project_id: i64, + start: String, + end: String, +) -> (StatusCode, Value) { + send( + app, + "POST", + "/api/entries", + Some(json!({ "project_id": project_id, "started_at": start, "ended_at": end })), + ) + .await +} + +#[tokio::test] +async fn clients_and_projects_crud() { + let app = app().await; + + let (status, client) = send( + &app, + "POST", + "/api/clients", + Some(json!({ "name": " Acme " })), + ) + .await; + assert_eq!(status, StatusCode::CREATED); + assert_eq!(client["name"], "Acme"); + let id = client["id"].as_i64().unwrap(); + + let (status, _) = send( + &app, + "POST", + "/api/clients", + Some(json!({ "name": "Acme" })), + ) + .await; + assert_eq!(status, StatusCode::CONFLICT); + let (status, _) = send(&app, "POST", "/api/clients", Some(json!({ "name": " " }))).await; + assert_eq!(status, StatusCode::UNPROCESSABLE_ENTITY); + + let (status, p) = send( + &app, + "POST", + &format!("/api/clients/{id}/projects"), + Some(json!({ "name": "Site web" })), + ) + .await; + assert_eq!(status, StatusCode::CREATED); + assert_eq!(p["client_name"], "Acme"); + let (status, _) = send( + &app, + "POST", + "/api/clients/999/projects", + Some(json!({ "name": "X" })), + ) + .await; + assert_eq!(status, StatusCode::NOT_FOUND); + + let (status, c) = send( + &app, + "PATCH", + &format!("/api/clients/{id}"), + Some(json!({ "name": "Acme Corp", "archived": true })), + ) + .await; + assert_eq!(status, StatusCode::OK); + assert_eq!(c["name"], "Acme Corp"); + assert_eq!(c["archived"], true); + + let (_, list) = send(&app, "GET", "/api/clients", None).await; + assert_eq!(list.as_array().unwrap().len(), 0); + let (_, list) = send(&app, "GET", "/api/clients?archived=true", None).await; + assert_eq!(list.as_array().unwrap().len(), 1); + + // Tracking on a project of an archived client is refused. + let (status, _) = send( + &app, + "POST", + "/api/timer/start", + Some(json!({ "project_id": p["id"] })), + ) + .await; + assert_eq!(status, StatusCode::UNPROCESSABLE_ENTITY); + + let (status, _) = send(&app, "DELETE", &format!("/api/clients/{id}"), None).await; + assert_eq!(status, StatusCode::NO_CONTENT); + let (status, _) = send(&app, "DELETE", &format!("/api/projects/{}", p["id"]), None).await; + assert_eq!( + status, + StatusCode::NOT_FOUND, + "projects are deleted with their client" + ); +} + +#[tokio::test] +async fn timer_start_switch_stop() { + let app = app().await; + let site = project(&app, "Acme", "Site").await; + let api = project(&app, "Globex", "API").await; + + let (status, timer) = send(&app, "GET", "/api/timer", None).await; + assert_eq!(status, StatusCode::OK); + assert!(timer.is_null()); + + let (status, first) = send( + &app, + "POST", + "/api/timer/start", + Some(json!({ "project_id": site, "note": "maquettes" })), + ) + .await; + assert_eq!(status, StatusCode::CREATED); + assert!(first["ended_at"].is_null()); + + // Backdate it so switching leaves a non-empty entry. + let hour_ago = (chrono::Utc::now() - chrono::Duration::hours(1)).to_rfc3339(); + let (status, _) = send( + &app, + "PATCH", + &format!("/api/entries/{}", first["id"]), + Some(json!({ "started_at": hour_ago })), + ) + .await; + assert_eq!(status, StatusCode::OK); + + let (_, second) = send( + &app, + "POST", + "/api/timer/start", + Some(json!({ "project_id": api })), + ) + .await; + let (_, timer) = send(&app, "GET", "/api/timer", None).await; + assert_eq!(timer["id"], second["id"]); + assert_eq!(timer["client_name"], "Globex"); + + let (_, entries) = send(&app, "GET", "/api/entries", None).await; + let first = entries + .as_array() + .unwrap() + .iter() + .find(|e| e["id"] == first["id"]) + .unwrap(); + assert!( + !first["ended_at"].is_null(), + "switching stops the previous timer" + ); + assert!((3599..=3601).contains(&first["seconds"].as_i64().unwrap())); + assert_eq!(first["note"], "maquettes"); + + // Same-second stop discards the empty entry; either way nothing runs afterwards. + send(&app, "POST", "/api/timer/stop", None).await; + let (_, timer) = send(&app, "GET", "/api/timer", None).await; + assert!(timer.is_null()); + let (status, _) = send(&app, "POST", "/api/timer/stop", None).await; + assert_eq!(status, StatusCode::CONFLICT); +} + +#[tokio::test] +async fn manual_entries() { + let app = app().await; + let p = project(&app, "Acme", "Site").await; + + let (status, e) = add_entry( + &app, + p, + local(2026, 3, 10, 9, 0), + local(2026, 3, 10, 11, 30), + ) + .await; + assert_eq!(status, StatusCode::CREATED); + assert_eq!(e["seconds"], 9000); + assert_eq!(e["overlaps"], false); + + let (status, _) = add_entry( + &app, + p, + local(2026, 3, 10, 12, 0), + local(2026, 3, 10, 11, 0), + ) + .await; + assert_eq!(status, StatusCode::UNPROCESSABLE_ENTITY); + let (status, _) = add_entry( + &app, + 999, + local(2026, 3, 10, 12, 0), + local(2026, 3, 10, 13, 0), + ) + .await; + assert_eq!(status, StatusCode::UNPROCESSABLE_ENTITY); + + let (status, o) = add_entry( + &app, + p, + local(2026, 3, 10, 11, 0), + local(2026, 3, 10, 12, 0), + ) + .await; + assert_eq!(status, StatusCode::CREATED); + assert_eq!(o["overlaps"], true, "overlaps are allowed but flagged"); + + let (status, o) = send( + &app, + "PATCH", + &format!("/api/entries/{}", o["id"]), + Some(json!({ "started_at": local(2026, 3, 10, 11, 30), "note": "revue" })), + ) + .await; + assert_eq!(status, StatusCode::OK); + assert_eq!(o["overlaps"], false); + assert_eq!(o["seconds"], 1800); + assert_eq!(o["note"], "revue"); + + let (_, list) = send( + &app, + "GET", + "/api/entries?from=2026-03-10&to=2026-03-10", + None, + ) + .await; + assert_eq!(list.as_array().unwrap().len(), 2); + let (_, list) = send(&app, "GET", "/api/entries?from=2026-03-11", None).await; + assert_eq!(list.as_array().unwrap().len(), 0); + + let (status, _) = send(&app, "DELETE", &format!("/api/entries/{}", o["id"]), None).await; + assert_eq!(status, StatusCode::NO_CONTENT); + let (status, _) = send(&app, "DELETE", &format!("/api/entries/{}", o["id"]), None).await; + assert_eq!(status, StatusCode::NOT_FOUND); +} + +#[tokio::test] +async fn reports_clip_and_group() { + let app = app().await; + let site = project(&app, "Acme", "Site").await; + let api = project(&app, "Globex", "API").await; + + // 22:00 → 02:00 across the 10th and 11th. + add_entry( + &app, + site, + local(2026, 3, 10, 22, 0), + local(2026, 3, 11, 2, 0), + ) + .await; + add_entry( + &app, + api, + local(2026, 3, 11, 9, 0), + local(2026, 3, 11, 10, 30), + ) + .await; + // Outside the period. + add_entry( + &app, + api, + local(2026, 3, 20, 9, 0), + local(2026, 3, 20, 17, 0), + ) + .await; + + let (status, r) = send( + &app, + "GET", + "/api/reports?from=2026-03-11&to=2026-03-11&group_by=client", + None, + ) + .await; + assert_eq!(status, StatusCode::OK); + assert_eq!( + r["total_seconds"], + 2 * 3600 + 5400, + "clipped at the period start" + ); + let rows = r["rows"].as_array().unwrap(); + assert_eq!(rows[0]["label"], "Acme"); + assert_eq!(rows[0]["seconds"], 7200); + assert_eq!(rows[0]["percent"], 100); + assert_eq!(rows[1]["label"], "Globex"); + assert_eq!(rows[1]["percent"], 75); + + let (_, r) = send( + &app, + "GET", + "/api/reports?from=2026-03-10&to=2026-03-12&group_by=day", + None, + ) + .await; + let days: Vec<(String, i64)> = r["rows"] + .as_array() + .unwrap() + .iter() + .map(|row| { + ( + row["key"].as_str().unwrap().to_owned(), + row["seconds"].as_i64().unwrap(), + ) + }) + .collect(); + assert_eq!( + days, + vec![ + ("2026-03-10".into(), 7200), + ("2026-03-11".into(), 7200 + 5400), + ("2026-03-12".into(), 0), + ] + ); + + let (_, r) = send( + &app, + "GET", + &format!("/api/reports?from=2026-03-01&to=2026-03-31&project_id={api}"), + None, + ) + .await; + assert_eq!(r["total_seconds"], 5400 + 8 * 3600); + assert_eq!(r["rows"][0]["label"], "Globex / API"); + + let (status, _) = send( + &app, + "GET", + "/api/reports?from=2026-03-12&to=2026-03-11", + None, + ) + .await; + assert_eq!(status, StatusCode::UNPROCESSABLE_ENTITY); +} + +#[tokio::test] +async fn html_pages() { + let app = app().await; + + let (status, _) = send_form(&app, "/ui/clients", "name=Acme").await; + assert_eq!(status, StatusCode::SEE_OTHER); + let (status, _) = send_form(&app, "/ui/clients/1/projects", "name=Site+web").await; + assert_eq!(status, StatusCode::SEE_OTHER); + let (status, html) = send_form(&app, "/ui/clients", "name=Acme").await; + assert_eq!(status, StatusCode::CONFLICT); + assert!(html.contains("id=\"error-message\"")); + + let (status, html) = get_html(&app, "/clients").await; + assert_eq!(status, StatusCode::OK); + assert!(html.contains("Site web")); + + let (status, html) = send_form(&app, "/ui/timer/start", "project_id=1¬e=d%C3%A9mo").await; + assert_eq!(status, StatusCode::OK); + assert!(html.contains("Arrêter") && html.contains("démo")); + + let (status, html) = get_html(&app, "/").await; + assert_eq!(status, StatusCode::OK); + assert!(html.contains("data-started")); + + let (status, _) = send_form( + &app, + "/ui/entries", + "project_id=1&started_at=2026-03-10T09%3A00&ended_at=2026-03-10T10%3A15¬e=", + ) + .await; + assert_eq!(status, StatusCode::SEE_OTHER); + let (status, html) = get_html(&app, "/entries?from=2026-03-09&to=2026-03-15&client_id=").await; + assert_eq!(status, StatusCode::OK); + assert!(html.contains("1:15")); + + let (status, html) = + get_html(&app, "/reports?from=2026-03-01&to=2026-03-31&group_by=day").await; + assert_eq!(status, StatusCode::OK); + assert!(html.contains("1:15") && html.contains("mar. 10/03/2026")); +} + +#[tokio::test] +async fn colors() { + let app = app().await; + + // Palette colors are handed out in order; an explicit color wins. + let (_, a) = send(&app, "POST", "/api/clients", Some(json!({ "name": "A" }))).await; + let (_, b) = send(&app, "POST", "/api/clients", Some(json!({ "name": "B" }))).await; + assert_eq!(a["color"], tempus::repo::PALETTE[0]); + assert_eq!(b["color"], tempus::repo::PALETTE[1]); + let (status, c) = send( + &app, + "POST", + "/api/clients", + Some(json!({ "name": "C", "color": "#FF0000" })), + ) + .await; + assert_eq!(status, StatusCode::CREATED); + assert_eq!(c["color"], "#ff0000"); + + for bad in [json!("red"), json!("#12345"), json!("#gggggg"), Value::Null] { + let (status, _) = send( + &app, + "PATCH", + &format!("/api/clients/{}", a["id"]), + Some(json!({ "color": bad })), + ) + .await; + assert_eq!(status, StatusCode::UNPROCESSABLE_ENTITY, "{bad}"); + } + + // Projects inherit their client's color until they get their own. + let (_, p) = send( + &app, + "POST", + &format!("/api/clients/{}/projects", a["id"]), + Some(json!({ "name": "Site" })), + ) + .await; + assert!(p["color"].is_null()); + assert_eq!(p["effective_color"], a["color"]); + + let (_, a2) = send( + &app, + "PATCH", + &format!("/api/clients/{}", a["id"]), + Some(json!({ "color": "#000000" })), + ) + .await; + assert_eq!(a2["name"], "A", "other fields are untouched"); + let (_, list) = send( + &app, + "GET", + &format!("/api/clients/{}/projects", a["id"]), + None, + ) + .await; + assert_eq!(list[0]["effective_color"], "#000000"); + + let uri = format!("/api/projects/{}", p["id"]); + let (_, p) = send(&app, "PATCH", &uri, Some(json!({ "color": "#00ff00" }))).await; + assert_eq!(p["effective_color"], "#00ff00"); + let (_, p) = send(&app, "PATCH", &uri, Some(json!({ "name": "Site web" }))).await; + assert_eq!(p["color"], "#00ff00", "absent color is left unchanged"); + + // Entries and reports carry the colors. + add_entry( + &app, + p["id"].as_i64().unwrap(), + local(2026, 3, 10, 9, 0), + local(2026, 3, 10, 10, 0), + ) + .await; + let (_, entries) = send(&app, "GET", "/api/entries", None).await; + assert_eq!(entries[0]["color"], "#00ff00"); + assert_eq!(entries[0]["client_color"], "#000000"); + let (_, r) = send( + &app, + "GET", + "/api/reports?from=2026-03-10&to=2026-03-10&group_by=client", + None, + ) + .await; + assert_eq!(r["rows"][0]["color"], "#000000"); + let (_, r) = send( + &app, + "GET", + "/api/reports?from=2026-03-10&to=2026-03-10&group_by=day", + None, + ) + .await; + assert!(r["rows"][0]["color"].is_null()); + + let (_, p) = send(&app, "PATCH", &uri, Some(json!({ "color": null }))).await; + assert!(p["color"].is_null()); + assert_eq!(p["effective_color"], "#000000"); + + // HTML forms: an untouched picker keeps inheriting, "↺" resets. + let id = p["id"].as_i64().unwrap(); + let (status, _) = send_form( + &app, + &format!("/ui/projects/{id}"), + "name=Site&color=%23000000", + ) + .await; + assert_eq!(status, StatusCode::SEE_OTHER); + let (_, list) = send( + &app, + "GET", + &format!("/api/clients/{}/projects", a["id"]), + None, + ) + .await; + assert!(list[0]["color"].is_null()); + send_form( + &app, + &format!("/ui/projects/{id}"), + "name=Site&color=%23123456", + ) + .await; + let (_, list) = send( + &app, + "GET", + &format!("/api/clients/{}/projects", a["id"]), + None, + ) + .await; + assert_eq!(list[0]["color"], "#123456"); + send_form( + &app, + &format!("/ui/projects/{id}"), + "name=Site&color=%23123456&inherit=true", + ) + .await; + let (_, list) = send( + &app, + "GET", + &format!("/api/clients/{}/projects", a["id"]), + None, + ) + .await; + assert!(list[0]["color"].is_null()); + + let (status, html) = get_html(&app, "/clients").await; + assert_eq!(status, StatusCode::OK); + assert!(html.contains("--color: #000000")); +}