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);