Add PWA mobile attendance shortcut
This commit is contained in:
@@ -6,6 +6,12 @@
|
||||
{% set __title_user = current_user if current_user is defined else None %}
|
||||
{% set __firm_branding = get_current_firm_branding(request, __title_user) %}
|
||||
<meta name="theme-color" content="{{ __firm_branding.primary_color or '#1e3a8a' }}" />
|
||||
<link rel="manifest" href="/manifest.webmanifest" />
|
||||
<meta name="mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-title" content="ARRR ERP" />
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
|
||||
<link rel="apple-touch-icon" href="/static/pwa/icons/icon-192.png" />
|
||||
{% if __firm_branding.favicon_url %}<link rel="icon" href="{{ __firm_branding.favicon_url }}" />{% endif %}
|
||||
{% set __title_auth = __title_user and request.session.get("otp_verified", False) %}
|
||||
{% if __title_auth %}
|
||||
@@ -502,6 +508,17 @@
|
||||
{{ flash }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if current_path == '/employee/attendance' or current_path == '/mobile/attendance' %}
|
||||
<div id="af-pwa-install-banner" class="mb-6 hidden rounded-2xl border border-brand-200 bg-brand-50 px-4 py-3 text-sm text-brand-900 shadow-soft">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<div>
|
||||
<div class="font-semibold">Install ARRR ERP Attendance</div>
|
||||
<div class="text-xs text-brand-800">Add this attendance screen to your mobile home screen for faster punch-in and punch-out.</div>
|
||||
</div>
|
||||
<button id="af-pwa-install-button" type="button" class="rounded-xl bg-brand-600 px-4 py-2 text-xs font-semibold text-white hover:bg-brand-700">Install</button>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
</div>
|
||||
@@ -627,5 +644,37 @@
|
||||
</script>
|
||||
{% endif %}
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
if ('serviceWorker' in navigator) {
|
||||
window.addEventListener('load', function () {
|
||||
navigator.serviceWorker.register('/sw.js', { scope: '/' }).catch(function () {
|
||||
// PWA remains optional; normal ERP browser use continues without service worker.
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var deferredPrompt = null;
|
||||
var banner = null;
|
||||
var button = null;
|
||||
|
||||
window.addEventListener('beforeinstallprompt', function (event) {
|
||||
deferredPrompt = event;
|
||||
banner = document.getElementById('af-pwa-install-banner');
|
||||
button = document.getElementById('af-pwa-install-button');
|
||||
if (!banner || !button) return;
|
||||
event.preventDefault();
|
||||
banner.classList.remove('hidden');
|
||||
button.addEventListener('click', async function () {
|
||||
if (!deferredPrompt) return;
|
||||
deferredPrompt.prompt();
|
||||
try { await deferredPrompt.userChoice; } catch (err) {}
|
||||
deferredPrompt = null;
|
||||
banner.classList.add('hidden');
|
||||
}, { once: true });
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user