Compare commits

..

12 Commits

5 changed files with 84 additions and 27 deletions

View File

@@ -1,4 +1,4 @@
Applicazione web per interfacciarsi a PizzaExpress, disponibile per il download su [questo repository](https://git.fiorencis.eu/SmerdoRepository/PizzaExpress) ([release compilata](https://git.fiorencis.eu/SmerdoRepository/PizzaExpress/releases))
Applicazione web per interfacciarsi a PizzaExpress, disponibile per il download su [questo repository](https://git.fiorencis.eu/EduProjects/PizzaExpress) ([release compilata](https://git.fiorencis.eu/EduProjects/PizzaExpress/releases))
## Informazioni su CORS
Per svariati motivi il web frontend potrebbe non riuscire ad effettuare richieste API ad altri endpoint per direttive CORS.

View File

@@ -8,12 +8,13 @@
</head>
<body>
<form id="addForm" onsubmit="handleAddPizza(event)" >
<label for="id">ID Pizza</label><br>
<input type="number" id="id" name="id" required><br>
<label for="name">Nome</label><br>
<input type="text" id="name" name="name" required><br>
<input type="text" id="name" name="nome" required><br>
<label for="prezzo">Prezzo</label><br>
<input type="number" step="0.01" id="price" name="price" required><br><br>
<input type="number" step="0.01" id="price" name="prezzo" required><br>
<label for="note">Note</label><br>
<input type="text" id="note" name="note" required>
<br><br>
<input type="submit" value="Aggiungi">
</form>
</body>

View File

@@ -2,7 +2,6 @@
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PizzaExpress Web</title>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>

View File

@@ -1,4 +1,4 @@
const apiUrl = "http://localhost:5011";
const apiUrl = "http://localhost:5000"; // Inserire qui l'URL del web server Kestrel
function listPizze(){
let reply;
@@ -11,14 +11,15 @@ function listPizze(){
.then((response) => response.json())
.then((pizze) => {
// Creiamo la tabella
let table = '<table><tr><th>ID</th><th>Nome</th><th>Prezzo</th><th>Azioni</th></tr>';
let table = '<table><tr><th>ID</th><th>Nome</th><th>Prezzo</th><th>Note</th><th>Azioni</th></tr>';
// Aggiungiamo ogni pizza come riga della tabella
pizze.pizze.forEach(pizza => {
pizze.forEach(pizza => {
table += `<tr>
<td>${pizza.id}</td>
<td>${pizza.nome}</td>
<td>${pizza.prezzo.toFixed(2)}€</td>
<td>${pizza.note}</td>
<td><button class="editBtn" onclick="editPizza(${pizza.id})">Modifica</button>
<button class="delBtn" onclick="deletePizza(${pizza.id})">X</button></td>
</tr>`;
@@ -84,14 +85,14 @@ function editPizza(id){
}
}
function addPizza(id, nome, prezzo){
function addPizza(nome, prezzo, note){
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
const raw = JSON.stringify({
"id": id,
"nome": nome,
"prezzo": prezzo
"prezzo": prezzo,
"note": note
});
const requestOptions = {
@@ -117,8 +118,8 @@ function handleAddPizza(event){
event.preventDefault();
const nome = document.getElementById("name").value;
const id = document.getElementById("id").value;
const prezzo = document.getElementById("price").value;
const note = document.getElementById("note").value;
addPizza(id, nome, prezzo);
addPizza(nome, prezzo, note);
}

View File

@@ -1,5 +1,12 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{
background-color: gainsboro;
background: linear-gradient(135deg, #f5f5f5 0%, #ffffff 100%);
min-height: 100vh;
}
body, button{
@@ -8,26 +15,65 @@ body, button{
header{
text-align: center;
background-color: red;
background: linear-gradient(135deg, #d32f2f 0%, #b71c1c 100%);
color: white;
padding: 10px;
margin-bottom: 15px;
padding: 20px;
margin-bottom: 30px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
table, td, th{
border: 1px solid black;
header h1 {
font-size: 2.5em;
font-weight: 700;
letter-spacing: 1px;
}
table{
width: 100%;
border-collapse: collapse;
background-color: white;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
border-radius: 8px;
overflow: hidden;
}
td, th{
padding: 5px;
padding: 12px 15px;
text-align: left;
border-bottom: 1px solid #e0e0e0;
}
th{
background-color: #f5f5f5;
font-weight: 600;
color: #333;
}
tr:hover {
background-color: #fafafa;
}
button{
padding: 5px;
background-color: black;
padding: 10px 16px;
background-color: #1976d2;
color: white;
border-radius: 5px;
border-radius: 6px;
border-style: none;
cursor: pointer;
font-weight: 600;
transition: all 0.3s ease;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
button:hover {
background-color: #1565c0;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
transform: translateY(-2px);
}
button:active {
transform: translateY(0);
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.pageControls{
@@ -35,14 +81,24 @@ button{
flex-direction: column;
align-items: center;
text-align: center;
gap: 20px;
padding: 30px;
}
.editBtn{
background-color: aqua;
color: black;
background-color: #ff9800;
color: white;
}
.editBtn:hover {
background-color: #f57c00;
}
.delBtn{
background-color: red;
background-color: #d32f2f;
color: white;
}
.delBtn:hover {
background-color: #b71c1c;
}