update,
This commit is contained in:
BIN
tsc1877/task1/_ref/2022/IERG4210-22S-Phase4.pdf
Normal file
BIN
tsc1877/task1/_ref/2022/IERG4210-22S-Phase4.pdf
Normal file
Binary file not shown.
BIN
tsc1877/task1/_ref/2022/IERG4210-22S-Phase5-Updated.pdf
Normal file
BIN
tsc1877/task1/_ref/2022/IERG4210-22S-Phase5-Updated.pdf
Normal file
Binary file not shown.
BIN
tsc1877/task1/_ref/2022/IERG4210-22S-Phase5.pdf
Normal file
BIN
tsc1877/task1/_ref/2022/IERG4210-22S-Phase5.pdf
Normal file
Binary file not shown.
BIN
tsc1877/task1/_ref/2024/IERG4210-24S-Phase1.pdf
Normal file
BIN
tsc1877/task1/_ref/2024/IERG4210-24S-Phase1.pdf
Normal file
Binary file not shown.
BIN
tsc1877/task1/_ref/2024/IERG4210-24S-Phase2_v2.pdf
Normal file
BIN
tsc1877/task1/_ref/2024/IERG4210-24S-Phase2_v2.pdf
Normal file
Binary file not shown.
BIN
tsc1877/task1/_ref/2024/IERG4210-24S-Phase3.pdf
Normal file
BIN
tsc1877/task1/_ref/2024/IERG4210-24S-Phase3.pdf
Normal file
Binary file not shown.
BIN
tsc1877/task1/_ref/2024/IERG4210-24S-Phase4.pdf
Normal file
BIN
tsc1877/task1/_ref/2024/IERG4210-24S-Phase4.pdf
Normal file
Binary file not shown.
BIN
tsc1877/task1/_ref/2024/IERG4210-24S-Phase5.pdf
Normal file
BIN
tsc1877/task1/_ref/2024/IERG4210-24S-Phase5.pdf
Normal file
Binary file not shown.
BIN
tsc1877/task1/_ref/2024/Tutorial 3.pdf
Normal file
BIN
tsc1877/task1/_ref/2024/Tutorial 3.pdf
Normal file
Binary file not shown.
BIN
tsc1877/task1/_ref/2024/Tutorial 4.pdf
Normal file
BIN
tsc1877/task1/_ref/2024/Tutorial 4.pdf
Normal file
Binary file not shown.
BIN
tsc1877/task1/_ref/2024/Tutorial 5.pdf
Normal file
BIN
tsc1877/task1/_ref/2024/Tutorial 5.pdf
Normal file
Binary file not shown.
BIN
tsc1877/task1/_ref/2024/Tutorial 6.pdf
Normal file
BIN
tsc1877/task1/_ref/2024/Tutorial 6.pdf
Normal file
Binary file not shown.
BIN
tsc1877/task1/_ref/2024/Tutorial 7.pdf
Normal file
BIN
tsc1877/task1/_ref/2024/Tutorial 7.pdf
Normal file
Binary file not shown.
BIN
tsc1877/task1/_ref/2024/Tutorial 8.pdf
Normal file
BIN
tsc1877/task1/_ref/2024/Tutorial 8.pdf
Normal file
Binary file not shown.
BIN
tsc1877/task1/_ref/2024/Tutorial 9.pdf
Normal file
BIN
tsc1877/task1/_ref/2024/Tutorial 9.pdf
Normal file
Binary file not shown.
BIN
tsc1877/task1/_ref/85fd7f2e-6c8e-4bfc-a9ec-12666cc02e23__2_en.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/_ref/85fd7f2e-6c8e-4bfc-a9ec-12666cc02e23__2_en.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/_ref/IERG4210 2024 Spring Tutorial 2.pptx
Normal file
BIN
tsc1877/task1/_ref/IERG4210 2024 Spring Tutorial 2.pptx
Normal file
Binary file not shown.
BIN
tsc1877/task1/_ref/IERG4210-24S-Phase1/0.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/_ref/IERG4210-24S-Phase1/0.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/_ref/IERG4210-24S-Phase1/1.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/_ref/IERG4210-24S-Phase1/1.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/_ref/IERG4210-24S-Phase1/2.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/_ref/IERG4210-24S-Phase1/2.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/_ref/IERG4210-24S-Phase1/3.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/_ref/IERG4210-24S-Phase1/3.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/_ref/chrome_XeuGI0DOuj.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/_ref/chrome_XeuGI0DOuj.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/_ref/old_project/cart.db
Normal file
BIN
tsc1877/task1/_ref/old_project/cart.db
Normal file
Binary file not shown.
78
tsc1877/task1/_ref/old_project/form.html
Normal file
78
tsc1877/task1/_ref/old_project/form.html
Normal file
@@ -0,0 +1,78 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>IERG4210 Admin Panel</title>
|
||||
<style>
|
||||
#drop-area {
|
||||
width: 300px;
|
||||
height: 200px;
|
||||
border: 2px dashed #ccc;
|
||||
border-radius: 5px;
|
||||
text-align: center;
|
||||
font-family: Arial, sans-serif;
|
||||
margin: 0 auto;
|
||||
margin-top: 20px;
|
||||
}
|
||||
#drop-area.highlight {
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
#drop-area .message {
|
||||
margin: 80px auto;
|
||||
font-size: 18px;
|
||||
color: #888;
|
||||
}
|
||||
#thumbnail {
|
||||
max-width: 200px;
|
||||
max-height: 200px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>IERG4210 Admin Panel</h1>
|
||||
<h1>Add Category</h1>
|
||||
<form action="/addCategory" method="POST">
|
||||
<label for="categoryName">Category Name:</label>
|
||||
<input type="text" id="categoryName" name="categoryName" required>
|
||||
<button type="submit">Add Category</button>
|
||||
</form>
|
||||
|
||||
<h1>Add Product</h1>
|
||||
<form action="/addProduct" method="POST">
|
||||
<label for="productName">Product Name:</label>
|
||||
<input type="text" id="productName" name="productName" required>
|
||||
|
||||
<label for="category">Category:</label>
|
||||
<select id="category" name="category" required>
|
||||
<option value="" selected disabled>Select a category</option>
|
||||
<script>
|
||||
// Fetch categories from the server and populate the dropdown options
|
||||
fetch('/categories')
|
||||
.then(response => response.json())
|
||||
.then(categories => {
|
||||
const categorySelect = document.getElementById('category');
|
||||
categories.forEach(category => {
|
||||
const option = document.createElement('option');
|
||||
option.value = category.catid;
|
||||
option.textContent = category.name;
|
||||
categorySelect.appendChild(option);
|
||||
});
|
||||
})
|
||||
.catch(error => console.error(error));
|
||||
</script>
|
||||
</select>
|
||||
|
||||
<label for="price">Price:</label>
|
||||
<input type="number" id="price" name="price" required>
|
||||
|
||||
<label for="description">Description:</label>
|
||||
<textarea id="description" name="description" required></textarea>
|
||||
|
||||
<label for="image">Image:</label>
|
||||
<input type="file" id="image" name="image" accept="image/*" required>
|
||||
|
||||
<button type="submit">Add Product</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
85
tsc1877/task1/_ref/old_project/server.js
Normal file
85
tsc1877/task1/_ref/old_project/server.js
Normal file
@@ -0,0 +1,85 @@
|
||||
// Import the 'path' module
|
||||
const path = require("path");
|
||||
const express = require("express");
|
||||
const sqlite3 = require("sqlite3").verbose();
|
||||
|
||||
const app = express();
|
||||
const db = new sqlite3.Database("cart.db");
|
||||
|
||||
// Use middleware to parse the request body
|
||||
app.use(express.urlencoded({ extended: true }));
|
||||
|
||||
app.get("/", (req, res) => {
|
||||
res.sendFile(path.join(__dirname, "form.html"));
|
||||
});
|
||||
|
||||
app.get("/categories", (req, res) => {
|
||||
const selectCategoriesQuery = `SELECT * FROM categories`;
|
||||
db.all(selectCategoriesQuery, (err, rows) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
res.status(500).json({ error: "Failed to fetch categories" });
|
||||
} else {
|
||||
res.json(rows);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Handle POST request to add a new category
|
||||
app.post("/addCategory", (req, res) => {
|
||||
const categoryName = req.body.categoryName;
|
||||
|
||||
// Insert the new category into the categories table
|
||||
const insertCategoryQuery = `INSERT INTO categories (name) VALUES (?)`;
|
||||
db.run(insertCategoryQuery, [categoryName], (err) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
res.status(500).send("Error adding category");
|
||||
} else {
|
||||
res.send(`
|
||||
<script>
|
||||
alert('Category added successfully');
|
||||
window.location.href = '/';
|
||||
</script>
|
||||
`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Handle POST request to add a new product
|
||||
app.post("/addProduct", (req, res) => {
|
||||
const productName = req.body.productName;
|
||||
const category = req.body.category;
|
||||
const price = req.body.price;
|
||||
const description = req.body.description;
|
||||
|
||||
let imageUrl = "";
|
||||
if (req.file) {
|
||||
imageUrl = req.file.filename;
|
||||
}
|
||||
|
||||
// Insert the new product into the products table
|
||||
const insertProductQuery = `INSERT INTO products (name, catid, price, description) VALUES (?, ?, ?, ?)`;
|
||||
db.run(
|
||||
insertProductQuery,
|
||||
[productName, category, price, description],
|
||||
(err) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
res.status(500).send("Error adding product");
|
||||
} else {
|
||||
res.send(`
|
||||
<script>
|
||||
alert('Category added successfully');
|
||||
window.location.href = '/';
|
||||
</script>
|
||||
`);
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Start the server
|
||||
app.listen(3000, () => {
|
||||
console.log("Server started on port 3000");
|
||||
});
|
BIN
tsc1877/task1/_ref/paymentsequence_Simple.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/_ref/paymentsequence_Simple.png
(Stored with Git LFS)
Normal file
Binary file not shown.
Reference in New Issue
Block a user