diff --git a/.gitignore b/.gitignore index b81632a..0464c1d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ backend/target backend/.env +backend/start.bat frontend/elm-stuff -.idea \ No newline at end of file +.idea diff --git a/Database_Relationship_Diagram.pdf b/Database_Relationship_Diagram.pdf new file mode 100644 index 0000000..758522d Binary files /dev/null and b/Database_Relationship_Diagram.pdf differ diff --git a/Mockups/PNG/Chemical Database Advanced Search.png b/Mockups/PNG/Chemical Database Advanced Search.png new file mode 100644 index 0000000..ab62602 Binary files /dev/null and b/Mockups/PNG/Chemical Database Advanced Search.png differ diff --git a/Mockups/PNG/Chemical Database New Chemical 2.png b/Mockups/PNG/Chemical Database New Chemical 2.png new file mode 100644 index 0000000..8be8e13 Binary files /dev/null and b/Mockups/PNG/Chemical Database New Chemical 2.png differ diff --git a/Mockups/PNG/Chemical Database New Chemical 3.png b/Mockups/PNG/Chemical Database New Chemical 3.png new file mode 100644 index 0000000..6e0fe8a Binary files /dev/null and b/Mockups/PNG/Chemical Database New Chemical 3.png differ diff --git a/Mockups/PNG/Chemical Database New Chemical.png b/Mockups/PNG/Chemical Database New Chemical.png new file mode 100644 index 0000000..5ac9927 Binary files /dev/null and b/Mockups/PNG/Chemical Database New Chemical.png differ diff --git a/Mockups/PNG/Chemical Database Search.png b/Mockups/PNG/Chemical Database Search.png new file mode 100644 index 0000000..e55f06f Binary files /dev/null and b/Mockups/PNG/Chemical Database Search.png differ diff --git a/Mockups/PNG/Chemical Database Website.png b/Mockups/PNG/Chemical Database Website.png new file mode 100644 index 0000000..098e7e5 Binary files /dev/null and b/Mockups/PNG/Chemical Database Website.png differ diff --git a/Mockups/SVG/Chemical Database Advanced Search.svg b/Mockups/SVG/Chemical Database Advanced Search.svg new file mode 100644 index 0000000..ec769c2 --- /dev/null +++ b/Mockups/SVG/Chemical Database Advanced Search.svg @@ -0,0 +1,400 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + Chemical Database + + + + + + + + + Building + Room + Product Name + Manufacturer + Ingredients + Keyword(s) + State of Matter + GHS Label + Advanced Search + + + + + + + + + + + + + + + + + diff --git a/Mockups/SVG/Chemical Database New Chemical 2.svg b/Mockups/SVG/Chemical Database New Chemical 2.svg new file mode 100644 index 0000000..5e04ecb --- /dev/null +++ b/Mockups/SVG/Chemical Database New Chemical 2.svg @@ -0,0 +1,630 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + Chemical Database + + + + + + + + + + Substance Information Amount of Chemical + + + + + Quantity + + Container Type + + Purpose + + + + + State of Matter + + + + + SDS Information SDS Link + + Signal Word + GHS labeling + + P-Codes + + + + + + + + H-Codes + + + Date Recieved + + Date Expiration + Days until expiration + + + + + + + + + diff --git a/Mockups/SVG/Chemical Database New Chemical 3.svg b/Mockups/SVG/Chemical Database New Chemical 3.svg new file mode 100644 index 0000000..f388b3c --- /dev/null +++ b/Mockups/SVG/Chemical Database New Chemical 3.svg @@ -0,0 +1,411 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + Ingredients + Chemical Database + + + + + + + + + Does this chemical contain petroleum? + + Ingredients + CAS Number + Weight % + + + + + + + + + + + + + + + + *Only the top 5 ingredients on the SDS are needed if there is more than 5 ingredients in the chemical + Powered by A-Team + + If so, what is the weight percent? + + + diff --git a/Mockups/SVG/Chemical Database New Chemical.svg b/Mockups/SVG/Chemical Database New Chemical.svg new file mode 100644 index 0000000..50142ce --- /dev/null +++ b/Mockups/SVG/Chemical Database New Chemical.svg @@ -0,0 +1,73 @@ + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/Mockups/SVG/Chemical Database Search.svg b/Mockups/SVG/Chemical Database Search.svg new file mode 100644 index 0000000..eebe028 --- /dev/null +++ b/Mockups/SVG/Chemical Database Search.svg @@ -0,0 +1,772 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + Chemical Database + + + + Chemical Name 1 + Chemical Name 2 + Chemical Name 3 + + + Isopropyl Alcohol + + + + + + + + + + + + + Location Building + Location Building + Location Building + Location Room + Location Room + Location Room + + Manufacturer Name + Manufacturer Name + Manufacturer Name + Building + + + + + + + EngineeringRowan Hall + + + + + + + + + + + Chemical Name 4 + + + + + Location Building + Location Room + Manufacturer Name + Manufacturer + Company #1Company #2Company #3Company #4 + + + + + + + diff --git a/Mockups/SVG/Chemical Database Website.svg b/Mockups/SVG/Chemical Database Website.svg new file mode 100644 index 0000000..1a70d25 --- /dev/null +++ b/Mockups/SVG/Chemical Database Website.svg @@ -0,0 +1,276 @@ + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + Chemical Database Powered by A-Team + Advanced Search + + + + + + + + + + + + + + + diff --git a/README.md b/README.md index da36a6b..d6fb9a2 100644 --- a/README.md +++ b/README.md @@ -16,20 +16,4 @@ Coded in Rust, manages database manipulation using AJAX requests from frontend. * [simplelog](https://github.com/drakulix/simplelog.rs) ## frontend -Coded in Elm, makes requests to the backend to access database and returns to the user. - -### Dependencies: -* Core Elm Packages - * [browser](https://github.com/elm/browser) - * [core](https://github.com/elm/core) - * [html](https://github.com/elm/html) - * [http](https://github.com/elm/http) - * [json](https://github.com/elm/json) - * [url](https://github.com/elm/url) - * [bytes](https://github.com/elm/bytes) - * [file](https://github.com/elm/file) - * [time](https://github.com/elm/time) - * [virtual-dom](https://github.com/elm/virtual-dom) -* [elm-json-decode-pipeline 1.0.0](https://github.com/NoRedInk/elm-json-decode-pipeline) -* [elm-format-number 6.0.2](https://github.com/cuducos/elm-format-number) -* [elm-round 1.0.4](https://github.com/myrho/elm-round) +Coded in HTML/CSS/JS, makes requests to the backend to access database and returns to the user. \ No newline at end of file diff --git a/backend/Cargo.lock b/backend/Cargo.lock index f901f2b..c79987c 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -183,6 +183,15 @@ dependencies = [ "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "diesel_migrations" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "migrations_internals 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "migrations_macros 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "dotenv" version = "0.13.0" @@ -305,6 +314,24 @@ dependencies = [ "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "migrations_internals" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "diesel 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "migrations_macros" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "migrations_internals 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "mime" version = "0.2.6" @@ -429,6 +456,11 @@ name = "quick-error" version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "quote" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "quote" version = "0.6.11" @@ -708,6 +740,16 @@ dependencies = [ "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "syn" +version = "0.11.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "syn" version = "0.15.26" @@ -718,6 +760,14 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "synom" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "synstructure" version = "0.10.1" @@ -822,6 +872,11 @@ dependencies = [ "smallvec 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "unicode-xid" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "unicode-xid" version = "0.1.0" @@ -871,6 +926,7 @@ version = "0.1.0" dependencies = [ "csv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "diesel 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "diesel_migrations 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "dotenv 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "rouille 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -924,6 +980,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum deflate 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)" = "8a6abb26e16e8d419b5c78662aa9f82857c2386a073da266840e474d5055ec86" "checksum diesel 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "66d7d3a2f8a24763a1a52b5324737b4d24141bb294440ed9094db60bd6cd29ee" "checksum diesel_derives 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "62a27666098617d52c487a41f70de23d44a1dc1f3aa5877ceba2790fb1f1cab4" +"checksum diesel_migrations 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3cde8413353dc7f5d72fa8ce0b99a560a359d2c5ef1e5817ca731cd9008f4c" "checksum dotenv 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d0a1279c96732bc6800ce6337b6a614697b0e74ae058dc03c62ebeb78b4d86" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" @@ -940,6 +997,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" "checksum memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e1dd4eaac298c32ce07eb6ed9242eda7d82955b9170b7d6db59b2e02cc63fcb8" +"checksum migrations_internals 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8089920229070f914b9ce9b07ef60e175b2b9bc2d35c3edd8bf4433604e863b9" +"checksum migrations_macros 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1664412abf7db2b8a6d58be42a38b099780cc542b5b350383b805d88932833fe" "checksum mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0" "checksum mime_guess 1.8.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2d4c0961143b8efdcfa29c3ae63281601b446a4a668165454b6c90f8024954c5" "checksum multipart 0.15.4 (registry+https://github.com/rust-lang/crates.io-index)" = "adba94490a79baf2d6a23eac897157047008272fa3eecb3373ae6377b91eca28" @@ -955,6 +1014,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" "checksum proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)" = "38fddd23d98b2144d197c0eca5705632d4fe2667d14a6be5df8934f8d74f1978" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" +"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" "checksum rand 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "dee497e66d8d76bf08ce20c8d36e16f93749ab0bf89975b4f8ae5cee660c2da2" "checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c" @@ -987,7 +1047,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum simplelog 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e95345f185d5adeb8ec93459d2dc99654e294cc6ccf5b75414d8ea262de9a13" "checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" "checksum smallvec 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "88aea073965ab29f6edb5493faf96ad662fb18aa9eeb186a3b7057951605ed15" +"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" "checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9" +"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" "checksum term 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5e6b677dd1e8214ea1ef4297f85dbcbed8e8cdddb561040cc998ca2551c37561" @@ -1000,6 +1062,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426" +"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" "checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" diff --git a/backend/Cargo.toml b/backend/Cargo.toml index cf8acf8..697c6cd 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -7,6 +7,7 @@ edition = "2018" [dependencies] rouille = "3.0.0" diesel = { version = "1.3.3", features = ["mysql"] } +diesel_migrations = "1.4.0" dotenv = "0.13.0" serde = { version = "1.0", features = ["derive"]} serde_json = "1.0" diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..0a85710 --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,17 @@ +# Use rust image +FROM rust:1.33 + +# Set working directory of rust app +WORKDIR /usr/src/webdev + +# Copy current directory, into docker +COPY . /usr/src/webdev + +# Build the app +RUN cargo build --release + +# Make port 8080 available +EXPOSE 8000:8000 + +# Run the app +CMD ["target/release/web_dev"] diff --git a/backend/src/lib.rs b/backend/src/lib.rs index 8a0f7a3..2fdbd10 100644 --- a/backend/src/lib.rs +++ b/backend/src/lib.rs @@ -1,6 +1,9 @@ #[macro_use] extern crate diesel; +#[macro_use] +extern crate diesel_migrations; + pub mod errors; pub mod users; diff --git a/backend/src/main.rs b/backend/src/main.rs index e8ea9fa..d0ee78b 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -1,10 +1,14 @@ +#[macro_use] +extern crate diesel_migrations; + use std::env; use std::sync::Mutex; +use std::thread; +use std::time; use log::debug; use log::error; use log::info; -use log::trace; use log::warn; use diesel::prelude::*; @@ -18,17 +22,19 @@ use web_dev::errors::WebdevErrorKind; use web_dev::users::models::UserRequest; use web_dev::users::requests::handle_user; +embed_migrations!(); + fn main() { dotenv().ok(); - simplelog::TermLogger::init(simplelog::LevelFilter::Trace, simplelog::Config::default()) + simplelog::SimpleLogger::init(simplelog::LevelFilter::Trace, simplelog::Config::default()) .unwrap(); info!("Connecting to database"); let database_url = match env::var("DATABASE_URL") { Ok(url) => url, - Err(e) => { + Err(_e) => { error!("Could not read DATABASE_URL environment variable"); return; } @@ -36,16 +42,22 @@ fn main() { debug!("Connecting to {}", database_url); - let connection = match MysqlConnection::establish(&database_url) { - Ok(c) => c, - Err(e) => { - error!("Could not connect to database: {}", e); - return; + let connection = loop { + match MysqlConnection::establish(&database_url) { + Ok(c) => break c, + Err(e) => { + warn!("Could not connect to database: {}", e); + info!("Retrying in a second"); + thread::sleep(time::Duration::from_secs(1)); + } } }; debug!("Connected to database"); + info!("Running migrations"); + embedded_migrations::run(&connection); + let connection_mutex = Mutex::new(connection); info!("Starting server on 0.0.0.0:8000"); diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..96b735b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,30 @@ +version: "3.1" +services: + api: + image: webdev_api + deploy: + replicas: 1 + resources: + limits: + cpus: "0.1" + memory: 50M + restart_policy: + condition: on-failure + ports: + - "8000:8000" + environment: + DATABASE_URL: mysql://root:apple1@db/web_dev + + db: + image: mysql + command: --default-authentication-plugin=mysql_native_password + restart: always + environment: + MYSQL_ROOT_PASSWORD: apple1 + MYSQL_DATABASE: web_dev + + frontend: + image: webdev_frontend + ports: + - "80:80" + diff --git a/docker.sh b/docker.sh new file mode 100644 index 0000000..561bf70 --- /dev/null +++ b/docker.sh @@ -0,0 +1,3 @@ +docker build -t webdev_frontend frontend +docker build -t webdev_api backend +docker-compose up -d diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000..e10f250 --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,5 @@ +FROM httpd:2.4 +COPY ./www /usr/local/apache2/htdocs +COPY ./apache2/httpd.conf /usr/local/apache2/conf/httpd.conf +EXPOSE 80 + diff --git a/frontend/apache2/httpd.conf b/frontend/apache2/httpd.conf new file mode 100644 index 0000000..a7e58ef --- /dev/null +++ b/frontend/apache2/httpd.conf @@ -0,0 +1,550 @@ +# +# This is the main Apache HTTP server configuration file. It contains the +# configuration directives that give the server its instructions. +# See for detailed information. +# In particular, see +# +# for a discussion of each configuration directive. +# +# Do NOT simply read the instructions in here without understanding +# what they do. They're here only as hints or reminders. If you are unsure +# consult the online docs. You have been warned. +# +# Configuration and logfile names: If the filenames you specify for many +# of the server's control files begin with "/" (or "drive:/" for Win32), the +# server will use that explicit path. If the filenames do *not* begin +# with "/", the value of ServerRoot is prepended -- so "logs/access_log" +# with ServerRoot set to "/usr/local/apache2" will be interpreted by the +# server as "/usr/local/apache2/logs/access_log", whereas "/logs/access_log" +# will be interpreted as '/logs/access_log'. + +# +# ServerRoot: The top of the directory tree under which the server's +# configuration, error, and log files are kept. +# +# Do not add a slash at the end of the directory path. If you point +# ServerRoot at a non-local disk, be sure to specify a local disk on the +# Mutex directive, if file-based mutexes are used. If you wish to share the +# same ServerRoot for multiple httpd daemons, you will need to change at +# least PidFile. +# +ServerRoot "/usr/local/apache2" + +# +# Mutex: Allows you to set the mutex mechanism and mutex file directory +# for individual mutexes, or change the global defaults +# +# Uncomment and change the directory if mutexes are file-based and the default +# mutex file directory is not on a local disk or is not appropriate for some +# other reason. +# +# Mutex default:logs + +# +# Listen: Allows you to bind Apache to specific IP addresses and/or +# ports, instead of the default. See also the +# directive. +# +# Change this to Listen on specific IP addresses as shown below to +# prevent Apache from glomming onto all bound IP addresses. +# +#Listen 12.34.56.78:80 +Listen 80 + +# +# Dynamic Shared Object (DSO) Support +# +# To be able to use the functionality of a module which was built as a DSO you +# have to place corresponding `LoadModule' lines at this location so the +# directives contained in it are actually available _before_ they are used. +# Statically compiled modules (those listed by `httpd -l') do not need +# to be loaded here. +# +# Example: +# LoadModule foo_module modules/mod_foo.so +# +LoadModule mpm_event_module modules/mod_mpm_event.so +#LoadModule mpm_prefork_module modules/mod_mpm_prefork.so +#LoadModule mpm_worker_module modules/mod_mpm_worker.so +LoadModule authn_file_module modules/mod_authn_file.so +#LoadModule authn_dbm_module modules/mod_authn_dbm.so +#LoadModule authn_anon_module modules/mod_authn_anon.so +#LoadModule authn_dbd_module modules/mod_authn_dbd.so +#LoadModule authn_socache_module modules/mod_authn_socache.so +LoadModule authn_core_module modules/mod_authn_core.so +LoadModule authz_host_module modules/mod_authz_host.so +LoadModule authz_groupfile_module modules/mod_authz_groupfile.so +LoadModule authz_user_module modules/mod_authz_user.so +#LoadModule authz_dbm_module modules/mod_authz_dbm.so +#LoadModule authz_owner_module modules/mod_authz_owner.so +#LoadModule authz_dbd_module modules/mod_authz_dbd.so +LoadModule authz_core_module modules/mod_authz_core.so +#LoadModule authnz_ldap_module modules/mod_authnz_ldap.so +#LoadModule authnz_fcgi_module modules/mod_authnz_fcgi.so +LoadModule access_compat_module modules/mod_access_compat.so +LoadModule auth_basic_module modules/mod_auth_basic.so +#LoadModule auth_form_module modules/mod_auth_form.so +#LoadModule auth_digest_module modules/mod_auth_digest.so +#LoadModule allowmethods_module modules/mod_allowmethods.so +#LoadModule isapi_module modules/mod_isapi.so +#LoadModule file_cache_module modules/mod_file_cache.so +#LoadModule cache_module modules/mod_cache.so +#LoadModule cache_disk_module modules/mod_cache_disk.so +#LoadModule cache_socache_module modules/mod_cache_socache.so +#LoadModule socache_shmcb_module modules/mod_socache_shmcb.so +#LoadModule socache_dbm_module modules/mod_socache_dbm.so +#LoadModule socache_memcache_module modules/mod_socache_memcache.so +LoadModule watchdog_module modules/mod_watchdog.so +#LoadModule macro_module modules/mod_macro.so +#LoadModule dbd_module modules/mod_dbd.so +#LoadModule bucketeer_module modules/mod_bucketeer.so +#LoadModule dumpio_module modules/mod_dumpio.so +#LoadModule echo_module modules/mod_echo.so +#LoadModule example_hooks_module modules/mod_example_hooks.so +#LoadModule case_filter_module modules/mod_case_filter.so +#LoadModule case_filter_in_module modules/mod_case_filter_in.so +#LoadModule example_ipc_module modules/mod_example_ipc.so +#LoadModule buffer_module modules/mod_buffer.so +#LoadModule data_module modules/mod_data.so +#LoadModule ratelimit_module modules/mod_ratelimit.so +LoadModule reqtimeout_module modules/mod_reqtimeout.so +#LoadModule ext_filter_module modules/mod_ext_filter.so +#LoadModule request_module modules/mod_request.so +#LoadModule include_module modules/mod_include.so +LoadModule filter_module modules/mod_filter.so +#LoadModule reflector_module modules/mod_reflector.so +#LoadModule substitute_module modules/mod_substitute.so +#LoadModule sed_module modules/mod_sed.so +#LoadModule charset_lite_module modules/mod_charset_lite.so +LoadModule deflate_module modules/mod_deflate.so +#LoadModule xml2enc_module modules/mod_xml2enc.so +#LoadModule proxy_html_module modules/mod_proxy_html.so +LoadModule mime_module modules/mod_mime.so +#LoadModule ldap_module modules/mod_ldap.so +LoadModule log_config_module modules/mod_log_config.so +#LoadModule log_debug_module modules/mod_log_debug.so +#LoadModule log_forensic_module modules/mod_log_forensic.so +#LoadModule logio_module modules/mod_logio.so +#LoadModule lua_module modules/mod_lua.so +LoadModule env_module modules/mod_env.so +#LoadModule mime_magic_module modules/mod_mime_magic.so +#LoadModule cern_meta_module modules/mod_cern_meta.so +#LoadModule expires_module modules/mod_expires.so +LoadModule headers_module modules/mod_headers.so +#LoadModule ident_module modules/mod_ident.so +#LoadModule usertrack_module modules/mod_usertrack.so +#LoadModule unique_id_module modules/mod_unique_id.so +LoadModule setenvif_module modules/mod_setenvif.so +LoadModule version_module modules/mod_version.so +#LoadModule remoteip_module modules/mod_remoteip.so +LoadModule proxy_module modules/mod_proxy.so +LoadModule proxy_connect_module modules/mod_proxy_connect.so +LoadModule proxy_ftp_module modules/mod_proxy_ftp.so +LoadModule proxy_http_module modules/mod_proxy_http.so +LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so +LoadModule proxy_scgi_module modules/mod_proxy_scgi.so +LoadModule proxy_uwsgi_module modules/mod_proxy_uwsgi.so +LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so +LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so +LoadModule proxy_ajp_module modules/mod_proxy_ajp.so +LoadModule proxy_balancer_module modules/mod_proxy_balancer.so +LoadModule proxy_express_module modules/mod_proxy_express.so +LoadModule proxy_hcheck_module modules/mod_proxy_hcheck.so +#LoadModule session_module modules/mod_session.so +#LoadModule session_cookie_module modules/mod_session_cookie.so +#LoadModule session_crypto_module modules/mod_session_crypto.so +#LoadModule session_dbd_module modules/mod_session_dbd.so +LoadModule slotmem_shm_module modules/mod_slotmem_shm.so +LoadModule slotmem_plain_module modules/mod_slotmem_plain.so +#LoadModule ssl_module modules/mod_ssl.so +#LoadModule optional_hook_export_module modules/mod_optional_hook_export.so +#LoadModule optional_hook_import_module modules/mod_optional_hook_import.so +#LoadModule optional_fn_import_module modules/mod_optional_fn_import.so +#LoadModule optional_fn_export_module modules/mod_optional_fn_export.so +#LoadModule dialup_module modules/mod_dialup.so +#LoadModule http2_module modules/mod_http2.so +#LoadModule proxy_http2_module modules/mod_proxy_http2.so +#LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so +#LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so +#LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so +#LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so +LoadModule unixd_module modules/mod_unixd.so +#LoadModule heartbeat_module modules/mod_heartbeat.so +#LoadModule heartmonitor_module modules/mod_heartmonitor.so +#LoadModule dav_module modules/mod_dav.so +LoadModule status_module modules/mod_status.so +LoadModule autoindex_module modules/mod_autoindex.so +#LoadModule asis_module modules/mod_asis.so +#LoadModule info_module modules/mod_info.so +#LoadModule suexec_module modules/mod_suexec.so + + #LoadModule cgid_module modules/mod_cgid.so + + + #LoadModule cgi_module modules/mod_cgi.so + +#LoadModule dav_fs_module modules/mod_dav_fs.so +#LoadModule dav_lock_module modules/mod_dav_lock.so +#LoadModule vhost_alias_module modules/mod_vhost_alias.so +#LoadModule negotiation_module modules/mod_negotiation.so +LoadModule dir_module modules/mod_dir.so +#LoadModule imagemap_module modules/mod_imagemap.so +#LoadModule actions_module modules/mod_actions.so +#LoadModule speling_module modules/mod_speling.so +#LoadModule userdir_module modules/mod_userdir.so +LoadModule alias_module modules/mod_alias.so +#LoadModule rewrite_module modules/mod_rewrite.so + + +# +# If you wish httpd to run as a different user or group, you must run +# httpd as root initially and it will switch. +# +# User/Group: The name (or #number) of the user/group to run httpd as. +# It is usually good practice to create a dedicated user and group for +# running httpd, as with most system services. +# +User daemon +Group daemon + + + +# 'Main' server configuration +# +# The directives in this section set up the values used by the 'main' +# server, which responds to any requests that aren't handled by a +# definition. These values also provide defaults for +# any containers you may define later in the file. +# +# All of these directives may appear inside containers, +# in which case these default settings will be overridden for the +# virtual host being defined. +# + +# +# ServerAdmin: Your address, where problems with the server should be +# e-mailed. This address appears on some server-generated pages, such +# as error documents. e.g. admin@your-domain.com +# +ServerAdmin you@example.com + +# +# ServerName gives the name and port that the server uses to identify itself. +# This can often be determined automatically, but we recommend you specify +# it explicitly to prevent problems during startup. +# +# If your host doesn't have a registered DNS name, enter its IP address here. +# +#ServerName www.example.com:80 + +# +# Deny access to the entirety of your server's filesystem. You must +# explicitly permit access to web content directories in other +# blocks below. +# + + AllowOverride none + Require all denied + + +# +# Note that from this point forward you must specifically allow +# particular features to be enabled - so if something's not working as +# you might expect, make sure that you have specifically enabled it +# below. +# + +# +# DocumentRoot: The directory out of which you will serve your +# documents. By default, all requests are taken from this directory, but +# symbolic links and aliases may be used to point to other locations. +# +DocumentRoot "/usr/local/apache2/htdocs" + + # + # Possible values for the Options directive are "None", "All", + # or any combination of: + # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews + # + # Note that "MultiViews" must be named *explicitly* --- "Options All" + # doesn't give it to you. + # + # The Options directive is both complicated and important. Please see + # http://httpd.apache.org/docs/2.4/mod/core.html#options + # for more information. + # + Options Indexes FollowSymLinks + + # + # AllowOverride controls what directives may be placed in .htaccess files. + # It can be "All", "None", or any combination of the keywords: + # AllowOverride FileInfo AuthConfig Limit + # + AllowOverride None + + # + # Controls who can get stuff from this server. + # + Require all granted + + +# +# DirectoryIndex: sets the file that Apache will serve if a directory +# is requested. +# + + DirectoryIndex index.html + + +# +# The following lines prevent .htaccess and .htpasswd files from being +# viewed by Web clients. +# + + Require all denied + + +# +# ErrorLog: The location of the error log file. +# If you do not specify an ErrorLog directive within a +# container, error messages relating to that virtual host will be +# logged here. If you *do* define an error logfile for a +# container, that host's errors will be logged there and not here. +# +ErrorLog /proc/self/fd/2 + +# +# LogLevel: Control the number of messages logged to the error_log. +# Possible values include: debug, info, notice, warn, error, crit, +# alert, emerg. +# +LogLevel warn + + + # + # The following directives define some format nicknames for use with + # a CustomLog directive (see below). + # + LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined + LogFormat "%h %l %u %t \"%r\" %>s %b" common + + + # You need to enable mod_logio.c to use %I and %O + LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio + + + # + # The location and format of the access logfile (Common Logfile Format). + # If you do not define any access logfiles within a + # container, they will be logged here. Contrariwise, if you *do* + # define per- access logfiles, transactions will be + # logged therein and *not* in this file. + # + CustomLog /proc/self/fd/1 common + + # + # If you prefer a logfile with access, agent, and referer information + # (Combined Logfile Format) you can use the following directive. + # + #CustomLog "logs/access_log" combined + + + + # + # Redirect: Allows you to tell clients about documents that used to + # exist in your server's namespace, but do not anymore. The client + # will make a new request for the document at its new location. + # Example: + # Redirect permanent /foo http://www.example.com/bar + + # + # Alias: Maps web paths into filesystem paths and is used to + # access content that does not live under the DocumentRoot. + # Example: + # Alias /webpath /full/filesystem/path + # + # If you include a trailing / on /webpath then the server will + # require it to be present in the URL. You will also likely + # need to provide a section to allow access to + # the filesystem path. + + # + # ScriptAlias: This controls which directories contain server scripts. + # ScriptAliases are essentially the same as Aliases, except that + # documents in the target directory are treated as applications and + # run by the server when requested rather than as documents sent to the + # client. The same rules about trailing "/" apply to ScriptAlias + # directives as to Alias. + # + ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/" + + + + + # + # ScriptSock: On threaded servers, designate the path to the UNIX + # socket used to communicate with the CGI daemon of mod_cgid. + # + #Scriptsock cgisock + + +# +# "/usr/local/apache2/cgi-bin" should be changed to whatever your ScriptAliased +# CGI directory exists, if you have that configured. +# + + AllowOverride None + Options None + Require all granted + + + + # + # Avoid passing HTTP_PROXY environment to CGI's on this or any proxied + # backend servers which have lingering "httpoxy" defects. + # 'Proxy' request header is undefined by the IETF, not listed by IANA + # + RequestHeader unset Proxy early + + + + # + # TypesConfig points to the file containing the list of mappings from + # filename extension to MIME-type. + # + TypesConfig conf/mime.types + + # + # AddType allows you to add to or override the MIME configuration + # file specified in TypesConfig for specific file types. + # + #AddType application/x-gzip .tgz + # + # AddEncoding allows you to have certain browsers uncompress + # information on the fly. Note: Not all browsers support this. + # + #AddEncoding x-compress .Z + #AddEncoding x-gzip .gz .tgz + # + # If the AddEncoding directives above are commented-out, then you + # probably should define those extensions to indicate media types: + # + AddType application/x-compress .Z + AddType application/x-gzip .gz .tgz + + # + # AddHandler allows you to map certain file extensions to "handlers": + # actions unrelated to filetype. These can be either built into the server + # or added with the Action directive (see below) + # + # To use CGI scripts outside of ScriptAliased directories: + # (You will also need to add "ExecCGI" to the "Options" directive.) + # + #AddHandler cgi-script .cgi + + # For type maps (negotiated resources): + #AddHandler type-map var + + # + # Filters allow you to process content before it is sent to the client. + # + # To parse .shtml files for server-side includes (SSI): + # (You will also need to add "Includes" to the "Options" directive.) + # + #AddType text/html .shtml + #AddOutputFilter INCLUDES .shtml + + +# +# The mod_mime_magic module allows the server to use various hints from the +# contents of the file itself to determine its type. The MIMEMagicFile +# directive tells the module where the hint definitions are located. +# +#MIMEMagicFile conf/magic + +# +# Customizable error responses come in three flavors: +# 1) plain text 2) local redirects 3) external redirects +# +# Some examples: +#ErrorDocument 500 "The server made a boo boo." +#ErrorDocument 404 /missing.html +#ErrorDocument 404 "/cgi-bin/missing_handler.pl" +#ErrorDocument 402 http://www.example.com/subscription_info.html +# + +# +# MaxRanges: Maximum number of Ranges in a request before +# returning the entire resource, or one of the special +# values 'default', 'none' or 'unlimited'. +# Default setting is to accept 200 Ranges. +#MaxRanges unlimited + +# +# EnableMMAP and EnableSendfile: On systems that support it, +# memory-mapping or the sendfile syscall may be used to deliver +# files. This usually improves server performance, but must +# be turned off when serving from networked-mounted +# filesystems or if support for these functions is otherwise +# broken on your system. +# Defaults: EnableMMAP On, EnableSendfile Off +# +#EnableMMAP off +#EnableSendfile on + +# Supplemental configuration +# +# The configuration files in the conf/extra/ directory can be +# included to add extra features or to modify the default configuration of +# the server, or you may simply copy their contents here and change as +# necessary. + +# Server-pool management (MPM specific) +#Include conf/extra/httpd-mpm.conf + +# Multi-language error messages +#Include conf/extra/httpd-multilang-errordoc.conf + +# Fancy directory listings +#Include conf/extra/httpd-autoindex.conf + +# Language settings +#Include conf/extra/httpd-languages.conf + +# User home directories +#Include conf/extra/httpd-userdir.conf + +# Real-time info on requests and configuration +#Include conf/extra/httpd-info.conf + +# Virtual hosts +#Include conf/extra/httpd-vhosts.conf + +# Local access to the Apache HTTP Server Manual +#Include conf/extra/httpd-manual.conf + +# Distributed authoring and versioning (WebDAV) +#Include conf/extra/httpd-dav.conf + +# Various default settings +#Include conf/extra/httpd-default.conf + +# Configure mod_proxy_html to understand HTML4/XHTML1 + +Include conf/extra/proxy-html.conf + + +# Secure (SSL/TLS) connections +#Include conf/extra/httpd-ssl.conf +# +# Note: The following must must be present to support +# starting without SSL on platforms with no /dev/random equivalent +# but a statically compiled-in mod_ssl. +# + +SSLRandomSeed startup builtin +SSLRandomSeed connect builtin + + +ServerName frontend +ProxyPass /api/v1 http://api:8000 diff --git a/frontend/www/.htaccess b/frontend/www/.htaccess deleted file mode 100755 index 35caa4a..0000000 --- a/frontend/www/.htaccess +++ /dev/null @@ -1 +0,0 @@ -DirectoryIndex index.html \ No newline at end of file diff --git a/frontend/www/PeopleDatabase/AllUsers.html b/frontend/www/PeopleDatabase/AllUsers.html new file mode 100644 index 0000000..335fdda --- /dev/null +++ b/frontend/www/PeopleDatabase/AllUsers.html @@ -0,0 +1,57 @@ + + + + + + + Rowan University Databases | People Database + + + + + + + + +
+
+ +
+ +

