78 lines
2.3 KiB
HTML
78 lines
2.3 KiB
HTML
<!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> |