Auto-sync: 20260323_020000

This commit is contained in:
Paolo 2026-03-23 02:00:01 +01:00
parent 6372935e1c
commit 4b9d4930cd
4 changed files with 73 additions and 42 deletions

BIN
.DS_Store vendored

Binary file not shown.

View file

@ -1,3 +1,3 @@
index.html,1773586765860,5737ce966fa8786becaf7f36a32992cf44102fb3a217c226c30576c993b33e63
404.html,1773344753356,05cbc6f94d7a69ce2e29646eab13be2c884e61ba93e3094df5028866876d18b3
report.html,1774223974711,2848745a7b4437e80aabba9bd776c1c7f90b1be21e67ddaf062c22a21ac99554
report.html,1774225497103,87e2cc9055f15faf5a6228e0933ea51a1fb147cecdcfd3336df8299474f0126e

View file

@ -5,9 +5,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Report Giocatori - TetraQ</title>
<script defer src="/__/firebase/10.8.0/firebase-app-compat.js"></script>
<script defer src="/__/firebase/10.8.0/firebase-firestore-compat.js"></script>
<script defer src="/__/firebase/init.js"></script>
<script src="/__/firebase/10.8.0/firebase-app-compat.js"></script>
<script src="/__/firebase/10.8.0/firebase-auth-compat.js"></script>
<script src="/__/firebase/10.8.0/firebase-firestore-compat.js"></script>
<script src="/__/firebase/init.js"></script>
<style>
body {
@ -45,6 +46,7 @@
cursor: pointer; font-weight: bold; transition: background-color 0.2s;
}
.login-box button:hover { background-color: #c0392b; }
.login-box button:disabled { background-color: #95a5a6; cursor: not-allowed; }
.error { color: #e74c3c; font-weight: bold; font-size: 14px; margin-top: -5px; margin-bottom: 15px; }
/* --- STILI DASHBOARD --- */
@ -113,20 +115,18 @@
td { border-bottom: 1px solid #ecf0f1; color: #2c3e50; }
tr:hover td { background-color: #fbfcfc; }
th:nth-child(1) { width: 15%; } /* Accesso */
th:nth-child(2) { width: 25%; } /* Giocatore */
th:nth-child(3) { width: 15%; } /* Statistiche (Nuova) */
th:nth-child(4) { width: 25%; } /* Connessione */
th:nth-child(5) { width: 20%; } /* Dispositivo */
th:nth-child(1) { width: 15%; }
th:nth-child(2) { width: 25%; }
th:nth-child(3) { width: 15%; }
th:nth-child(4) { width: 25%; }
th:nth-child(5) { width: 20%; }
/* Tipografia Specifica Tabella */
.player-name { font-weight: 800; color: #2c3e50; font-size: 15px; }
.player-level { font-weight: normal; color: #e74c3c; } /* Rosso come nell'app */
.player-level { font-weight: normal; color: #e74c3c; }
.sub-text { display: block; font-size: 12px; color: #95a5a6; margin-top: 4px; font-weight: 500; }
.data-text { font-weight: 500; color: #2c3e50; font-size: 14px; }
.stat-value { font-weight: bold; color: #3498db; }
/* Badge Sistema Operativo */
.badge {
padding: 4px 8px; border-radius: 4px; color: white;
font-weight: 800; font-size: 11px; text-transform: uppercase;
@ -164,9 +164,9 @@
<h2>Area Riservata</h2>
<div id="login-error" class="error"></div>
<form id="login-form">
<input type="text" id="username" autocomplete="username" required>
<input type="email" id="email" autocomplete="username" required>
<input type="password" id="password" placeholder="Password" autocomplete="current-password" required>
<button type="submit">Accedi al Database</button>
<button type="submit" id="login-btn">Accedi al Database</button>
</form>
</div>
</div>
@ -174,8 +174,8 @@
<div id="dashboard-view">
<div class="container">
<div class="header-top">
<h1>Dettaglio Giocatori</h1>
<button class="btn-logout" onclick="logout()">Disconnetti</button>
<h1>📊 Report Statistiche TetraQ</h1>
<button class="btn-logout" onclick="logout()">Disconnetti 🚪</button>
</div>
<form class="filter-section" id="filter-form">
@ -241,10 +241,8 @@
</div>
<script>
// --- CONFIGURAZIONE SICUREZZA ---
const PASSWORD_SEGRETA = "!!TetraQ!!";
const UTENTE_SEGRETO = "io";
let allData = [];
let unsubscribeLeaderboard = null;
// --- FUNZIONI DI UTILITÀ ---
function formatTime(seconds) {
@ -265,39 +263,71 @@
return dateObj.toLocaleDateString('it-IT', { year: 'numeric', month: '2-digit', day: '2-digit' });
}
// --- GESTIONE LOGIN ---
document.getElementById('login-form').addEventListener('submit', function(e) {
e.preventDefault();
const user = document.getElementById('username').value.trim().toLowerCase();
const pwd = document.getElementById('password').value;
if (user === UTENTE_SEGRETO && pwd === PASSWORD_SEGRETA) {
// --- LISTENER AUTENTICAZIONE FIREBASE ---
firebase.auth().onAuthStateChanged((user) => {
if (user) {
// L'utente è loggato, mostra la dashboard
document.getElementById('login-view').style.display = 'none';
document.getElementById('dashboard-view').style.display = 'block';
loadFirebaseData();
} else {
document.getElementById('login-error').innerText = "Credenziali errate! Riprova.";
// Nessun utente loggato, mostra il login
document.getElementById('dashboard-view').style.display = 'none';
document.getElementById('login-view').style.display = 'flex';
if(unsubscribeLeaderboard) {
unsubscribeLeaderboard(); // Ferma l'ascolto del database se fai logout
}
}
});
// --- GESTIONE LOGIN ---
document.getElementById('login-form').addEventListener('submit', function(e) {
e.preventDefault();
const email = document.getElementById('email').value.trim();
const pwd = document.getElementById('password').value;
const btn = document.getElementById('login-btn');
btn.disabled = true;
btn.innerText = "Accesso in corso...";
document.getElementById('login-error').innerText = "";
// Usa l'Auth sicuro di Firebase
firebase.auth().signInWithEmailAndPassword(email, pwd)
.then(() => {
// Il successo è gestito da onAuthStateChanged
btn.disabled = false;
btn.innerText = "Accedi al Database";
})
.catch((error) => {
btn.disabled = false;
btn.innerText = "Accedi al Database";
let errorMessage = "Errore durante il login.";
if(error.code === 'auth/user-not-found' || error.code === 'auth/wrong-password' || error.code === 'auth/invalid-credential') {
errorMessage = "Email o password errati.";
}
document.getElementById('login-error').innerText = errorMessage;
});
});
function logout() {
document.getElementById('password').value = '';
document.getElementById('login-error').innerText = '';
document.getElementById('dashboard-view').style.display = 'none';
document.getElementById('login-view').style.display = 'flex';
document.getElementById('table-body').innerHTML = '<tr><td colspan="5" class="empty">Caricamento dati dal database...</td></tr>';
allData = [];
firebase.auth().signOut().then(() => {
document.getElementById('email').value = '';
document.getElementById('password').value = '';
document.getElementById('table-body').innerHTML = '<tr><td colspan="5" class="empty">Caricamento dati dal database...</td></tr>';
allData = [];
});
}
// --- CONNESSIONE A FIREBASE ---
// --- CONNESSIONE A FIREBASE FIRESTORE ---
function loadFirebaseData() {
const db = firebase.firestore();
db.collection('leaderboard').orderBy('lastActive', 'desc').onSnapshot((snapshot) => {
// Salviamo la funzione di unsubscribe per fermare il listener al logout
unsubscribeLeaderboard = db.collection('leaderboard').orderBy('lastActive', 'desc').onSnapshot((snapshot) => {
allData = [];
snapshot.forEach(doc => {
let data = doc.data();
// Gestione Date Firebase
if (data.lastActive) {
data.dateObj = data.lastActive.toDate();
data.dateStr = data.dateObj.toISOString().substring(0, 10);
@ -309,7 +339,6 @@
data.createdObj = data.accountCreated.toDate();
}
// Nascondi account sviluppatore se necessario
if ((data.name || '').toUpperCase() !== 'PIPPO') {
allData.push(data);
}
@ -317,7 +346,12 @@
applyFilters();
}, error => {
console.error("Errore lettura database:", error);
document.getElementById('table-body').innerHTML = '<tr><td colspan="5" class="empty" style="color:#e74c3c;">Errore di connessione a Firebase. Riprova.</td></tr>';
// Se c'è un errore (es. permessi negati), forse non siamo admin
if (error.code === 'permission-denied') {
document.getElementById('table-body').innerHTML = '<tr><td colspan="5" class="empty" style="color:#e74c3c;">Accesso Negato: Non hai i permessi per leggere questi dati.</td></tr>';
} else {
document.getElementById('table-body').innerHTML = '<tr><td colspan="5" class="empty" style="color:#e74c3c;">Errore di connessione a Firebase. Riprova.</td></tr>';
}
});
}
@ -351,7 +385,6 @@
let city = (row.city || '').toLowerCase();
let name = (row.name || 'Sconosciuto').toLowerCase();
// Filtri Logica
if (fDa !== '' && row.dateStr < fDa) mostra = false;
if (fA !== '' && row.dateStr > fA) mostra = false;
@ -371,7 +404,6 @@
else if (platform === 'Android') { android++; badgeClass = 'badge-android'; }
else { desktop++; platformDisplay = 'Desktop'; }
// Costruzione Riga Tabella
html += `
<tr>
<td data-label="Ultimo Accesso">
@ -405,7 +437,6 @@
html = '<tr><td colspan="5" class="empty">Nessun giocatore corrisponde ai filtri selezionati.</td></tr>';
}
// Aggiorna la vista
document.getElementById('table-body').innerHTML = html;
document.getElementById('totale-text').innerText = tot;
document.getElementById('ios-text').innerText = ios;

View file

@ -1,7 +1,7 @@
name: tetraq
description: A new Flutter project.
publish_to: 'none'
version: 1.1.6+8
version: 1.1.7+1
environment:
sdk: ^3.10.7