Spaces:
Sleeping
Sleeping
Commit
·
cdea9a5
1
Parent(s):
42321ac
updated home and past data for styling
Browse files- web/index.html +25 -90
- web/past_data.html +290 -130
web/index.html
CHANGED
|
@@ -5,81 +5,7 @@
|
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
<title>CTRL + ALT + HEAL</title>
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
-
<link
|
| 9 |
-
href="https://fonts.googleapis.com/css2?family=Rubik:wght@400;700&display=swap"
|
| 10 |
-
rel="stylesheet"
|
| 11 |
-
/>
|
| 12 |
-
<style>
|
| 13 |
-
:root {
|
| 14 |
-
--tropical-indigo: rgb(120, 187, 242);
|
| 15 |
-
--wisteria: rgb(197, 217, 251);
|
| 16 |
-
--latte-cream: #ffffff;
|
| 17 |
-
}
|
| 18 |
-
|
| 19 |
-
body {
|
| 20 |
-
font-family: "Rubik", sans-serif;
|
| 21 |
-
background-color: var(--latte-cream);
|
| 22 |
-
color: #333;
|
| 23 |
-
}
|
| 24 |
-
|
| 25 |
-
.fade-in {
|
| 26 |
-
opacity: 0;
|
| 27 |
-
transform: translateY(30px);
|
| 28 |
-
transition: all 0.8s ease-out;
|
| 29 |
-
}
|
| 30 |
-
.fade-in.show {
|
| 31 |
-
opacity: 1;
|
| 32 |
-
transform: translateY(0);
|
| 33 |
-
}
|
| 34 |
-
|
| 35 |
-
.glass-card {
|
| 36 |
-
background: rgba(162, 160, 160, 0.075);
|
| 37 |
-
backdrop-filter: blur(12px);
|
| 38 |
-
border-radius: 1rem;
|
| 39 |
-
border: 1px solid rgba(255, 255, 255, 0.3);
|
| 40 |
-
padding: 2rem;
|
| 41 |
-
text-align: center;
|
| 42 |
-
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
| 43 |
-
}
|
| 44 |
-
.glass-card:hover {
|
| 45 |
-
transform: translateY(-5px);
|
| 46 |
-
box-shadow: 0 15px 25px rgba(0, 0, 0, 0.2);
|
| 47 |
-
}
|
| 48 |
-
|
| 49 |
-
.nav-link {
|
| 50 |
-
position: relative;
|
| 51 |
-
padding-bottom: 4px;
|
| 52 |
-
transition: color 0.3s;
|
| 53 |
-
}
|
| 54 |
-
.nav-link::after {
|
| 55 |
-
content: "";
|
| 56 |
-
position: absolute;
|
| 57 |
-
width: 0%;
|
| 58 |
-
height: 2px;
|
| 59 |
-
bottom: 0;
|
| 60 |
-
left: 0;
|
| 61 |
-
background-color: var(--tropical-indigo);
|
| 62 |
-
transition: width 0.3s ease;
|
| 63 |
-
}
|
| 64 |
-
.nav-link:hover::after {
|
| 65 |
-
width: 100%;
|
| 66 |
-
}
|
| 67 |
-
|
| 68 |
-
.parallax {
|
| 69 |
-
background-attachment: fixed;
|
| 70 |
-
background-size: cover;
|
| 71 |
-
background-position: center;
|
| 72 |
-
position: relative;
|
| 73 |
-
}
|
| 74 |
-
|
| 75 |
-
/* Typing effect styles */
|
| 76 |
-
#typed-heading,
|
| 77 |
-
#typed-paragraph {
|
| 78 |
-
overflow: hidden;
|
| 79 |
-
white-space: nowrap;
|
| 80 |
-
border-right: 2px solid var(--tropical-indigo);
|
| 81 |
-
}
|
| 82 |
-
</style>
|
| 83 |
</head>
|
| 84 |
<body>
|
| 85 |
<!-- NAVBAR -->
|
|
@@ -101,9 +27,9 @@
|
|
| 101 |
<ul class="hidden md:flex space-x-6 font-medium text-gray-800">
|
| 102 |
<li><a href="index.html" class="nav-link">Home</a></li>
|
| 103 |
<li><a href="analyzer.html" class="nav-link">Analyzer</a></li>
|
| 104 |
-
<li
|
| 105 |
-
|
| 106 |
-
|
| 107 |
</ul>
|
| 108 |
|
| 109 |
<!-- Hamburger Menu -->
|
|
@@ -169,9 +95,9 @@
|
|
| 169 |
|
| 170 |
<!-- HERO SECTION -->
|
| 171 |
<section
|
| 172 |
-
class="relative min-h-[600px] flex items-center justify-center"
|
| 173 |
style="
|
| 174 |
-
background-image: url('https://
|
| 175 |
background-size: cover;
|
| 176 |
background-position: center;
|
| 177 |
"
|
|
@@ -284,9 +210,18 @@
|
|
| 284 |
</footer>
|
| 285 |
|
| 286 |
<script type="module">
|
| 287 |
-
import { initializeApp } from
|
| 288 |
-
import {
|
| 289 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
|
| 291 |
const firebaseConfig = {
|
| 292 |
apiKey: "AIzaSyAPhM_Ee7cLzyKHs5zyFy8g5ZOk9-pubRI",
|
|
@@ -294,7 +229,7 @@
|
|
| 294 |
projectId: "login-tutorial-7a9e1",
|
| 295 |
storageBucket: "login-tutorial-7a9e1.firebasestorage.app",
|
| 296 |
messagingSenderId: "491093197824",
|
| 297 |
-
appId: "1:491093197824:web:9f866..."
|
| 298 |
};
|
| 299 |
|
| 300 |
const app = initializeApp(firebaseConfig);
|
|
@@ -304,28 +239,28 @@
|
|
| 304 |
let currentUser = null;
|
| 305 |
|
| 306 |
onAuthStateChanged(auth, (user) => {
|
| 307 |
-
const authNavItem = document.getElementById(
|
| 308 |
if (authNavItem) {
|
| 309 |
if (user) {
|
| 310 |
-
authNavItem.innerHTML =
|
|
|
|
| 311 |
} else {
|
| 312 |
-
authNavItem.innerHTML =
|
|
|
|
| 313 |
}
|
| 314 |
}
|
| 315 |
});
|
| 316 |
|
| 317 |
-
|
| 318 |
window.logout = async () => {
|
| 319 |
try {
|
| 320 |
await signOut(auth);
|
| 321 |
localStorage.clear();
|
| 322 |
-
window.location.href =
|
| 323 |
} catch (error) {
|
| 324 |
console.error("Error signing out:", error);
|
| 325 |
}
|
| 326 |
};
|
| 327 |
|
| 328 |
-
|
| 329 |
// Fade-in on scroll
|
| 330 |
const fadeObserver = new IntersectionObserver(
|
| 331 |
(entries) => {
|
|
|
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
<title>CTRL + ALT + HEAL</title>
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="style.css" />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
</head>
|
| 10 |
<body>
|
| 11 |
<!-- NAVBAR -->
|
|
|
|
| 27 |
<ul class="hidden md:flex space-x-6 font-medium text-gray-800">
|
| 28 |
<li><a href="index.html" class="nav-link">Home</a></li>
|
| 29 |
<li><a href="analyzer.html" class="nav-link">Analyzer</a></li>
|
| 30 |
+
<li id="authNavItem">
|
| 31 |
+
<a href="login.html" class="nav-link">Login</a>
|
| 32 |
+
</li>
|
| 33 |
</ul>
|
| 34 |
|
| 35 |
<!-- Hamburger Menu -->
|
|
|
|
| 95 |
|
| 96 |
<!-- HERO SECTION -->
|
| 97 |
<section
|
| 98 |
+
class="relative min-h-[600px] flex items-center justify-center mt-20"
|
| 99 |
style="
|
| 100 |
+
background-image: url('https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTPzQvOMCaRXTQhCvcYwmi_vdYxJtMpMW7KBA&s');
|
| 101 |
background-size: cover;
|
| 102 |
background-position: center;
|
| 103 |
"
|
|
|
|
| 210 |
</footer>
|
| 211 |
|
| 212 |
<script type="module">
|
| 213 |
+
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.22.0/firebase-app.js";
|
| 214 |
+
import {
|
| 215 |
+
getAuth,
|
| 216 |
+
onAuthStateChanged,
|
| 217 |
+
signOut,
|
| 218 |
+
} from "https://www.gstatic.com/firebasejs/9.22.0/firebase-auth.js";
|
| 219 |
+
import {
|
| 220 |
+
getFirestore,
|
| 221 |
+
doc,
|
| 222 |
+
getDoc,
|
| 223 |
+
updateDoc,
|
| 224 |
+
} from "https://www.gstatic.com/firebasejs/9.22.0/firebase-firestore.js";
|
| 225 |
|
| 226 |
const firebaseConfig = {
|
| 227 |
apiKey: "AIzaSyAPhM_Ee7cLzyKHs5zyFy8g5ZOk9-pubRI",
|
|
|
|
| 229 |
projectId: "login-tutorial-7a9e1",
|
| 230 |
storageBucket: "login-tutorial-7a9e1.firebasestorage.app",
|
| 231 |
messagingSenderId: "491093197824",
|
| 232 |
+
appId: "1:491093197824:web:9f866...",
|
| 233 |
};
|
| 234 |
|
| 235 |
const app = initializeApp(firebaseConfig);
|
|
|
|
| 239 |
let currentUser = null;
|
| 240 |
|
| 241 |
onAuthStateChanged(auth, (user) => {
|
| 242 |
+
const authNavItem = document.getElementById("authNavItem");
|
| 243 |
if (authNavItem) {
|
| 244 |
if (user) {
|
| 245 |
+
authNavItem.innerHTML =
|
| 246 |
+
'<button onclick="logout()" class="hover:text-[#6B9080] text-red-600">Logout</button>';
|
| 247 |
} else {
|
| 248 |
+
authNavItem.innerHTML =
|
| 249 |
+
'<a href="login.html" class="hover:text-[#6B9080]">Login</a>';
|
| 250 |
}
|
| 251 |
}
|
| 252 |
});
|
| 253 |
|
|
|
|
| 254 |
window.logout = async () => {
|
| 255 |
try {
|
| 256 |
await signOut(auth);
|
| 257 |
localStorage.clear();
|
| 258 |
+
window.location.href = "login.html";
|
| 259 |
} catch (error) {
|
| 260 |
console.error("Error signing out:", error);
|
| 261 |
}
|
| 262 |
};
|
| 263 |
|
|
|
|
| 264 |
// Fade-in on scroll
|
| 265 |
const fadeObserver = new IntersectionObserver(
|
| 266 |
(entries) => {
|
web/past_data.html
CHANGED
|
@@ -1,145 +1,305 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
<
|
| 11 |
-
<
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
<ul class="hidden md:flex space-x-6 font-medium text-gray-800">
|
| 14 |
<li><a href="index.html" class="nav-link">Home</a></li>
|
|
|
|
| 15 |
<li><a href="analyzer.html" class="nav-link">Analyzer</a></li>
|
| 16 |
<li><a href="past_data.html" class="nav-link">Past Reports</a></li>
|
| 17 |
-
<li
|
| 18 |
-
|
|
|
|
| 19 |
</ul>
|
| 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 |
} else {
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
}
|
| 90 |
-
} catch (error) {
|
| 91 |
-
console.warn('Error syncing report to backend (continuing anyway):', error);
|
| 92 |
}
|
| 93 |
-
}
|
| 94 |
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
| 98 |
<div class="bg-white border border-gray-200 rounded-lg p-4 shadow">
|
| 99 |
<div class="flex justify-between mb-2">
|
| 100 |
-
<div class="font-semibold text-green-700">Report: ${
|
|
|
|
|
|
|
| 101 |
<div class="text-xs text-gray-500">${d}</div>
|
| 102 |
</div>
|
| 103 |
-
<pre class="whitespace-pre-wrap text-sm text-gray-700 mb-2">${
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
<div class="border-t border-gray-200 pt-2 mt-2">
|
| 106 |
-
<div class="font-medium">Finding ${i+1}: ${
|
| 107 |
-
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
</div>
|
| 110 |
-
`
|
|
|
|
|
|
|
| 111 |
</div>
|
| 112 |
`;
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
}
|
| 131 |
-
const data = await response.json();
|
| 132 |
-
console.log('Report successfully sent to backend:', data);
|
| 133 |
-
recsEl.innerHTML = data.map(doc => renderAnalysis(doc)).join("");
|
| 134 |
-
} catch (error) {
|
| 135 |
-
console.error('Error sending report to backend:', error);
|
| 136 |
-
recsEl.innerHTML = '<p class="text-sm text-gray-500">No saved analyses yet.</p>';
|
| 137 |
}
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
/* try {
|
| 143 |
const q = query(
|
| 144 |
collection(db, "users", user.uid, "analyses"),
|
| 145 |
orderBy("createdAt", "desc")
|
|
@@ -175,12 +335,12 @@
|
|
| 175 |
console.error('Error fetching analyses:', error);
|
| 176 |
recsEl.innerHTML = '<p class="text-sm text-red-500">Error loading analyses.</p>';
|
| 177 |
}*/
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
</body>
|
| 186 |
-
</html>
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8" />
|
| 5 |
+
<title>Past Analyzes - CTRL + ALT + HEAL</title>
|
| 6 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 7 |
+
<script src="script.js"></script>
|
| 8 |
+
<link rel="stylesheet" href="style.css" />
|
| 9 |
+
</head>
|
| 10 |
+
<body class="bg-[#F7F8F9] min-h-screen">
|
| 11 |
+
<nav
|
| 12 |
+
class="fixed top-0 left-0 w-full z-50 backdrop-blur-md bg-white/20 border-b border-white/30 shadow-md"
|
| 13 |
+
>
|
| 14 |
+
<div class="flex justify-between items-center w-full px-6 py-4">
|
| 15 |
+
<!-- Logo -->
|
| 16 |
+
<a
|
| 17 |
+
href="index.html"
|
| 18 |
+
class="text-2xl font-bold text-black hover:text-[var(--tropical-indigo)] transition"
|
| 19 |
+
>
|
| 20 |
+
CTRL + ALT + HEAL
|
| 21 |
+
</a>
|
| 22 |
+
|
| 23 |
<ul class="hidden md:flex space-x-6 font-medium text-gray-800">
|
| 24 |
<li><a href="index.html" class="nav-link">Home</a></li>
|
| 25 |
+
<li><a href="profile.html" class="nav-link">Profile</a></li>
|
| 26 |
<li><a href="analyzer.html" class="nav-link">Analyzer</a></li>
|
| 27 |
<li><a href="past_data.html" class="nav-link">Past Reports</a></li>
|
| 28 |
+
<li id="authNavItem">
|
| 29 |
+
<a href="login.html" class="nav-link">Login</a>
|
| 30 |
+
</li>
|
| 31 |
</ul>
|
| 32 |
+
|
| 33 |
+
<!-- Hamburger Menu -->
|
| 34 |
+
<button
|
| 35 |
+
id="hamburger"
|
| 36 |
+
class="md:hidden text-[var(--latte-cream)] text-2xl"
|
| 37 |
+
>
|
| 38 |
+
☰
|
| 39 |
+
</button>
|
| 40 |
+
</div>
|
| 41 |
+
|
| 42 |
+
<!-- Mobile Menu -->
|
| 43 |
+
<ul
|
| 44 |
+
id="mobile-menu"
|
| 45 |
+
class="hidden flex-col space-y-4 bg-white/30 backdrop-blur-lg border border-white/20 rounded-xl shadow-lg mt-2 p-4 mx-6 md:hidden"
|
| 46 |
+
>
|
| 47 |
+
<li>
|
| 48 |
+
<a
|
| 49 |
+
href="index.html"
|
| 50 |
+
class="block text-gray-800 hover:text-[var(--tropical-indigo)]"
|
| 51 |
+
>Home</a
|
| 52 |
+
>
|
| 53 |
+
</li>
|
| 54 |
+
<li>
|
| 55 |
+
<a
|
| 56 |
+
href="analyzer.html"
|
| 57 |
+
class="block text-gray-800 hover:text-[var(--tropical-indigo)]"
|
| 58 |
+
>Analyzer</a
|
| 59 |
+
>
|
| 60 |
+
</li>
|
| 61 |
+
<li>
|
| 62 |
+
<a
|
| 63 |
+
href="past_data.html"
|
| 64 |
+
class="block text-gray-800 hover:text-[var(--tropical-indigo)]"
|
| 65 |
+
>Past Reports</a
|
| 66 |
+
>
|
| 67 |
+
</li>
|
| 68 |
+
<li>
|
| 69 |
+
<a
|
| 70 |
+
href="profile.html"
|
| 71 |
+
class="block text-gray-800 hover:text-[var(--tropical-indigo)]"
|
| 72 |
+
>Profile</a
|
| 73 |
+
>
|
| 74 |
+
</li>
|
| 75 |
+
<li>
|
| 76 |
+
<a
|
| 77 |
+
href="login.html"
|
| 78 |
+
class="block text-gray-800 hover:text-[var(--tropical-indigo)]"
|
| 79 |
+
>Login</a
|
| 80 |
+
>
|
| 81 |
+
</li>
|
| 82 |
+
</ul>
|
| 83 |
+
</nav>
|
| 84 |
+
|
| 85 |
+
<main class="max-w-4xl mx-auto px-4 pt-24 text-gray-800">
|
| 86 |
+
<div class="bg-white border border-gray-200 rounded-lg p-6 shadow mb-6">
|
| 87 |
+
<h2 class="text-xl font-semibold mb-4">
|
| 88 |
+
Your Past Analyzes
|
| 89 |
+
</h1>
|
| 90 |
+
<p id="auth-status" class="text-sm text-gray-500 mb-6">
|
| 91 |
+
Checking sign-in status…
|
| 92 |
+
</p>
|
| 93 |
+
|
| 94 |
+
<div id="recs-container" class="space-y-4">
|
| 95 |
+
<p class="text-sm text-gray-500">
|
| 96 |
+
Sign in to view your saved analyzes.
|
| 97 |
+
</p>
|
| 98 |
+
</div>
|
| 99 |
+
</div>
|
| 100 |
+
</main>
|
| 101 |
+
|
| 102 |
+
<script type="module">
|
| 103 |
+
import {
|
| 104 |
+
getFirestore,
|
| 105 |
+
collection,
|
| 106 |
+
query,
|
| 107 |
+
orderBy,
|
| 108 |
+
getDocs,
|
| 109 |
+
} from "https://www.gstatic.com/firebasejs/9.22.0/firebase-firestore.js";
|
| 110 |
+
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.22.0/firebase-app.js";
|
| 111 |
+
import {
|
| 112 |
+
getAuth,
|
| 113 |
+
onAuthStateChanged,
|
| 114 |
+
signOut,
|
| 115 |
+
} from "https://www.gstatic.com/firebasejs/9.22.0/firebase-auth.js";
|
| 116 |
+
|
| 117 |
+
const firebaseConfig = {
|
| 118 |
+
apiKey: "AIzaSyAPhM_Ee7cLzyKHs5zyFy8g5ZOk9-pubRI",
|
| 119 |
+
authDomain: "login-tutorial-7a9e1.firebaseapp.com",
|
| 120 |
+
projectId: "login-tutorial-7a9e1",
|
| 121 |
+
storageBucket: "login-tutorial-7a9e1.firebasestorage.app",
|
| 122 |
+
messagingSenderId: "491093197824",
|
| 123 |
+
appId: "1:491093197824:web:9f866...",
|
| 124 |
+
};
|
| 125 |
+
|
| 126 |
+
const app = initializeApp(firebaseConfig);
|
| 127 |
+
const auth = getAuth(app);
|
| 128 |
+
const db = getFirestore(app);
|
| 129 |
+
|
| 130 |
+
onAuthStateChanged(auth, async (user) => {
|
| 131 |
+
const authNavItem = document.getElementById("authNavItem");
|
| 132 |
+
const homeNavDesktop = document.querySelector(
|
| 133 |
+
'ul.md\\:flex li a[href="index.html"]'
|
| 134 |
+
)?.parentElement; // Desktop <li>
|
| 135 |
+
const homeNavMobile = document.querySelector(
|
| 136 |
+
'#mobile-menu a[href="index.html"]'
|
| 137 |
+
)?.parentElement; // Mobile <li>
|
| 138 |
+
|
| 139 |
+
if (user) {
|
| 140 |
+
// Update login/logout button
|
| 141 |
+
if (authNavItem) {
|
| 142 |
+
authNavItem.innerHTML =
|
| 143 |
+
'<button onclick="logout()" class="hover:text-[#6B9080] text-red-600">Logout</button>';
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
// Hide Home button
|
| 147 |
+
if (homeNavDesktop) homeNavDesktop.style.display = "none";
|
| 148 |
+
if (homeNavMobile) homeNavMobile.style.display = "none";
|
| 149 |
+
|
| 150 |
+
// Update auth status
|
| 151 |
+
statusEl.textContent = `Signed in as ${user.email || user.uid}`;
|
| 152 |
+
|
| 153 |
+
// Fetch past reports
|
| 154 |
+
async function getPastReports() {
|
| 155 |
+
try {
|
| 156 |
+
const url = api("reports/", { user_id: user.email });
|
| 157 |
+
const response = await fetch(url, {
|
| 158 |
+
method: "GET",
|
| 159 |
+
headers: { "Content-Type": "application/json" },
|
| 160 |
+
});
|
| 161 |
+
if (!response.ok)
|
| 162 |
+
throw new Error(`HTTP error! status: ${response.status}`);
|
| 163 |
+
const data = await response.json();
|
| 164 |
+
recsEl.innerHTML = data
|
| 165 |
+
.map((doc) => renderAnalysis(doc))
|
| 166 |
+
.join("");
|
| 167 |
+
} catch (error) {
|
| 168 |
+
console.error("Error sending report to backend:", error);
|
| 169 |
+
recsEl.innerHTML =
|
| 170 |
+
'<p class="text-sm text-gray-500">No saved analyses yet.</p>';
|
| 171 |
+
}
|
| 172 |
+
}
|
| 173 |
+
getPastReports();
|
| 174 |
} else {
|
| 175 |
+
// Update login/logout button
|
| 176 |
+
if (authNavItem) {
|
| 177 |
+
authNavItem.innerHTML =
|
| 178 |
+
'<a href="login.html" class="hover:text-[#6B9080]">Login</a>';
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
// Show Home button
|
| 182 |
+
if (homeNavDesktop) homeNavDesktop.style.display = "";
|
| 183 |
+
if (homeNavMobile) homeNavMobile.style.display = "";
|
| 184 |
+
|
| 185 |
+
// Update auth status
|
| 186 |
+
statusEl.textContent = "Not signed in.";
|
| 187 |
+
recsEl.innerHTML =
|
| 188 |
+
'<p class="text-sm text-gray-500">Please sign in to see your analyses.</p>';
|
| 189 |
+
}
|
| 190 |
+
});
|
| 191 |
+
|
| 192 |
+
window.logout = async () => {
|
| 193 |
+
try {
|
| 194 |
+
await signOut(auth);
|
| 195 |
+
localStorage.clear();
|
| 196 |
+
window.location.href = "login.html";
|
| 197 |
+
} catch (error) {
|
| 198 |
+
console.error("Error signing out:", error);
|
| 199 |
+
}
|
| 200 |
+
};
|
| 201 |
+
|
| 202 |
+
const statusEl = document.getElementById("auth-status");
|
| 203 |
+
const recsEl = document.getElementById("recs-container");
|
| 204 |
+
async function sendReportToBackend(report, userId) {
|
| 205 |
+
try {
|
| 206 |
+
const response = await fetch("http://localhost:9000/save_report/", {
|
| 207 |
+
method: "POST",
|
| 208 |
+
headers: {
|
| 209 |
+
"Content-Type": "application/json",
|
| 210 |
+
},
|
| 211 |
+
body: JSON.stringify({
|
| 212 |
+
...report,
|
| 213 |
+
user_id: userId,
|
| 214 |
+
sync_timestamp: new Date().toISOString(),
|
| 215 |
+
}),
|
| 216 |
+
});
|
| 217 |
+
|
| 218 |
+
if (!response.ok) {
|
| 219 |
+
console.warn(
|
| 220 |
+
`Failed to sync report to backend: ${response.status}`
|
| 221 |
+
);
|
| 222 |
+
} else {
|
| 223 |
+
console.log("Report successfully synced to backend");
|
| 224 |
+
}
|
| 225 |
+
} catch (error) {
|
| 226 |
+
console.warn(
|
| 227 |
+
"Error syncing report to backend (continuing anyway):",
|
| 228 |
+
error
|
| 229 |
+
);
|
| 230 |
}
|
|
|
|
|
|
|
| 231 |
}
|
|
|
|
| 232 |
|
| 233 |
+
function renderAnalysis(item) {
|
| 234 |
+
const d =
|
| 235 |
+
item.createdAt && item.createdAt.toDate
|
| 236 |
+
? item.createdAt.toDate().toLocaleString()
|
| 237 |
+
: "";
|
| 238 |
+
return `
|
| 239 |
<div class="bg-white border border-gray-200 rounded-lg p-4 shadow">
|
| 240 |
<div class="flex justify-between mb-2">
|
| 241 |
+
<div class="font-semibold text-green-700">Report: ${
|
| 242 |
+
item.reportDate || "N/A"
|
| 243 |
+
}</div>
|
| 244 |
<div class="text-xs text-gray-500">${d}</div>
|
| 245 |
</div>
|
| 246 |
+
<pre class="whitespace-pre-wrap text-sm text-gray-700 mb-2">${
|
| 247 |
+
item.ocr_text || ""
|
| 248 |
+
}</pre>
|
| 249 |
+
${(Array.isArray(item.Detected_Anomolies)
|
| 250 |
+
? item.Detected_Anomolies
|
| 251 |
+
: []
|
| 252 |
+
)
|
| 253 |
+
.map(
|
| 254 |
+
(r, i) => `
|
| 255 |
<div class="border-t border-gray-200 pt-2 mt-2">
|
| 256 |
+
<div class="font-medium">Finding ${i + 1}: ${
|
| 257 |
+
r.findings || ""
|
| 258 |
+
}</div>
|
| 259 |
+
<div class="text-sm text-gray-600">Severity: ${
|
| 260 |
+
r.severity || ""
|
| 261 |
+
}</div>
|
| 262 |
+
<div class="text-sm text-gray-600">Recommendations: ${(
|
| 263 |
+
r.recommendations || []
|
| 264 |
+
).join(", ")}</div>
|
| 265 |
</div>
|
| 266 |
+
`
|
| 267 |
+
)
|
| 268 |
+
.join("")}
|
| 269 |
</div>
|
| 270 |
`;
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
onAuthStateChanged(auth, async (user) => {
|
| 274 |
+
if (user) {
|
| 275 |
+
statusEl.textContent = `Signed in as ${user.email || user.uid}`;
|
| 276 |
+
|
| 277 |
+
async function getPastReports() {
|
| 278 |
+
try {
|
| 279 |
+
const url = api("reports/", { user_id: user.email });
|
| 280 |
+
const response = await fetch(url, {
|
| 281 |
+
method: "GET",
|
| 282 |
+
headers: {
|
| 283 |
+
"Content-Type": "application/json",
|
| 284 |
+
},
|
| 285 |
+
});
|
| 286 |
+
if (!response.ok) {
|
| 287 |
+
throw new Error(`HTTP error! status: ${response.status}`);
|
| 288 |
+
}
|
| 289 |
+
const data = await response.json();
|
| 290 |
+
console.log("Report successfully sent to backend:", data);
|
| 291 |
+
recsEl.innerHTML = data
|
| 292 |
+
.map((doc) => renderAnalysis(doc))
|
| 293 |
+
.join("");
|
| 294 |
+
} catch (error) {
|
| 295 |
+
console.error("Error sending report to backend:", error);
|
| 296 |
+
recsEl.innerHTML =
|
| 297 |
+
'<p class="text-sm text-gray-500">No saved analyses yet.</p>';
|
| 298 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
}
|
| 300 |
+
getPastReports();
|
| 301 |
+
|
| 302 |
+
/* try {
|
|
|
|
|
|
|
| 303 |
const q = query(
|
| 304 |
collection(db, "users", user.uid, "analyses"),
|
| 305 |
orderBy("createdAt", "desc")
|
|
|
|
| 335 |
console.error('Error fetching analyses:', error);
|
| 336 |
recsEl.innerHTML = '<p class="text-sm text-red-500">Error loading analyses.</p>';
|
| 337 |
}*/
|
| 338 |
+
} else {
|
| 339 |
+
statusEl.textContent = "Not signed in.";
|
| 340 |
+
recsEl.innerHTML =
|
| 341 |
+
'<p class="text-sm text-gray-500">Please sign in to see your analyses.</p>';
|
| 342 |
+
}
|
| 343 |
+
});
|
| 344 |
+
</script>
|
| 345 |
+
</body>
|
| 346 |
+
</html>
|