From 0ace3273b4fe0ba02f8aaf04e043f2ae6e1f15a2 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Tue, 13 Feb 2024 11:59:14 +0000 Subject: [PATCH] #10 Started to create a table for administrating users --- scripts/create_tables.sql | 2 +- scripts/test_data.sql | 92 ++++++++++++++++++++++++--------------- static/css/admin.css | 82 +++++++++++++++------------------- static/css/style.css | 4 +- templates/admin.html | 10 +++-- 5 files changed, 102 insertions(+), 88 deletions(-) diff --git a/scripts/create_tables.sql b/scripts/create_tables.sql index 1d7cca8..5b67e22 100644 --- a/scripts/create_tables.sql +++ b/scripts/create_tables.sql @@ -60,7 +60,7 @@ CREATE TABLE IF NOT EXISTS Views ( ON DELETE CASCADE ON UPDATE NO ACTION, productID INTEGER NOT NULL - REFERENCES Users (id) + REFERENCES Products (id) ON DELETE CASCADE ON UPDATE NO ACTION, viewDate TIMESTAMP NOT NULL diff --git a/scripts/test_data.sql b/scripts/test_data.sql index 32ce1f3..ec62cbd 100644 --- a/scripts/test_data.sql +++ b/scripts/test_data.sql @@ -1,37 +1,61 @@ -INSERT INTO Users (first_name, last_name, username, email, phone, password, role) VALUES ("Luke", "Else", "lukejelse04", "test@test.com", "07498 289321", "test213", "Customer"); +INSERT INTO Users (first_name, last_name, username, email, phone, password, role) VALUES ("Luke", "Else", "luke-else", "test@test.com", "07498 289321", "cbe0cd68cbca3868250c0ba545c48032f43eb0e8a5e6bab603d109251486f77a91e46a3146d887e37416c6bdb6cbe701bd514de778573c9b0068483c1c626aec", "Seller"); +INSERT INTO Users (first_name, last_name, username, email, phone, password, role) VALUES ("Luke", "Else", "test-customer", "test@test.net", "07498 289322", "cbe0cd68cbca3868250c0ba545c48032f43eb0e8a5e6bab603d109251486f77a91e46a3146d887e37416c6bdb6cbe701bd514de778573c9b0068483c1c626aec", "Customer"); +INSERT INTO Users (first_name, last_name, username, email, phone, password, role) VALUES ("Luke", "Else", "test-seller", "test@test.not", "07498 289323", "cbe0cd68cbca3868250c0ba545c48032f43eb0e8a5e6bab603d109251486f77a91e46a3146d887e37416c6bdb6cbe701bd514de778573c9b0068483c1c626aec", "Seller"); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID, quantityAvailable) VALUES ("12' Brake Disks", "brake-disks.bmp", "this is a product", 20.99, 1, 1, 10); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID, quantityAvailable) VALUES ("Exhaust Manifold", "manifold.bmp", "This is a super cool product that can be installed into your car to take the gasses from the inside all the way to the outside. Mad I know.", 20.99, 1, 1, 9); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID, quantityAvailable) VALUES ("Single Turbo", "turbo.bmp", "this is a product", 20.99, 1, 1, 0); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID, quantityAvailable) VALUES ("Exhaust Manifold", "manifold.bmp", "This is a super cool product that can be installed into your car to take the gasses from the inside all the way to the outside. Mad I know.", 20.99, 1, 2, 4); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID, quantityAvailable) VALUES ("12' Brake Disks", "brake-disks.bmp", "this is a product", 20.99, 1, 2, 3); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID, quantityAvailable) VALUES ("17' Alloy Wheels", "alloy.bmp", "These super stylish alloys offer a fresh trendy look for your car. Whether a brand new Mercedes or a niffty little banger, it will uplift the vehicle 10-fold", 20.99, 1, 3, 9); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID, quantityAvailable) VALUES ("Single Turbo", "turbo.bmp", "this is a product", 20.99, 1, 4, 3); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID, quantityAvailable) VALUES ("Exhaust Manifold", "manifold.bmp", "This is a super cool product that can be installed into your car to take the gasses from the inside all the way to the outside. Mad I know.", 20.99, 1, 4, 2); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID, quantityAvailable) VALUES ("17' Alloy Wheels", "alloy.bmp", "These super stylish alloys offer a fresh trendy look for your car. Whether a brand new Mercedes or a niffty little banger, it will uplift the vehicle 10-fold", 20.99, 1, 4, 1); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID, quantityAvailable) VALUES ("Exhaust Manifold", "manifold.bmp", "This is a super cool product that can be installed into your car to take the gasses from the inside all the way to the outside. Mad I know.", 20.99, 1, 6, 7); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID, quantityAvailable) VALUES ("Single Turbo", "turbo.bmp", "this is a product", 20.99, 1, 6, 1232); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, quantityAvailable, postedDate) VALUES ("12' Brake Disks", "brake-disks.bmp", "this is a product", 20.99, 1, 1, 10, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, quantityAvailable, postedDate) VALUES ("Exhaust Manifold", "manifold.bmp", "This is a super cool product that can be installed into your car to take the gasses from the inside all the way to the outside. Mad I know.", 20.99, 1, 1, 9, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, quantityAvailable, postedDate) VALUES ("Single Turbo", "turbo.bmp", "this is a product", 20.99, 1, 1, 0, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, quantityAvailable, postedDate) VALUES ("Exhaust Manifold", "manifold.bmp", "This is a super cool product that can be installed into your car to take the gasses from the inside all the way to the outside. Mad I know.", 20.99, 1, 2, 4, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, quantityAvailable, postedDate) VALUES ("12' Brake Disks", "brake-disks.bmp", "this is a product", 20.99, 1, 2, 3, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, quantityAvailable, postedDate) VALUES ("17' Alloy Wheels", "alloy.bmp", "These super stylish alloys offer a fresh trendy look for your car. Whether a brand new Mercedes or a niffty little banger, it will uplift the vehicle 10-fold", 20.99, 1, 3, 9, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, quantityAvailable, postedDate) VALUES ("Single Turbo", "turbo.bmp", "this is a product", 20.99, 1, 4, 3, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, quantityAvailable, postedDate) VALUES ("Exhaust Manifold", "manifold.bmp", "This is a super cool product that can be installed into your car to take the gasses from the inside all the way to the outside. Mad I know.", 20.99, 1, 4, 2, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, quantityAvailable, postedDate) VALUES ("17' Alloy Wheels", "alloy.bmp", "These super stylish alloys offer a fresh trendy look for your car. Whether a brand new Mercedes or a niffty little banger, it will uplift the vehicle 10-fold", 20.99, 1, 4, 1, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, quantityAvailable, postedDate) VALUES ("Exhaust Manifold", "manifold.bmp", "This is a super cool product that can be installed into your car to take the gasses from the inside all the way to the outside. Mad I know.", 20.99, 1, 6, 7, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, quantityAvailable, postedDate) VALUES ("Single Turbo", "turbo.bmp", "this is a product", 20.99, 1, 6, 1232, datetime()); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("17' Alloy Wheels", "alloy.bmp", "These super stylish alloys offer a fresh trendy look for your car. Whether a brand new Mercedes or a niffty little banger, it will uplift the vehicle 10-fold", 20.99, 1, 1); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("Exhaust Manifold", "manifold.bmp", "This is a super cool product that can be installed into your car to take the gasses from the inside all the way to the outside. Mad I know.", 20.99, 1, 1); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("Single Turbo", "turbo.bmp", "this is a product", 20.99, 1, 1); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("17' Alloy Wheels", "alloy.bmp", "These super stylish alloys offer a fresh trendy look for your car. Whether a brand new Mercedes or a niffty little banger, it will uplift the vehicle 10-fold", 20.99, 1, 2); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("12' Brake Disks", "brake-disks.bmp", "this is a product", 20.99, 1, 2); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("17' Alloy Wheels", "alloy.bmp", "These super stylish alloys offer a fresh trendy look for your car. Whether a brand new Mercedes or a niffty little banger, it will uplift the vehicle 10-fold", 20.99, 1, 3); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("Exhaust Manifold", "manifold.bmp", "This is a super cool product that can be installed into your car to take the gasses from the inside all the way to the outside. Mad I know.", 20.99, 1, 4); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("Single Turbo", "turbo.bmp", "this is a product", 20.99, 1, 4); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("12' Brake Disks", "brake-disks.bmp", "this is a product", 20.99, 1, 4); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("12' Brake Disks", "brake-disks.bmp", "this is a product", 20.99, 1, 6); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("12' Brake Disks", "brake-disks.bmp", "this is a product", 20.99, 1, 6); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, postedDate) VALUES ("17' Alloy Wheels", "alloy.bmp", "These super stylish alloys offer a fresh trendy look for your car. Whether a brand new Mercedes or a niffty little banger, it will uplift the vehicle 10-fold", 20.99, 1, 1, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, postedDate) VALUES ("Exhaust Manifold", "manifold.bmp", "This is a super cool product that can be installed into your car to take the gasses from the inside all the way to the outside. Mad I know.", 20.99, 1, 1, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, postedDate) VALUES ("Single Turbo", "turbo.bmp", "this is a product", 20.99, 1, 1, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, postedDate) VALUES ("17' Alloy Wheels", "alloy.bmp", "These super stylish alloys offer a fresh trendy look for your car. Whether a brand new Mercedes or a niffty little banger, it will uplift the vehicle 10-fold", 20.99, 1, 2, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, postedDate) VALUES ("12' Brake Disks", "brake-disks.bmp", "this is a product", 20.99, 1, 2, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, postedDate) VALUES ("17' Alloy Wheels", "alloy.bmp", "These super stylish alloys offer a fresh trendy look for your car. Whether a brand new Mercedes or a niffty little banger, it will uplift the vehicle 10-fold", 20.99, 1, 3, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, postedDate) VALUES ("Exhaust Manifold", "manifold.bmp", "This is a super cool product that can be installed into your car to take the gasses from the inside all the way to the outside. Mad I know.", 20.99, 1, 4, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, postedDate) VALUES ("Single Turbo", "turbo.bmp", "this is a product", 20.99, 1, 4, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, postedDate) VALUES ("12' Brake Disks", "brake-disks.bmp", "this is a product", 20.99, 1, 4, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, postedDate) VALUES ("12' Brake Disks", "brake-disks.bmp", "this is a product", 20.99, 1, 6, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, postedDate) VALUES ("12' Brake Disks", "brake-disks.bmp", "this is a product", 20.99, 1, 6, datetime()); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("17' Alloy Wheels", "alloy.bmp", "These super stylish alloys offer a fresh trendy look for your car. Whether a brand new Mercedes or a niffty little banger, it will uplift the vehicle 10-fold", 20.99, 1, 1); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("Exhaust Manifold", "manifold.bmp", "This is a super cool product that can be installed into your car to take the gasses from the inside all the way to the outside. Mad I know.", 20.99, 1, 1); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("12' Brake Disks", "brake-disks.bmp", "this is a product", 20.99, 1, 1); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("Single Turbo", "turbo.bmp", "this is a product", 20.99, 1, 2); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("Single Turbo", "turbo.bmp", "this is a product", 20.99, 1, 2); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("17' Alloy Wheels", "alloy.bmp", "These super stylish alloys offer a fresh trendy look for your car. Whether a brand new Mercedes or a niffty little banger, it will uplift the vehicle 10-fold", 20.99, 1, 3); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("12' Brake Disks", "brake-disks.bmp", "this is a product", 20.99, 1, 4); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("17' Alloy Wheels", "alloy.bmp", "These super stylish alloys offer a fresh trendy look for your car. Whether a brand new Mercedes or a niffty little banger, it will uplift the vehicle 10-fold", 20.99, 1, 4); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("Single Turbo", "turbo.bmp", "this is a product", 20.99, 1, 4); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("Exhaust Manifold", "manifold.bmp", "This is a super cool product that can be installed into your car to take the gasses from the inside all the way to the outside. Mad I know.", 20.99, 1, 6); -INSERT INTO Products (name, image, description, cost, sellerID, categoryID) VALUES ("17' Alloy Wheels", "alloy.bmp", "These super stylish alloys offer a fresh trendy look for your car. Whether a brand new Mercedes or a niffty little banger, it will uplift the vehicle 10-fold", 20.99, 1, 6); \ No newline at end of file +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, postedDate) VALUES ("17' Alloy Wheels", "alloy.bmp", "These super stylish alloys offer a fresh trendy look for your car. Whether a brand new Mercedes or a niffty little banger, it will uplift the vehicle 10-fold", 20.99, 1, 1, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, postedDate) VALUES ("Exhaust Manifold", "manifold.bmp", "This is a super cool product that can be installed into your car to take the gasses from the inside all the way to the outside. Mad I know.", 20.99, 1, 1, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, postedDate) VALUES ("12' Brake Disks", "brake-disks.bmp", "this is a product", 20.99, 1, 1, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, postedDate) VALUES ("Single Turbo", "turbo.bmp", "this is a product", 20.99, 1, 2, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, postedDate) VALUES ("Single Turbo", "turbo.bmp", "this is a product", 20.99, 1, 2, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, postedDate) VALUES ("17' Alloy Wheels", "alloy.bmp", "These super stylish alloys offer a fresh trendy look for your car. Whether a brand new Mercedes or a niffty little banger, it will uplift the vehicle 10-fold", 20.99, 1, 3, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, postedDate) VALUES ("12' Brake Disks", "brake-disks.bmp", "this is a product", 20.99, 1, 4, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, postedDate) VALUES ("17' Alloy Wheels", "alloy.bmp", "These super stylish alloys offer a fresh trendy look for your car. Whether a brand new Mercedes or a niffty little banger, it will uplift the vehicle 10-fold", 20.99, 1, 4, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, postedDate) VALUES ("Single Turbo", "turbo.bmp", "this is a product", 20.99, 1, 4, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, postedDate) VALUES ("Exhaust Manifold", "manifold.bmp", "This is a super cool product that can be installed into your car to take the gasses from the inside all the way to the outside. Mad I know.", 20.99, 1, 6, datetime()); +INSERT INTO Products (name, image, description, cost, sellerID, categoryID, postedDate) VALUES ("17' Alloy Wheels", "alloy.bmp", "These super stylish alloys offer a fresh trendy look for your car. Whether a brand new Mercedes or a niffty little banger, it will uplift the vehicle 10-fold", 20.99, 1, 6, datetime()); + +INSERT INTO Views (userID, productID, viewDate) VALUES (1, 1, datetime()); +INSERT INTO Views (userID, productID, viewDate) VALUES (1, 1, datetime()); +INSERT INTO Views (userID, productID, viewDate) VALUES (1, 1, datetime()); +INSERT INTO Views (userID, productID, viewDate) VALUES (1, 1, datetime()); +INSERT INTO Views (userID, productID, viewDate) VALUES (1, 1, datetime()); +INSERT INTO Views (userID, productID, viewDate) VALUES (1, 1, datetime()); +INSERT INTO Views (userID, productID, viewDate) VALUES (1, 1, datetime()); +INSERT INTO Views (userID, productID, viewDate) VALUES (1, 1, datetime()); +INSERT INTO Views (userID, productID, viewDate) VALUES (1, 1, datetime()); +INSERT INTO Views (userID, productID, viewDate) VALUES (1, 1, datetime()); +INSERT INTO Views (userID, productID, viewDate) VALUES (1, 1, datetime()); + +INSERT INTO Views (userID, productID, viewDate) VALUES (1, 2, datetime()); +INSERT INTO Views (userID, productID, viewDate) VALUES (1, 2, datetime()); +INSERT INTO Views (userID, productID, viewDate) VALUES (1, 2, datetime()); +INSERT INTO Views (userID, productID, viewDate) VALUES (1, 2, datetime()); +INSERT INTO Views (userID, productID, viewDate) VALUES (1, 2, datetime()); +INSERT INTO Views (userID, productID, viewDate) VALUES (1, 2, datetime()); +INSERT INTO Views (userID, productID, viewDate) VALUES (1, 2, datetime()); +INSERT INTO Views (userID, productID, viewDate) VALUES (1, 2, datetime()); +INSERT INTO Views (userID, productID, viewDate) VALUES (1, 2, datetime()); \ No newline at end of file diff --git a/static/css/admin.css b/static/css/admin.css index 39dd8dc..ac7d960 100644 --- a/static/css/admin.css +++ b/static/css/admin.css @@ -1,50 +1,38 @@ -/* Resetting default table styles */ +.user-container { + display: flex; + justify-content: center; + width: 80%; +} table { - border-collapse: collapse; - width: 100%; - margin-bottom: 20px; - } + width: 80%; +} + +/****** table style ******/ +table tbody>tr>td:last-child{ + text-align: center; +} + +.table.table-style { - /* Styling table headers */ - th { - background-color: #f2f2f2; - color: #333; - font-weight: bold; - padding: 10px; - text-align: left; - } +} + +.table.table-style tr td:last-child { - /* Styling table rows */ - tr:nth-child(even) { - background-color: #f9f9f9; - } - - tr:hover { - background-color: #f2f2f2; - } - - /* Styling table data cells */ - td { - padding: 10px; - } - - /* Add a border to the bottom of the header row */ - th { - border-bottom: 2px solid #ddd; - } - - /* Add a border to all other rows and cells */ - tr:not(:first-child) { - border-top: 1px solid #ddd; - } - - td { - border-bottom: 1px solid #ddd; - } - - /* Responsive table */ - @media (max-width: 768px) { - table { - overflow-x: auto; - } - } \ No newline at end of file +} + +.table.table-style > thead > tr > td, +.table.table-style > tbody > tr > td, +.table.table-style > tfoot > tr > td { + padding-left: 10px; +} + +.table.table-style tr { +} + +.table.table-style tbody > tr { + background-color: var(--bg-secondary); +} + +.table.table-style tbody > tr:nth-child(even) { + background-color: var(--bg-grad-1); +} \ No newline at end of file diff --git a/static/css/style.css b/static/css/style.css index 26b01ab..7860cdd 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -1,8 +1,8 @@ :root { --bg: #282c34; --bg-secondary: #474d57; - --bg-grad-1: #484e58; - --bg-grad-2: #4e5560; + --bg-grad-1: rgb(55, 57, 62); + --bg-grad-2: #3b3e42; --bg-grad-3: #59616d; --bg-grad-4: #606a7b; --bg-grad-5: #606978; diff --git a/templates/admin.html b/templates/admin.html index a1b108f..5bafd60 100644 --- a/templates/admin.html +++ b/templates/admin.html @@ -3,12 +3,13 @@ {% if users != None %}

Showing {{users|count}} users

- +
- - - + + + + @@ -17,6 +18,7 @@ +
UsernameE-MailPhone NumberUsernameE-MailPhone NumberBUTTON
{{user.username}} {{user.email}} {{user.phone}}{{user.phone}}