From 9f43a1c04ca68126607e4a9e175ec13360db9e1e 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: Fri, 14 Apr 2023 21:29:53 +0400 Subject: [PATCH 1/2] =?UTF-8?q?=D0=A4=D1=80=D0=BE=D0=BD=D1=82=D0=B5=D0=BD?= =?UTF-8?q?=D0=B4:=20=D0=B7=D0=B0=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=B4=D0=BB=D1=8F=20=D0=B4=D0=B0=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D0=B5=D0=B9=D1=88=D0=B5=D0=B9=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 12 +- backend/src/endpoints/car.rs | 59 - backend/src/endpoints/car_station.rs | 59 - backend/src/endpoints/client.rs | 59 - backend/src/endpoints/mod.rs | 5 - backend/src/endpoints/owner.rs | 59 - backend/src/endpoints/rent.rs | 59 - backend/src/lib.rs | 15 - backend/src/main.rs | 98 -- backend/src/storages/mod.rs | 2 - backend/src/storages/postgres/car.rs | 113 -- backend/src/storages/postgres/car_station.rs | 96 -- backend/src/storages/postgres/client.rs | 111 -- backend/src/storages/postgres/mod.rs | 5 - backend/src/storages/postgres/owner.rs | 111 -- backend/src/storages/postgres/rent.rs | 117 -- backend/src/storages/traits.rs | 50 - {backend => frontend}/Cargo.lock | 1348 +++++------------ {backend => frontend}/Cargo.toml | 10 +- frontend/index.html | 8 + 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 + {backend => frontend}/src/models/car.rs | 2 +- .../src/models/car_station.rs | 2 +- {backend => frontend}/src/models/client.rs | 2 +- {backend => frontend}/src/models/mod.rs | 2 +- {backend => frontend}/src/models/rent.rs | 2 +- 31 files changed, 580 insertions(+), 1985 deletions(-) delete mode 100644 backend/src/endpoints/car.rs delete mode 100644 backend/src/endpoints/car_station.rs delete mode 100644 backend/src/endpoints/client.rs delete mode 100644 backend/src/endpoints/mod.rs delete mode 100644 backend/src/endpoints/owner.rs delete mode 100644 backend/src/endpoints/rent.rs delete mode 100644 backend/src/lib.rs delete mode 100644 backend/src/main.rs delete mode 100644 backend/src/storages/mod.rs delete mode 100644 backend/src/storages/postgres/car.rs delete mode 100644 backend/src/storages/postgres/car_station.rs delete mode 100644 backend/src/storages/postgres/client.rs delete mode 100644 backend/src/storages/postgres/mod.rs delete mode 100644 backend/src/storages/postgres/owner.rs delete mode 100644 backend/src/storages/postgres/rent.rs delete mode 100644 backend/src/storages/traits.rs rename {backend => frontend}/Cargo.lock (51%) rename {backend => frontend}/Cargo.toml (57%) create mode 100644 frontend/index.html create mode 100644 frontend/src/components/app.rs create mode 100644 frontend/src/components/header.rs create mode 100644 frontend/src/components/mod.rs create mode 100644 frontend/src/components/router.rs create mode 100644 frontend/src/lib.rs create mode 100644 frontend/src/main.rs rename {backend => frontend}/src/models/car.rs (90%) rename {backend => frontend}/src/models/car_station.rs (84%) rename {backend => frontend}/src/models/client.rs (90%) rename {backend => frontend}/src/models/mod.rs (79%) rename {backend => frontend}/src/models/rent.rs (88%) diff --git a/.gitignore b/.gitignore index 02d4c7e..902a5d5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,16 @@ # ---> Rust # Generated by Cargo # will have compiled files and executables -backend/debug/ -backend/target/ -backend/.env +frontend/debug/ +frontend/target/ +frontend/.env +frontend/dist # These are backup files generated by rustfmt **/*.rs.bk # MSVC Windows builds of rustc generate these, which store debugging information -backend/*.pdb +frontend/*.pdb + +.vscode +.vscode/* \ No newline at end of file diff --git a/backend/src/endpoints/car.rs b/backend/src/endpoints/car.rs deleted file mode 100644 index 4b4c510..0000000 --- a/backend/src/endpoints/car.rs +++ /dev/null @@ -1,59 +0,0 @@ -use std::sync::Mutex; -use crate::models::car::*; -use actix_web::{web, get, post, patch, delete, Responder, HttpResponse}; -use crate::State; - -#[get("/")] -pub async fn get_cars(state: web::Data>) -> impl Responder { - match state.lock() { - Ok(guard) => match guard.car_repository.read_all().await { - Ok(result) => HttpResponse::Ok().json(result), - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - }, - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - } -} - -#[get("/{id}")] -pub async fn get_car(state: web::Data>, path: web::Path<(u32, )>) -> impl Responder { - match state.lock() { - Ok(guard) => match guard.car_repository.read(path.into_inner().0).await { - Ok(result) => HttpResponse::Ok().json(result), - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - }, - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - } -} - -#[post("/")] -pub async fn create_car(state: web::Data>, json: web::Json) -> impl Responder { - match state.lock() { - Ok(guard) => match guard.car_repository.create(json.0).await { - Ok(result) => HttpResponse::Ok().json(result), - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - }, - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - } -} - -#[patch("/{id}")] -pub async fn update_car(state: web::Data>, json: web::Json, path: web::Path<(u32, )>) -> impl Responder { - match state.lock() { - Ok(guard) => match guard.car_repository.update(path.into_inner().0, json.0).await { - Ok(result) => HttpResponse::Ok().json(result), - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - }, - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - } -} - -#[delete("/{id}")] -pub async fn delete_car(state: web::Data>, path: web::Path<(u32, )>) -> impl Responder { - match state.lock() { - Ok(guard) => match guard.car_repository.delete(path.into_inner().0).await { - Ok(result) => HttpResponse::Ok().json(result), - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - }, - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - } -} \ No newline at end of file diff --git a/backend/src/endpoints/car_station.rs b/backend/src/endpoints/car_station.rs deleted file mode 100644 index 36b3d8e..0000000 --- a/backend/src/endpoints/car_station.rs +++ /dev/null @@ -1,59 +0,0 @@ -use std::sync::Mutex; -use crate::models::car_station::*; -use actix_web::{web, get, post, patch, delete, Responder, HttpResponse}; -use crate::State; - -#[get("/")] -pub async fn get_car_stations(state: web::Data>) -> impl Responder { - match state.lock() { - Ok(guard) => match guard.car_station_repository.read_all().await { - Ok(result) => HttpResponse::Ok().json(result), - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - }, - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - } -} - -#[get("/{id}")] -pub async fn get_car_station(state: web::Data>, path: web::Path<(u32, )>) -> impl Responder { - match state.lock() { - Ok(guard) => match guard.car_station_repository.read(path.into_inner().0).await { - Ok(result) => HttpResponse::Ok().json(result), - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - }, - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - } -} - -#[post("/")] -pub async fn create_car_station(state: web::Data>, json: web::Json) -> impl Responder { - match state.lock() { - Ok(guard) => match guard.car_station_repository.create(json.0).await { - Ok(result) => HttpResponse::Ok().json(result), - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - }, - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - } -} - -#[patch("/{id}")] -pub async fn update_car_station(state: web::Data>, json: web::Json, path: web::Path<(u32, )>) -> impl Responder { - match state.lock() { - Ok(guard) => match guard.car_station_repository.update(path.into_inner().0, json.0).await { - Ok(result) => HttpResponse::Ok().json(result), - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - }, - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - } -} - -#[delete("/{id}")] -pub async fn delete_car_station(state: web::Data>, path: web::Path<(u32, )>) -> impl Responder { - match state.lock() { - Ok(guard) => match guard.car_station_repository.delete(path.into_inner().0).await { - Ok(result) => HttpResponse::Ok().json(result), - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - }, - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - } -} \ No newline at end of file diff --git a/backend/src/endpoints/client.rs b/backend/src/endpoints/client.rs deleted file mode 100644 index d85a862..0000000 --- a/backend/src/endpoints/client.rs +++ /dev/null @@ -1,59 +0,0 @@ -use std::sync::Mutex; -use crate::models::client::*; -use actix_web::{web, get, post, patch, delete, Responder, HttpResponse}; -use crate::State; - -#[get("/")] -pub async fn get_clients(state: web::Data>) -> impl Responder { - match state.lock() { - Ok(guard) => match guard.client_repository.read_all().await { - Ok(result) => HttpResponse::Ok().json(result), - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - }, - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - } -} - -#[get("/{id}")] -pub async fn get_client(state: web::Data>, path: web::Path<(u32, )>) -> impl Responder { - match state.lock() { - Ok(guard) => match guard.client_repository.read(path.into_inner().0).await { - Ok(result) => HttpResponse::Ok().json(result), - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - }, - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - } -} - -#[post("/")] -pub async fn create_client(state: web::Data>, json: web::Json) -> impl Responder { - match state.lock() { - Ok(guard) => match guard.client_repository.create(json.0).await { - Ok(result) => HttpResponse::Ok().json(result), - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - }, - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - } -} - -#[patch("/{id}")] -pub async fn update_client(state: web::Data>, json: web::Json, path: web::Path<(u32, )>) -> impl Responder { - match state.lock() { - Ok(guard) => match guard.client_repository.update(path.into_inner().0, json.0).await { - Ok(result) => HttpResponse::Ok().json(result), - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - }, - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - } -} - -#[delete("/{id}")] -pub async fn delete_client(state: web::Data>, path: web::Path<(u32, )>) -> impl Responder { - match state.lock() { - Ok(guard) => match guard.client_repository.delete(path.into_inner().0).await { - Ok(result) => HttpResponse::Ok().json(result), - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - }, - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - } -} \ No newline at end of file diff --git a/backend/src/endpoints/mod.rs b/backend/src/endpoints/mod.rs deleted file mode 100644 index 2c3aab9..0000000 --- a/backend/src/endpoints/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod client; -pub mod car_station; -pub mod car; -pub mod rent; -pub mod owner; \ No newline at end of file diff --git a/backend/src/endpoints/owner.rs b/backend/src/endpoints/owner.rs deleted file mode 100644 index 0c65251..0000000 --- a/backend/src/endpoints/owner.rs +++ /dev/null @@ -1,59 +0,0 @@ -use std::sync::Mutex; -use crate::models::client::*; -use actix_web::{web, get, post, patch, delete, Responder, HttpResponse}; -use crate::State; - -#[get("/")] -pub async fn get_owners(state: web::Data>) -> impl Responder { - match state.lock() { - Ok(guard) => match guard.owner_repository.read_all().await { - Ok(result) => HttpResponse::Ok().json(result), - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - }, - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - } -} - -#[get("/{id}")] -pub async fn get_owner(state: web::Data>, path: web::Path<(u32, )>) -> impl Responder { - match state.lock() { - Ok(guard) => match guard.owner_repository.read(path.into_inner().0).await { - Ok(result) => HttpResponse::Ok().json(result), - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - }, - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - } -} - -#[post("/")] -pub async fn create_owner(state: web::Data>, json: web::Json) -> impl Responder { - match state.lock() { - Ok(guard) => match guard.owner_repository.create(json.0).await { - Ok(result) => HttpResponse::Ok().json(result), - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - }, - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - } -} - -#[patch("/{id}")] -pub async fn update_owner(state: web::Data>, json: web::Json, path: web::Path<(u32, )>) -> impl Responder { - match state.lock() { - Ok(guard) => match guard.owner_repository.update(path.into_inner().0, json.0).await { - Ok(result) => HttpResponse::Ok().json(result), - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - }, - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - } -} - -#[delete("/{id}")] -pub async fn delete_owner(state: web::Data>, path: web::Path<(u32, )>) -> impl Responder { - match state.lock() { - Ok(guard) => match guard.owner_repository.delete(path.into_inner().0).await { - Ok(result) => HttpResponse::Ok().json(result), - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - }, - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - } -} \ No newline at end of file diff --git a/backend/src/endpoints/rent.rs b/backend/src/endpoints/rent.rs deleted file mode 100644 index 005b843..0000000 --- a/backend/src/endpoints/rent.rs +++ /dev/null @@ -1,59 +0,0 @@ -use std::sync::Mutex; -use crate::models::rent::*; -use actix_web::{web, get, post, patch, delete, Responder, HttpResponse}; -use crate::State; - -#[get("/")] -pub async fn get_rents(state: web::Data>) -> impl Responder { - match state.lock() { - Ok(guard) => match guard.rent_repository.read_all().await { - Ok(result) => HttpResponse::Ok().json(result), - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - }, - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - } -} - -#[get("/{id}")] -pub async fn get_rent(state: web::Data>, path: web::Path<(u32, )>) -> impl Responder { - match state.lock() { - Ok(guard) => match guard.rent_repository.read(path.into_inner().0).await { - Ok(result) => HttpResponse::Ok().json(result), - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - }, - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - } -} - -#[post("/")] -pub async fn create_rent(state: web::Data>, json: web::Json) -> impl Responder { - match state.lock() { - Ok(guard) => match guard.rent_repository.create(json.0).await { - Ok(result) => HttpResponse::Ok().json(result), - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - }, - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - } -} - -#[patch("/{id}")] -pub async fn update_rent(state: web::Data>, json: web::Json, path: web::Path<(u32, )>) -> impl Responder { - match state.lock() { - Ok(guard) => match guard.rent_repository.update(path.into_inner().0, json.0).await { - Ok(result) => HttpResponse::Ok().json(result), - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - }, - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - } -} - -#[delete("/{id}")] -pub async fn delete_rent(state: web::Data>, path: web::Path<(u32, )>) -> impl Responder { - match state.lock() { - Ok(guard) => match guard.rent_repository.delete(path.into_inner().0).await { - Ok(result) => HttpResponse::Ok().json(result), - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - }, - Err(error) => HttpResponse::InternalServerError().json(error.to_string()) - } -} \ No newline at end of file diff --git a/backend/src/lib.rs b/backend/src/lib.rs deleted file mode 100644 index 7278f76..0000000 --- a/backend/src/lib.rs +++ /dev/null @@ -1,15 +0,0 @@ -use storages::traits::OwnerRepository; - -use crate::storages::traits::{CarRepository, CarStationRepository, ClientRepository, RentRepository}; - -pub mod endpoints; -pub mod models; -pub mod storages; - -pub struct State { - pub car_repository: Box, - pub car_station_repository: Box, - pub client_repository: Box, - pub owner_repository: Box, - pub rent_repository: Box -} \ No newline at end of file diff --git a/backend/src/main.rs b/backend/src/main.rs deleted file mode 100644 index 7a37b36..0000000 --- a/backend/src/main.rs +++ /dev/null @@ -1,98 +0,0 @@ -use std::sync::{Arc, Mutex}; -use actix_web::{App, HttpServer, web}; -use actix_web::web::Data; -use dotenv_codegen::dotenv; -use backend::State; -use tokio_postgres::NoTls; -use backend::storages::postgres::car::PostgresCarRepository; -use backend::storages::postgres::car_station::PostgresCarStationRepository; -use backend::storages::postgres::client::PostgresClientRepository; -use backend::storages::postgres::rent::PostgresRentRepository; -use backend::storages::postgres::owner::PostgresOwnerRepository; -use backend::endpoints::car_station::*; -use backend::endpoints::car::*; -use backend::endpoints::client::*; -use backend::endpoints::rent::*; -use backend::endpoints::owner::*; - -#[actix_web::main] -async fn main() -> std::io::Result<()> { - let (client, connection) = tokio_postgres::connect( - &format!("host={} user={} password={} dbname={}", dotenv!("HOST"), dotenv!("USER"), dotenv!("PASSWORD"), dotenv!("DBNAME")), - NoTls - ).await.unwrap(); - - tokio::spawn(async move { - if let Err(e) = connection.await { - eprintln!("connection error: {}", e); - } - }); - - let client = Arc::new(client); - - let car_repository = PostgresCarRepository { connection: Arc::clone(&client) }; - - let car_station_repository = PostgresCarStationRepository { connection: Arc::clone(&client) }; - - let client_repository = PostgresClientRepository { connection: Arc::clone(&client) }; - - let owner_repository = PostgresOwnerRepository { connection: Arc::clone(&client) }; - - let rent_repository = PostgresRentRepository { connection: Arc::clone(&client) }; - - let state = Data::new(Mutex::new(State { - car_repository: Box::new(car_repository), - car_station_repository: Box::new(car_station_repository), - client_repository: Box::new(client_repository), - owner_repository: Box::new(owner_repository), - rent_repository: Box::new(rent_repository) - })); - - HttpServer::new(move || { - App::new() - .app_data(Data::clone(&state)) - .service( - web::scope("/cars") - .service(get_cars) - .service(get_car) - .service(create_car) - .service(update_car) - .service(delete_car) - ) - .service( - web::scope("/clients") - .service(get_clients) - .service(get_client) - .service(create_client) - .service(update_client) - .service(delete_client) - ) - .service( - web::scope("/owners") - .service(get_owners) - .service(get_owner) - .service(create_owner) - .service(update_owner) - .service(delete_owner) - ) - .service( - web::scope("/car_stations") - .service(get_car_stations) - .service(get_car_station) - .service(create_car_station) - .service(update_car_station) - .service(delete_car_station) - ) - .service( - web::scope("/rents") - .service(get_rents) - .service(get_rent) - .service(create_rent) - .service(update_rent) - .service(delete_rent) - ) - }) - .bind("127.0.0.1:8080")? - .run() - .await -} \ No newline at end of file diff --git a/backend/src/storages/mod.rs b/backend/src/storages/mod.rs deleted file mode 100644 index 4acaacf..0000000 --- a/backend/src/storages/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod traits; -pub mod postgres; \ No newline at end of file diff --git a/backend/src/storages/postgres/car.rs b/backend/src/storages/postgres/car.rs deleted file mode 100644 index c878fd0..0000000 --- a/backend/src/storages/postgres/car.rs +++ /dev/null @@ -1,113 +0,0 @@ -use tokio_postgres::Client as PgClient; -use std::sync::Arc; -use crate::models::car::{BindingCar, Car}; -use crate::storages::traits::CarRepository; -use async_trait::async_trait; - -pub struct PostgresCarRepository { - pub connection: Arc -} - -#[async_trait] -impl CarRepository for PostgresCarRepository { - async fn create(&self, car: BindingCar) -> Result { - let result = self.connection.query( - "INSERT INTO Car(brand, model, price, owner_id, car_station_id) \ - VALUES ($1, $2, $3, $4, $5) RETURNING *", - &[&car.brand, &car.model, &car.price, &car.owner_id, &car.car_station_id] - ).await; - - if let Ok(rows) = result { - let row = rows.get(0).unwrap(); - Ok(Car { - id: row.get("id"), - brand: row.get("brand"), - model: row.get("model"), - price: row.get("price"), - owner_id: row.get("owner_id"), - car_station_id: row.get("car_station_id") - }) - } else { - Err("Something gone wrong during creation of Car".to_owned()) - } - } - - async fn read(&self, id: u32) -> Result { - let result = self.connection.query( - "SELECT * FROM Car WHERE id = $1", &[&id] - ).await; - - if let Ok(rows) = result { - let row = rows.get(0).ok_or("Car not found".to_owned())?; - Ok(Car { - id: row.get("id"), - brand: row.get("brand"), - model: row.get("model"), - price: row.get("price"), - owner_id: row.get("owner_id"), - car_station_id: row.get("car_station_id") - }) - } else { - Err("Something gone wrong during reading of Car".to_owned()) - } - } - - async fn read_all(&self) -> Result, String> { - let result = self.connection.query( - "SELECT * FROM Car", &[] - ).await; - - if let Ok(rows) = result { - Ok( - rows.into_iter().map(|r| Car { - id: r.get("id"), - brand: r.get("brand"), - model: r.get("model"), - price: r.get("price"), - owner_id: r.get("owner_id"), - car_station_id: r.get("car_station_id") - }).collect() - ) - } else { - Err("Something gone wrong during reading CarStations".to_owned()) - } - } - - async fn update(&self, id: u32, car: BindingCar) -> Result { - let result = self.connection.query( - "UPDATE Car SET brand = $1, model = $2, price = $3, owner_id = $4, car_station_id = $5 WHERE id = $6 RETURNING *", - &[&car.brand, &car.model, &car.price, &car.owner_id, &car.car_station_id, &id] - ).await; - - if let Ok(rows) = &result { - let row = rows.get(0).unwrap(); - Ok(Car { - id: row.get("id"), - brand: row.get("brand"), - model: row.get("model"), - price: row.get("price"), - owner_id: row.get("owner_id"), - car_station_id: row.get("car_station_id") - }) - } else { - Err("Something gone wrong during updating of Car".to_owned()) - } - } - - async fn delete(&self, id: u32) -> Result<(), String> { - let result = self.connection.execute( - "DELETE FROM Car WHERE id = $1", - &[&id] - ).await; - - if let Ok(rows) = result { - if rows == 0 { - Err("Car not found".to_owned()) - } else { - Ok(()) - } - } else { - Err("Something gone wrong during deleting of Car".to_owned()) - } - } -} \ No newline at end of file diff --git a/backend/src/storages/postgres/car_station.rs b/backend/src/storages/postgres/car_station.rs deleted file mode 100644 index 5b57867..0000000 --- a/backend/src/storages/postgres/car_station.rs +++ /dev/null @@ -1,96 +0,0 @@ -use tokio_postgres::Client as PgClient; -use std::sync::Arc; -use crate::models::car_station::{BindingCarStation, CarStation}; -use crate::storages::traits::CarStationRepository; -use async_trait::async_trait; - -pub struct PostgresCarStationRepository { - pub connection: Arc -} - -#[async_trait] -impl CarStationRepository for PostgresCarStationRepository { - async fn create(&self, car_station: BindingCarStation) -> Result { - let result = self.connection.query( - "INSERT INTO Car_Station(address) \ - VALUES ($1) RETURNING *", - &[&car_station.address] - ).await; - if let Ok(rows) = result { - let row = rows.get(0).unwrap(); - Ok(CarStation { - id: row.get("id"), - address: row.get("address") - }) - } else { - Err("Something gone wrong during creation of CarStation".to_owned()) - } - } - - async fn read(&self, id: u32) -> Result { - let result = self.connection.query( - "SELECT * FROM Car_Station WHERE id = $1", &[&id] - ).await; - - if let Ok(rows) = result { - let row = rows.get(0).ok_or("CarStation not found".to_owned())?; - Ok(CarStation { - id: row.get("id"), - address: row.get("address") - }) - } else { - Err("Something gone wrong during reading of CarStation".to_owned()) - } - } - - async fn read_all(&self) -> Result, String> { - let result = self.connection.query( - "SELECT * FROM Car_Station", &[] - ).await; - - if let Ok(rows) = result { - Ok( - rows.into_iter().map(|r| CarStation { - id: r.get("id"), - address: r.get("address") - }).collect() - ) - } else { - Err("Something gone wrong during reading CarStations".to_owned()) - } - } - - async fn update(&self, id: u32, car_station: BindingCarStation) -> Result { - let result = self.connection.query( - "UPDATE Car_Station SET address = $1 WHERE id = $2 RETURNING *", - &[&car_station.address, &id] - ).await; - - if let Ok(rows) = result { - let row = rows.get(0).unwrap(); - Ok(CarStation { - id: row.get("id"), - address: row.get("address") - }) - } else { - Err("Something gone wrong during updating of CarStation".to_owned()) - } - } - - async fn delete(&self, id: u32) -> Result<(), String> { - let result = self.connection.execute( - "DELETE FROM Car_Station WHERE id = $1", - &[&id] - ).await; - - if let Ok(rows) = result { - if rows == 0 { - Err("CarStation not found".to_owned()) - } else { - Ok(()) - } - } else { - Err("Something gone wrong during deleting of CarStation".to_owned()) - } - } -} \ No newline at end of file diff --git a/backend/src/storages/postgres/client.rs b/backend/src/storages/postgres/client.rs deleted file mode 100644 index 88bfeb0..0000000 --- a/backend/src/storages/postgres/client.rs +++ /dev/null @@ -1,111 +0,0 @@ -use tokio_postgres::Client as PgClient; -use std::sync::Arc; -use crate::models::client::{BindingClient, Client}; -use crate::storages::traits::ClientRepository; -use async_trait::async_trait; - -pub struct PostgresClientRepository { - pub connection: Arc -} - -#[async_trait] -impl ClientRepository for PostgresClientRepository { - async fn create(&self, client: BindingClient) -> Result { - let result = self.connection.query( - "INSERT INTO Client(name, surname, middlename, phone) \ - VALUES ($1, $2, $3, $4) RETURNING *", - &[&client.name, &client.surname, &client.middlename, &client.phone] - ).await; - - if let Ok(rows) = &result { - let row = rows.get(0).unwrap(); - Ok(Client { - id: row.get("id"), - name: row.get("name"), - surname: row.get("surname"), - middlename: row.get("middlename"), - phone: row.get("phone") - }) - } else { - Err("Something gone wrong during creation of Client".to_owned()) - } - } - - async fn read(&self, id: u32) -> Result { - let result= self.connection.query( - "SELECT * FROM Client WHERE id = $1", &[&id] - ).await; - - if let Ok(rows) = result { - - let row = rows.get(0).ok_or("Client not found".to_owned())?; - Ok(Client { - id: row.get("id"), - name: row.get("name"), - surname: row.get("surname"), - middlename: row.get("middlename"), - phone: row.get("phone") - }) - } else { - Err("Something gone wrong during reading of Client".to_owned()) - } - } - - async fn read_all(&self) -> Result, String> { - let result = self.connection.query( - "SELECT * FROM Client", &[] - ).await; - - if let Ok(rows) = result { - Ok( - rows.into_iter().map(|r| Client { - id: r.get("id"), - name: r.get("name"), - surname: r.get("surname"), - middlename: r.get("middlename"), - phone: r.get("phone") - }).collect() - ) - } else { - Err("Something gone wrong during reading Clients".to_owned()) - } - } - - async fn update(&self, id: u32, client: BindingClient) -> Result { - let result = self.connection.query( - "UPDATE Client SET name = $1, surname = $2, middlename = $3, phone = $4 \ - WHERE id = $5 RETURNING *", - &[&client.name, &client.surname, &client.middlename, &client.phone, &id] - ).await; - - if let Ok(rows) = result { - let row = rows.get(0).unwrap(); - Ok(Client { - id: row.get("id"), - name: row.get("name"), - surname: row.get("surname"), - middlename: row.get("middlename"), - phone: row.get("phone") - }) - } else { - Err("Something gone wrong during updating of Client".to_owned()) - } - } - - async fn delete(&self, id: u32) -> Result<(), String> { - let result = self.connection.execute( - "DELETE FROM Client WHERE id = $1", - &[&id] - ).await; - - if let Ok(rows) = result { - if rows == 0 { - Err("Client not found".to_owned()) - } else { - Ok(()) - } - } else { - Err("Something gone wrong during deleting of Client".to_owned()) - } - } -} diff --git a/backend/src/storages/postgres/mod.rs b/backend/src/storages/postgres/mod.rs deleted file mode 100644 index 2c3aab9..0000000 --- a/backend/src/storages/postgres/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod client; -pub mod car_station; -pub mod car; -pub mod rent; -pub mod owner; \ No newline at end of file diff --git a/backend/src/storages/postgres/owner.rs b/backend/src/storages/postgres/owner.rs deleted file mode 100644 index 7f63f2d..0000000 --- a/backend/src/storages/postgres/owner.rs +++ /dev/null @@ -1,111 +0,0 @@ -use tokio_postgres::Client as PgClient; -use std::sync::Arc; -use crate::models::client::{BindingClient, Client}; -use crate::storages::traits::OwnerRepository; -use async_trait::async_trait; - -pub struct PostgresOwnerRepository { - pub connection: Arc -} - -#[async_trait] -impl OwnerRepository for PostgresOwnerRepository { - async fn create(&self, client: BindingClient) -> Result { - let result = self.connection.query( - "INSERT INTO Owner(name, surname, middlename, phone) \ - VALUES ($1, $2, $3, $4) RETURNING *", - &[&client.name, &client.surname, &client.middlename, &client.phone] - ).await; - - if let Ok(rows) = &result { - let row = rows.get(0).unwrap(); - Ok(Client { - id: row.get("id"), - name: row.get("name"), - surname: row.get("surname"), - middlename: row.get("middlename"), - phone: row.get("phone") - }) - } else { - Err("Something gone wrong during creation of Owner".to_owned()) - } - } - - async fn read(&self, id: u32) -> Result { - let result= self.connection.query( - "SELECT * FROM Owner WHERE id = $1", &[&id] - ).await; - - if let Ok(rows) = result { - - let row = rows.get(0).ok_or("Owner not found".to_owned())?; - Ok(Client { - id: row.get("id"), - name: row.get("name"), - surname: row.get("surname"), - middlename: row.get("middlename"), - phone: row.get("phone") - }) - } else { - Err("Something gone wrong during reading of Owner".to_owned()) - } - } - - async fn read_all(&self) -> Result, String> { - let result = self.connection.query( - "SELECT * FROM Owner", &[] - ).await; - - if let Ok(rows) = result { - Ok( - rows.into_iter().map(|r| Client { - id: r.get("id"), - name: r.get("name"), - surname: r.get("surname"), - middlename: r.get("middlename"), - phone: r.get("phone") - }).collect() - ) - } else { - Err("Something gone wrong during reading Owner".to_owned()) - } - } - - async fn update(&self, id: u32, client: BindingClient) -> Result { - let result = self.connection.query( - "UPDATE Owner SET name = $1, surname = $2, middlename = $3, phone = $4 \ - WHERE id = $5 RETURNING *", - &[&client.name, &client.surname, &client.middlename, &client.phone, &id] - ).await; - - if let Ok(rows) = result { - let row = rows.get(0).unwrap(); - Ok(Client { - id: row.get("id"), - name: row.get("name"), - surname: row.get("surname"), - middlename: row.get("middlename"), - phone: row.get("phone") - }) - } else { - Err("Something gone wrong during updating of Owner".to_owned()) - } - } - - async fn delete(&self, id: u32) -> Result<(), String> { - let result = self.connection.execute( - "DELETE FROM Owner WHERE id = $1", - &[&id] - ).await; - - if let Ok(rows) = result { - if rows == 0 { - Err("Owner not found".to_owned()) - } else { - Ok(()) - } - } else { - Err("Something gone wrong during deleting of Owner".to_owned()) - } - } -} diff --git a/backend/src/storages/postgres/rent.rs b/backend/src/storages/postgres/rent.rs deleted file mode 100644 index 585a1e1..0000000 --- a/backend/src/storages/postgres/rent.rs +++ /dev/null @@ -1,117 +0,0 @@ -use tokio_postgres::Client as PgClient; -use std::sync::Arc; -use crate::models::rent::{BindingRent, Rent}; -use crate::storages::traits::RentRepository; -use async_trait::async_trait; - -pub struct PostgresRentRepository { - pub connection: Arc -} - -#[async_trait] -impl RentRepository for PostgresRentRepository { - async fn create(&self, rent: BindingRent) -> Result { - let query_result = self.connection.query( - "SELECT * FROM Rent WHERE car_id=$1 AND time_amount IS NOT NULL", - &[&rent.car_id] - ).await; - - if let Ok(rows) = query_result { - if rows.len() > 0 { - return Err("The car is already occupied".to_owned()); - } - } else { - return Err("Something gone wrong during checking for existing rents".to_owned()); - } - - let result = self.connection.query( - "INSERT INTO Rent(time_amount, client_id, car_id) \ - VALUES ($1, $2, $3) RETURNING *", - &[&rent.time_amount, &rent.client_id, &rent.car_id] - ).await; - - if let Ok(rows) = result { - let row = rows.get(0).unwrap(); - Ok(Rent { - id: row.get("id"), - start_time: row.get("start_time"), - time_amount: row.get("time_amount"), - client_id: row.get("client_id"), - car_id: row.get("car_id") - }) - } else { - Err("Something gone wrong during creation of Rent".to_owned()) - } - } - - async fn read(&self, id: u32) -> Result { - let result = self.connection.query( - "SELECT * FROM Rent WHERE id = $1", &[&id] - ).await; - - if let Ok(rows) = result { - let row = rows.get(0).ok_or("Rent not found".to_owned())?; - Ok(Rent { - id: row.get("id"), - start_time: row.get("start_time"), - time_amount: row.get("time_amount"), - client_id: row.get("client_id"), - car_id: row.get("car_id") - }) - } else { - Err("Something gone wrong during reading of Rent".to_owned()) - } - } - - async fn read_all(&self) -> Result, String> { - let result = self.connection.query( - "SELECT * FROM Rent", &[] - ).await; - - if let Ok(rows) = result { - Ok( - rows.into_iter().map(|r| Rent { - id: r.get("id"), - start_time: r.get("start_time"), - time_amount: r.get("time_amount"), - client_id: r.get("client_id"), - car_id: r.get("car_id") - }).collect() - ) - } else { - Err("Something gone wrong during reading CarStations".to_owned()) - } - } - - async fn update(&self, id: u32, rent: BindingRent) -> Result { - let result = self.connection.query( - "UPDATE Rent SET time_amount = $2, client_id = $3, car_id = $4 WHERE id = $5 RETURNING *", - &[&rent.time_amount, &rent.client_id, &rent.car_id, &id] - ).await; - - if let Ok(rows) = result { - let row = rows.get(0).unwrap(); - Ok(Rent { - id: row.get("id"), - start_time: row.get("start_time"), - time_amount: row.get("time_amount"), - client_id: row.get("client_id"), - car_id: row.get("car_id") - }) - } else { - Err("Something gone wrong during updating of Rent".to_owned()) - } - } - - async fn delete(&self, id: u32) -> Result<(), String> { - let result = self.connection.execute( - "DELETE FROM Rent WHERE id = $1", &[&id] - ).await; - - if let Ok(_) = result { - Ok(()) - } else { - Err("Something gone wrong during deletion of Rent".to_owned()) - } - } -} \ No newline at end of file diff --git a/backend/src/storages/traits.rs b/backend/src/storages/traits.rs deleted file mode 100644 index 5a38418..0000000 --- a/backend/src/storages/traits.rs +++ /dev/null @@ -1,50 +0,0 @@ -use crate::models::client::*; -use crate::models::car_station::*; -use crate::models::car::*; -use crate::models::rent::*; -use async_trait::async_trait; - -#[async_trait] -pub trait ClientRepository { - async fn create(&self, client: BindingClient) -> Result; - async fn read(&self, id: u32) -> Result; - async fn read_all(&self) -> Result, String>; - async fn update(&self, id: u32, client: BindingClient) -> Result; - async fn delete(&self, id: u32) -> Result<(), String>; -} - -#[async_trait] -pub trait CarRepository { - async fn create(&self, car: BindingCar) -> Result; - async fn read(&self, id: u32) -> Result; - async fn read_all(&self) -> Result, String>; - async fn update(&self, id: u32, car: BindingCar) -> Result; - async fn delete(&self, id: u32) -> Result<(), String>; -} - -#[async_trait] -pub trait CarStationRepository { - async fn create(&self, car_station: BindingCarStation) -> Result; - async fn read(&self, id: u32) -> Result; - async fn read_all(&self) -> Result, String>; - async fn update(&self, id: u32, car_station: BindingCarStation) -> Result; - async fn delete(&self, id: u32) -> Result<(), String>; -} - -#[async_trait] -pub trait RentRepository { - async fn create(&self, rent: BindingRent) -> Result; - async fn read(&self, id: u32) -> Result; - async fn read_all(&self) -> Result, String>; - async fn update(&self, id: u32, rent: BindingRent) -> Result; - async fn delete(&self, id: u32) -> Result<(), String>; -} - -#[async_trait] -pub trait OwnerRepository { - async fn create(&self, client: BindingClient) -> Result; - async fn read(&self, id: u32) -> Result; - async fn read_all(&self) -> Result, String>; - async fn update(&self, id: u32, client: BindingClient) -> Result; - async fn delete(&self, id: u32) -> Result<(), String>; -} \ No newline at end of file diff --git a/backend/Cargo.lock b/frontend/Cargo.lock similarity index 51% rename from backend/Cargo.lock rename to frontend/Cargo.lock index 57cf057..91213aa 100644 --- a/backend/Cargo.lock +++ b/frontend/Cargo.lock @@ -2,240 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "actix-codec" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a7559404a7f3573127aab53c08ce37a6c6a315c374a31070f3c91cd1b4a7fe" -dependencies = [ - "bitflags", - "bytes", - "futures-core", - "futures-sink", - "log", - "memchr", - "pin-project-lite", - "tokio", - "tokio-util", -] - -[[package]] -name = "actix-http" -version = "3.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2079246596c18b4a33e274ae10c0e50613f4d32a4198e09c7b93771013fed74" -dependencies = [ - "actix-codec", - "actix-rt", - "actix-service", - "actix-utils", - "ahash 0.8.3", - "base64", - "bitflags", - "brotli", - "bytes", - "bytestring", - "derive_more", - "encoding_rs", - "flate2", - "futures-core", - "h2", - "http", - "httparse", - "httpdate", - "itoa", - "language-tags", - "local-channel", - "mime", - "percent-encoding", - "pin-project-lite", - "rand", - "sha1", - "smallvec", - "tokio", - "tokio-util", - "tracing", - "zstd", -] - -[[package]] -name = "actix-macros" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" -dependencies = [ - "quote", - "syn 1.0.109", -] - -[[package]] -name = "actix-router" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d66ff4d247d2b160861fa2866457e85706833527840e4133f8f49aa423a38799" -dependencies = [ - "bytestring", - "http", - "regex", - "serde", - "tracing", -] - -[[package]] -name = "actix-rt" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15265b6b8e2347670eb363c47fc8c75208b4a4994b27192f345fcbe707804f3e" -dependencies = [ - "futures-core", - "tokio", -] - -[[package]] -name = "actix-server" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e8613a75dd50cc45f473cee3c34d59ed677c0f7b44480ce3b8247d7dc519327" -dependencies = [ - "actix-rt", - "actix-service", - "actix-utils", - "futures-core", - "futures-util", - "mio", - "num_cpus", - "socket2 0.4.9", - "tokio", - "tracing", -] - -[[package]] -name = "actix-service" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b894941f818cfdc7ccc4b9e60fa7e53b5042a2e8567270f9147d5591893373a" -dependencies = [ - "futures-core", - "paste", - "pin-project-lite", -] - -[[package]] -name = "actix-utils" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88a1dcdff1466e3c2488e1cb5c36a71822750ad43839937f85d2f4d9f8b705d8" -dependencies = [ - "local-waker", - "pin-project-lite", -] - -[[package]] -name = "actix-web" -version = "4.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd3cb42f9566ab176e1ef0b8b3a896529062b4efc6be0123046095914c4c1c96" -dependencies = [ - "actix-codec", - "actix-http", - "actix-macros", - "actix-router", - "actix-rt", - "actix-server", - "actix-service", - "actix-utils", - "actix-web-codegen", - "ahash 0.7.6", - "bytes", - "bytestring", - "cfg-if", - "cookie", - "derive_more", - "encoding_rs", - "futures-core", - "futures-util", - "http", - "itoa", - "language-tags", - "log", - "mime", - "once_cell", - "pin-project-lite", - "regex", - "serde", - "serde_json", - "serde_urlencoded", - "smallvec", - "socket2 0.4.9", - "time 0.3.20", - "url", -] - -[[package]] -name = "actix-web-codegen" -version = "4.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2262160a7ae29e3415554a3f1fc04c764b1540c116aa524683208078b7a75bc9" -dependencies = [ - "actix-router", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom", - "once_cell", - "version_check", -] - -[[package]] -name = "ahash" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" -dependencies = [ - "cfg-if", - "getrandom", - "once_cell", - "version_check", -] - -[[package]] -name = "aho-corasick" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" -dependencies = [ - "memchr", -] - -[[package]] -name = "alloc-no-stdlib" -version = "2.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" - -[[package]] -name = "alloc-stdlib" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" -dependencies = [ - "alloc-no-stdlib", -] - [[package]] name = "android_system_properties" version = "0.1.5" @@ -246,15 +12,10 @@ dependencies = [ ] [[package]] -name = "async-trait" -version = "0.1.68" +name = "anymap2" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.12", -] +checksum = "d301b3b94cb4b2f23d7917810addbbaff90738e0ca2be692bd027e70d7e0330c" [[package]] name = "autocfg" @@ -263,61 +24,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] -name = "backend" -version = "0.1.0" +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" dependencies = [ - "actix-web", - "async-trait", - "chrono", - "dotenv", - "dotenv_codegen", "serde", - "serde_json", - "tokio", - "tokio-postgres", ] [[package]] -name = "base64" -version = "0.21.0" +name = "boolinator" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[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 = "brotli" -version = "3.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1a0b1dbcc8ae29329621f8d4f0d835787c1c38bb1401979b49d13b0b305ff68" -dependencies = [ - "alloc-no-stdlib", - "alloc-stdlib", - "brotli-decompressor", -] - -[[package]] -name = "brotli-decompressor" -version = "2.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b6561fd3f895a11e8f72af2cb7d22e08366bebc2b6b57f7744c4bda27034744" -dependencies = [ - "alloc-no-stdlib", - "alloc-stdlib", -] +checksum = "cfa8873f51c92e232f9bac4065cddef41b714152812bfc5f7672ba16d6ef8cd9" [[package]] name = "bumpalo" @@ -325,35 +44,11 @@ version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - -[[package]] -name = "bytes" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" - -[[package]] -name = "bytestring" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "238e4886760d98c4f899360c834fa93e62cf7f721ac3c2da375cbdf4b8679aae" -dependencies = [ - "bytes", -] - [[package]] name = "cc" version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" -dependencies = [ - "jobserver", -] [[package]] name = "cfg-if" @@ -372,7 +67,7 @@ dependencies = [ "num-integer", "num-traits", "serde", - "time 0.1.45", + "time", "wasm-bindgen", "winapi", ] @@ -388,20 +83,13 @@ dependencies = [ ] [[package]] -name = "convert_case" -version = "0.4.0" +name = "console_error_panic_hook" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "cookie" -version = "0.16.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e859cd57d0710d9e06c381b550c06e76992472a8c6d527aecd2fc673dcc231fb" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" dependencies = [ - "percent-encoding", - "time 0.3.20", - "version_check", + "cfg-if", + "wasm-bindgen", ] [[package]] @@ -410,34 +98,6 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" -[[package]] -name = "cpufeatures" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "280a9f2d8b3a38871a3c8a46fb80db65e5e5ed97da80c4d08bf27fb63e35e181" -dependencies = [ - "libc", -] - -[[package]] -name = "crc32fast" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - [[package]] name = "cxx" version = "1.0.94" @@ -462,7 +122,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.12", + "syn 2.0.13", ] [[package]] @@ -479,93 +139,9 @@ checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.12", + "syn 2.0.13", ] -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn 1.0.109", -] - -[[package]] -name = "digest" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" -dependencies = [ - "block-buffer", - "crypto-common", - "subtle", -] - -[[package]] -name = "dotenv" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" - -[[package]] -name = "dotenv_codegen" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56966279c10e4f8ee8c22123a15ed74e7c8150b658b26c619c53f4a56eb4a8aa" -dependencies = [ - "dotenv_codegen_implementation", - "proc-macro-hack", -] - -[[package]] -name = "dotenv_codegen_implementation" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53e737a3522cd45f6adc19b644ce43ef53e1e9045f2d2de425c1f468abd4cf33" -dependencies = [ - "dotenv", - "proc-macro-hack", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "encoding_rs" -version = "0.8.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "fallible-iterator" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" - -[[package]] -name = "flate2" -version = "1.0.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" -dependencies = [ - "crc32fast", - "miniz_oxide", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - [[package]] name = "form_urlencoded" version = "1.1.0" @@ -575,6 +151,31 @@ 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" @@ -591,6 +192,12 @@ 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" @@ -599,7 +206,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.12", + "syn 2.0.13", ] [[package]] @@ -620,53 +227,184 @@ 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 = "generic-array" -version = "0.14.7" +name = "gloo" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +checksum = "3a4bef6b277b3ab073253d4bca60761240cf8d6998f4bd142211957b69a61b20" dependencies = [ - "typenum", - "version_check", + "gloo-console", + "gloo-dialogs", + "gloo-events", + "gloo-file", + "gloo-history", + "gloo-net", + "gloo-render", + "gloo-storage", + "gloo-timers", + "gloo-utils", + "gloo-worker", ] [[package]] -name = "getrandom" -version = "0.2.8" +name = "gloo-console" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "82b7ce3c05debe147233596904981848862b068862e9ec3e34be446077190d3f" dependencies = [ - "cfg-if", - "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "gloo-utils", + "js-sys", + "serde", + "wasm-bindgen", + "web-sys", ] [[package]] -name = "h2" -version = "0.3.16" +name = "gloo-dialogs" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5be7b54589b581f624f566bf5d8eb2bab1db736c51528720b6bd36b96b55924d" +checksum = "67062364ac72d27f08445a46cab428188e2e224ec9e37efdba48ae8c289002e6" dependencies = [ - "bytes", - "fnv", + "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", - "futures-util", - "http", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", + "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]] @@ -684,38 +422,6 @@ dependencies = [ "libc", ] -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "http" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - -[[package]] -name = "httparse" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" - -[[package]] -name = "httpdate" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" - [[package]] name = "iana-time-zone" version = "0.1.54" @@ -741,13 +447,12 @@ dependencies = [ ] [[package]] -name = "idna" -version = "0.3.0" +name = "implicit-clone" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +checksum = "40fc102e70475c320b185cd18c1e48bba2d7210b63970a4d581ef903e4368ef7" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "indexmap", ] [[package]] @@ -766,15 +471,6 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" -[[package]] -name = "jobserver" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" -dependencies = [ - "libc", -] - [[package]] name = "js-sys" version = "0.3.61" @@ -784,12 +480,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "language-tags" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" - [[package]] name = "libc" version = "0.2.140" @@ -805,34 +495,6 @@ dependencies = [ "cc", ] -[[package]] -name = "local-channel" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f303ec0e94c6c54447f84f3b0ef7af769858a9c4ef56ef2a986d3dcd4c3fc9c" -dependencies = [ - "futures-core", - "futures-sink", - "futures-util", - "local-waker", -] - -[[package]] -name = "local-waker" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e34f76eb3611940e0e7d53a9aaa4e6a3151f69541a282fd0dad5571420c53ff1" - -[[package]] -name = "lock_api" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "log" version = "0.4.17" @@ -842,48 +504,12 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "md-5" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca" -dependencies = [ - "digest", -] - [[package]] name = "memchr" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" -[[package]] -name = "mime" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" - -[[package]] -name = "miniz_oxide" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" -dependencies = [ - "adler", -] - -[[package]] -name = "mio" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" -dependencies = [ - "libc", - "log", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys", -] - [[package]] name = "num-integer" version = "0.1.45" @@ -919,35 +545,6 @@ version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-sys", -] - -[[package]] -name = "paste" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" - [[package]] name = "percent-encoding" version = "2.2.0" @@ -955,21 +552,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" [[package]] -name = "phf" -version = "0.11.1" +name = "pin-project" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928c6535de93548188ef63bb7c4036bd415cd8f36ad25af44b9789b2ee72a48c" +checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" dependencies = [ - "phf_shared", + "pin-project-internal", ] [[package]] -name = "phf_shared" -version = "0.11.1" +name = "pin-project-internal" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1fb5f6f826b772a8d4c0394209441e7d37cbbb967ae9c7e0e8134365c9ee676" +checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" dependencies = [ - "siphasher", + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] @@ -985,62 +584,76 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] -name = "pkg-config" -version = "0.3.26" +name = "pinned" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" - -[[package]] -name = "postgres-protocol" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b7fa9f396f51dffd61546fd8573ee20592287996568e6175ceb0f8699ad75d" +checksum = "a829027bd95e54cfe13e3e258a1ae7b645960553fb82b75ff852c29688ee595b" dependencies = [ - "base64", - "byteorder", - "bytes", - "fallible-iterator", - "hmac", - "md-5", - "memchr", - "rand", - "sha2", - "stringprep", + "futures", + "rustversion", + "thiserror", ] [[package]] -name = "postgres-types" -version = "0.2.5" +name = "prettyplease" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f028f05971fe20f512bcc679e2c10227e57809a3af86a7606304435bc8896cd6" +checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" dependencies = [ - "bytes", - "chrono", - "fallible-iterator", - "postgres-protocol", + "proc-macro2", + "syn 1.0.109", ] [[package]] -name = "ppv-lite86" -version = "0.2.17" +name = "proc-macro-error" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] [[package]] -name = "proc-macro-hack" -version = "0.5.20+deprecated" +name = "proc-macro-error-attr" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] [[package]] name = "proc-macro2" -version = "1.0.54" +version = "1.0.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e472a104799c74b514a57226160104aa483546de37e839ec50e3c2e41dd87534" +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" @@ -1051,69 +664,16 @@ dependencies = [ ] [[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" +name = "route-recognizer" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] +checksum = "afab94fb28594581f62d981211a9a4d53cc8130bbcbbb89a0440d9b8e81a7746" [[package]] -name = "rand_core" -version = "0.6.4" +name = "rustversion" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags", -] - -[[package]] -name = "regex" -version = "1.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.6.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] +checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" [[package]] name = "ryu" @@ -1121,24 +681,12 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - [[package]] name = "scratch" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" -[[package]] -name = "semver" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" - [[package]] name = "serde" version = "1.0.159" @@ -1148,6 +696,17 @@ 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" @@ -1156,7 +715,7 @@ checksum = "4c614d17805b093df4b147b51339e7e44bf05ef59fba1e45d83500bcfb4d8585" dependencies = [ "proc-macro2", "quote", - "syn 2.0.12", + "syn 2.0.13", ] [[package]] @@ -1182,43 +741,6 @@ dependencies = [ "serde", ] -[[package]] -name = "sha1" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - -[[package]] -name = "sha2" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - -[[package]] -name = "signal-hook-registry" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" -dependencies = [ - "libc", -] - -[[package]] -name = "siphasher" -version = "0.3.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" - [[package]] name = "slab" version = "0.4.8" @@ -1228,48 +750,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "smallvec" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" - -[[package]] -name = "socket2" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "socket2" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc8d618c6641ae355025c449427f9e96b98abf99a772be3cef6708d15c77147a" -dependencies = [ - "libc", - "windows-sys", -] - -[[package]] -name = "stringprep" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ee348cb74b87454fff4b551cbf727025810a004f88aeacae7f85b87f4e9a1c1" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "subtle" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" - [[package]] name = "syn" version = "1.0.109" @@ -1283,9 +763,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.12" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79d9531f94112cfc3e4c8f5f02cb2b58f72c97b7efd85f70203cc6d8efda5927" +checksum = "4c9da457c5285ac1f936ebd076af6dac17a61cfe7826f2076b4d015cf47bc8ec" dependencies = [ "proc-macro2", "quote", @@ -1301,6 +781,26 @@ 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" @@ -1308,52 +808,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" dependencies = [ "libc", - "wasi 0.10.0+wasi-snapshot-preview1", + "wasi", "winapi", ] -[[package]] -name = "time" -version = "0.3.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" -dependencies = [ - "itoa", - "serde", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" - -[[package]] -name = "time-macros" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36" -dependencies = [ - "time-core", -] - -[[package]] -name = "tinyvec" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - [[package]] name = "tokio" version = "1.27.0" @@ -1361,65 +819,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001" dependencies = [ "autocfg", - "bytes", - "libc", - "mio", - "num_cpus", - "parking_lot", "pin-project-lite", - "signal-hook-registry", - "socket2 0.4.9", - "tokio-macros", "windows-sys", ] [[package]] -name = "tokio-macros" -version = "2.0.0" +name = "tokio-stream" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce" +checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.12", -] - -[[package]] -name = "tokio-postgres" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e89f6234aa8fd43779746012fcf53603cdb91fdd8399aa0de868c2d56b6dde1" -dependencies = [ - "async-trait", - "byteorder", - "bytes", - "fallible-iterator", - "futures-channel", - "futures-util", - "log", - "parking_lot", - "percent-encoding", - "phf", - "pin-project-lite", - "postgres-protocol", - "postgres-types", - "socket2 0.5.1", - "tokio", - "tokio-util", -] - -[[package]] -name = "tokio-util" -version = "0.7.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" -dependencies = [ - "bytes", "futures-core", - "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] @@ -1429,11 +841,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", - "log", "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" @@ -1443,50 +866,18 @@ dependencies = [ "once_cell", ] -[[package]] -name = "typenum" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" - -[[package]] -name = "unicode-bidi" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" - [[package]] name = "unicode-ident" version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" -[[package]] -name = "unicode-normalization" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" -dependencies = [ - "tinyvec", -] - [[package]] name = "unicode-width" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" -[[package]] -name = "url" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", -] - [[package]] name = "version_check" version = "0.9.4" @@ -1499,12 +890,6 @@ version = "0.10.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - [[package]] name = "wasm-bindgen" version = "0.2.84" @@ -1530,6 +915,18 @@ dependencies = [ "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" @@ -1559,6 +956,16 @@ 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" @@ -1666,31 +1073,70 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] -name = "zstd" -version = "0.12.3+zstd.1.5.2" +name = "yew" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76eea132fb024e0e13fd9c2f5d5d595d8a967aa72382ac2f9d39fcc95afd0806" +checksum = "5dbecfe44343b70cc2932c3eb445425969ae21754a8ab3a0966981c1cf7af1cc" dependencies = [ - "zstd-safe", + "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 = "zstd-safe" -version = "6.0.4+zstd.1.5.4" +name = "yew-macro" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7afb4b54b8910cf5447638cb54bf4e8a65cbedd783af98b98c62ffe91f185543" +checksum = "b64c253c1d401f1ea868ca9988db63958cfa15a69f739101f338d6f05eea8301" dependencies = [ - "libc", - "zstd-sys", + "boolinator", + "once_cell", + "prettyplease", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] -name = "zstd-sys" -version = "2.0.7+zstd.1.5.4" +name = "yew-router" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94509c3ba2fe55294d752b79842c530ccfab760192521df74a081a78d2b3c7f5" +checksum = "426ee0486d2572a6c5e39fbdbc48b58d59bb555f3326f54631025266cf04146e" dependencies = [ - "cc", - "libc", - "pkg-config", + "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/backend/Cargo.toml b/frontend/Cargo.toml similarity index 57% rename from backend/Cargo.toml rename to frontend/Cargo.toml index 3f2713e..5246bba 100644 --- a/backend/Cargo.toml +++ b/frontend/Cargo.toml @@ -1,17 +1,13 @@ [package] -name = "backend" +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] -tokio = { version = "1", features = ["full"] } -dotenv = "0.15" -actix-web = "4" -tokio-postgres = { version = "0.7.8", features = ["with-chrono-0_4"] } +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"] } -async-trait = "0.1.68" -dotenv_codegen = "0.15.0" \ No newline at end of file +yew-router = "0.17" \ No newline at end of file diff --git a/frontend/index.html b/frontend/index.html new file mode 100644 index 0000000..d5763a5 --- /dev/null +++ b/frontend/index.html @@ -0,0 +1,8 @@ + + + + + + Каршеринг от Гуся + + \ No newline at end of file diff --git a/frontend/src/components/app.rs b/frontend/src/components/app.rs new file mode 100644 index 0000000..1671bde --- /dev/null +++ b/frontend/src/components/app.rs @@ -0,0 +1,16 @@ +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 new file mode 100644 index 0000000..cd71037 --- /dev/null +++ b/frontend/src/components/header.rs @@ -0,0 +1,51 @@ +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 new file mode 100644 index 0000000..0ee30ba --- /dev/null +++ b/frontend/src/components/mod.rs @@ -0,0 +1,3 @@ +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 new file mode 100644 index 0000000..5742fdc --- /dev/null +++ b/frontend/src/components/router.rs @@ -0,0 +1,82 @@ +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 new file mode 100644 index 0000000..cb3e897 --- /dev/null +++ b/frontend/src/lib.rs @@ -0,0 +1,2 @@ +pub mod models; +pub mod components; \ No newline at end of file diff --git a/frontend/src/main.rs b/frontend/src/main.rs new file mode 100644 index 0000000..273b42d --- /dev/null +++ b/frontend/src/main.rs @@ -0,0 +1,5 @@ +mod components; + +fn main() { + yew::Renderer::::new().render(); +} diff --git a/backend/src/models/car.rs b/frontend/src/models/car.rs similarity index 90% rename from backend/src/models/car.rs rename to frontend/src/models/car.rs index ec2fa17..211a734 100644 --- a/backend/src/models/car.rs +++ b/frontend/src/models/car.rs @@ -1,4 +1,4 @@ -use serde::{Serialize, Deserialize}; +use serde::{ Serialize, Deserialize }; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Car { diff --git a/backend/src/models/car_station.rs b/frontend/src/models/car_station.rs similarity index 84% rename from backend/src/models/car_station.rs rename to frontend/src/models/car_station.rs index 1e208a2..87f9238 100644 --- a/backend/src/models/car_station.rs +++ b/frontend/src/models/car_station.rs @@ -1,4 +1,4 @@ -use serde::{Serialize, Deserialize}; +use serde::{ Serialize, Deserialize }; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct CarStation { diff --git a/backend/src/models/client.rs b/frontend/src/models/client.rs similarity index 90% rename from backend/src/models/client.rs rename to frontend/src/models/client.rs index 0e0f7a7..1fbeb4b 100644 --- a/backend/src/models/client.rs +++ b/frontend/src/models/client.rs @@ -1,4 +1,4 @@ -use serde::{Serialize, Deserialize}; +use serde::{ Serialize, Deserialize }; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Client { diff --git a/backend/src/models/mod.rs b/frontend/src/models/mod.rs similarity index 79% rename from backend/src/models/mod.rs rename to frontend/src/models/mod.rs index 4783b7d..66a08c9 100644 --- a/backend/src/models/mod.rs +++ b/frontend/src/models/mod.rs @@ -1,4 +1,4 @@ -pub mod client; pub mod car_station; pub mod car; +pub mod client; pub mod rent; \ No newline at end of file diff --git a/backend/src/models/rent.rs b/frontend/src/models/rent.rs similarity index 88% rename from backend/src/models/rent.rs rename to frontend/src/models/rent.rs index 72dec1c..faa8924 100644 --- a/backend/src/models/rent.rs +++ b/frontend/src/models/rent.rs @@ -3,7 +3,7 @@ use serde::{Serialize, Deserialize}; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Rent { pub id: i32, - pub start_time: chrono::NaiveTime, + pub start_time: chrono::NaiveDateTime, pub time_amount: Option, pub client_id: i32, pub car_id: i32 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 2/2] =?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