From 0456f467c71e92b89538c319095cd14ca4ef0361 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Tue, 23 Jun 2026 11:13:56 -0500 Subject: [PATCH] feat(dashboard): add heartbeat send button next to Support PIN Upload icon button beside the PIN badge triggers sendHeartbeat AJAX call to HQ, which includes the health token (HQ derives the PIN). --- .../admin/tmpl/dashboard/default.php | 10 +++++- .../com_mokosuiteclient/media/js/dashboard.js | 34 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/source/packages/com_mokosuiteclient/admin/tmpl/dashboard/default.php b/source/packages/com_mokosuiteclient/admin/tmpl/dashboard/default.php index 574640a3..34f0910c 100644 --- a/source/packages/com_mokosuiteclient/admin/tmpl/dashboard/default.php +++ b/source/packages/com_mokosuiteclient/admin/tmpl/dashboard/default.php @@ -61,7 +61,15 @@ $actionLogsEnabled = Joomla\CMS\Component\ComponentHelper::isEnabled('com_action supportPin)): ?>
Support PIN - escape($this->supportPin); ?> + + escape($this->supportPin); ?> + +
diff --git a/source/packages/com_mokosuiteclient/media/js/dashboard.js b/source/packages/com_mokosuiteclient/media/js/dashboard.js index 05335437..065fde22 100644 --- a/source/packages/com_mokosuiteclient/media/js/dashboard.js +++ b/source/packages/com_mokosuiteclient/media/js/dashboard.js @@ -110,6 +110,40 @@ document.addEventListener('DOMContentLoaded', function () { }); } + // Heartbeat + PIN send button + var hbBtn = document.getElementById('mokosuiteclient-btn-heartbeat-pin'); + if (hbBtn) { + hbBtn.addEventListener('click', function () { + var btn = this; + var url = btn.dataset.url; + var token = btn.dataset.token; + var icon = btn.querySelector('span'); + + btn.disabled = true; + if (icon) icon.className = 'icon-spinner icon-spin'; + + var fd = new FormData(); + fd.append(token, '1'); + + fetch(url, {method: 'POST', body: fd, headers: {'X-Requested-With': 'XMLHttpRequest'}}) + .then(function (r) { return r.json(); }) + .then(function (d) { + if (d.success) { + Joomla.renderMessages({message: [d.message || 'Heartbeat sent to HQ.']}); + } else { + Joomla.renderMessages({error: [d.message || 'Heartbeat failed.']}); + } + }) + .catch(function () { + Joomla.renderMessages({error: ['Network error sending heartbeat.']}); + }) + .finally(function () { + btn.disabled = false; + if (icon) icon.className = 'icon-upload'; + }); + }); + } + // Akeeba import buttons ['btn-import-admintools', 'btn-import-ats-dash'].forEach(function(id) { var btn = document.getElementById(id);