People Database

+
+
+
+ +
+
+
+
+
+ + + + diff --git a/frontend/www/PeopleDatabase/css/AllUsers.css b/frontend/www/PeopleDatabase/css/AllUsers.css new file mode 100644 index 0000000..4eeeeac --- /dev/null +++ b/frontend/www/PeopleDatabase/css/AllUsers.css @@ -0,0 +1,31 @@ +#table { + align-items: center; + display: flex; + justify-content: center; +} + +#rtrndata { + border-collapse: collapse; + border-bottom: 1px solid black; + text-align: center; + font-size: 1.5em; + font-family: 'Trebuchet MS'; +} + +#rtrndata th { + background-color: #EEBB00; + color: #57150B; + padding: 1em; +} + +#rtrndata td { + padding: 1em; +} + +#rtrndata tr:nth-child(even) { + background-color: #f0f0f0; +} + +#rtrndata tr:hover { + background-color: #EEEEEE; +} diff --git a/frontend/www/css/template.css b/frontend/www/css/template.css new file mode 100644 index 0000000..9a8c357 --- /dev/null +++ b/frontend/www/css/template.css @@ -0,0 +1,99 @@ +body { + font: 15px/1.5 'Trebuchet MS'; + padding: 0; + margin: 0; +} + +/* Global */ +.container{ + width: 80%; + margin: auto; + overflow: hidden; +} + +/* Header */ +header{ + background: #57150B; + padding-top: 2em; + min-height: 4em; + border-bottom: #FFCC00 3px solid; +} + +header #branding h1 { + float: left; + text-align: center; + margin-top: 1em; + color: #FFCC00; + font: bold 5em 'Palatino Linotype'; +} + +header #branding img { + float: left; + width: 10em; + filter: brightness(0.6) sepia(1) hue-rotate(-2deg) contrast(1.5) saturate(3); +} + +header nav { + float: right; + padding-top: 1.5em; +} + +.navbutton { + background: #FFCC00; + border: none; + border-radius: 0.5em; + padding: 0.2em 0.5em; + text-align: center; + font-size: 2em; +} + +/* Sidenav */ +.sidenav { + height: 100%; + width: 0; + position: fixed; + z-index: 1; + top: 0; + right: 0; + background-color: #e2e2e2; + overflow-x: hidden; + padding-top: 4em; + transition: 0.5s; +} + +.sidenav a, .dropdown { + padding: 0.3em 0.3em 0.3em 1.4em; + text-decoration: none; + font-size: 2em; + color: #818181; + background-color: none; + display: block; + transition: 0.3s; + cursor: pointer; +} + +.sidenav a:hover { + color: #2a2a2a; +} + +.sidenav .closebtn { + position: absolute; + top: 0; + right: 0.5em; + font-size: 2em; + margin-left: 3em; +} + +.active { + background-color: rgba(0,0,0,0.1); +} + +.ddmenu { + background-color: rgba(0,0,0,0.1); + padding-left: 8px; +} + +.fa-caret-down { + float: right; + padding-right: 8px; +} diff --git a/frontend/www/hello_world.js b/frontend/www/hello_world.js deleted file mode 100644 index da86379..0000000 --- a/frontend/www/hello_world.js +++ /dev/null @@ -1,5 +0,0 @@ -function hello_world(){ - x = document.getElementById("JsHi"); - x.innerHTML ="

