Compare commits

...

3 Commits

Author SHA1 Message Date
2cdb601706 Bump version: 1.3.52 → 1.3.53
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 1m23s
2025-07-18 17:36:28 +01:00
e84441e7f1 add and hide button 2025-07-18 17:36:25 +01:00
7ad67a80f5 better logged in logic 2025-07-18 17:33:26 +01:00
4 changed files with 30 additions and 6 deletions

View File

@ -1,5 +1,5 @@
[tool.bumpversion]
current_version = "1.3.52"
current_version = "1.3.53"
commit = true
tag = true
tag_name = "{new_version}"

View File

@ -1 +1 @@
1.3.52
1.3.53

View File

@ -49,18 +49,35 @@
<p>Version: <a href="#" id="version-link">{{ version }}</a></p>
</footer>
<input type="hidden" id="is-logged-in" value="{{ 'true' if session.get('logged_in') else 'false' }}">
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
{% block scripts %}{% endblock %}
<script>
if ('serviceWorker' in navigator && 'PushManager' in window) {
const isLoggedIn = document.getElementById('is-logged-in').value === 'true';
navigator.serviceWorker.register('{{ url_for("static", filename="service-worker.js") }}').then(function(registration) {
console.log('ServiceWorker registration successful with scope: ', registration.scope);
// Check for the 'loggedin' query parameter to trigger the prompt
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.has('loggedin')) {
const enableNotificationsBtn = document.getElementById('enable-notifications-btn');
function setupNotificationButton() {
registration.pushManager.getSubscription().then(function(subscription) {
if (enableNotificationsBtn) {
if (subscription) {
enableNotificationsBtn.style.display = 'none';
} else {
enableNotificationsBtn.style.display = 'block';
enableNotificationsBtn.addEventListener('click', function() {
askPermission(registration);
});
}
}
});
}
if (enableNotificationsBtn) {
setupNotificationButton();
}
}, function(err) {
console.log('ServiceWorker registration failed: ', err);
@ -141,6 +158,10 @@
.then(response => {
if (response.ok) {
console.log('Subscription saved successfully.');
const enableNotificationsBtn = document.getElementById('enable-notifications-btn');
if (enableNotificationsBtn) {
enableNotificationsBtn.style.display = 'none';
}
return response.json();
} else {
console.error('Failed to save subscription. Status:', response.status);

View File

@ -5,6 +5,9 @@
{% block content %}
<h1>Welcome {{ username }}!</h1>
<br>
<button id="enable-notifications-btn" class="btn btn-primary">Enable Notifications</button>
<br>
<br>
<h2>You have {{ accounts }} active accounts</h2>
<br>