-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassistant.html
More file actions
460 lines (404 loc) · 16.9 KB
/
Copy pathassistant.html
File metadata and controls
460 lines (404 loc) · 16.9 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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
<!DOCTYPE html>
<html lang="fr" class="light-mode">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Assistant Intelligent HardLink</title>
<link rel="stylesheet" href="global.css">
<link rel="stylesheet" href="dashboard.css">
<style>
/* Styles spécifiques pour l'Assistant Intelligent en plein écran */
.assistant-container {
width: 98%; /* Augmenté de 15% (environ 95% -> 98% pour rester dans l'écran) */
max-width: 1250px; /* Augmenté de 1150px à 1250px pour plus d'espace */
height: calc(100vh - 10px); /* Hauteur calculée pour laisser 5px en haut et 5px en bas */
background-color: #1a1f26; /* Raven Black */
border-radius: 15px;
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
display: flex;
flex-direction: column;
overflow: hidden;
border: 1px solid #4a4a4a; /* Bordure grise cohérente */
margin: 5px auto; /* 5px en haut et en bas, centré horizontalement */
z-index: 10;
position: relative;
backdrop-filter: blur(10px);
}
.assistant-header {
background-color: #1a1f26;
color: #0077b3;
padding: 20px;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid #4a4a4a;
}
.assistant-header h2 {
margin: 0;
display: flex;
align-items: center;
gap: 12px;
font-weight: 700;
letter-spacing: 1px;
}
.assistant-messages {
flex: 1;
padding: 25px; /* Restauré */
overflow-y: auto;
background-color: rgba(11, 14, 17, 0.5);
display: flex;
flex-direction: column;
gap: 20px; /* Restauré */
scrollbar-width: thin;
scrollbar-color: #0077b3 #1a1f26;
}
.message {
max-width: 85%; /* Restauré */
padding: 15px 25px; /* Restauré */
font-size: 1.05em; /* Restauré */
line-height: 1.6; /* Restauré */
border-radius: 15px; /* Restauré */
position: relative;
animation: fadeIn 0.4s ease-out forwards;
}
.bot-message {
background-color: #2c3e50;
color: #e0e0e0;
align-self: flex-start;
border-bottom-left-radius: 2px;
border: 1px solid #4a4a4a;
box-shadow: 5px 5px 15px rgba(0,0,0,0.3);
width: 100%; /* S'adapte à la largeur du conteneur */
max-width: 950px; /* Largeur optimale pour les colonnes */
}
/* Conteneur pour les informations en colonnes */
.info-grid {
display: grid;
grid-template-columns: repeat(3, 1fr); /* Forcé à 3 colonnes sur la même ligne */
gap: 10px 30px;
margin-top: 15px;
width: 100%;
}
/* Adaptation pour mobile */
@media (max-width: 768px) {
.info-grid {
grid-template-columns: 1fr;
}
}
.info-item {
border-bottom: 1px solid rgba(255,255,255,0.08);
padding: 8px 0; /* Plus d'espace vertical */
display: flex;
justify-content: space-between;
align-items: center;
}
.info-label {
color: #00d2ff;
font-weight: 700;
margin-right: 15px;
white-space: nowrap;
}
.info-value {
color: #ffffff;
text-align: right;
font-weight: 400;
}
/* Conteneur pour les boutons en grille */
.button-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
gap: 8px;
margin: 15px 0;
}
.user-message {
background-color: #0077b3;
color: white;
align-self: flex-end;
border-bottom-right-radius: 2px;
box-shadow: -5px 5px 15px rgba(0,0,0,0.3);
}
.assistant-input-container {
padding: 20px 30px;
background-color: #1a1f26;
border-top: 1px solid #4a4a4a;
display: flex;
gap: 15px;
align-items: center;
}
#assistant-input {
flex: 1;
padding: 14px 25px;
background-color: #2c3e50;
border: 1px solid #4a4a4a;
border-radius: 30px;
font-size: 1.05em;
color: #e0e0e0;
outline: none;
transition: all 0.3s;
}
#assistant-input:focus {
border-color: #0077b3;
box-shadow: 0 0 10px rgba(0, 119, 179, 0.3);
}
#assistant-send {
background-color: #0077b3;
color: white;
border: none;
padding: 12px 30px;
border-radius: 30px;
font-size: 1em;
font-weight: 700;
cursor: pointer;
transition: all 0.3s ease;
box-shadow: 0 4px 15px rgba(0, 119, 179, 0.3);
}
#assistant-send:hover {
background-color: #005f99;
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(0, 119, 179, 0.4);
}
.assistant-footer {
padding: 8px;
text-align: center;
font-size: 0.85em;
color: #666;
border-top: 1px solid rgba(74, 74, 74, 0.3);
background-color: #1a1f26;
}
html.light-mode .assistant-container {
background-color: var(--container-bg);
border-color: var(--border-color);
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
}
html.light-mode .assistant-header {
background-color: var(--card-bg);
color: var(--text-color);
border-bottom: 1px solid var(--border-color);
}
html.light-mode .assistant-messages {
background-color: #f4f7fb;
}
html.light-mode .bot-message {
background-color: #ffffff;
color: #243143;
border-color: rgba(0, 0, 0, 0.1);
box-shadow: 3px 3px 12px rgba(0, 0, 0, 0.08);
}
html.light-mode .user-message {
background-color: var(--accent-blue);
color: #ffffff;
}
html.light-mode .assistant-input-container {
background-color: var(--card-bg);
border-top: 1px solid var(--border-color);
}
html.light-mode #assistant-input {
background-color: #ffffff;
color: #243143;
border-color: rgba(0, 0, 0, 0.12);
}
html.light-mode #assistant-input:focus {
box-shadow: 0 0 10px rgba(0, 119, 179, 0.15);
}
html.light-mode .assistant-footer {
background-color: var(--container-bg);
color: #333;
border-top: 1px solid rgba(0, 0, 0, 0.08);
}
html.light-mode .back-btn {
color: #243143;
border-color: rgba(0, 0, 0, 0.12);
}
html.light-mode .back-btn:hover {
background-color: rgba(0, 0, 0, 0.05);
color: #000;
}
.back-btn {
background-color: transparent;
color: #888;
border: 1px solid #4a4a4a;
padding: 10px 20px;
border-radius: 8px;
font-weight: 600;
text-decoration: none;
transition: all 0.3s ease;
}
.back-btn:hover {
background-color: #4a4a4a;
color: white;
text-decoration: none;
}
/* Styles pour les commandes cliquables */
.clickable-command {
color: #00d2ff;
text-decoration: none;
cursor: pointer;
font-size: 0.9em; /* Un peu plus petit */
font-weight: 700;
padding: 3px 12px; /* Réduit de 4px 10px */
background-color: rgba(0, 210, 255, 0.1);
border: 1px solid rgba(0, 210, 255, 0.2);
border-radius: 15px; /* Réduit de 20px */
display: inline-block;
margin: 2px 4px; /* Réduit de 4px */
transition: all 0.3s;
}
.clickable-command:hover {
background-color: #00d2ff;
color: #1a1f26;
transform: scale(1.05);
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(15px); }
to { opacity: 1; transform: translateY(0); }
}
</style>
<script src="js/auth_check.js"></script>
</head>
<body class="dashboard-body">
<div id="background-slider">
<img src="img/fibre3.jpg" alt="Background Image 4" class="active">
</div>
<div class="assistant-container">
<div class="assistant-header">
<h2>
HardLink - Assistant Intelligent <span id="header-date" style="font-size: 0.6em; color: #888; margin-left: 15px; font-weight: 400;"></span>
</h2>
<a href="dashboard.html" class="back-btn">Retour au Dashboard</a>
</div>
<div class="assistant-messages" id="assistant-messages">
<!-- Les messages s'afficheront ici -->
</div>
<div class="assistant-input-container">
<input type="text" id="assistant-input" placeholder="Posez votre question sur les clients, sites, équipements ou jointures..." autocomplete="off">
<button id="assistant-send">Envoyer</button>
</div>
<div class="assistant-footer">
© 2026 HardLink - Tous droits réservés
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const messagesContainer = document.getElementById('assistant-messages');
const inputField = document.getElementById('assistant-input');
const sendButton = document.getElementById('assistant-send');
const headerDateSpan = document.getElementById('header-date');
// Mise à jour de l'heure dans le titre
function updateDateTime() {
const now = new Date();
headerDateSpan.textContent = now.toLocaleString('fr-FR', {
weekday: 'long', day: 'numeric', month: 'long', year: 'numeric',
hour: '2-digit', minute: '2-digit', second: '2-digit'
});
}
setInterval(updateDateTime, 1000);
updateDateTime();
// Récupérer le nom de l'utilisateur
function getUsername() {
try {
const currentUser = JSON.parse(localStorage.getItem('currentUser'));
return (currentUser && currentUser.username) ? currentUser.username : 'Utilisateur';
} catch (e) {
return 'Utilisateur';
}
}
const username = getUsername();
// Ajouter un message à l'interface
function addMessage(text, isBot = false) {
const messageDiv = document.createElement('div');
messageDiv.className = `message ${isBot ? 'bot-message' : 'user-message'}`;
if (isBot) {
// Formatage basique (gras)
let formattedText = text.replace(/\*\*(.*?)\*\*/g, '<b>$1</b>');
// Souligné
formattedText = formattedText.replace(/<u>(.*?)<\/u>/g, '<u>$1</u>');
// Support pour les grilles d'infos (Lignes commençant par •)
if (formattedText.includes('• ')) {
// On transforme chaque ligne • Label: Valeur en un item d'info
formattedText = formattedText.replace(/• (.*?): (.*?)(?:\n|<br>|$)/g, '<div class="info-item"><span class="info-label">$1</span><span class="info-value">$2</span></div>');
// On regroupe les items consécutifs dans une grille (Compatibilité dotall via [\s\S])
formattedText = formattedText.replace(/(<div class="info-item">[\s\S]*?<\/div>)+/g, '<div class="info-grid">$&</div>');
}
// Support pour les boutons en grille (Plan E)
if (formattedText.includes('[[') && (formattedText.includes('SITE A') || formattedText.includes('SITE B'))) {
formattedText = formattedText.replace(/\[\[(.*?)\|(.*?)\]\]/g, (match, label, command) => {
return `<span class="clickable-command" onclick="sendDirectCommand('${command.trim()}')">${label.trim()}</span>`;
});
// On regroupe les boutons consécutifs dans une grille
formattedText = formattedText.replace(/(<span class="clickable-command">[\s\S]*?<\/span>\s*)+/g, '<div class="button-grid">$&</div>');
} else {
// Support standard pour les liens cliquables personnalisés [[Label|Commande]]
formattedText = formattedText.replace(/\[\[(.*?)\|(.*?)\]\]/g, (match, label, command) => {
return `<span class="clickable-command" onclick="sendDirectCommand('${command.trim()}')">${label.trim()}</span>`;
});
}
// Conversion des retours à la ligne restants (après les grilles)
formattedText = formattedText.replace(/\n/g, '<br>');
messageDiv.innerHTML = formattedText;
} else {
messageDiv.textContent = text;
}
messagesContainer.appendChild(messageDiv);
// Faire défiler pour que le début du nouveau message soit visible
if (isBot) {
messageDiv.scrollIntoView({ behavior: 'smooth', block: 'start' });
} else {
messagesContainer.scrollTop = messagesContainer.scrollHeight;
}
}
// Fonction pour envoyer une commande directement via un clic
window.sendDirectCommand = function(command) {
inputField.value = command;
sendMessage();
};
// Message de bienvenue
setTimeout(() => {
addMessage(`Bonjour Monsieur ${username} ! Je suis l'Assistant Intelligent de HardLink.\n\nComment puis-je vous aider aujourd'hui ?\n\nVoici les **plans flash** :\nTapez **A-Client**, **B-Site**, **C-Equipement**, **D-Dérangement** ou **E-Jointure**. A vous !`, true);
}, 500);
// Envoi du message
async function sendMessage() {
const message = inputField.value.trim();
if (!message) return;
addMessage(message, false);
inputField.value = '';
inputField.disabled = true;
sendButton.disabled = true;
try {
const response = await fetch('api/chatbot.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
message: message,
username: username
})
});
const data = await response.json();
if (data.success) {
addMessage(data.reply, true);
// Action spéciale si retournée par l'API
if (data.action === 'close') {
setTimeout(() => {
window.location.href = 'dashboard.html';
}, 2000);
}
} else {
addMessage("Désolé, j'ai rencontré une erreur lors du traitement de votre demande.", true);
}
} catch (error) {
console.error('Erreur assistant:', error);
addMessage("Désolé, une erreur réseau s'est produite. Vérifiez votre connexion.", true);
} finally {
inputField.disabled = false;
sendButton.disabled = false;
inputField.focus();
}
}
sendButton.addEventListener('click', sendMessage);
inputField.addEventListener('keypress', (e) => {
if (e.key === 'Enter') sendMessage();
});
inputField.focus();
});
</script>
</body>
</html>