From 60ed796b5ad25675076ce93885a3160df950043d Mon Sep 17 00:00:00 2001 From: CyberMind-FR Date: Sun, 1 Feb 2026 08:33:30 +0100 Subject: [PATCH] fix(metablogizer): Fix require path and async hosting status load - Fix qrcode require path (slash to dot notation) - Load hosting status asynchronously to prevent XHR timeout - Dashboard now loads instantly with sites, HAProxy/IP populate after Co-Authored-By: Claude Opus 4.5 --- .../luci-static/resources/metablogizer/api.js | 5 ++-- .../resources/view/metablogizer/dashboard.js | 24 +++++++++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/package/secubox/luci-app-metablogizer/htdocs/luci-static/resources/metablogizer/api.js b/package/secubox/luci-app-metablogizer/htdocs/luci-static/resources/metablogizer/api.js index 65456967..ee778c46 100644 --- a/package/secubox/luci-app-metablogizer/htdocs/luci-static/resources/metablogizer/api.js +++ b/package/secubox/luci-app-metablogizer/htdocs/luci-static/resources/metablogizer/api.js @@ -202,13 +202,12 @@ return baseclass.extend({ var self = this; return Promise.all([ self.getStatus(), - self.listSites(), - self.getHostingStatus().catch(function() { return {}; }) + self.listSites() ]).then(function(results) { return { status: results[0] || {}, sites: results[1] || [], - hosting: results[2] || {} + hosting: {} }; }); } diff --git a/package/secubox/luci-app-metablogizer/htdocs/luci-static/resources/view/metablogizer/dashboard.js b/package/secubox/luci-app-metablogizer/htdocs/luci-static/resources/view/metablogizer/dashboard.js index 8fe8d26b..015056ed 100644 --- a/package/secubox/luci-app-metablogizer/htdocs/luci-static/resources/view/metablogizer/dashboard.js +++ b/package/secubox/luci-app-metablogizer/htdocs/luci-static/resources/view/metablogizer/dashboard.js @@ -3,7 +3,7 @@ 'require ui'; 'require fs'; 'require metablogizer.api as api'; -'require metablogizer/qrcode as qrcode'; +'require metablogizer.qrcode as qrcode'; return view.extend({ status: {}, @@ -27,6 +27,22 @@ return view.extend({ var sites = this.sites; var hosting = this.hosting; + // Load hosting status asynchronously after render + api.getHostingStatus().then(function(h) { + self.hosting = h || {}; + var haproxyEl = document.getElementById('haproxy-status'); + var ipEl = document.getElementById('public-ip'); + if (haproxyEl) { + haproxyEl.innerHTML = ''; + haproxyEl.appendChild(h.haproxy_status === 'running' ? + E('span', { 'style': 'color:#0a0' }, _('Running')) : + E('span', { 'style': 'color:#a00' }, _('Stopped'))); + } + if (ipEl) { + ipEl.textContent = h.public_ip || '-'; + } + }).catch(function() {}); + return E('div', { 'class': 'cbi-map' }, [ E('h2', {}, _('MetaBlogizer')), E('div', { 'class': 'cbi-map-descr' }, _('Static site publisher with HAProxy vhosts and SSL')), @@ -41,13 +57,11 @@ return view.extend({ ]), E('tr', { 'class': 'tr' }, [ E('td', { 'class': 'td' }, _('HAProxy')), - E('td', { 'class': 'td' }, hosting.haproxy_status === 'running' ? - E('span', { 'style': 'color:#0a0' }, _('Running')) : - E('span', { 'style': 'color:#a00' }, _('Stopped'))) + E('td', { 'class': 'td', 'id': 'haproxy-status' }, E('em', {}, _('Loading...'))) ]), E('tr', { 'class': 'tr' }, [ E('td', { 'class': 'td' }, _('Public IP')), - E('td', { 'class': 'td' }, hosting.public_ip || '-') + E('td', { 'class': 'td', 'id': 'public-ip' }, _('Loading...')) ]), E('tr', { 'class': 'tr' }, [ E('td', { 'class': 'td' }, _('Sites')),