From e4305fbb4160b3a5055a0645ececf9da17ea7cbd Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Fri, 23 Dec 2022 11:40:44 +0200 Subject: [PATCH] CAPITAL BUT WILL CHANGE --- Backend/Cargo.toml | 16 + Backend/LICENSE | 21 + Backend/diesel.toml | 8 + Backend/migrations/.keep | 0 .../down.sql | 6 + .../up.sql | 36 + Backend/src/admin_data.rs | 40 + Backend/src/driver_data.rs | 21 + Backend/src/lib.rs | 34 + Backend/src/models.rs | 106 +++ Backend/src/radar_data.rs | 0 Backend/src/schema.rs | 132 +++ Backend/src/ticket_data.rs | 57 ++ Backend/src/vehicle_data.rs | 0 Frontend/Cargo.lock | 866 ++++++++++++++++++ Frontend/Cargo.toml | 10 + Frontend/index.html | 7 + Frontend/src/main.rs | 61 ++ 18 files changed, 1421 insertions(+) create mode 100644 Backend/Cargo.toml create mode 100644 Backend/LICENSE create mode 100644 Backend/diesel.toml create mode 100644 Backend/migrations/.keep create mode 100644 Backend/migrations/00000000000000_diesel_initial_setup/down.sql create mode 100644 Backend/migrations/00000000000000_diesel_initial_setup/up.sql create mode 100644 Backend/src/admin_data.rs create mode 100644 Backend/src/driver_data.rs create mode 100644 Backend/src/lib.rs create mode 100644 Backend/src/models.rs create mode 100644 Backend/src/radar_data.rs create mode 100644 Backend/src/schema.rs create mode 100644 Backend/src/ticket_data.rs create mode 100644 Backend/src/vehicle_data.rs create mode 100644 Frontend/Cargo.lock create mode 100644 Frontend/Cargo.toml create mode 100644 Frontend/index.html create mode 100644 Frontend/src/main.rs diff --git a/Backend/Cargo.toml b/Backend/Cargo.toml new file mode 100644 index 0000000..175fd33 --- /dev/null +++ b/Backend/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "backend" +version = "0.1.0" +edition = "2021" +default-run = "main" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +diesel = { version = "2.0.0",features = ["postgres","r2d2"] } +dotenv = "0.15" +chrono = "0.2.25" +common = { path = "../common"} +actix-web = "4.0.0-rc.1" +tokio = { version = "1.17.0", features = ["full"] } +yew = { version = "0.20.0", features = ["csr"] } diff --git a/Backend/LICENSE b/Backend/LICENSE new file mode 100644 index 0000000..f1e6739 --- /dev/null +++ b/Backend/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Linly + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Backend/diesel.toml b/Backend/diesel.toml new file mode 100644 index 0000000..35a12ff --- /dev/null +++ b/Backend/diesel.toml @@ -0,0 +1,8 @@ +# For documentation on how to configure this file, +# see https://diesel.rs/guides/configuring-diesel-cli + +[print_schema] +file = "src/schema.rs" + +[migrations_directory] +dir = "migrations" diff --git a/Backend/migrations/.keep b/Backend/migrations/.keep new file mode 100644 index 0000000..e69de29 diff --git a/Backend/migrations/00000000000000_diesel_initial_setup/down.sql b/Backend/migrations/00000000000000_diesel_initial_setup/down.sql new file mode 100644 index 0000000..a9f5260 --- /dev/null +++ b/Backend/migrations/00000000000000_diesel_initial_setup/down.sql @@ -0,0 +1,6 @@ +-- This file was automatically created by Diesel to setup helper functions +-- and other internal bookkeeping. This file is safe to edit, any future +-- changes will be added to existing projects as new migrations. + +DROP FUNCTION IF EXISTS diesel_manage_updated_at(_tbl regclass); +DROP FUNCTION IF EXISTS diesel_set_updated_at(); diff --git a/Backend/migrations/00000000000000_diesel_initial_setup/up.sql b/Backend/migrations/00000000000000_diesel_initial_setup/up.sql new file mode 100644 index 0000000..d68895b --- /dev/null +++ b/Backend/migrations/00000000000000_diesel_initial_setup/up.sql @@ -0,0 +1,36 @@ +-- This file was automatically created by Diesel to setup helper functions +-- and other internal bookkeeping. This file is safe to edit, any future +-- changes will be added to existing projects as new migrations. + + + + +-- Sets up a trigger for the given table to automatically set a column called +-- `updated_at` whenever the row is modified (unless `updated_at` was included +-- in the modified columns) +-- +-- # Example +-- +-- ```sql +-- CREATE TABLE users (id SERIAL PRIMARY KEY, updated_at TIMESTAMP NOT NULL DEFAULT NOW()); +-- +-- SELECT diesel_manage_updated_at('users'); +-- ``` +CREATE OR REPLACE FUNCTION diesel_manage_updated_at(_tbl regclass) RETURNS VOID AS $$ +BEGIN + EXECUTE format('CREATE TRIGGER set_updated_at BEFORE UPDATE ON %s + FOR EACH ROW EXECUTE PROCEDURE diesel_set_updated_at()', _tbl); +END; +$$ LANGUAGE plpgsql; + +CREATE OR REPLACE FUNCTION diesel_set_updated_at() RETURNS trigger AS $$ +BEGIN + IF ( + NEW IS DISTINCT FROM OLD AND + NEW.updated_at IS NOT DISTINCT FROM OLD.updated_at + ) THEN + NEW.updated_at := current_timestamp; + END IF; + RETURN NEW; +END; +$$ LANGUAGE plpgsql; diff --git a/Backend/src/admin_data.rs b/Backend/src/admin_data.rs new file mode 100644 index 0000000..d188ac5 --- /dev/null +++ b/Backend/src/admin_data.rs @@ -0,0 +1,40 @@ +use crate::models::{Admin, AdminEmail, NewAdmin, NewAdminEmail}; +use diesel::prelude::*; + +pub fn listadmins(connection: &mut PgConnection) -> String { + use crate::schema::admins::dsl::*; + let query = admins.load::(connection).expect("KANKER"); + let admin_list = query + .iter() + .map(|admin| format!("{} {}\n", admin.name, admin.address)) + .collect(); + return admin_list; +} +pub fn addmin(connection: &mut PgConnection, new_admin: NewAdmin) { + use crate::schema::admins::dsl::*; + diesel::insert_into(admins) + .values(&new_admin) + .execute(connection) + .expect("LOL DEAD NOT WORKING INSERTION"); +} +pub fn addmail(connection: &mut PgConnection, admin_email: String, inserted_id: i32) { + use crate::schema::admin_emails::dsl::*; + let inserted_email = NewAdminEmail { + admin_id: &inserted_id, + email: &admin_email, + }; + diesel::insert_into(admin_emails) + .values(inserted_email) + .execute(connection) + .expect("You FOOL! You didn't put an email in there"); +} + +pub fn listadminmails(connection: &mut PgConnection) { + use crate::schema::admin_emails::dsl::*; + let results = admin_emails + .load::(connection) + .expect("hecc D:"); + for addmail in results { + println!("{} {}", addmail.email, addmail.admin_id); + } +} diff --git a/Backend/src/driver_data.rs b/Backend/src/driver_data.rs new file mode 100644 index 0000000..d1c64e6 --- /dev/null +++ b/Backend/src/driver_data.rs @@ -0,0 +1,21 @@ +use diesel::prelude::*; +use crate::models::{Driver,NewDriver}; + +pub fn listdrivers(connection: &mut PgConnection) +{ + use crate::schema::drivers::dsl::*; + let queury = drivers.load::(connection).expect("KANKER"); + for driver in queury + { + println!("{} {}",driver.name ,driver.address); + } +} + +pub fn addriver(connection: &mut PgConnection, new_driver: NewDriver){ + + use crate::schema::drivers::dsl::*; + diesel::insert_into(drivers) + .values(&new_driver) + .execute(connection) + .expect("Couldn't insert new driver :)"); +} diff --git a/Backend/src/lib.rs b/Backend/src/lib.rs new file mode 100644 index 0000000..f614478 --- /dev/null +++ b/Backend/src/lib.rs @@ -0,0 +1,34 @@ +use std::env; +pub mod admin_data; +pub mod driver_data; +pub mod models; +pub mod radar_data; +pub mod schema; +pub mod ticket_data; +pub mod vehicle_data; +use diesel::{Connection, PgConnection}; +use dotenv::dotenv; + +//boiler plate :D +pub fn establish_connection() -> PgConnection { + dotenv().ok(); + let database_url = env::var("DATABASE_URL").expect("fix your .env idot"); + PgConnection::establish(&database_url) + .unwrap_or_else(|_| panic!("Error connecting to {}", database_url)) +} +// +//Pool instead + +// pub type PgPool = r2d2::Pool>; +// pub type PgPooledConnection = PooledConnection>; +// fn init_pool(database_url: &str) -> Result { +// let manager = ConnectionManager::::new(database_url); +// Pool::builder().build(manager) +// } +// +// pub fn establish_connection() -> PgPool { +// dotenv().ok(); +// +// let database_url = env::var("DATABASE_URL").expect("pls obama put the link this time"); +// init_pool(&database_url).expect("Failed to create pool") +// } diff --git a/Backend/src/models.rs b/Backend/src/models.rs new file mode 100644 index 0000000..c9b89c4 --- /dev/null +++ b/Backend/src/models.rs @@ -0,0 +1,106 @@ +use diesel::{prelude::*, data_types::PgDate}; +use crate::schema::*; + + + +//Admins +#[derive(Queryable,Debug,AsChangeset,Identifiable)] +pub +struct Admin { + pub id: i32, + pub name: String, + pub address: String +} + +#[derive(Insertable)] +#[diesel(table_name = admins)] +pub +struct NewAdmin<'a> { + pub id: i32, + pub name: &'a str, + pub address: &'a str +} + +#[derive(Queryable,AsChangeset,Associations)] +#[diesel(belongs_to(Admin))] +pub struct AdminEmail { + pub admin_id: i32, + pub email: String, +} + +#[derive(Insertable,Associations)] +#[diesel(belongs_to(Admin))] +#[diesel(table_name = admin_emails)] +pub struct NewAdminEmail<'a> { + pub admin_id: &'a i32, + pub email: &'a str, +} + + +//Ticket things +#[derive(Queryable)] +pub struct Ticket { + pub id: i32, + pub category: String, + pub description: String, + pub issue_date: PgDate +} + +#[derive(Insertable)] +#[diesel(table_name = tickets)] +pub struct NewTicket<'a> { + pub category: &'a str, + pub description: &'a str, +} + +#[derive(Insertable)] +#[diesel(table_name = issued_tickets)] +pub struct IssuedTicket { + ticket: i32, + vehicle: String, + driver: Option, + officer: i32, +} + +#[derive(Insertable)] +#[diesel(table_name = auto_issued_tickets)] +pub struct AutoIssuedTicket<'a> { + ticket: &'a i32, + vehicle: &'a str, + driver: Option, + radar: &'a i32, +} + +//Drivers +#[derive(Queryable,AsChangeset,Identifiable)] +pub struct Driver { + pub id: i32, + pub name: String, + pub address: String, + pub reg_date: PgDate, + pub birthdate: PgDate, +} + +#[derive(Insertable)] +#[diesel(table_name = drivers)] +pub +struct NewDriver<'a> { + pub id: i32, + pub name: &'a str, + pub address: &'a str, + reg_date: PgDate, + birthdate: PgDate, +} + +//Vehicles +#[derive(Queryable,AsChangeset)] +#[diesel(belongs_to(Driver))] +pub struct Vehicle { + pub model: Option, + pub color: Option, + pub chasse_num: i32, + pub plate_num: String, + pub vehicle_type: String, + pub owner: i32 + +} diff --git a/Backend/src/radar_data.rs b/Backend/src/radar_data.rs new file mode 100644 index 0000000..e69de29 diff --git a/Backend/src/schema.rs b/Backend/src/schema.rs new file mode 100644 index 0000000..5c41e55 --- /dev/null +++ b/Backend/src/schema.rs @@ -0,0 +1,132 @@ +// @generated automatically by Diesel CLI. + +diesel::table! { + admin_emails (admin_id, email) { + admin_id -> Int4, + email -> Text, + } +} + +diesel::table! { + admins (id) { + id -> Int4, + name -> Text, + address -> Text, + } +} + +diesel::table! { + auto_issued_tickets (ticket) { + ticket -> Int4, + vehicle -> Text, + driver -> Nullable, + radar -> Int4, + } +} + +diesel::table! { + driver_phones (driver, number) { + driver -> Int4, + number -> Int4, + } +} + +diesel::table! { + drivers (id) { + id -> Int4, + name -> Text, + address -> Text, + reg_date -> Date, + birthdate -> Date, + } +} + +diesel::table! { + issued_tickets (ticket) { + ticket -> Int4, + vehicle -> Text, + driver -> Nullable, + officer -> Int4, + } +} + +diesel::table! { + officer_emails (officer, email) { + officer -> Int4, + email -> Text, + } +} + +diesel::table! { + officer_phones (officer, number) { + officer -> Int4, + number -> Int4, + } +} + +diesel::table! { + officers (badge_num) { + badge_num -> Int4, + id -> Text, + jurisdiction -> Nullable, + } +} + +diesel::table! { + radars (serialnumber) { + serialnumber -> Int4, + #[sql_name = "type"] + type_ -> Nullable, + address -> Nullable, + } +} + +diesel::table! { + tickets (id) { + id -> Int4, + category -> Text, + description -> Text, + issue_date -> Date, + } +} + +diesel::table! { + vehicles (plate_num) { + model -> Nullable, + color -> Nullable, + chasse_num -> Nullable, + plate_num -> Text, + vehicle_type -> Text, + category -> Text, + owner -> Nullable, + } +} + +diesel::joinable!(admin_emails -> admins (admin_id)); +diesel::joinable!(auto_issued_tickets -> drivers (driver)); +diesel::joinable!(auto_issued_tickets -> radars (radar)); +diesel::joinable!(auto_issued_tickets -> tickets (ticket)); +diesel::joinable!(auto_issued_tickets -> vehicles (vehicle)); +diesel::joinable!(driver_phones -> drivers (driver)); +diesel::joinable!(issued_tickets -> drivers (driver)); +diesel::joinable!(issued_tickets -> officers (officer)); +diesel::joinable!(issued_tickets -> tickets (ticket)); +diesel::joinable!(issued_tickets -> vehicles (vehicle)); +diesel::joinable!(officer_emails -> officers (officer)); +diesel::joinable!(officer_phones -> officers (officer)); +diesel::joinable!(vehicles -> drivers (owner)); + +diesel::allow_tables_to_appear_in_same_query!( + admin_emails, + admins, + auto_issued_tickets, + driver_phones, + drivers, + issued_tickets, + officer_emails, + officer_phones, + officers, + radars, + tickets, + vehicles, +); diff --git a/Backend/src/ticket_data.rs b/Backend/src/ticket_data.rs new file mode 100644 index 0000000..6f30221 --- /dev/null +++ b/Backend/src/ticket_data.rs @@ -0,0 +1,57 @@ +use crate::models::{AutoIssuedTicket, IssuedTicket, NewTicket, Ticket}; +use common::CommonTicket; +use diesel::prelude::*; + +pub fn create_ticket(connection: &mut PgConnection, ticket: NewTicket) { + use crate::schema::tickets::dsl::*; + diesel::insert_into(tickets) + .values(&ticket) + .execute(connection) + .expect("Didn't save ticket AAAAAA"); +} + +pub fn get_tickets(connection: &mut PgConnection, amount: i64) -> Vec { + use crate::schema::tickets::dsl::*; + let results = tickets + .limit(amount) + .load::(connection) + .expect("KANKER TIKET"); + return results + .iter() + .map(|ticket| CommonTicket { + id: ticket.id, + category: String::from(&ticket.category), + description: String::from(&ticket.description), + }) + .collect(); //Shoves everything to a vector +} + +pub fn get_ticket(connection: &mut PgConnection, tickid: i32) -> CommonTicket { + use crate::schema::tickets::dsl::*; + let ticket = &mut tickets + .filter(id.eq(tickid)) + .limit(1) + .load::(connection) + .expect("no tickets :(")[0]; + return CommonTicket { + id: ticket.id, + category: String::from(&ticket.category), + description: String::from(&ticket.description), + }; +} + +pub fn issue_ticket(connection: &mut PgConnection, issued_ticket: IssuedTicket) { + use crate::schema::issued_tickets::dsl::*; + diesel::insert_into(issued_tickets) + .values(issued_ticket) + .execute(connection) + .expect("PAINNNN IT NO WORKEY (issued tickets)"); +} + +pub fn auto_issue_ticket(connection: &mut PgConnection, issued_ticket: AutoIssuedTicket) { + use crate::schema::auto_issued_tickets::dsl::*; + diesel::insert_into(auto_issued_tickets) + .values(issued_ticket) + .execute(connection) + .expect("PAINNNN IT NO WORKEY (issued tickets)"); +} diff --git a/Backend/src/vehicle_data.rs b/Backend/src/vehicle_data.rs new file mode 100644 index 0000000..e69de29 diff --git a/Frontend/Cargo.lock b/Frontend/Cargo.lock new file mode 100644 index 0000000..cd9c47b --- /dev/null +++ b/Frontend/Cargo.lock @@ -0,0 +1,866 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[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.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[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 = "db-frontend" +version = "0.1.0" +dependencies = [ + "yew", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" + +[[package]] +name = "futures-io" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" + +[[package]] +name = "futures-macro" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" + +[[package]] +name = "futures-task" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" + +[[package]] +name = "futures-util" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" +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 = [ + "gloo-events", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "gloo-history" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ce5ae65c5d76e2bbd9f274d7dcc00a306a79964305efa275a0ac728caaeb792" +dependencies = [ + "gloo-events", + "gloo-utils", + "serde", + "serde-wasm-bindgen", + "serde_urlencoded", + "thiserror", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "gloo-net" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9050ff8617e950288d7bf7f300707639fdeda5ca0d0ecf380cff448cfd52f4a6" +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.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98c4a8d6391675c6b2ee1a6c8d06e8e2d03605c44cec1270675985a4c2a5500b" +dependencies = [ + "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.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "implicit-clone" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "649cb12b410f9519ebc452e87a8e32c4f8cfc080968cf9b4db43d40d1da4d7e4" +dependencies = [ + "indexmap", +] + +[[package]] +name = "indexmap" +version = "1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "itoa" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" + +[[package]] +name = "js-sys" +version = "0.3.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.138" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" + +[[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_cpus" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" + +[[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", +] + +[[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.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c142c0e46b57171fe0c528bee8c5b7569e80f0c17e377cd0e30ea57dbc11bb51" +dependencies = [ + "proc-macro2", + "syn", +] + +[[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", + "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.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +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.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rustversion" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" + +[[package]] +name = "ryu" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" + +[[package]] +name = "serde" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "256b9932320c590e707b94576e3cc1f7c9024d0ee6612dfbcf1cb106cbe8e055" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde-wasm-bindgen" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "618365e8e586c22123d692b72a7d791d5ee697817b65a218cdf12a98870af0f7" +dependencies = [ + "fnv", + "js-sys", + "serde", + "wasm-bindgen", +] + +[[package]] +name = "serde_derive" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4eae9b04cbffdfd550eb462ed33bc6a1b68c935127d008b27444d08380f94e4" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db" +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.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] + +[[package]] +name = "syn" +version = "1.0.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio" +version = "1.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eab6d665857cc6ca78d6e80303a02cea7a7851e85dfbd77cbdc09bd129f1ef46" +dependencies = [ + "autocfg", + "pin-project-lite", + "windows-sys", +] + +[[package]] +name = "tokio-stream" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" +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", +] + +[[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.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasm-bindgen" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" + +[[package]] +name = "web-sys" +version = "0.3.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +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.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" + +[[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", +] diff --git a/Frontend/Cargo.toml b/Frontend/Cargo.toml new file mode 100644 index 0000000..1cdee84 --- /dev/null +++ b/Frontend/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "db-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"] } +common = { path = "../common"} diff --git a/Frontend/index.html b/Frontend/index.html new file mode 100644 index 0000000..82479d5 --- /dev/null +++ b/Frontend/index.html @@ -0,0 +1,7 @@ + + + + + Ze greatest + + diff --git a/Frontend/src/main.rs b/Frontend/src/main.rs new file mode 100644 index 0000000..d693b6a --- /dev/null +++ b/Frontend/src/main.rs @@ -0,0 +1,61 @@ +use yew::prelude::*; +use common::CommonTicket; +#[function_component] +fn App() -> Html { + let counter = use_state(|| 0); + let onclick = { + let counter = counter.clone(); + move |_| { + let value = *counter + 1; + counter.set(value); + } + }; + +let stdnts = vec! [ + Stdnt { + id: 1, + name: "Hamada".to_string(), + email: "Hamada@Gmail.com".to_string(), + gpa: 3.4 + }, + Stdnt { + id: 2, + name: "Gamal".to_string(), + email: "Gamal@Gmail.com".to_string(), + gpa: 4.0 + }, + Stdnt { + id: 3, + name: "Joe".to_string(), + email: "joe@proton.mail".to_string(), + gpa: 3.8 + } +]; +let stdnts_comp = stdnts.iter().map(|stdnt| html! { + <> +

{format!("Name: {}", stdnt.name)}

+

{format!("Email: {}", stdnt.email)}

+

{format!("GPA: {}",stdnt.gpa)}

+
+ +}).collect::(); + + html! { +
+ +

{ *counter }

+

{ "Students:" }

+

{ stdnts_comp }

+
+ } +} +struct Stdnt { + id: usize, + name: String, + gpa: f32, + email: String, +} + +fn main() { + yew::Renderer::::new().render(); +}