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": "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": {