-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
296 lines (257 loc) · 14 KB
/
index.html
File metadata and controls
296 lines (257 loc) · 14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<!DOCTYPE html>
<html lang="he" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CULINARIA | הקולקציה הפרטית</title>
<link href="https://fonts.googleapis.com/css2?family=Assistant:wght@200;300;400;600&family=Playfair+Display:ital,wght@0,400;0,700;1,400&display=swap" rel="stylesheet">
<style>
:root {
--gold: #d4af37;
--gold-light: #f1c40f;
--dark: #121212;
--glass-bg: rgba(255, 255, 255, 0.95);
--glass-border: rgba(255, 255, 255, 0.2);
--shadow: 0 15px 35px rgba(0,0,0,0.2);
}
body {
font-family: 'Assistant', sans-serif;
margin: 0;
color: #fff;
background: url('https://images.unsplash.com/photo-1514362545857-3bc16c4c7d1b?q=80&w=2070&auto=format&fit=crop') no-repeat center center fixed;
background-size: cover;
overflow-x: hidden;
}
body::before {
content: "";
position: fixed;
top: 0; left: 0; width: 100%; height: 100%;
background: radial-gradient(circle, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.8) 100%);
backdrop-filter: blur(8px);
z-index: -1;
}
header { padding: 100px 20px 40px; text-align: center; }
header h1 { font-family: 'Playfair Display', serif; font-size: 4.5rem; letter-spacing: 15px; margin: 0; color: var(--gold); text-shadow: 2px 2px 10px rgba(0,0,0,0.5); }
header p { font-family: 'Playfair Display', serif; font-style: italic; font-size: 1.2rem; letter-spacing: 3px; opacity: 0.9; }
.container { max-width: 1200px; margin: auto; padding: 0 20px 100px; }
.controls-wrapper { display: flex; justify-content: center; align-items: center; gap: 20px; margin-bottom: 60px; flex-wrap: wrap; }
.btn-tab {
background: rgba(255,255,255,0.05); border: 1px solid var(--gold); padding: 12px 35px;
color: var(--gold); cursor: pointer; font-size: 0.9rem; letter-spacing: 2px;
transition: 0.4s; backdrop-filter: blur(5px); outline: none;
}
.btn-tab.active, .btn-tab:hover { background: var(--gold); color: var(--dark); box-shadow: 0 0 20px rgba(212, 175, 55, 0.4); }
#categoryFilter { background: rgba(0,0,0,0.5); border: 1px solid var(--gold); padding: 12px 20px; color: var(--gold); outline: none; }
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 30px; }
.recipe-card {
background: var(--glass-bg); padding: 50px 30px; color: var(--dark); border-radius: 2px;
text-align: center; transition: 0.5s; cursor: pointer; border: 1px solid var(--glass-border);
position: relative; overflow: hidden;
}
.recipe-card:hover { transform: translateY(-10px); background: #fff; box-shadow: var(--shadow); }
.card-category { color: var(--gold); font-size: 0.75rem; letter-spacing: 4px; text-transform: uppercase; margin-bottom: 20px; font-weight: 600; display: block; }
.card-title { font-family: 'Playfair Display', serif; font-size: 1.8rem; margin: 0; font-weight: 400; }
/* מודאל */
.modal { display: none; position: fixed; z-index: 3000; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); backdrop-filter: blur(15px); }
.modal-content {
background: #fff; color: var(--dark); margin: 2% auto; padding: 60px;
width: 90%; max-width: 850px; max-height: 85vh; overflow-y: auto;
border-radius: 4px; position: relative; box-shadow: 0 25px 50px rgba(0,0,0,0.5);
}
.close-modal { position: absolute; left: 30px; top: 20px; font-size: 35px; cursor: pointer; color: var(--gold); }
/* עיצוב טפסי עריכה */
.edit-input, .edit-textarea {
width: 100%; border: none; border-bottom: 1px solid #ddd; padding: 12px 0;
margin-bottom: 25px; font-size: 1rem; outline: none; transition: 0.3s; background: transparent;
}
.edit-input:focus, .edit-textarea:focus { border-bottom: 2px solid var(--gold); }
.section-header { font-family: 'Playfair Display', serif; color: var(--gold); border-bottom: 1px solid #eee; padding-bottom: 10px; margin-top: 40px; font-size: 1.4rem; }
/* צ'אט */
#chat-icon { position: fixed; bottom: 30px; left: 30px; background: var(--dark); color: var(--gold); width: 65px; height: 65px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 30px; border: 1px solid var(--gold); z-index: 4000; cursor: pointer; }
#chat-window { display: none; position: fixed; bottom: 110px; left: 30px; width: 360px; height: 500px; background: #fff; border-radius: 12px; box-shadow: var(--shadow); flex-direction: column; overflow: hidden; z-index: 4000; color: var(--dark); }
.chat-header { background: var(--dark); color: var(--gold); padding: 20px; display: flex; justify-content: space-between; }
#chat-messages { flex: 1; padding: 20px; overflow-y: auto; background: #f9f9f9; display: flex; flex-direction: column; gap: 10px; }
.chat-bubble { max-width: 80%; padding: 12px; border-radius: 10px; font-size: 0.9rem; }
.bubble-user { align-self: flex-end; background: var(--gold); color: #fff; }
.bubble-bot { align-self: flex-start; background: #eee; }
.chat-input-area { padding: 15px; display: flex; gap: 10px; border-top: 1px solid #eee; }
.chat-input-area input { flex: 1; border: 1px solid #ddd; padding: 10px; border-radius: 20px; outline: none; }
</style>
</head>
<body>
<header>
<h1>CULINARIA</h1>
<p>THE ART OF GASTRONOMY • PRIVATE COLLECTION</p>
</header>
<div class="container">
<div class="controls-wrapper">
<button id="btn-view" class="btn-tab active" onclick="showSection('view')">האוסף</button>
<button id="btn-add" class="btn-tab" onclick="showSection('add')">הוספה</button>
<select id="categoryFilter" onchange="filterByCategory()">
<option value="all">כל התפריט</option>
<option value="ארוחות">ארוחות</option>
<option value="עוגות">עוגות</option>
<option value="מרקים">מרקים</option>
</select>
</div>
<div id="viewSection">
<div id="recipesGrid" class="recipe-grid"></div>
</div>
<div id="addSection" style="display:none;">
<div style="background: #fff; padding: 60px; max-width: 700px; margin: auto; color: var(--dark);">
<h2 style="font-family:'Playfair Display'; text-align: center; font-size: 2.5rem; margin-bottom: 40px;">יצירה חדשה</h2>
<input type="text" id="newTitle" class="edit-input" placeholder="שם המנה">
<input type="text" id="newDescription" class="edit-input" placeholder="תיאור קצר">
<div style="display: flex; gap: 20px;">
<input type="text" id="newCat" class="edit-input" placeholder="קטגוריה">
<input type="number" id="newTime" class="edit-input" placeholder="דקות">
</div>
<textarea id="newIngredients" class="edit-textarea" rows="4" placeholder="מרכיבים..."></textarea>
<textarea id="newInstructions" class="edit-textarea" rows="6" placeholder="הוראות הכנה..."></textarea>
<button class="btn-tab active" style="width:100%; margin-top: 20px;" onclick="sendToPython()">הוסף לאוסף</button>
</div>
</div>
</div>
<div id="recipeModal" class="modal">
<div class="modal-content">
<span class="close-modal" onclick="closeModal()">×</span>
<div id="modalData"></div>
</div>
</div>
<div id="chat-icon" onclick="toggleChat()">✧</div>
<div id="chat-window">
<div class="chat-header"><span>Chef Assistant</span><span onclick="toggleChat()" style="cursor:pointer">×</span></div>
<div id="chat-messages"></div>
<div class="chat-input-area">
<input type="text" id="chat-input" placeholder="שאל את השף...">
<button onclick="askChef()" style="background:var(--gold); border:none; color:white; border-radius:50%; width:35px; cursor:pointer;">➤</button>
</div>
</div>
<script>
const API_BASE = "http://127.0.0.1:8000/recipes";
const CHAT_URL = "http://127.0.0.1:8000/ask";
let allRecipes = [];
async function loadData() {
const res = await fetch(API_BASE);
allRecipes = await res.json();
renderGrid(allRecipes);
}
function renderGrid(recipes) {
document.getElementById("recipesGrid").innerHTML = recipes.map(r => `
<div class="recipe-card" onclick="openRecipe(${r.RecipeId || r.RecipeID})">
<span class="card-category">${r.Category || 'GOURMET'}</span>
<h3 class="card-title">${r.Title}</h3>
<p style="margin-top:20px; font-size:0.8rem; letter-spacing:1px; opacity:0.5;">
${r.PrepTimeMinutes || 30} MIN • ${r.IsDairy ? 'DAIRY' : 'PARVE'}
</p>
</div>
`).join('');
}
function openRecipe(id) {
const recipe = allRecipes.find(r => (r.RecipeId || r.RecipeID) == id);
document.getElementById("modalData").innerHTML = `
<div id="viewMode">
<span class="card-category">${recipe.Category}</span>
<h2 style="font-family:'Playfair Display'; font-size:3.5rem; margin:10px 0;">${recipe.Title}</h2>
<p style="font-style:italic; color:#777; font-size:1.1rem; margin-bottom:40px;">${recipe.Description || ''}</p>
<h4 class="section-header">המרכיבים</h4>
<p style="white-space: pre-line; line-height:2;">${recipe.Ingredients}</p>
<h4 class="section-header">אופן ההכנה</h4>
<p style="white-space: pre-line; line-height:2;">${recipe.Instructions}</p>
<div style="margin-top:50px; display:flex; gap:20px;">
<button class="btn-tab active" onclick="toggleEdit()">עריכת מתכון</button>
<button onclick="deleteItem(${id})" style="background:none; border:none; color:red; cursor:pointer;">מחיקה</button>
</div>
</div>
<div id="editMode" style="display:none;">
<h2 style="font-family:'Playfair Display'; color:var(--gold);">עריכת אומנות הבישול</h2>
<input type="text" id="editTitle" class="edit-input" value="${recipe.Title}">
<textarea id="editIngredients" class="edit-textarea" rows="6">${recipe.Ingredients}</textarea>
<textarea id="editInstructions" class="edit-textarea" rows="10">${recipe.Instructions}</textarea>
<button class="btn-tab active" style="width:100%" onclick="updateRecipe(${id})">שמור שינויים</button>
</div>
`;
document.getElementById("recipeModal").style.display = "block";
}
async function updateRecipe(id) {
const payload = {
Title: document.getElementById("editTitle").value,
Ingredients: document.getElementById("editIngredients").value,
Instructions: document.getElementById("editInstructions").value
};
await fetch(`${API_BASE}/${id}`, {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(payload)
});
closeModal();
loadData();
}
function toggleEdit() {
const v = document.getElementById("viewMode"), e = document.getElementById("editMode");
v.style.display = "none"; e.style.display = "block";
}
function closeModal() { document.getElementById("recipeModal").style.display = "none"; }
function showSection(s) {
document.getElementById('viewSection').style.display = s === 'view' ? 'block' : 'none';
document.getElementById('addSection').style.display = s === 'add' ? 'block' : 'none';
document.querySelectorAll('.btn-tab').forEach(b => b.classList.remove('active'));
document.getElementById('btn-' + s).classList.add('active');
}
async function deleteItem(id) {
if(confirm("למחוק יצירה זו?")) { await fetch(`${API_BASE}/${id}`, {method:'DELETE'}); closeModal(); loadData(); }
}
async function askChef() {
const inp = document.getElementById('chat-input'), msg = document.getElementById('chat-messages');
if(!inp.value) return;
msg.innerHTML += `<div class="chat-bubble bubble-user">${inp.value}</div>`;
const res = await fetch(`${CHAT_URL}?question=${encodeURIComponent(inp.value)}`);
const data = await res.json();
msg.innerHTML += `<div class="chat-bubble bubble-bot">${data.answer}</div>`;
inp.value = ''; msg.scrollTop = msg.scrollHeight;
}
function toggleChat() {
const c = document.getElementById('chat-window');
c.style.display = c.style.display === 'flex' ? 'none' : 'flex';
}
function filterByCategory() {
const selected = document.getElementById("categoryFilter").value;
if (selected === "all") {
renderGrid(allRecipes);
return;
}
const filtered = allRecipes.filter(r =>
r.Category && r.Category.trim() === selected
);
renderGrid(filtered);
}
async function sendToPython() {
const payload = {
Title: document.getElementById("newTitle").value,
Description: document.getElementById("newDescription").value,
Ingredients: document.getElementById("newIngredients").value,
Instructions: document.getElementById("newInstructions").value,
Category: document.getElementById("newCat").value,
PrepTimeMinutes: parseInt(document.getElementById("newTime").value) || 30,
Difficulty: "Easy", // לפי ה-Schema שלך
IsDairy: 0 // לפי ה-Schema שלך
};
const res = await fetch(API_BASE, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(payload)
});
if (!res.ok) {
alert("שגיאה בהוספת מתכון");
return;
}
alert("המתכון נוסף בהצלחה");
showSection('view');
loadData();
}
window.onload = loadData;
</script>
</body>
</html>