Mobile Views jetzt als PWA

This commit is contained in:
concierge committed 2026-10-29 08:08:23 +01:00
1 parent d8692ab20e
commit b41c3bc3a6
11 files changed
+785 -37

No files matched your search

+12
View File
@@ -96,6 +96,18 @@ def create_app(config_name=None):
app.static_folder, 'favicon.ico', mimetype='image/vnd.microsoft.icon'
)
# Service Worker für die PWA. Er wird bewusst an der App-Wurzel
# ausgeliefert, damit er auch die statischen Assets unter /static
# kontrollieren kann. Der Pfad berücksichtigt ein gesetztes SCRIPT_NAME
# (Reverse-Proxy-Prefix) automatisch.
@app.route('/sw.js')
def service_worker():
response = send_from_directory(
app.static_folder, 'js/sw.js', mimetype='application/javascript'
)
response.headers['Cache-Control'] = 'no-cache'
return response
# Root redirect
@app.route('/')
def index():
+66 -1
View File
@@ -1,7 +1,10 @@
"""
Haupt-Views
"""
from flask import Blueprint, render_template, g, redirect, url_for, request
from flask import (
Blueprint, render_template, g, redirect, url_for, request, jsonify,
make_response, session
)
from cmbnet.auth import login_required, role_required
views_bp = Blueprint('views', __name__)
@@ -57,6 +60,68 @@ def gruppen(**kwargs):
return render_template('gruppen.html')
@views_bp.route('/manifest.webmanifest')
def manifest(tenant=None, **kwargs):
"""Liefert das Web-App-Manifest für die mobilen Views."""
account = getattr(g, 'current_account', None)
role = account['role'] if account else session.get('role')
if role == 'Dispatcher':
start_url = url_for('views.dispatcher_mobil', tenant=tenant)
name = 'CMBNet Dispatcher'
short_name = 'CMB Dispo'
elif role == 'Gruppe':
start_url = url_for('views.gruppen', tenant=tenant)
name = 'CMBNet Gruppe'
short_name = 'CMB Gruppe'
else:
start_url = url_for('views.index', tenant=tenant)
name = 'CMBNet'
short_name = 'CMBNet'
icon_192 = url_for('static', filename='img/icon-192.png')
icon_512 = url_for('static', filename='img/icon-512.png')
payload = {
'id': start_url,
'name': name,
'short_name': short_name,
'description': 'CMBNet – mobile Einsatzansicht',
'lang': 'de',
'start_url': start_url,
'scope': url_for('views.index', tenant=tenant),
'display': 'standalone',
'display_override': ['standalone', 'minimal-ui'],
'background_color': '#f7f9fc',
'theme_color': '#2563eb',
'icons': [
{
'src': icon_192,
'sizes': '192x192',
'type': 'image/png',
'purpose': 'any'
},
{
'src': icon_512,
'sizes': '512x512',
'type': 'image/png',
'purpose': 'any'
},
{
'src': icon_512,
'sizes': '512x512',
'type': 'image/png',
'purpose': 'maskable'
}
]
}
response = make_response(jsonify(payload))
response.headers['Content-Type'] = 'application/manifest+json'
response.headers['Cache-Control'] = 'no-cache'
return response
@views_bp.route('/praesentation')
@login_required
def praesentation(**kwargs):