AI_Portal / static /test.html
Moncey10's picture
Update static/test.html
8035a7f verified
Raw
History Blame Contribute Delete
2.13 kB
<!DOCTYPE html>
<html>
<head>
<title>Firebase Test</title>
<style>
body { font-family: sans-serif; padding: 2rem; background: #f5f5f5; }
.log { background: #1a1a1a; color: #fff; padding: 1rem; border-radius: 8px; margin-top: 1rem; font-size: 0.9rem; line-height: 2; }
.ok { color: #4ade80; }
.err { color: #f87171; }
</style>
</head>
<body>
<h2>Firebase Connection Test</h2>
<p>Check results below:</p>
<div class="log" id="log">Running...</div>
<script type="module">
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.12.0/firebase-app.js";
import { getFirestore, doc, setDoc, getDoc } from "https://www.gstatic.com/firebasejs/10.12.0/firebase-firestore.js";
const log = (msg, ok = true) => {
const div = document.getElementById('log');
div.innerHTML += `<div class="${ok ? 'ok' : 'err'}">${msg}</div>`;
};
document.getElementById('log').innerHTML = '';
const firebaseConfig = {
apiKey: "AIzaSyAvcYiLnzwJjtYY9jO6Ax_vcfs8Kl2WsqM",
authDomain: "internal-ai-support-portal.firebaseapp.com",
projectId: "internal-ai-support-portal",
storageBucket: "internal-ai-support-portal.firebasestorage.app",
messagingSenderId: "568502815360",
appId: "1:568502815360:web:2f02eae536cd883a037465"
};
try {
const app = initializeApp(firebaseConfig);
log("βœ… Firebase app initialized");
const db = getFirestore(app);
log("βœ… Firestore connected");
// Write test
await setDoc(doc(db, "test", "ping"), {
message: "Firebase works!",
time: new Date().toISOString()
});
log("βœ… Write success β€” document written to Firestore");
// Read test
const snap = await getDoc(doc(db, "test", "ping"));
if (snap.exists()) {
log("βœ… Read success β€” data: " + JSON.stringify(snap.data()));
} else {
log("❌ Read failed β€” document not found", false);
}
} catch (e) {
log("❌ Error: " + e.message, false);
}
</script>
</body>
</html>