Actualiser assets/js/app.js
CI / PHP Syntax Check (push) Has been cancelled
CI / JavaScript Lint (push) Has been cancelled
CI / Docker Build Test (push) Has been cancelled
CI / Validate Translation Files (push) Has been cancelled
CI / Auto-merge develop → main (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / PHP Syntax Check (push) Has been cancelled
CI / JavaScript Lint (push) Has been cancelled
CI / Docker Build Test (push) Has been cancelled
CI / Validate Translation Files (push) Has been cancelled
CI / Auto-merge develop → main (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
This commit is contained in:
+7
-19
@@ -5197,35 +5197,23 @@ function _applyInsightPhase() {
|
||||
|
||||
// ===== DASHBOARD =====
|
||||
async function loadDashboard() {
|
||||
// Show shimmer on stat cards while loading
|
||||
['stat-dispensa', 'stat-frigo', 'stat-freezer'].forEach(id => {
|
||||
const el = document.getElementById(id);
|
||||
if (el) el.classList.add('stat-loading');
|
||||
});
|
||||
|
||||
// Render one card per known location, with shimmer while loading
|
||||
renderDashboardLocationCards({});
|
||||
try {
|
||||
const [summaryData, statsData] = await Promise.all([
|
||||
api('inventory_summary'),
|
||||
api('stats')
|
||||
]);
|
||||
|
||||
// Update stat cards
|
||||
const summary = summaryData.summary || [];
|
||||
let total = 0;
|
||||
['dispensa', 'frigo', 'freezer'].forEach(loc => {
|
||||
const counts = {};
|
||||
Object.keys(LOCATIONS).forEach(loc => {
|
||||
const s = summary.find(x => x.location === loc);
|
||||
const count = s ? s.product_count : 0;
|
||||
const el = document.getElementById(`stat-${loc}`);
|
||||
el.textContent = count;
|
||||
el.classList.remove('stat-loading');
|
||||
total += count;
|
||||
});
|
||||
// Add non-standard locations
|
||||
summary.forEach(s => {
|
||||
if (!['dispensa', 'frigo', 'freezer'].includes(s.location)) {
|
||||
total += s.product_count;
|
||||
}
|
||||
counts[loc] = s ? s.product_count : 0;
|
||||
total += counts[loc];
|
||||
});
|
||||
renderDashboardLocationCards(counts);
|
||||
// Load shopping list count from Bring!
|
||||
loadShoppingCount();
|
||||
// Show last known total instantly, then refresh from server
|
||||
|
||||
Reference in New Issue
Block a user