From 6e99d9dd8826008d8494c55cd25fdcb8283d7c8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=9F=D0=BE=D0=BB?= =?UTF-8?q?=D0=B5=D0=B2=D0=BE=D0=B9?= Date: Sun, 14 May 2023 22:32:01 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A4=D1=80=D0=BE=D0=BD=D1=82=D0=B5=D0=BD?= =?UTF-8?q?=D0=B4:=20=D0=9E=D0=BD=D0=BE=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/Cargo.lock | 1142 ---------------------------- frontend/Cargo.toml | 13 - frontend/app.py | 423 +++++++++++ frontend/index.html | 8 - frontend/requirements.txt | Bin 0 -> 450 bytes frontend/src/components/app.rs | 16 - frontend/src/components/header.rs | 51 -- frontend/src/components/mod.rs | 3 - frontend/src/components/router.rs | 82 -- frontend/src/lib.rs | 2 - frontend/src/main.rs | 5 - frontend/src/models/car.rs | 20 - frontend/src/models/car_station.rs | 12 - frontend/src/models/client.rs | 18 - frontend/src/models/mod.rs | 4 - frontend/src/models/rent.rs | 17 - frontend/templates/admin.html | 18 + frontend/templates/base.html | 36 + frontend/templates/cars.html | 74 ++ frontend/templates/clients.html | 59 ++ frontend/templates/login.html | 24 + frontend/templates/owners.html | 91 +++ frontend/templates/rent.html | 34 + frontend/templates/rents.html | 109 +++ frontend/templates/report.html | 23 + 25 files changed, 891 insertions(+), 1393 deletions(-) delete mode 100644 frontend/Cargo.lock delete mode 100644 frontend/Cargo.toml create mode 100644 frontend/app.py delete mode 100644 frontend/index.html create mode 100644 frontend/requirements.txt delete mode 100644 frontend/src/components/app.rs delete mode 100644 frontend/src/components/header.rs delete mode 100644 frontend/src/components/mod.rs delete mode 100644 frontend/src/components/router.rs delete mode 100644 frontend/src/lib.rs delete mode 100644 frontend/src/main.rs delete mode 100644 frontend/src/models/car.rs delete mode 100644 frontend/src/models/car_station.rs delete mode 100644 frontend/src/models/client.rs delete mode 100644 frontend/src/models/mod.rs delete mode 100644 frontend/src/models/rent.rs create mode 100644 frontend/templates/admin.html create mode 100644 frontend/templates/base.html create mode 100644 frontend/templates/cars.html create mode 100644 frontend/templates/clients.html create mode 100644 frontend/templates/login.html create mode 100644 frontend/templates/owners.html create mode 100644 frontend/templates/rent.html create mode 100644 frontend/templates/rents.html create mode 100644 frontend/templates/report.html diff --git a/frontend/Cargo.lock b/frontend/Cargo.lock deleted file mode 100644 index 91213aa..0000000 --- a/frontend/Cargo.lock +++ /dev/null @@ -1,1142 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - -[[package]] -name = "anymap2" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d301b3b94cb4b2f23d7917810addbbaff90738e0ca2be692bd027e70d7e0330c" - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", -] - -[[package]] -name = "boolinator" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfa8873f51c92e232f9bac4065cddef41b714152812bfc5f7672ba16d6ef8cd9" - -[[package]] -name = "bumpalo" -version = "3.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" - -[[package]] -name = "cc" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "chrono" -version = "0.4.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" -dependencies = [ - "iana-time-zone", - "js-sys", - "num-integer", - "num-traits", - "serde", - "time", - "wasm-bindgen", - "winapi", -] - -[[package]] -name = "codespan-reporting" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" -dependencies = [ - "termcolor", - "unicode-width", -] - -[[package]] -name = "console_error_panic_hook" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" -dependencies = [ - "cfg-if", - "wasm-bindgen", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" - -[[package]] -name = "cxx" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93" -dependencies = [ - "cc", - "cxxbridge-flags", - "cxxbridge-macro", - "link-cplusplus", -] - -[[package]] -name = "cxx-build" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b" -dependencies = [ - "cc", - "codespan-reporting", - "once_cell", - "proc-macro2", - "quote", - "scratch", - "syn 2.0.13", -] - -[[package]] -name = "cxxbridge-flags" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb" - -[[package]] -name = "cxxbridge-macro" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.13", -] - -[[package]] -name = "form_urlencoded" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" -dependencies = [ - "percent-encoding", -] - -[[package]] -name = "frontend" -version = "0.1.0" -dependencies = [ - "chrono", - "serde", - "serde_json", - "yew", - "yew-router", -] - -[[package]] -name = "futures" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" - -[[package]] -name = "futures-io" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" - -[[package]] -name = "futures-macro" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.13", -] - -[[package]] -name = "futures-sink" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" - -[[package]] -name = "futures-task" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" - -[[package]] -name = "futures-util" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite", - "pin-utils", - "slab", -] - -[[package]] -name = "gloo" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a4bef6b277b3ab073253d4bca60761240cf8d6998f4bd142211957b69a61b20" -dependencies = [ - "gloo-console", - "gloo-dialogs", - "gloo-events", - "gloo-file", - "gloo-history", - "gloo-net", - "gloo-render", - "gloo-storage", - "gloo-timers", - "gloo-utils", - "gloo-worker", -] - -[[package]] -name = "gloo-console" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82b7ce3c05debe147233596904981848862b068862e9ec3e34be446077190d3f" -dependencies = [ - "gloo-utils", - "js-sys", - "serde", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "gloo-dialogs" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67062364ac72d27f08445a46cab428188e2e224ec9e37efdba48ae8c289002e6" -dependencies = [ - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "gloo-events" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b107f8abed8105e4182de63845afcc7b69c098b7852a813ea7462a320992fc" -dependencies = [ - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "gloo-file" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8d5564e570a38b43d78bdc063374a0c3098c4f0d64005b12f9bbe87e869b6d7" -dependencies = [ - "futures-channel", - "gloo-events", - "js-sys", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "gloo-history" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd451019e0b7a2b8a7a7b23e74916601abf1135c54664e57ff71dcc26dfcdeb7" -dependencies = [ - "gloo-events", - "gloo-utils", - "serde", - "serde-wasm-bindgen", - "serde_urlencoded", - "thiserror", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "gloo-net" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9902a044653b26b99f7e3693a42f171312d9be8b26b5697bd1e43ad1f8a35e10" -dependencies = [ - "futures-channel", - "futures-core", - "futures-sink", - "gloo-utils", - "js-sys", - "pin-project", - "serde", - "serde_json", - "thiserror", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - -[[package]] -name = "gloo-render" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fd9306aef67cfd4449823aadcd14e3958e0800aa2183955a309112a84ec7764" -dependencies = [ - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "gloo-storage" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6ab60bf5dbfd6f0ed1f7843da31b41010515c745735c970e821945ca91e480" -dependencies = [ - "gloo-utils", - "js-sys", - "serde", - "serde_json", - "thiserror", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "gloo-timers" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" -dependencies = [ - "futures-channel", - "futures-core", - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "gloo-utils" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8e8fc851e9c7b9852508bc6e3f690f452f474417e8545ec9857b7f7377036b5" -dependencies = [ - "js-sys", - "serde", - "serde_json", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "gloo-worker" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13471584da78061a28306d1359dd0178d8d6fc1c7c80e5e35d27260346e0516a" -dependencies = [ - "anymap2", - "bincode", - "gloo-console", - "gloo-utils", - "js-sys", - "serde", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "hermit-abi" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] - -[[package]] -name = "iana-time-zone" -version = "0.1.54" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c17cc76786e99f8d2f055c11159e7f0091c42474dcc3189fbab96072e873e6d" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "windows", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" -dependencies = [ - "cxx", - "cxx-build", -] - -[[package]] -name = "implicit-clone" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40fc102e70475c320b185cd18c1e48bba2d7210b63970a4d581ef903e4368ef7" -dependencies = [ - "indexmap", -] - -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown", -] - -[[package]] -name = "itoa" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" - -[[package]] -name = "js-sys" -version = "0.3.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "libc" -version = "0.2.140" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" - -[[package]] -name = "link-cplusplus" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" -dependencies = [ - "cc", -] - -[[package]] -name = "log" -version = "0.4.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" -dependencies = [ - "autocfg", -] - -[[package]] -name = "num_cpus" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "once_cell" -version = "1.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" - -[[package]] -name = "percent-encoding" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" - -[[package]] -name = "pin-project" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "pinned" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a829027bd95e54cfe13e3e258a1ae7b645960553fb82b75ff852c29688ee595b" -dependencies = [ - "futures", - "rustversion", - "thiserror", -] - -[[package]] -name = "prettyplease" -version = "0.1.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" -dependencies = [ - "proc-macro2", - "syn 1.0.109", -] - -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - -[[package]] -name = "proc-macro2" -version = "1.0.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d0dd4be24fcdcfeaa12a432d588dc59bbad6cad3510c67e74a2b6b2fc950564" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "prokio" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b55e106e5791fa5a13abd13c85d6127312e8e09098059ca2bc9b03ca4cf488" -dependencies = [ - "futures", - "gloo", - "num_cpus", - "once_cell", - "pin-project", - "pinned", - "tokio", - "tokio-stream", - "wasm-bindgen-futures", -] - -[[package]] -name = "quote" -version = "1.0.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "route-recognizer" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afab94fb28594581f62d981211a9a4d53cc8130bbcbbb89a0440d9b8e81a7746" - -[[package]] -name = "rustversion" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" - -[[package]] -name = "ryu" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" - -[[package]] -name = "scratch" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" - -[[package]] -name = "serde" -version = "1.0.159" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c04e8343c3daeec41f58990b9d77068df31209f2af111e059e9fe9646693065" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde-wasm-bindgen" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b4c031cd0d9014307d82b8abf653c0290fbdaeb4c02d00c63cf52f728628bf" -dependencies = [ - "js-sys", - "serde", - "wasm-bindgen", -] - -[[package]] -name = "serde_derive" -version = "1.0.159" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c614d17805b093df4b147b51339e7e44bf05ef59fba1e45d83500bcfb4d8585" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.13", -] - -[[package]] -name = "serde_json" -version = "1.0.95" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d721eca97ac802aa7777b701877c8004d950fc142651367300d21c1cc0194744" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[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 = "slab" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" -dependencies = [ - "autocfg", -] - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c9da457c5285ac1f936ebd076af6dac17a61cfe7826f2076b4d015cf47bc8ec" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "termcolor" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "thiserror" -version = "1.0.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.13", -] - -[[package]] -name = "time" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi", - "winapi", -] - -[[package]] -name = "tokio" -version = "1.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001" -dependencies = [ - "autocfg", - "pin-project-lite", - "windows-sys", -] - -[[package]] -name = "tokio-stream" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313" -dependencies = [ - "futures-core", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "tracing" -version = "0.1.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" -dependencies = [ - "cfg-if", - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "tracing-core" -version = "0.1.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" -dependencies = [ - "once_cell", -] - -[[package]] -name = "unicode-ident" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" - -[[package]] -name = "unicode-width" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - -[[package]] -name = "wasm-bindgen" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn 1.0.109", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" - -[[package]] -name = "web-sys" -version = "0.3.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdacb41e6a96a052c6cb63a144f24900236121c6f63f4f8219fef5977ecb0c25" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -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.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - -[[package]] -name = "yew" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dbecfe44343b70cc2932c3eb445425969ae21754a8ab3a0966981c1cf7af1cc" -dependencies = [ - "console_error_panic_hook", - "futures", - "gloo", - "implicit-clone", - "indexmap", - "js-sys", - "prokio", - "rustversion", - "serde", - "slab", - "thiserror", - "tokio", - "tracing", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "yew-macro", -] - -[[package]] -name = "yew-macro" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b64c253c1d401f1ea868ca9988db63958cfa15a69f739101f338d6f05eea8301" -dependencies = [ - "boolinator", - "once_cell", - "prettyplease", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "yew-router" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "426ee0486d2572a6c5e39fbdbc48b58d59bb555f3326f54631025266cf04146e" -dependencies = [ - "gloo", - "js-sys", - "route-recognizer", - "serde", - "serde_urlencoded", - "tracing", - "wasm-bindgen", - "web-sys", - "yew", - "yew-router-macro", -] - -[[package]] -name = "yew-router-macro" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b249cdb39e0cddaf0644dedc781854524374664793479fdc01e6a65d6e6ae3" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] diff --git a/frontend/Cargo.toml b/frontend/Cargo.toml deleted file mode 100644 index 5246bba..0000000 --- a/frontend/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "frontend" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -yew = { version = "0.20.0", features = ["csr"] } -chrono = { version = "0.4.24", features = ["serde"] } -serde_json = "1.0" -serde = { version = "1.0.159", features = ["derive"] } -yew-router = "0.17" \ No newline at end of file diff --git a/frontend/app.py b/frontend/app.py new file mode 100644 index 0000000..72e406e --- /dev/null +++ b/frontend/app.py @@ -0,0 +1,423 @@ +from flask import Flask, request, render_template, session, redirect, url_for +import requests + +app = Flask(__name__) +app.secret_key = 'Kill me already' + + +@app.route('/login', methods=['GET', 'POST']) +def login(): + if request.method == 'POST': + if not request.form.get('username') or not request.form.get('password'): + return render_template('login.html', title='Авторизация', errors='Необходимо заполнить все поля', + logged_in=False) + + response = requests.post("http://localhost:8080/api/login", + json={ + 'username': request.form.get('username'), + 'password': request.form.get('password') + }) + + if response.status_code != 200: + return render_template('login.html', title='Авторизация', errors='Неверный логин или пароль', + logged_in=False) + + session['token'] = response.json()['token'] + session['administrator_id'] = response.json()['administrator_id'] + session['car_station_id'] = response.json()['car_station_id'] + + return redirect(url_for('rents')) + + return render_template('login.html', title='Авторизация', logged_in=False) + + +@app.route('/logout') +def logout(): + session.pop('token') + session.pop('administrator_id') + session.pop('car_station_id') + + requests.post('http://localhost:8080/api/logout') + + return redirect(url_for('login')) + + +@app.route('/rents', methods=['GET', 'POST']) +def rents(): + if not session['token']: + return redirect(url_for('login')) + + rents_data = requests.get('http://localhost:8080/api/rents/', headers={'Authorization': session['token']}).json() + cars = list( + filter(lambda c: c['car_station_id'] == session['car_station_id'], + requests.get('http://localhost:8080/api/cars/', headers={'Authorization': session['token']}).json() + ) + ) + clients = requests.get('http://localhost:8080/api/clients/', headers={'Authorization': session['token']}).json() + + for rent in rents_data: + from datetime import datetime + + date_format = '%Y-%m-%dT%H:%M:%S.%f' + + parsed_date = datetime.strptime(rent['start_time'], date_format) + rent['start_time'] = parsed_date.strftime('%Y-%m-%d %H:%M:%S') + + for car in cars: + if car['id'] == rent['car_id']: + rent['car'] = car + if not rent['time_amount']: + cars.remove(car) + break + for client in clients: + if client['id'] == rent['client_id']: + rent['client'] = client + break + + if request.method == 'POST': + if not request.form.get('id') and (not request.form.get('client_id') or not request.form.get('car_id')): + return render_template( + 'rents.html', + errors='Необходимо заполнить все поля', + title='Аренды', + rents=rents_data, + cars=cars, + clients=clients, + logged_in=True, + selected_client=int(request.args.get('client')) if request.args.get('client') else None, + selected_car=int(request.args.get('car')) if request.args.get('car') else None + ) + + response = None + if request.form.get('id'): + response = requests.get(f'http://localhost:8080/api/rents/{request.form.get("id")}/end', + headers={'Authorization': session['token']}) + else: + response = requests.post('http://localhost:8080/api/rents/', headers={'Authorization': session['token']}, json={ + "client_id": int(request.form.get('client_id')), + "car_id": int(request.form.get('car_id')) + }) + + if response.status_code != 200: + return render_template( + 'rents.html', + title='Аренды', + errors=response.json(), + rents=rents_data, + cars=cars, + clients=clients, + logged_in=True, + selected_client=int(request.args.get('client')) if request.args.get('client') else None, + selected_car=int(request.args.get('car')) if request.args.get('car') else None + ) + + if request.form.get('id'): + return redirect(url_for('rent', id=request.form.get('id'))) + + rents_data = requests.get('http://localhost:8080/api/rents/', + headers={'Authorization': session['token']}).json() + cars = list( + filter(lambda c: c['car_station_id'] == session['car_station_id'], + requests.get('http://localhost:8080/api/cars/', headers={'Authorization': session['token']}).json() + ) + ) + clients = requests.get('http://localhost:8080/api/clients/', headers={'Authorization': session['token']}).json() + + for rent in rents_data: + from datetime import datetime + + date_format = '%Y-%m-%dT%H:%M:%S.%f' + + parsed_date = datetime.strptime(rent['start_time'], date_format) + rent['start_time'] = parsed_date.strftime('%Y-%m-%d %H:%M:%S') + + for car in cars: + if car['id'] == rent['car_id']: + rent['car'] = car + if not rent['time_amount']: + cars.remove(car) + break + for client in clients: + if client['id'] == rent['client_id']: + rent['client'] = client + break + + return render_template( + 'rents.html', + title='Аренды', + rents=rents_data, + cars=cars, + clients=clients, + logged_in=True, + selected_client=int(request.args.get('client')) if request.args.get('client') else None, + selected_car=int(request.args.get('car')) if request.args.get('car') else None + ) + + +@app.route('/rents/', methods=['GET', 'POST']) +def rent(id): + if not session['token']: + return redirect(url_for('login')) + + rent = requests.get(f'http://localhost:8080/api/rents/{id}', headers={'Authorization': session['token']}).json() + client = requests.get(f'http://localhost:8080/api/clients/{rent["client_id"]}', headers={'Authorization': session['token']}).json() + car = requests.get(f'http://localhost:8080/api/cars/{rent["car_id"]}', headers={'Authorization': session['token']}).json() + + rent['client'] = client + rent['car'] = car + + from datetime import datetime + + date_format = '%Y-%m-%dT%H:%M:%S.%f' + + parsed_date = datetime.strptime(rent['start_time'], date_format) + rent['start_time'] = parsed_date.strftime('%Y-%m-%d %H:%M:%S') + + import math + return render_template('rent.html', title='Просмотр аренды', rent=rent, logged_in=True, float=float, int=int, math=math) + + +@app.route('/clients', defaults={'id': 0}, methods=['GET', 'POST']) +@app.route('/clients/', methods=['GET', 'POST']) +def clients(id): + if not session['token']: + return redirect(url_for('login')) + + clients = requests.get('http://localhost:8080/api/clients/', headers={'Authorization': session['token']}).json() + + if request.method == 'POST': + if id != 0: + if not request.form.get('name') or not request.form.get('surname') or not request.form.get('middlename') or not request.form.get('phone'): + return render_template( + 'clients.html', + title='Изменение клиента', + errors='Должны быть заполнены все поля!', + current_client=list(filter(lambda c: c['id'] == id, clients))[0], + clients=clients, + logged_in=True + ) + + response = requests.patch(f'http://localhost:8080/api/clients/{id}', headers={'Authorization': session['token']}, + json={ + 'name': request.form.get('name'), + 'surname': request.form.get('surname'), + 'middlename': request.form.get('middlename'), + 'phone': request.form.get('phone') + }) + + if response.status_code != 200: + return render_template( + 'clients.html', + title='Изменение клиента', + errors=response.json(), + clients=clients, + current_client=list(filter(lambda c: c['id'] == id, clients))[0], + logged_in=True + ) + + return redirect(url_for('clients')) + else: + if not request.form.get('name') or not request.form.get('surname') or not request.form.get('middlename') or not request.form.get('phone'): + return render_template('clients.html', title='Клиенты', errors='Должны быть заполнены все поля!', + clients=clients, logged_in=True) + + response = requests.post('http://localhost:8080/api/clients/', headers={'Authorization': session['token']}, + json={ + 'name': request.form.get('name'), + 'surname': request.form.get('surname'), + 'middlename': request.form.get('middlename'), + 'phone': request.form.get('phone') + }) + + if response.status_code != 200: + return render_template('clients.html', title='Клиенты', errors=response.json(), clients=clients, + logged_in=True) + + clients = requests.get('http://localhost:8080/api/clients/', headers={'Authorization': session['token']}).json() + + if id != 0: + return render_template('clients.html', title='Изменение клиента', clients=clients, logged_in=True, current_client=list(filter(lambda c: c['id'] == id, clients))[0]) + + return render_template('clients.html', title='Клиенты', clients=clients, logged_in=True) + + +@app.route('/owners', defaults={'id': 0}, methods=['GET', 'POST']) +@app.route('/owners/', methods=['GET', 'POST']) +def owners(id): + if not session['token']: + return redirect(url_for('login')) + + owners = requests.get('http://localhost:8080/api/owners/', headers={'Authorization': session['token']}).json() + cars = list( + filter(lambda c: c['car_station_id'] == session['car_station_id'], + requests.get('http://localhost:8080/api/cars/', headers={'Authorization': session['token']}).json() + ) + ) + + if request.method == 'POST': + if id != 0: + if not request.form.get('name') or not request.form.get('surname') or not request.form.get('middlename') or not request.form.get('phone'): + return render_template( + 'owners.html', + title='Изменение владельца', + errors='Должны быть заполнены все поля!', + current_owner=list(filter(lambda c: c['id'] == id, owners))[0], + owners=owners, + cars=cars, + logged_in=True + ) + + response = requests.patch(f'http://localhost:8080/api/owners/{id}', headers={'Authorization': session['token']}, + json={ + 'name': request.form.get('name'), + 'surname': request.form.get('surname'), + 'middlename': request.form.get('middlename'), + 'phone': request.form.get('phone') + }) + + if response.status_code != 200: + return render_template( + 'owners.html', + title='Изменение владельца', + errors=response.json(), + owners=owners, + cars=cars, + current_owner=list(filter(lambda c: c['id'] == id, owners))[0], + logged_in=True + ) + + return redirect(url_for('owners')) + else: + if not request.form.get('name') or not request.form.get('surname') or not request.form.get('middlename') or not request.form.get('phone'): + return render_template('owners.html', title='Владельцы', errors='Должны быть заполнены все поля!', + cars=cars, + owners=owners, logged_in=True) + + response = requests.post('http://localhost:8080/api/owners/', headers={'Authorization': session['token']}, + json={ + 'name': request.form.get('name'), + 'surname': request.form.get('surname'), + 'middlename': request.form.get('middlename'), + 'phone': request.form.get('phone') + }) + + if response.status_code != 200: + return render_template('owners.html', title='Владельцы', errors=response.json(), owners=owners, + cars=cars, + logged_in=True) + + owners = requests.get('http://localhost:8080/api/owners/', headers={'Authorization': session['token']}).json() + + if id != 0: + return render_template('owners.html', title='Изменение владельца', owners=owners, cars=cars, logged_in=True, current_owner=list(filter(lambda c: c['id'] == id, owners))[0]) + + return render_template('owners.html', title='Владельца', owners=owners, cars=cars, logged_in=True) + + +@app.route('/cars', defaults={'id': 0}, methods=['GET', 'POST']) +@app.route('/cars/', methods=['GET', 'POST']) +def cars(id): + if not session['token']: + return redirect(url_for('login')) + + owners = requests.get('http://localhost:8080/api/owners/', headers={'Authorization': session['token']}).json() + cars = list( + filter(lambda c: c['car_station_id'] == session['car_station_id'], + requests.get('http://localhost:8080/api/cars/', headers={'Authorization': session['token']}).json() + ) + ) + + if request.method == 'POST': + if id != 0: + if not request.form.get('brand') or not request.form.get('model') or not request.form.get('price') or not request.form.get('owner_id'): + return render_template( + 'cars.html', + title='Изменение автомобиля', + errors='Должны быть заполнены все поля!', + current_car=list(filter(lambda c: c['id'] == id, cars))[0], + cars=cars, + owners=owners, + logged_in=True, + selected_owner=int(request.args.get('owner')) if request.args.get('owner') else None + ) + + response = requests.patch(f'http://localhost:8080/api/cars/{id}', headers={'Authorization': session['token']}, + json={ + 'brand': request.form.get('brand'), + 'model': request.form.get('model'), + 'price': float(request.form.get('price')), + 'owner_id': int(request.form.get('owner_id')), + 'car_station_id': session['car_station_id'] + }) + + if response.status_code != 200: + return render_template( + 'cars.html', + title='Изменение автомобиля', + errors=response.json(), + cars=cars, + owners=owners, + current_car=list(filter(lambda c: c['id'] == id, cars))[0], + logged_in=True, + selected_owner=int(request.args.get('owner')) if request.args.get('owner') else None + ) + + return redirect(url_for('cars')) + else: + if not request.form.get('brand') or not request.form.get('model') or not request.form.get('price') or not request.form.get('owner_id'): + return render_template('cars.html', title='Автомобили', errors='Должны быть заполнены все поля!', + owners=owners, selected_owner=int(request.args.get('owner')) if request.args.get('owner') else None, + cars=cars, logged_in=True) + + response = requests.post('http://localhost:8080/api/cars/', headers={'Authorization': session['token']}, + json={ + 'brand': request.form.get('brand'), + 'model': request.form.get('model'), + 'price': float(request.form.get('price')), + 'owner_id': int(request.form.get('owner_id')), + 'car_station_id': session['car_station_id'] + }) + + if response.status_code != 200: + return render_template('cars.html', title='Автомобили', errors=response.json(), cars=cars, + owners=owners, selected_owner=int(request.args.get('owner')) if request.args.get('owner') else None, + logged_in=True) + + cars = requests.get('http://localhost:8080/api/cars/', headers={'Authorization': session['token']}).json() + + if id != 0: + return render_template('cars.html', title='Изменение автомобиля', cars=cars, logged_in=True, owners=owners, selected_owner=int(request.args.get('owner')) if request.args.get('owner') else None, current_car=list(filter(lambda c: c['id'] == id, cars))[0]) + + return render_template('cars.html', title='Автомобили', cars=cars, logged_in=True, owners=owners, selected_owner=int(request.args.get('owner')) if request.args.get('owner') else None) + + +@app.route('/report') +def report(): + if not session['token']: + return redirect(url_for('login')) + + response = requests.get('http://localhost:8080/api/cars/report', headers={'Authorization': session['token']}) + reports = list() + for report in response.json(): + report['income'] = float(report['income']) + reports.append(report) + + return render_template('report.html', title='Отчёт', reports=reports, logged_in=True) + + +@app.route('/admin', methods=['GET', 'POST']) +def admin(): + if not session['token']: + return redirect(url_for('login')) + + if request.method == 'POST': + response = requests.get('http://localhost:8080/benchmark', headers={'Authorization': session['token']}) + result = response.json() + + return render_template('admin.html', title='Панель администратора', logged_in=True, result=result) + + return render_template('admin.html', title='Панель администратора', logged_in=True) + + +if __name__ == '__main__': + app.run() diff --git a/frontend/index.html b/frontend/index.html deleted file mode 100644 index d5763a5..0000000 --- a/frontend/index.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - Каршеринг от Гуся - - \ No newline at end of file diff --git a/frontend/requirements.txt b/frontend/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..ee6a2b84728aebd3142b5e6e05971dd1bc556a75 GIT binary patch literal 450 zcmZXQyKcfj5Jhi|#HS=OwnJ!WQ$(VoNWDB93J*WB6L|3;Nc zU3Ai3jh6godexjsHPu90$6GW7V|=QF$xys8@4f1vfd7iR)eCtwUuQ5&{~NQ-W%)_( zGIq;u%U$$b)^jypO9`H1iUdW@%w6#TAJ`b(DY&J_)}?lI2%c+b?v9dfSC|0z?VW0M zAn~f$Ec!p`bHe*#H0l literal 0 HcmV?d00001 diff --git a/frontend/src/components/app.rs b/frontend/src/components/app.rs deleted file mode 100644 index 1671bde..0000000 --- a/frontend/src/components/app.rs +++ /dev/null @@ -1,16 +0,0 @@ -use yew::prelude::*; -use yew_router::{BrowserRouter, Switch}; -use super::router::*; - -#[function_component] -pub fn App() -> Html { - html! { -
-
- - render={switch} /> - -
-
- } -} \ No newline at end of file diff --git a/frontend/src/components/header.rs b/frontend/src/components/header.rs deleted file mode 100644 index cd71037..0000000 --- a/frontend/src/components/header.rs +++ /dev/null @@ -1,51 +0,0 @@ -use yew::prelude::*; -use yew_router::{prelude::use_navigator}; -use super::router::*; - -#[function_component] -pub fn Header() -> Html { - let navigator = use_navigator().unwrap(); - html! { - - } -} \ No newline at end of file diff --git a/frontend/src/components/mod.rs b/frontend/src/components/mod.rs deleted file mode 100644 index 0ee30ba..0000000 --- a/frontend/src/components/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod app; -pub mod header; -pub mod router; \ No newline at end of file diff --git a/frontend/src/components/router.rs b/frontend/src/components/router.rs deleted file mode 100644 index 5742fdc..0000000 --- a/frontend/src/components/router.rs +++ /dev/null @@ -1,82 +0,0 @@ -use yew::prelude::*; -use yew_router::prelude::*; -use super::header::Header; - -#[derive(Routable, PartialEq, Clone)] -pub enum Route { - #[at("/")] - Home, - - #[at("/cars/add")] - CarsAdd, - #[at("/cars/")] - CarsAll, - #[at("/cars/occupied")] - CarsOccupied, - #[at("/cars/free")] - CarsFree, - #[at("/cars/:id")] - CarView { id: u32 }, - - #[at("/owners/add")] - OwnersAdd, - #[at("/owners/")] - OwnersAll, - #[at("/owners/:id")] - OwnerView { id: u32 }, - - #[at("/clients/add")] - ClientsAdd, - #[at("/clients/")] - ClientsAll, - #[at("/clients/:id")] - ClientView { id: u32 }, - - #[at("/car_stations/add")] - CarStationsAdd, - #[at("/car_stations/")] - CarStationsAll, - #[at("/car_stations/:id")] - CarStationsView { id: u32 }, - - #[at("/rents/add")] - RentsAdd, - #[at("/rents/")] - RentsAll, - #[at("/rents/finished")] - RentsFinished, - #[at("/rents/ongoing")] - RentsOngoing, - #[at("/rents/:id")] - RentView { id: u32 }, -} - -pub fn switch(route: Route) -> Html { - match route { - Route::Home => html!{
}, - - Route::CarsAdd => html!{}, - Route::CarsAll => html!{}, - Route::CarsOccupied => html!{}, - Route::CarsFree => html!{}, - Route::CarView { id } => html!{}, - - Route::OwnersAdd => html!{}, - Route::OwnersAll => html!{}, - Route::OwnerView { id } => html!{}, - - Route::ClientsAdd => html!{}, - Route::ClientsAll => html!{}, - Route::ClientView { id } => html!{}, - - Route::CarStationsAdd => html!{}, - Route::CarStationsAll => html!{}, - Route::CarStationsView { id } => html!{}, - - Route::RentsAdd => html!{}, - Route::RentsAll => html!{}, - Route::RentsFinished => html!{}, - Route::RentsOngoing => html!{}, - Route::RentView { id } => html!{}, - } -} \ No newline at end of file diff --git a/frontend/src/lib.rs b/frontend/src/lib.rs deleted file mode 100644 index cb3e897..0000000 --- a/frontend/src/lib.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod models; -pub mod components; \ No newline at end of file diff --git a/frontend/src/main.rs b/frontend/src/main.rs deleted file mode 100644 index 273b42d..0000000 --- a/frontend/src/main.rs +++ /dev/null @@ -1,5 +0,0 @@ -mod components; - -fn main() { - yew::Renderer::::new().render(); -} diff --git a/frontend/src/models/car.rs b/frontend/src/models/car.rs deleted file mode 100644 index 211a734..0000000 --- a/frontend/src/models/car.rs +++ /dev/null @@ -1,20 +0,0 @@ -use serde::{ Serialize, Deserialize }; - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct Car { - pub id: i32, - pub brand: String, - pub model: String, - pub price: f64, - pub owner_id: i32, - pub car_station_id: i32 -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct BindingCar { - pub brand: String, - pub model: String, - pub price: f64, - pub owner_id: u32, - pub car_station_id: u32 -} \ No newline at end of file diff --git a/frontend/src/models/car_station.rs b/frontend/src/models/car_station.rs deleted file mode 100644 index 87f9238..0000000 --- a/frontend/src/models/car_station.rs +++ /dev/null @@ -1,12 +0,0 @@ -use serde::{ Serialize, Deserialize }; - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct CarStation { - pub id: i32, - pub address: String -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct BindingCarStation { - pub address: String -} \ No newline at end of file diff --git a/frontend/src/models/client.rs b/frontend/src/models/client.rs deleted file mode 100644 index 1fbeb4b..0000000 --- a/frontend/src/models/client.rs +++ /dev/null @@ -1,18 +0,0 @@ -use serde::{ Serialize, Deserialize }; - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct Client { - pub id: i32, - pub name: String, - pub surname: String, - pub middlename: Option, - pub phone: String -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct BindingClient { - pub name: String, - pub surname: String, - pub middlename: Option, - pub phone: String -} \ No newline at end of file diff --git a/frontend/src/models/mod.rs b/frontend/src/models/mod.rs deleted file mode 100644 index 66a08c9..0000000 --- a/frontend/src/models/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod car_station; -pub mod car; -pub mod client; -pub mod rent; \ No newline at end of file diff --git a/frontend/src/models/rent.rs b/frontend/src/models/rent.rs deleted file mode 100644 index faa8924..0000000 --- a/frontend/src/models/rent.rs +++ /dev/null @@ -1,17 +0,0 @@ -use serde::{Serialize, Deserialize}; - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct Rent { - pub id: i32, - pub start_time: chrono::NaiveDateTime, - pub time_amount: Option, - pub client_id: i32, - pub car_id: i32 -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct BindingRent { - pub time_amount: Option, - pub client_id: u32, - pub car_id: u32 -} \ No newline at end of file diff --git a/frontend/templates/admin.html b/frontend/templates/admin.html new file mode 100644 index 0000000..ebb9da8 --- /dev/null +++ b/frontend/templates/admin.html @@ -0,0 +1,18 @@ +{% extends 'base.html' %} + +{% block content %} +
+
+
+
+ +
+ {% if result %} + + {% endif %} +
+
+
+{% endblock %} \ No newline at end of file diff --git a/frontend/templates/base.html b/frontend/templates/base.html new file mode 100644 index 0000000..2a54b58 --- /dev/null +++ b/frontend/templates/base.html @@ -0,0 +1,36 @@ + + + + + {{ title }} + + + + + + + + +
+ {% if logged_in %} + + {% endif %} + + {% block content %} + {% endblock %} +
+ {% block script %} + {% endblock %} + + \ No newline at end of file diff --git a/frontend/templates/cars.html b/frontend/templates/cars.html new file mode 100644 index 0000000..6c7b2e0 --- /dev/null +++ b/frontend/templates/cars.html @@ -0,0 +1,74 @@ +{% extends "base.html" %} + +{% block content %} +
+
+
+

{% if current_car %} Просмотр автомобиля {% else %} Регистрация автомобиля {% endif %}

+ {% if errors %} + + {% endif %} +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+

Все автомобили на стоянке

+ + + + + + + + + {% for car in cars|sort(attribute="brand")|sort(attribute="model")|sort(attribute="price") %} + + + + + + + + {% endfor %} +
МаркаМодельЦенаВладелецДействия
{{ car.brand }}{{ car.model }}{{ car.price }}Перейти к владельцу + +
+
+
+{% endblock %} + +{% block script %} + +{% endblock %} \ No newline at end of file diff --git a/frontend/templates/clients.html b/frontend/templates/clients.html new file mode 100644 index 0000000..0d85302 --- /dev/null +++ b/frontend/templates/clients.html @@ -0,0 +1,59 @@ +{% extends "base.html" %} + +{% block content %} +
+
+
+

{% if current_client %} Просмотр клиента {% else %} Регистрация клиента {% endif %}

+ {% if errors %} + + {% endif %} +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+

Все клиенты

+ + + + + + + + + {% for client in clients|sort(attribute="surname")|sort(attribute="name")|sort(attribute="middlename") %} + + + + + + + + {% endfor %} +
Номер телефонаФамилияИмяОтчествоДействия
{{ client.phone }}{{ client.surname }}{{ client.name }}{{ client.middlename }} + +
+
+
+{% endblock %} \ No newline at end of file diff --git a/frontend/templates/login.html b/frontend/templates/login.html new file mode 100644 index 0000000..6440a5f --- /dev/null +++ b/frontend/templates/login.html @@ -0,0 +1,24 @@ +{% extends "base.html" %} + +{% block content %} +
+
+
+ {% if errors %} + + {% endif %} +
+ +
+
+ +
+
+ +
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/frontend/templates/owners.html b/frontend/templates/owners.html new file mode 100644 index 0000000..7c4cb6b --- /dev/null +++ b/frontend/templates/owners.html @@ -0,0 +1,91 @@ +{% extends "base.html" %} + +{% block content %} +
+
+
+

{% if current_owner %} Просмотр владельца {% else %} Регистрация владельца {% endif %}

+ {% if errors %} + + {% endif %} +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ {% if current_owner %} +
+
+

Автомобили владельца

+ + + + + + + + + {% for car in cars|sort(attribute="brand")|sort(attribute="model")|sort(attribute="price") %} + {% if car.owner_id == current_owner.id %} + + + + + + + + {% endif %} + {% endfor %} +
МаркаМодельЦенаВладелецДействия
{{ car.brand }}{{ car.model }}{{ car.price }}Перейти к владельцу + +
+
+
+ {% endif %} +
+
+

Все владельцы

+ + + + + + + + + {% for owner in owners|sort(attribute="surname")|sort(attribute="name")|sort(attribute="middlename") %} + + + + + + + + {% endfor %} +
Номер телефонаФамилияИмяОтчествоДействия
{{ owner.phone }}{{ owner.surname }}{{ owner.name }}{{ owner.middlename }} + +
+
+
+{% endblock %} \ No newline at end of file diff --git a/frontend/templates/rent.html b/frontend/templates/rent.html new file mode 100644 index 0000000..1a96e02 --- /dev/null +++ b/frontend/templates/rent.html @@ -0,0 +1,34 @@ +{% extends "base.html" %} + +{% block content %} +
+
+
+
+
+
+
+ Дата начала: {{ rent.start_time }} +
+
+ Номер телефона клиента: {{ rent.client.phone }} +
+ +
+ Автомобиль: {{ rent.car.brand }} {{ rent.car.model }} +
+
+ Количество минут: {{ rent.time_amount }} +
+
+ Итоговая стоимость: {{ math.ceil(float(rent.car.price) * int(rent.time_amount) * 100) / 100 }} +
+
+
+
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/frontend/templates/rents.html b/frontend/templates/rents.html new file mode 100644 index 0000000..0da53a4 --- /dev/null +++ b/frontend/templates/rents.html @@ -0,0 +1,109 @@ +{% extends 'base.html' %} + +{% block content %} +
+
+
+

Создание аренды

+ {% if errors %} + + {% endif %} +
+ +
+
+ +
+
+ +
+
+
+
+
+
+

Действительные аренды

+ + + + + + + + + + {% for rent in rents|sort(reverse=true, attribute="start_time") %} + {% if not rent.time_amount %} + + + + + + + + + {% endif %} + {% endfor %} +
Дата началаНомер телефона клиентаКлиентАвтомобильЦена за минутуДействия
{{ rent.start_time }}{{ rent.client.phone }}{{ rent.client.surname }} {{ rent.client.name }} {{ rent.client.middlename }}{{ rent.car.brand }} {{ rent.car.model }}{{ rent.car.price }} +
+ + +
+
+
+
+
+
+

Завершённые аренды

+ + + + + + + + + + {% for rent in rents|sort(reverse=true, attribute="start_time") %} + {% if rent.time_amount %} + + + + + + + + + {% endif %} + {% endfor %} +
Дата началаНомер телефона клиентаКлиентАвтомобильЦена за минутуДействия
{{ rent.start_time }}{{ rent.client.phone }}{{ rent.client.surname }} {{ rent.client.name }} {{ rent.client.middlename }}{{ rent.car.brand }} {{ rent.car.model }}{{ rent.car.price }} + Посмотреть +
+
+
+{% endblock %} + +{% block script %} + +{% endblock %} \ No newline at end of file diff --git a/frontend/templates/report.html b/frontend/templates/report.html new file mode 100644 index 0000000..df0cfd8 --- /dev/null +++ b/frontend/templates/report.html @@ -0,0 +1,23 @@ +{% extends 'base.html' %} + +{% block content %} +
+
+

Отчёт по машинам

+ + + + + + + {% for report in reports|sort(reverse=true, attribute="income") %} + + + + + + {% endfor %} +
АвтомобильВзят в аренду в этом месяце (раз)Доход с машины за этот месяц
{{ report.brand }} {{ report.model }}{{ report.times }} {{ report.income }}
+
+
+{% endblock %} \ No newline at end of file