Compare commits

..

22 Commits

Author SHA1 Message Date
be744fb8c4 Removed viewport to temporairly compensate for lack of responsive designing (sorry) 2026-01-29 09:43:02 +01:00
4512c077ec Stylesheet update (grazie Claude Haiku 4.5 😭) 2026-01-29 09:01:53 +01:00
1a88eb52e2 Fix handling risposta JSON per PizzaExpress 0.3.6 2026-01-29 08:55:22 +01:00
b7846c31d7 Cambiato URL in endpoint di release 2026-01-29 08:53:48 +01:00
a579f2e995 Reso campo note del form di aggiunta obbligatorio 2025-12-04 09:28:43 +01:00
d66cf4483b Fix non corrispondenza id campo "note" su funzione di handle del form 2025-12-04 09:12:36 +01:00
ca08a3ced9 Aggiunto campo note nel form di aggiunta 2025-12-04 09:10:58 +01:00
af1a64f2dc Aggiunta campo "note" 2025-12-04 09:09:26 +01:00
084cbb2b5f Rimosso ID Pizza da form di aggiunta 2025-12-04 09:06:48 +01:00
e67df056b6 Changed API URL to development HTTPS web server 2025-12-04 08:39:19 +01:00
67fbedba7d Secondo update link repository PizzaExpress 2025-11-28 08:47:00 +00:00
1161670865 Update link repository server 2025-11-28 08:20:46 +00:00
c983e0c99d Aggiunta licenza al progetto 2025-11-26 09:47:11 +00:00
ccb7c6dbed Aggiunta link download release server in README 2025-11-24 13:04:22 +01:00
ba1a68a255 Aggiornamento link repository PizzaExpress su README.md 2025-11-20 08:00:51 +00:00
5702600095 Update README.md 2025-11-20 07:58:30 +00:00
306dd41e3b Small change to pizza add success message 2025-11-17 12:08:05 +01:00
c4475a1458 Reso il messaggio di aggiunta pizza più chiaro 2025-11-13 09:24:40 +01:00
85afdbdbbe Lieve aggiustamento form aggiunta 2025-11-13 09:24:10 +01:00
5dec469c24 Fix aggiunta pizza non funzionante 2025-11-13 09:23:31 +01:00
f38f06bef6 Implementazione form aggiunta 2025-11-13 09:10:46 +01:00
a28fdb198b Controlli allineati al centro 2025-11-13 08:52:43 +01:00
6 changed files with 140 additions and 27 deletions

13
LICENSE Normal file
View File

@@ -0,0 +1,13 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.

View File

@@ -1,3 +1,5 @@
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 ## Informazioni su CORS
Per svariati motivi il web frontend potrebbe non riuscire ad effettuare richieste API ad altri endpoint per direttive CORS. Per svariati motivi il web frontend potrebbe non riuscire ad effettuare richieste API ad altri endpoint per direttive CORS.
In caso di errori CORS assicurarsi che: In caso di errori CORS assicurarsi che:

21
add.html Normal file
View File

@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Aggiungi pizza</title>
<script src="script.js"></script>
</head>
<body>
<form id="addForm" onsubmit="handleAddPizza(event)" >
<label for="name">Nome</label><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="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>
</html>

View File

