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] [tool.bumpversion]
current_version = "1.3.52" current_version = "1.3.53"
commit = true commit = true
tag = true tag = true
tag_name = "{new_version}" 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> <p>Version: <a href="#" id="version-link">{{ version }}</a></p>
</footer> </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://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://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> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
{% block scripts %}{% endblock %} {% block scripts %}{% endblock %}
<script> <script>
if ('serviceWorker' in navigator && 'PushManager' in window) { 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) { navigator.serviceWorker.register('{{ url_for("static", filename="service-worker.js") }}').then(function(registration) {
console.log('ServiceWorker registration successful with scope: ', registration.scope); console.log('ServiceWorker registration successful with scope: ', registration.scope);
// Check for the 'loggedin' query parameter to trigger the prompt const enableNotificationsBtn = document.getElementById('enable-notifications-btn');
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.has('loggedin')) { function setupNotificationButton() {
askPermission(registration); 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) { }, function(err) {
console.log('ServiceWorker registration failed: ', err); console.log('ServiceWorker registration failed: ', err);
@ -141,6 +158,10 @@
.then(response => { .then(response => {
if (response.ok) { if (response.ok) {
console.log('Subscription saved successfully.'); console.log('Subscription saved successfully.');
const enableNotificationsBtn = document.getElementById('enable-notifications-btn');
if (enableNotificationsBtn) {
enableNotificationsBtn.style.display = 'none';
}
return response.json(); return response.json();
} else { } else {
console.error('Failed to save subscription. Status:', response.status); console.error('Failed to save subscription. Status:', response.status);

View File

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