Update templates/index.html
Browse files- templates/index.html +162 -42
templates/index.html
CHANGED
@@ -3,63 +3,168 @@
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
-
<title>Analyse d'Image</title>
|
|
|
7 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/9.1.6/marked.min.js"></script>
|
|
|
8 |
<style>
|
9 |
-
.
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
13 |
}
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
}
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
margin: 20px 0;
|
24 |
}
|
25 |
</style>
|
26 |
</head>
|
27 |
-
<body>
|
28 |
-
<div class="
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
<
|
39 |
-
|
40 |
-
<div
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
</div>
|
48 |
|
49 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
document.getElementById('uploadForm').addEventListener('submit', async (e) => {
|
51 |
e.preventDefault();
|
52 |
|
53 |
const loading = document.getElementById('loading');
|
54 |
-
const
|
55 |
const dissertationResult = document.getElementById('dissertationResult');
|
56 |
|
57 |
const formData = new FormData();
|
58 |
formData.append('image', document.getElementById('imageInput').files[0]);
|
59 |
|
60 |
-
loading.
|
61 |
-
|
62 |
-
dissertationResult.innerHTML = '';
|
63 |
|
64 |
try {
|
65 |
const response = await fetch('/analyze', {
|
@@ -70,15 +175,30 @@
|
|
70 |
const data = await response.json();
|
71 |
|
72 |
if (response.ok) {
|
73 |
-
|
|
|
|
|
|
|
74 |
dissertationResult.innerHTML = marked.parse(data.dissertation);
|
|
|
|
|
|
|
|
|
75 |
} else {
|
76 |
-
|
|
|
|
|
|
|
|
|
77 |
}
|
78 |
} catch (error) {
|
79 |
-
|
|
|
|
|
|
|
|
|
80 |
} finally {
|
81 |
-
loading.
|
82 |
}
|
83 |
});
|
84 |
</script>
|
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Mariam AI - Analyse d'Image</title>
|
7 |
+
<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
|
8 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/9.1.6/marked.min.js"></script>
|
9 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert2/11.7.32/sweetalert2.all.min.js"></script>
|
10 |
<style>
|
11 |
+
.loader {
|
12 |
+
width: 48px;
|
13 |
+
height: 48px;
|
14 |
+
border: 5px solid #FFF;
|
15 |
+
border-bottom-color: #6366F1;
|
16 |
+
border-radius: 50%;
|
17 |
+
display: inline-block;
|
18 |
+
box-sizing: border-box;
|
19 |
+
animation: rotation 1s linear infinite;
|
20 |
}
|
21 |
+
|
22 |
+
@keyframes rotation {
|
23 |
+
0% { transform: rotate(0deg); }
|
24 |
+
100% { transform: rotate(360deg); }
|
25 |
+
}
|
26 |
+
|
27 |
+
.fade-in {
|
28 |
+
animation: fadeIn 0.5s ease-in;
|
29 |
+
}
|
30 |
+
|
31 |
+
@keyframes fadeIn {
|
32 |
+
0% { opacity: 0; }
|
33 |
+
100% { opacity: 1; }
|
34 |
+
}
|
35 |
+
|
36 |
+
.upload-zone {
|
37 |
+
border: 2px dashed #6366F1;
|
38 |
+
transition: all 0.3s ease;
|
39 |
+
}
|
40 |
+
|
41 |
+
.upload-zone:hover {
|
42 |
+
border-color: #4F46E5;
|
43 |
+
background-color: #EEF2FF;
|
44 |
+
}
|
45 |
+
|
46 |
+
/* Style pour le markdown rendu */
|
47 |
+
.markdown-content table {
|
48 |
+
border-collapse: collapse;
|
49 |
+
width: 100%;
|
50 |
+
margin: 1rem 0;
|
51 |
+
}
|
52 |
+
|
53 |
+
.markdown-content th,
|
54 |
+
.markdown-content td {
|
55 |
+
border: 1px solid #e5e7eb;
|
56 |
+
padding: 0.75rem;
|
57 |
+
text-align: left;
|
58 |
}
|
59 |
+
|
60 |
+
.markdown-content th {
|
61 |
+
background-color: #f9fafb;
|
|
|
62 |
}
|
63 |
</style>
|
64 |
</head>
|
65 |
+
<body class="bg-gray-50">
|
66 |
+
<div class="min-h-screen">
|
67 |
+
<!-- Header -->
|
68 |
+
<header class="bg-white shadow-sm">
|
69 |
+
<div class="max-w-7xl mx-auto px-4 py-4 sm:px-6 lg:px-8">
|
70 |
+
<h1 class="text-3xl font-bold text-indigo-600">Mariam AI</h1>
|
71 |
+
<p class="mt-1 text-sm text-gray-500">Assistant d'analyse d'images intelligent</p>
|
72 |
+
</div>
|
73 |
+
</header>
|
74 |
+
|
75 |
+
<!-- Main content -->
|
76 |
+
<main class="max-w-7xl mx-auto px-4 py-8 sm:px-6 lg:px-8">
|
77 |
+
<!-- Upload Section -->
|
78 |
+
<div class="bg-white rounded-lg shadow p-6 mb-8">
|
79 |
+
<form id="uploadForm" class="space-y-6">
|
80 |
+
<div class="upload-zone rounded-lg p-8 text-center">
|
81 |
+
<input type="file" id="imageInput" accept="image/*" required
|
82 |
+
class="hidden" onchange="updateFileName()">
|
83 |
+
<label for="imageInput" class="cursor-pointer">
|
84 |
+
<div class="space-y-2">
|
85 |
+
<svg class="mx-auto h-12 w-12 text-indigo-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
86 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
87 |
+
d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"/>
|
88 |
+
</svg>
|
89 |
+
<div id="fileName" class="text-sm text-gray-500">
|
90 |
+
Cliquez ou glissez une image ici
|
91 |
+
</div>
|
92 |
+
</div>
|
93 |
+
</label>
|
94 |
+
</div>
|
95 |
+
<div class="flex justify-center">
|
96 |
+
<button type="submit"
|
97 |
+
class="inline-flex items-center px-6 py-3 border border-transparent text-base font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 transition-colors duration-200">
|
98 |
+
Analyser l'image
|
99 |
+
</button>
|
100 |
+
</div>
|
101 |
+
</form>
|
102 |
+
</div>
|
103 |
+
|
104 |
+
<!-- Loading indicator -->
|
105 |
+
<div id="loading" class="hidden">
|
106 |
+
<div class="flex flex-col items-center justify-center space-y-4">
|
107 |
+
<span class="loader"></span>
|
108 |
+
<p class="text-gray-500">Analyse en cours, veuillez patienter...</p>
|
109 |
+
</div>
|
110 |
+
</div>
|
111 |
+
|
112 |
+
<!-- Results Section -->
|
113 |
+
<div id="results" class="space-y-8 hidden">
|
114 |
+
<!-- Tableau Button -->
|
115 |
+
<div class="flex justify-center">
|
116 |
+
<button id="showTableau"
|
117 |
+
class="px-6 py-3 bg-indigo-600 text-white rounded-md hover:bg-indigo-700 transition-colors duration-200">
|
118 |
+
Voir le tableau d'analyse
|
119 |
+
</button>
|
120 |
+
</div>
|
121 |
+
|
122 |
+
<!-- Dissertation -->
|
123 |
+
<div class="bg-white rounded-lg shadow p-6">
|
124 |
+
<h2 class="text-2xl font-bold text-gray-900 mb-4">Dissertation</h2>
|
125 |
+
<div id="dissertationResult" class="prose max-w-none markdown-content">
|
126 |
+
</div>
|
127 |
+
</div>
|
128 |
+
</div>
|
129 |
+
</main>
|
130 |
</div>
|
131 |
|
132 |
<script>
|
133 |
+
let tableauContent = ''; // Variable pour stocker le contenu du tableau
|
134 |
+
|
135 |
+
function updateFileName() {
|
136 |
+
const input = document.getElementById('imageInput');
|
137 |
+
const fileName = document.getElementById('fileName');
|
138 |
+
if (input.files.length > 0) {
|
139 |
+
fileName.textContent = input.files[0].name;
|
140 |
+
} else {
|
141 |
+
fileName.textContent = 'Cliquez ou glissez une image ici';
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
document.getElementById('showTableau').addEventListener('click', () => {
|
146 |
+
Swal.fire({
|
147 |
+
title: 'Tableau d\'analyse',
|
148 |
+
html: marked.parse(tableauContent),
|
149 |
+
width: '80%',
|
150 |
+
customClass: {
|
151 |
+
htmlContainer: 'markdown-content'
|
152 |
+
}
|
153 |
+
});
|
154 |
+
});
|
155 |
+
|
156 |
document.getElementById('uploadForm').addEventListener('submit', async (e) => {
|
157 |
e.preventDefault();
|
158 |
|
159 |
const loading = document.getElementById('loading');
|
160 |
+
const results = document.getElementById('results');
|
161 |
const dissertationResult = document.getElementById('dissertationResult');
|
162 |
|
163 |
const formData = new FormData();
|
164 |
formData.append('image', document.getElementById('imageInput').files[0]);
|
165 |
|
166 |
+
loading.classList.remove('hidden');
|
167 |
+
results.classList.add('hidden');
|
|
|
168 |
|
169 |
try {
|
170 |
const response = await fetch('/analyze', {
|
|
|
175 |
const data = await response.json();
|
176 |
|
177 |
if (response.ok) {
|
178 |
+
// Stocker le tableau pour l'affichage ultérieur
|
179 |
+
tableauContent = data.tableau;
|
180 |
+
|
181 |
+
// Afficher la dissertation
|
182 |
dissertationResult.innerHTML = marked.parse(data.dissertation);
|
183 |
+
|
184 |
+
// Afficher la section des résultats avec animation
|
185 |
+
results.classList.remove('hidden');
|
186 |
+
results.classList.add('fade-in');
|
187 |
} else {
|
188 |
+
Swal.fire({
|
189 |
+
icon: 'error',
|
190 |
+
title: 'Erreur',
|
191 |
+
text: data.error
|
192 |
+
});
|
193 |
}
|
194 |
} catch (error) {
|
195 |
+
Swal.fire({
|
196 |
+
icon: 'error',
|
197 |
+
title: 'Erreur',
|
198 |
+
text: 'Une erreur est survenue lors de l\'analyse'
|
199 |
+
});
|
200 |
} finally {
|
201 |
+
loading.classList.add('hidden');
|
202 |
}
|
203 |
});
|
204 |
</script>
|