@@ -2,7 +2,6 @@
<html lang="it"> <html lang="it">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PizzaExpress Web</title> <title>PizzaExpress Web</title>
<link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="style.css">
<script src="script.js"></script> <script src="script.js"></script>
@@ -12,10 +11,14 @@
<h1>PizzaExpress</h1> <h1>PizzaExpress</h1>
</header> </header>
<main> <main>
<button onclick="location.href='add.html'">+</button> <div class="pageControls">
<div>
<button onclick="window.open('add.html', 'popup', 'width=400,height=300')">+</button>
<button onclick="listPizze()">Aggiorna</button> <button onclick="listPizze()">Aggiorna</button>
<br><br> <br><br>
</div>
<div id="tabellaPizze"></div> <div id="tabellaPizze"></div>
</div>
</main> </main>
</body> </body>
</html> </html>

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(){ function listPizze(){
let reply; let reply;
@@ -11,14 +11,15 @@ function listPizze(){
.then((response) => response.json()) .then((response) => response.json())
.then((pizze) => { .then((pizze) => {
// Creiamo la tabella // 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 // Aggiungiamo ogni pizza come riga della tabella
pizze.pizze.forEach(pizza => { pizze.forEach(pizza => {
table += `<tr> table += `<tr>
<td>${pizza.id}</td> <td>${pizza.id}</td>
<td>${pizza.nome}</td> <td>${pizza.nome}</td>
<td>${pizza.prezzo.toFixed(2)}€</td> <td>${pizza.prezzo.toFixed(2)}€</td>
<td>${pizza.note}</td>
<td><button class="editBtn" onclick="editPizza(${pizza.id})">Modifica</button> <td><button class="editBtn" onclick="editPizza(${pizza.id})">Modifica</button>
<button class="delBtn" onclick="deletePizza(${pizza.id})">X</button></td> <button class="delBtn" onclick="deletePizza(${pizza.id})">X</button></td>
</tr>`; </tr>`;
@@ -84,14 +85,14 @@ function editPizza(id){
} }
} }
function addPizza(nome, id, prezzo){ function addPizza(nome, prezzo, note){
const myHeaders = new Headers(); const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json"); myHeaders.append("Content-Type", "application/json");
const raw = JSON.stringify({ const raw = JSON.stringify({
"id": id,
"nome": nome, "nome": nome,
"prezzo": prezzo "prezzo": prezzo,
"note": note
}); });
const requestOptions = { const requestOptions = {
@@ -101,14 +102,24 @@ function addPizza(nome, id, prezzo){
redirect: "follow" redirect: "follow"
}; };
fetch(apiUrl + "/api/pizze/" + id, requestOptions) fetch(apiUrl + "/api/pizze", requestOptions)
.then((response) => response.text()) .then((response) => response.text())
.then((result) => { .then((result) => {
alert("Pizza aggiunta con successo!"); alert("Pizza aggiunta con successo! Aggiorna la lista per mostrarla in pagina.");
listPizze(); window.close();
}) })
.catch((error) => { .catch((error) => {
console.error(error) console.error(error)
alert("Errore nell'aggiunta, controllare la console per dettagli sull'errore."); alert("Errore nell'aggiunta, controllare la console per dettagli sull'errore.");
}); });
} }
function handleAddPizza(event){
event.preventDefault();
const nome = document.getElementById("name").value;
const prezzo = document.getElementById("price").value;
const note = document.getElementById("note").value;
addPizza(nome, prezzo, note);
}

View File

@@ -1,5 +1,12 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{ body{
background-color: gainsboro; background: linear-gradient(135deg, #f5f5f5 0%, #ffffff 100%);
min-height: 100vh;
} }
body, button{ body, button{
@@ -8,34 +15,90 @@ body, button{
header{ header{
text-align: center; text-align: center;
background-color: red; background: linear-gradient(135deg, #d32f2f 0%, #b71c1c 100%);
color: white; color: white;
padding: 10px; padding: 20px;
margin-bottom: 15px; margin-bottom: 30px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
} }
table, td, th{ header h1 {
border: 1px solid black; 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{ 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{ button{
padding: 5px; padding: 10px 16px;
background-color: black; background-color: #1976d2;
color: white; color: white;
border-radius: 5px; border-radius: 6px;
border-style: none; 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{
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
gap: 20px;
padding: 30px;
} }
.editBtn{ .editBtn{
background-color: aqua; background-color: #ff9800;
color: black; color: white;
}
.editBtn:hover {
background-color: #f57c00;
} }
.delBtn{ .delBtn{
background-color: red; background-color: #d32f2f;
color: white; color: white;
} }
.delBtn:hover {
background-color: #b71c1c;
}