feat: Info tab enriched — retroactive AI estimate, annual totals, inventory & activity stats

api/index.php:
- gemini_usage: retroactive AI call estimate from cache files (price/shelf/category)
  with per-entry token estimates (price ~475tok, shelf ~580tok, category ~230tok)
- yearly totals: sum tracked months + retro estimate for full 2026 view
- DB activity stats: products, inventory, transactions, expired, expiring_soon
- cache stats: price (255), shelf (30), category (7), foodfacts (10)
- system info: last backup timestamp+size, Bring! token expiry
- new constants: SHELF_CACHE_PATH, FOODFACTS_CACHE_PATH, BRING_TOKEN_PATH

assets/js/app.js:
- _renderInfoTab(): full rewrite — 4 cards (AI, Inventory, Activity, System)
- month displayed as localized name via Intl.DateTimeFormat (es. 'maggio 2026')
- tracked section shown when calls > 0; retro estimate always shown if gap exists
- year section: tracked + retro combined total
- pill() helper for consistent stat display

index.html: 4 cards with ids info-ai-content, info-inv-content, info-act-content, info-system-content

translations: updated settings.info.* keys in it/en/de (overview subtitle, retro labels, inv/act/system keys)
This commit is contained in:
dadaloop82
2026-05-18 06:33:59 +00:00
parent 9f554c6e22
commit cc0d9763ed
6 changed files with 419 additions and 103 deletions
+28 -5
View File
@@ -771,14 +771,37 @@
"est_cost": "Gesch. Kosten",
"input_tok": "Eingabe-Token",
"output_tok": "Ausgabe-Token",
"ai_calls": "KI-Aufrufe",
"ai_calls": "Aufrufe",
"by_action": "Aufschlüsselung nach Funktion",
"by_model": "Aufschlüsselung nach Modell",
"pricing_note": "Referenzpreise: gemini-2.5-flash $0.15/1M Input, $0.60/1M Output.",
"pricing_note": "Gemini Referenzpreise: 2.5-flash $0.15/M in · $0.60/M out — 2.0-flash $0.10/M in · $0.40/M out.",
"system_title": "System",
"db_size": "Datenbankgröße",
"log_size": "Log-Größe",
"log_level": "Log-Level"
"db_size": "Datenbank",
"log_size": "Protokolle",
"log_level": "Log-Level",
"ai_overview": "KI-Nutzungsübersicht, Inventar und Systemstatus",
"tracked_section": "Erfasst (seit Monitoring-Start)",
"retro_section": "Rückwirkende Schätzung — {month}",
"retro_note": "Schätzung basiert auf KI-Cache-Dateien, die vor der Monitoring-Aktivierung generiert wurden.",
"year_section": "Jahr {year} — Gesamtschätzung",
"calls_unit": "Aufrufe",
"inv_title": "Inventar",
"inv_active": "Aktiv",
"inv_products": "Produkte gesamt",
"inv_expiring": "Ablaufend (7T)",
"inv_expired": "Abgelaufen",
"inv_finished": "Leer",
"act_title": "Monatliche Aktivität",
"act_tx_month": "Bewegungen",
"act_restock": "Einkäufe",
"act_use": "Verbrauch",
"act_new_products": "Neue Produkte",
"act_tx_year": "Jährl. Bewegungen",
"price_cache": "Preiscache",
"cache_entries": "Produkte",
"last_backup": "Letztes Backup",
"bring_days": "Token läuft in {n} Tagen ab",
"bring_expired": "Token abgelaufen"
}
},
"expiry": {
+28 -5
View File
@@ -771,14 +771,37 @@
"est_cost": "Est. cost",
"input_tok": "Input tokens",
"output_tok": "Output tokens",
"ai_calls": "AI calls",
"ai_calls": "Calls",
"by_action": "Breakdown by function",
"by_model": "Breakdown by model",
"pricing_note": "Reference pricing: gemini-2.5-flash $0.15/1M input, $0.60/1M output.",
"pricing_note": "Gemini reference pricing: 2.5-flash $0.15/M in · $0.60/M out — 2.0-flash $0.10/M in · $0.40/M out.",
"system_title": "System",
"db_size": "Database size",
"log_size": "Log size",
"log_level": "Log level"
"db_size": "Database",
"log_size": "Logs",
"log_level": "Log level",
"ai_overview": "AI usage overview, inventory and system status",
"tracked_section": "Tracked (since monitoring start)",
"retro_section": "Retroactive estimate — {month}",
"retro_note": "Estimate based on AI cache files generated before monitoring was activated.",
"year_section": "Year {year} — total estimate",
"calls_unit": "calls",
"inv_title": "Inventory",
"inv_active": "Active",
"inv_products": "Total products",
"inv_expiring": "Expiring (7d)",
"inv_expired": "Expired",
"inv_finished": "Finished",
"act_title": "Monthly activity",
"act_tx_month": "Movements",
"act_restock": "Restocks",
"act_use": "Usages",
"act_new_products": "New products",
"act_tx_year": "Yearly movements",
"price_cache": "Price cache",
"cache_entries": "products",
"last_backup": "Last backup",
"bring_days": "token expires in {n} days",
"bring_expired": "token expired"
}
},
"expiry": {
+28 -5
View File
@@ -771,14 +771,37 @@
"est_cost": "Costo stimato",
"input_tok": "Token input",
"output_tok": "Token output",
"ai_calls": "Chiamate AI",
"ai_calls": "Chiamate",
"by_action": "Dettaglio per funzione",
"by_model": "Dettaglio per modello",
"pricing_note": "Prezzi di riferimento: gemini-2.5-flash $0.15/1M input, $0.60/1M output.",
"pricing_note": "Prezzi di riferimento Gemini: 2.5-flash $0.15/M in · $0.60/M out — 2.0-flash $0.10/M in · $0.40/M out.",
"system_title": "Sistema",
"db_size": "Dimensione database",
"log_size": "Dimensione log",
"log_level": "Livello di log"
"db_size": "Database",
"log_size": "Log",
"log_level": "Livello log",
"ai_overview": "Prospetto utilizzo AI, inventario e stato del sistema",
"tracked_section": "Tracciato (da inizio monitoraggio)",
"retro_section": "Stima retroattiva — {month}",
"retro_note": "Stima basata sulle voci presenti nei file di cache AI, generati prima dell'attivazione del monitoraggio.",
"year_section": "Anno {year} — totale stimato",
"calls_unit": "call",
"inv_title": "Inventario",
"inv_active": "Attivi",
"inv_products": "Prodotti totali",
"inv_expiring": "In scadenza (7gg)",
"inv_expired": "Scaduti",
"inv_finished": "Finiti",
"act_title": "Attività del mese",
"act_tx_month": "Movimenti",
"act_restock": "Acquisti",
"act_use": "Consumi",
"act_new_products": "Nuovi prodotti",
"act_tx_year": "Movimenti anno",
"price_cache": "Cache prezzi",
"cache_entries": "prodotti",
"last_backup": "Ultimo backup",
"bring_days": "token scade tra {n} giorni",
"bring_expired": "token scaduto"
}
},
"expiry": {