Hello from JavaScript

"; - -} \ No newline at end of file diff --git a/frontend/www/index.html b/frontend/www/index.html deleted file mode 100755 index c5cb890..0000000 --- a/frontend/www/index.html +++ /dev/null @@ -1,25 +0,0 @@ - - - Kluzy - - - - -

Kluzy-Test-Server

-

Note: Searches are exact only!

- -
    -
    - - - \ No newline at end of file diff --git a/frontend/www/js/env.js b/frontend/www/js/env.js new file mode 100644 index 0000000..5fe26d0 --- /dev/null +++ b/frontend/www/js/env.js @@ -0,0 +1 @@ +var database = "/api/v1/users/" diff --git a/frontend/www/js/getUsers.js b/frontend/www/js/getUsers.js new file mode 100644 index 0000000..b505af5 --- /dev/null +++ b/frontend/www/js/getUsers.js @@ -0,0 +1,74 @@ +function getUsers() +{ + var xhttp = new XMLHttpRequest + + // Response Parsing on state change + xhttp.onreadystatechange = function() { + if (this.readyState == 4 && this.status == 200) { + // Clear old table in case of update/multiple requests + var oldData = document.getElementById("rtrndata"); + oldData.parentNode.removeChild(oldData); + + // Parse JSON object into variable + var responseObject = JSON.parse(this.responseText); + + // Generate Table + var usrRtrn = document.getElementById("userReturn"); + var tbl = document.createElement("table"); + tbl.setAttribute("id", "rtrndata"); + + // Table Headers + var thd = document.createElement("thead"); + for (var i = 0; i < 4; i++) { + var th = document.createElement("th"); + switch (i) { + case 0: + th.innerHTML = "ID"; + break; + case 1: + th.innerHTML = "First Name"; + break; + case 2: + th.innerHTML = "Last Name"; + break; + case 3: + th.innerHTML = "Banner ID"; + break; + } + thd.appendChild(th); + } + tbl.appendChild(thd); + + // Table Body + var tbod = document.createElement("tbody") + for (var i = 0; i < responseObject.users.length; i++) { + var trow = document.createElement("tr"); + for (var j = 0; j < 4; j++) { + var td = document.createElement("td"); + switch (j) { + case 0: + td.innerHTML = responseObject.users[i].id; + break; + case 1: + td.innerHTML = responseObject.users[i].first_name; + break; + case 2: + td.innerHTML = responseObject.users[i].last_name; + break; + case 3: + td.innerHTML = responseObject.users[i].banner_id; + break; + } + trow.appendChild(td); + } + tbod.appendChild(trow); + } + tbl.appendChild(tbod); + usrRtrn.appendChild(tbl); + } + }; + + // Send Get Request + xhttp.open("GET", database, true); + xhttp.send(); +} diff --git a/frontend/www/js/sendNewUser.js b/frontend/www/js/sendNewUser.js new file mode 100644 index 0000000..56490b7 --- /dev/null +++ b/frontend/www/js/sendNewUser.js @@ -0,0 +1,16 @@ +function sendNewUser() +{ + var firstNameInput = document.getElementById("first_name"); + var lastNameInput = document.getElementById("last_name"); + var bannerIdInput = document.getElementById("banner_id"); + var newUser = { + first_name : firstNameInput.value, + last_name : lastNameInput.value, + banner_id : parseInt(bannerIdInput.value) + } + console.log(newUser); + var xhttp = new XMLHttpRequest(); + xhttp.open("POST", database, true); + xhttp.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); + xhttp.send(JSON.stringify(newUser)); +} diff --git a/frontend/www/js/sidenav.js b/frontend/www/js/sidenav.js new file mode 100644 index 0000000..5a493c5 --- /dev/null +++ b/frontend/www/js/sidenav.js @@ -0,0 +1,8 @@ +function opennav() { + document.getElementById("sidenav").style.width = "24em"; +} + +function closenav() +{ + document.getElementById("sidenav").style.width = "0em"; +} diff --git a/frontend/www/media/A-Team-Logo.png b/frontend/www/media/A-Team-Logo.png new file mode 100644 index 0000000..01800b8 Binary files /dev/null and b/frontend/www/media/A-Team-Logo.png differ diff --git a/frontend/www/settings.js b/frontend/www/settings.js deleted file mode 100644 index ef123d5..0000000 --- a/frontend/www/settings.js +++ /dev/null @@ -1 +0,0 @@ -var baseip="http://192.168.176.129"; \ No newline at end of file diff --git a/frontend/www/template.html b/frontend/www/template.html new file mode 100644 index 0000000..d616e62 --- /dev/null +++ b/frontend/www/template.html @@ -0,0 +1,44 @@ + + + + + + + Rowan University Databases | + + + + + +
    +
    + +
    + +

    Template

    +
    +
    +
    + + + + diff --git a/frontend/www/users/add.html b/frontend/www/users/add.html deleted file mode 100644 index e9b18cd..0000000 --- a/frontend/www/users/add.html +++ /dev/null @@ -1,24 +0,0 @@ - - - Kluzy-Users - - - - -

    Add Users

    -

    To add a user, fill out the textboxes and hit submit.

    -
    - First name:
    -
    - Last name:
    -
    - Email:
    -
    - Banner ID:
    -
    -
    -
    -
    -

    - - \ No newline at end of file diff --git a/frontend/www/users/add_user.js b/frontend/www/users/add_user.js deleted file mode 100644 index 83b213d..0000000 --- a/frontend/www/users/add_user.js +++ /dev/null @@ -1,45 +0,0 @@ -function add_user(){ - var fn, ln, em, bi, person - - if (document.getElementById("firstname")){ - fn = document.getElementById("firstname").value; - }else{ - fn = ""; - } - if (document.getElementById("lastname")){ - ln = document.getElementById("lastname").value; - } - else{ - ln=""; - } - if (document.getElementById("email")){ - em = document.getElementById("email").value; - }else{ - em = ""; - } - if (document.getElementById("banner_id")){ - bi = document.getElementById("banner_id").value; - } - else{ - bi=""; - } - console.log(fn + ", " + ln + ": " + em + " " + bi); - var xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - if (this.readyState == 4 && this.status == 200) { - document.getElementById("result").innerHTML = "User added!"; - } else { - document.getElementById("result").innerHTML ="Error adding user"; - } - } - if (fn !== "" | ln !== "" | bi !== ""){ - person = {first_name:fn , last_name:ln, banner_id:parseInt(bi), email:em }; - xhttp.open("POST", baseip+":8000/users/", true); - xhttp.send(JSON.stringify(person)); - console.log("Sent to database"); - }else{ - document.getElementById("result").innerHTML ="Error: First name, Last name, and Banner ID are required"; - console.log("Error in text fields"); - } - -} \ No newline at end of file diff --git a/frontend/www/users/edit.html b/frontend/www/users/edit.html deleted file mode 100644 index f4d825f..0000000 --- a/frontend/www/users/edit.html +++ /dev/null @@ -1,35 +0,0 @@ - - - Kluzy-Users - - - - -

    Edit User

    -

    Edit the user selected from your search.

    -
    -

    Current User Data

    -
    -
    -
    -

    Updated User Data

    -
    - First name:
    -
    - Last name:
    -
    - Email:
    -
    - Banner ID:
    -
    -
    -
    -
    -
    -

    -
    -

    DELETE USER

    -
    -
    - - \ No newline at end of file diff --git a/frontend/www/users/get_users.js b/frontend/www/users/get_users.js deleted file mode 100644 index aaf3d97..0000000 --- a/frontend/www/users/get_users.js +++ /dev/null @@ -1,44 +0,0 @@ -function get_users() { - var x, fn, ln,y; - var people; - //people.id = "seach_table"; - if (document.getElementById("firstname")){ - fn = document.getElementById("firstname").value; - }else{ - fn = ""; - } - if (document.getElementById("lastname")){ - ln = document.getElementById("lastname").value; - } - else{ - ln=""; - } - var xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - if (this.readyState == 4 && this.status == 200) { - var search_results = JSON.parse(this.responseText); - var search_table = document.createElement("TABLE"); - people = " Row First Name Last Name Email "; - for(x in search_results.users){ - //people += search_results.users[x].first_name+ " " + search_results.users[x].last_name + ", email: "+search_results.users[x].email+"
    "; - y=parseInt(x)+1; - people += " "+ y +""+search_results.users[x].first_name+ "" + search_results.users[x].last_name - + ""+search_results.users[x].email+"" + - ""; - } - document.getElementById("user").innerHTML = people; - } - }; - console.log("first name: \""+fn + "\" lastname: \"" + ln+"\""); - if (fn !=="" && ln !==""){ - xhttp.open("GET", baseip+":8000/users/?first_name_exact="+fn+"&last_name_exact="+ln, true); - }else if(fn !==""){ - xhttp.open("GET", baseip+":8000/users/?first_name_exact="+fn, true); - }else if(ln !==""){ - xhttp.open("GET", baseip+":8000/users/?last_name_exact="+ln, true); - }else { - console.log("Empty Search"); - xhttp.open("GET", baseip+":8000/users/", true); - } - xhttp.send(); -} diff --git a/frontend/www/users/index.html b/frontend/www/users/index.html deleted file mode 100644 index 38c7c69..0000000 --- a/frontend/www/users/index.html +++ /dev/null @@ -1,15 +0,0 @@ - - - Kluzy-Users - - - -

    Users-Test-Server

    -

    Welcome to the users database. Please select a function.

    -
    -
    - - \ No newline at end of file diff --git a/frontend/www/users/search.html b/frontend/www/users/search.html deleted file mode 100644 index 1845b88..0000000 --- a/frontend/www/users/search.html +++ /dev/null @@ -1,20 +0,0 @@ - - - Search Users - - - - -

    Search Users Database

    -

    Note: Searches are exact only!

    -
    - First name:
    -
    - Last name:
    -

    -
    -
    - -
    - - \ No newline at end of file diff --git a/frontend/www/users/update_user.js b/frontend/www/users/update_user.js deleted file mode 100644 index ed458d8..0000000 --- a/frontend/www/users/update_user.js +++ /dev/null @@ -1,82 +0,0 @@ -function get_user_from_url(){ - var url = window.location + ""; - var point = url.indexOf("="); - var user_id = url.substring(point+1, url.length); - - console.log("User ID is " + user_id); - var xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - if (this.readyState == 4 && this.status == 200) { - var search_results = JSON.parse(this.responseText); - var user = " First name: " + search_results.first_name + "" + - " Last name: " + search_results.last_name + "" + - " Email: " + search_results.email + "" + - " Banner ID: " + search_results.banner_id + ""; - document.getElementById("current_user").innerHTML = user; - }}; - xhttp.open("GET", baseip+":8000/users/"+user_id,true); - xhttp.send(); -} -function update_user(){ - if (document.getElementById("firstname").value === ""){ - fn = null; - }else{ - fn = document.getElementById("firstname").value; - } - - if (document.getElementById("lastname").value===""){ - ln=null - } - else{ - ln = document.getElementById("lastname").value; - } - if (document.getElementById("email").value===""){ - em=null; - }else{ - em = document.getElementById("email").value; - } - if (document.getElementById("banner_id").value===""){ - bi=null - } - else{ - bi = document.getElementById("banner_id").value; - } - var xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - if (this.readyState == 4 && this.status == 204) { - document.getElementById("result").innerHTML = "User Editted!"; - get_user_from_url(); - } else { - document.getElementById("result").innerHTML ="Error editted user"; - }} - // Reaquire User - var url = window.location + ""; - var point = url.indexOf("="); - var user_id = url.substring(point+1, url.length); - person = {first_name:fn , last_name:ln, banner_id:parseInt(bi), email:em }; - xhttp.open("POST", baseip+":8000/users/"+user_id, true); - xhttp.send(JSON.stringify(person)); - console.log("Sent to database"); - - -} - -function delete_user() { - var url = window.location + ""; - var point = url.indexOf("="); - var user_id = url.substring(point+1, url.length); - - var xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - if (this.readyState == 4 && this.status == 204) { - document.getElementById("result").innerHTML = "User Deleted!"; - - } else { - document.getElementById("result").innerHTML ="Error deleting user"; - }} - xhttp.open("DELETE", baseip+":8000/users/"+user_id, true); - xhttp.send(); - - - -} \ No newline at end of file