vineelagampa commited on
Commit
5210a5e
·
verified ·
1 Parent(s): 6267b9c

Upload past_data.html

Browse files
Files changed (1) hide show
  1. web/past_data.html +119 -0
web/past_data.html ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ </head>
8
+ <body class="bg-[#F7F8F9] min-h-screen">
9
+ <nav class="bg-white border border-gray-200 px-6 py-4 mb-8">
10
+ <div class="container mx-auto flex justify-between items-center">
11
+ <a href="index.html" class="text-2xl font-bold text-[#6B9080]">CTRL + ALT + HEAL</a>
12
+ <ul class="flex space-x-6 text-sm font-medium text-gray-700">
13
+ <li><a href="index.html" class="hover:text-[#6B9080]">Home</a></li>
14
+ <li><a href="analyzer.html" class="hover:text-[#6B9080]">Analyzer</a></li>
15
+ <li><a href="past_data.html" class="hover:text-[#6B9080]">Past Reports</a></li>
16
+ <li><a href="profile.html" class="hover:text-[#6B9080]">Profile</a></li>
17
+ <li id="authNavItem"><a href="login.html" class="hover:text-[#6B9080]">Login</a></li>
18
+ </ul>
19
+ </div>
20
+ </nav>
21
+
22
+ <main class="max-w-4xl mx-auto px-4">
23
+ <h1 class="text-2xl font-bold text-green-700 mb-4">Your Past Analyzes</h1>
24
+ <p id="auth-status" class="text-sm text-gray-500 mb-6">Checking sign-in status…</p>
25
+
26
+ <div id="recs-container" class="space-y-4">
27
+ <p class="text-sm text-gray-500">Sign in to view your saved analyzes.</p>
28
+ </div>
29
+ </main>
30
+
31
+
32
+
33
+
34
+ <script type="module">
35
+ import { getFirestore, collection, query, orderBy, getDocs } from 'https://www.gstatic.com/firebasejs/9.22.0/firebase-firestore.js';
36
+ import { initializeApp } from 'https://www.gstatic.com/firebasejs/9.22.0/firebase-app.js';
37
+ import { getAuth, onAuthStateChanged, signOut } from 'https://www.gstatic.com/firebasejs/9.22.0/firebase-auth.js';
38
+
39
+ const firebaseConfig = {
40
+ apiKey: "AIzaSyAPhM_Ee7cLzyKHs5zyFy8g5ZOk9-pubRI",
41
+ authDomain: "login-tutorial-7a9e1.firebaseapp.com",
42
+ projectId: "login-tutorial-7a9e1",
43
+ storageBucket: "login-tutorial-7a9e1.firebasestorage.app",
44
+ messagingSenderId: "491093197824",
45
+ appId: "1:491093197824:web:9f866..."
46
+ };
47
+
48
+ const app = initializeApp(firebaseConfig);
49
+ const auth = getAuth(app);
50
+ const db = getFirestore(app);
51
+
52
+ // Update navigation based on auth state
53
+ onAuthStateChanged(auth, (user) => {
54
+ const authNavItem = document.getElementById('authNavItem');
55
+ if (user) {
56
+ // User is logged in - show logout
57
+ authNavItem.innerHTML = '<button onclick="logout()" class="hover:text-[#6B9080] text-red-600">Logout</button>';
58
+ } else {
59
+ // User is logged out - show login
60
+ authNavItem.innerHTML = '<a href="login.html" class="hover:text-[#6B9080]">Login</a>';
61
+ }
62
+ });
63
+
64
+ // Logout function
65
+ window.logout = async () => {
66
+ try {
67
+ await signOut(auth);
68
+ localStorage.clear();
69
+ window.location.href = 'login.html';
70
+ } catch (error) {
71
+ console.error("Error signing out:", error);
72
+ }
73
+ };
74
+
75
+ const statusEl = document.getElementById("auth-status");
76
+ const recsEl = document.getElementById("recs-container");
77
+
78
+
79
+ function renderAnalysis(item) {
80
+ const d = item.createdAt && item.createdAt.toDate ? item.createdAt.toDate().toLocaleString() : "";
81
+ return `
82
+ <div class="bg-white border border-gray-200 rounded-lg p-4 shadow">
83
+ <div class="flex justify-between mb-2">
84
+ <div class="font-semibold text-green-700">Report: ${item.reportDate || "N/A"}</div>
85
+ <div class="text-xs text-gray-500">${d}</div>
86
+ </div>
87
+ <pre class="whitespace-pre-wrap text-sm text-gray-700 mb-2">${item.ocr_text || ""}</pre>
88
+ ${(Array.isArray(item.resolutions) ? item.resolutions : []).map((r,i) => `
89
+ <div class="border-t border-gray-200 pt-2 mt-2">
90
+ <div class="font-medium">Finding ${i+1}: ${r.findings || ""}</div>
91
+ <div class="text-sm text-gray-600">Severity: ${r.severity || ""}</div>
92
+ <div class="text-sm text-gray-600">Recommendations: ${(r.recommendations || []).join(", ")}</div>
93
+ </div>
94
+ `).join("")}
95
+ </div>
96
+ `;
97
+ }
98
+
99
+ onAuthStateChanged(auth, async (user) => {
100
+ if (user) {
101
+ statusEl.textContent = `Signed in as ${user.email || user.uid}`;
102
+ const q = query(
103
+ collection(db, "users", user.uid, "analyses"),
104
+ orderBy("createdAt", "desc")
105
+ );
106
+ const snap = await getDocs(q);
107
+ if (snap.empty) {
108
+ recsEl.innerHTML = '<p class="text-sm text-gray-500">No saved analyses yet.</p>';
109
+ return;
110
+ }
111
+ recsEl.innerHTML = snap.docs.map(doc => renderAnalysis(doc.data())).join("");
112
+ } else {
113
+ statusEl.textContent = "Not signed in.";
114
+ recsEl.innerHTML = '<p class="text-sm text-gray-500">Please sign in to see your analyses.</p>';
115
+ }
116
+ });
117
+ </script>
118
+ </body>
119
+ </html>