Allererste Fassung von Gruppen- und Dispatcher-Mobil View

This commit is contained in:
concierge committed 2026-10-28 14:23:15 +01:00
1 parent 47240302d0
commit 8e5f91948f
9 files changed
+1377 -14

No files matched your search

+12
View File
@@ -11,6 +11,18 @@ from cmbnet.utils.helpers import log_transaction
api_groups_bp = Blueprint('api_groups', __name__) api_groups_bp = Blueprint('api_groups', __name__)
@api_groups_bp.route('/groups/me')
@role_required(['Gruppe'])
def get_my_group(**kwargs):
from cmbnet.services.groups_service import GroupsService
groups = GroupsService.get_all(g.tenant_id)
account_id = g.current_account['id']
for group in groups.values():
if group.get('account_id') == account_id:
return jsonify(group)
return jsonify({'error': 'Gruppe nicht gefunden'}), 404
@api_groups_bp.route('/groups/<int:group_id>/alias', methods=['POST']) @api_groups_bp.route('/groups/<int:group_id>/alias', methods=['POST'])
@role_required(['Dispatcher', 'Administrator']) @role_required(['Dispatcher', 'Administrator'])
def update_group_alias(group_id, **kwargs): def update_group_alias(group_id, **kwargs):
+26
View File
@@ -11,6 +11,32 @@ from cmbnet.services.groups_service import GroupsService
api_init_bp = Blueprint('api_init', __name__) api_init_bp = Blueprint('api_init', __name__)
@api_init_bp.route('/init/me')
@login_required
def init_me(**kwargs):
account = getattr(g, 'current_account', None)
if not account:
return jsonify({'id': None, 'role': None, 'name': None})
return jsonify({
'id': account['id'],
'role': account['role'],
'name': account['name'],
'tenant_id': account['tenant_id'],
'tenant_code': account['tenant_code']
})
@api_init_bp.route('/init/groups/<int:group_id>/streets')
@login_required
def init_group_streets(group_id, **kwargs):
from cmbnet.services.groups_service import GroupsService
streets = GroupsService.get_streets_for_group(group_id, g.tenant_id)
result = []
for street in streets:
result.append(dict(street))
return jsonify(result)
@api_init_bp.route('/init/accounts') @api_init_bp.route('/init/accounts')
@login_required @login_required
def init_accounts(**kwargs): def init_accounts(**kwargs):
+3
View File
@@ -57,6 +57,9 @@ def login(**kwargs):
if role == 'Administrator': if role == 'Administrator':
return redirect(url_for('admin.dashboard', tenant=tenant_selected)) return redirect(url_for('admin.dashboard', tenant=tenant_selected))
elif role == 'Dispatcher': elif role == 'Dispatcher':
ua = (request.headers.get('User-Agent') or '').lower()
if any(x in ua for x in ['android', 'iphone', 'ipod', 'ipad', 'mobile']):
return redirect(url_for('views.dispatcher_mobil', tenant=tenant_selected))
return redirect(url_for('views.dispatcher', tenant=tenant_selected)) return redirect(url_for('views.dispatcher', tenant=tenant_selected))
elif role == 'Beobachter': elif role == 'Beobachter':
return redirect(url_for('views.beobachter', tenant=tenant_selected)) return redirect(url_for('views.beobachter', tenant=tenant_selected))
+6 -3
View File
@@ -1,7 +1,7 @@
""" """
Haupt-Views Haupt-Views
""" """
from flask import Blueprint, render_template, g, redirect, url_for from flask import Blueprint, render_template, g, redirect, url_for, request
from cmbnet.auth import login_required, role_required from cmbnet.auth import login_required, role_required
views_bp = Blueprint('views', __name__) views_bp = Blueprint('views', __name__)
@@ -17,6 +17,9 @@ def index(**kwargs):
if role == 'Administrator': if role == 'Administrator':
return redirect(url_for('admin.dashboard', tenant=tenant)) return redirect(url_for('admin.dashboard', tenant=tenant))
elif role == 'Dispatcher': elif role == 'Dispatcher':
ua = (request.headers.get('User-Agent') or '').lower()
if any(x in ua for x in ['android', 'iphone', 'ipod', 'ipad', 'mobile']):
return redirect(url_for('views.dispatcher_mobil', tenant=tenant))
return redirect(url_for('views.dispatcher', tenant=tenant)) return redirect(url_for('views.dispatcher', tenant=tenant))
elif role == 'Beobachter': elif role == 'Beobachter':
return redirect(url_for('views.beobachter', tenant=tenant)) return redirect(url_for('views.beobachter', tenant=tenant))
@@ -41,14 +44,14 @@ def beobachter(**kwargs):
@views_bp.route('/dispatcher_mobil') @views_bp.route('/dispatcher_mobil')
@role_required('Dispatcher') @role_required(['Dispatcher'])
def dispatcher_mobil(**kwargs): def dispatcher_mobil(**kwargs):
"""Dispatcher-Mobil-View""" """Dispatcher-Mobil-View"""
return render_template('dispatcher_mobil.html') return render_template('dispatcher_mobil.html')
@views_bp.route('/gruppen') @views_bp.route('/gruppen')
@login_required @role_required('Gruppe')
def gruppen(**kwargs): def gruppen(**kwargs):
"""Gruppen-View""" """Gruppen-View"""
return render_template('gruppen.html') return render_template('gruppen.html')
+34 -4
View File
@@ -232,9 +232,23 @@ class WebSocketBroker:
return bool(group and msg_row['receiver_id'] == group['id']) return bool(group and msg_row['receiver_id'] == group['id'])
return False return False
# Code 2000: nur Dispatcher und Beobachter. # Code 2000: Dispatcher, Beobachter und Gruppen.
if code == 2000: if code == 2000:
return role in ('Dispatcher', 'Beobachter') if role in ('Dispatcher', 'Beobachter'):
return True
if role == 'Gruppe':
group = db.execute(
'SELECT id FROM groups WHERE account_id = ? AND tenant_id = ?',
(account_id, tenant_id)
).fetchone()
payload = self._payload(msg_row)
group_id = None
if isinstance(payload, dict):
group_id = payload.get('group_id')
if group_id is None:
group_id = msg_row['receiver_id']
return bool(group and group_id == group['id'])
return False
return False return False
@@ -762,7 +776,11 @@ class WebSocketBroker:
elif code == 2000: elif code == 2000:
# Eine Gruppe sendet an Dispatcher und Beobachter. # Eine Gruppe sendet an Dispatcher und Beobachter.
# Im Gruppen/Mobil-View sollen nur Nachrichten an alle oder an diese Gruppe ankommen.
add_accounts(('Dispatcher', 'Beobachter')) add_accounts(('Dispatcher', 'Beobachter'))
group_id = self._resolve_group_id(tenant_id, message, sender, payload)
if group_id:
add_group_account(group_id)
elif code == 2: elif code == 2:
# Heartbeat-Antworten werden nur an Dispatcher-Views weitergegeben. # Heartbeat-Antworten werden nur an Dispatcher-Views weitergegeben.
@@ -788,15 +806,27 @@ class WebSocketBroker:
@staticmethod @staticmethod
def _payload(message): def _payload(message):
"""Liefert den JSON-Payload einer Nachricht oder None.""" """Liefert den JSON-Payload einer Nachricht oder None."""
if isinstance(message, dict):
msg = message.get('msg')
if isinstance(msg, dict):
return msg
if isinstance(msg, str):
try:
data = json.loads(msg)
return data if isinstance(data, dict) else None
except (ValueError, TypeError):
return None
return None
if hasattr(message, 'msg'):
if isinstance(message.msg, dict): if isinstance(message.msg, dict):
return message.msg return message.msg
if not isinstance(message.msg, str): if isinstance(message.msg, str):
return None
try: try:
data = json.loads(message.msg) data = json.loads(message.msg)
return data if isinstance(data, dict) else None return data if isinstance(data, dict) else None
except (ValueError, TypeError): except (ValueError, TypeError):
return None return None
return None
def _resolve_group_id(self, tenant_id, message, sender, payload): def _resolve_group_id(self, tenant_id, message, sender, payload):
"""Ermittelt die betroffene Gruppen-ID aus Payload, receiver_id oder Absender.""" """Ermittelt die betroffene Gruppen-ID aus Payload, receiver_id oder Absender."""
+326
View File
@@ -0,0 +1,326 @@
:root {
--mobile-bg: #f7f9fc;
--mobile-card: #ffffff;
--mobile-border: #d8e1ec;
--mobile-text: #1f2937;
--mobile-subtext: #4b5563;
--mobile-accent: #2563eb;
}
html[data-theme="dark"] {
--mobile-bg: #0f172a;
--mobile-card: #111827;
--mobile-border: #1f2937;
--mobile-text: #e5e7eb;
--mobile-subtext: #9ca3af;
--mobile-accent: #60a5fa;
}
* {
box-sizing: border-box;
}
body.mobile-page {
margin: 0;
background: var(--mobile-bg);
color: var(--mobile-text);
font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}
.mobile-app {
display: flex;
flex-direction: column;
height: 100dvh;
width: 100vw;
overflow: hidden;
}
.mobile-header {
background: var(--mobile-card);
border-bottom: 1px solid var(--mobile-border);
padding: 0.4rem 0.6rem;
}
.mobile-header-row {
display: flex;
align-items: center;
gap: 0.5rem;
}
.mobile-group-select,
.mobile-group-name {
flex: 1 1 auto;
min-width: 0;
}
.mobile-group-select {
width: 100%;
margin: 0;
padding: 0.4rem 0.6rem;
border-radius: 0.5rem;
border: 1px solid var(--mobile-border);
background: var(--mobile-card);
color: var(--mobile-text);
font-size: 0.9rem;
}
.mobile-group-name {
font-weight: 600;
font-size: 0.95rem;
padding: 0.4rem 0.2rem;
}
.mobile-icon-btn {
width: 2.2rem;
height: 2.2rem;
border-radius: 50%;
border: 1px solid var(--mobile-border);
background: var(--mobile-card);
color: var(--mobile-text);
display: flex;
align-items: center;
justify-content: center;
margin: 0;
padding: 0;
}
.mobile-tabs {
display: grid;
grid-template-columns: 1fr 1fr;
background: var(--mobile-card);
border-bottom: 1px solid var(--mobile-border);
}
.mobile-tab {
border: none;
background: transparent;
color: var(--mobile-subtext);
padding: 0.5rem 0;
margin: 0;
border-bottom: 2px solid transparent;
border-radius: 0;
}
.mobile-tab.active {
color: var(--mobile-text);
border-bottom-color: var(--mobile-accent);
}
.mobile-main {
flex: 1 1 auto;
min-height: 0;
position: relative;
}
.mobile-tab-panel {
display: none;
height: 100%;
width: 100%;
}
.mobile-tab-panel.active {
display: flex;
flex-direction: column;
}
.mobile-map {
flex: 1 1 auto;
height: 100%;
width: 100%;
}
.mobile-fab {
position: absolute;
right: 0.7rem;
bottom: 5.5rem;
width: 3rem;
height: 3rem;
border-radius: 50%;
border: none;
background: var(--mobile-accent);
color: #fff;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
margin: 0;
padding: 0;
z-index: 1000;
}
.mobile-fab-secondary {
bottom: 9rem;
background: var(--mobile-card);
color: var(--mobile-text);
border: 1px solid var(--mobile-border);
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
}
.mobile-work-btn {
position: absolute;
left: 50%;
transform: translateX(-50%);
bottom: 1rem;
border-radius: 999px;
background: var(--mobile-card);
color: var(--mobile-text);
border: 1px solid var(--mobile-border);
padding: 0.5rem 1.2rem;
margin: 0;
box-shadow: 0 10px 30px rgba(15, 23, 42, 0.22);
z-index: 1000;
}
.mobile-chat-messages {
flex: 1 1 auto;
min-height: 0;
overflow-y: auto;
padding: 0.6rem 0.7rem;
display: flex;
flex-direction: column;
gap: 0.4rem;
}
.mobile-chat-card {
display: flex;
flex-direction: column;
gap: 0.15rem;
padding: 0.5rem 0.6rem;
border-radius: 0.6rem;
background: var(--mobile-card);
border: 1px solid var(--mobile-border);
}
.mobile-chat-card.own {
align-self: flex-end;
background: rgba(37, 99, 235, 0.12);
}
html[data-theme="dark"] .mobile-chat-card.own {
background: rgba(96, 165, 250, 0.18);
}
.mobile-chat-meta {
font-size: 0.75rem;
color: var(--mobile-subtext);
}
.mobile-chat-fromto {
font-weight: 600;
font-size: 0.88rem;
}
.mobile-chat-text {
font-size: 0.9rem;
word-break: break-word;
}
.mobile-chat-form {
display: flex;
gap: 0.4rem;
padding: 0.5rem 0.6rem;
background: var(--mobile-card);
border-top: 1px solid var(--mobile-border);
}
.mobile-chat-input {
flex: 1 1 auto;
margin: 0;
padding: 0.45rem 0.6rem;
border-radius: 999px;
border: 1px solid var(--mobile-border);
background: var(--mobile-bg);
color: var(--mobile-text);
}
.mobile-chat-send {
margin: 0;
padding: 0.45rem 0.9rem;
border-radius: 999px;
}
.mobile-street-list {
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
gap: 0.4rem;
}
.mobile-street-item {
width: 100%;
text-align: left;
margin: 0;
padding: 0.5rem 0.7rem;
border-radius: 0.6rem;
border: 1px solid var(--mobile-border);
background: var(--mobile-card);
color: var(--mobile-text);
}
.mobile-street-item.active {
border-color: var(--mobile-accent);
box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.25);
}
.mobile-dialog-hint {
margin: 0 0 0.6rem;
color: var(--mobile-subtext);
font-size: 0.85rem;
}
.mobile-user-marker {
position: relative;
width: 16px;
height: 16px;
}
.mobile-user-dot {
width: 16px;
height: 16px;
border-radius: 50%;
background: #2563eb;
border: 3px solid #fff;
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.4);
}
.mobile-user-arrow {
position: absolute;
left: 50%;
top: 50%;
width: 0;
height: 0;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-bottom: 14px solid #2563eb;
transform-origin: 50% 100%;
transform: translate(-50%, -100%) rotate(0deg);
}
.mobile-group-marker {
position: relative;
width: 14px;
height: 14px;
}
.mobile-group-dot {
width: 14px;
height: 14px;
border-radius: 50%;
background: var(--marker-color);
border: 2px solid #fff;
box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.4);
}
@media (max-width: 420px) {
.mobile-work-btn {
bottom: 0.8rem;
}
.mobile-fab {
bottom: 5.2rem;
}
.mobile-fab-secondary {
bottom: 8.6rem;
}
}
+732
View File
@@ -0,0 +1,732 @@
/*
* Mobile Views: Dispatcher-Mobil & Gruppen
*/
const tenant = window.CMBNET_TENANT || window.location.pathname.split('/')[1];
const apiBase = `/${tenant}/api`;
const wsUrl = `${window.location.protocol === 'https:' ? 'wss' : 'ws'}://${window.location.host}/${tenant}/ws`;
const storageKey = `cmbnet:${tenant}:mobile`;
const viewMode = window.CMBNET_VIEW_MODE || 'mobile_dispatcher';
const currentAccountId = Number(window.CMBNET_ACCOUNT_ID) || null;
const currentRole = window.CMBNET_ROLE || null;
const DEFAULT_SETTINGS = {
opacity: 0.7,
weight: 20,
baseLayer: 'osm'
};
const STREET_STATES = ['unbearbeitet', 'zugewiesen', 'erledigt'];
const STREET_COLORS = {
unbearbeitet: '#1f6feb',
zugewiesen: '#d62828',
erledigt: '#2e9e4f'
};
const state = {
settings: {...DEFAULT_SETTINGS},
streets: [],
streetById: new Map(),
groups: [],
groupById: new Map(),
currentGroupId: null,
polylinesByStreetId: new Map(),
groupMarkers: new Map(),
currentPolyline: null,
currentStreetId: null,
ws: null,
authenticated: false,
reconnectTimer: null,
chatMessages: [],
chatKeys: new Set(),
userMarker: null,
userArrow: null,
watchId: null
};
const AudioContext = window.AudioContext || window.webkitAudioContext;
const audioCtx = new AudioContext();
let map, osmLayer, aerialLayer, currentBaseLayer;
document.addEventListener('DOMContentLoaded', initMobile);
async function initMobile() {
loadSettings();
initMap();
bindTabs();
bindButtons();
if (viewMode === 'mobile_dispatcher') {
try {
const groups = await fetchJson(`${apiBase}/init/groups`);
state.groups = Array.isArray(groups) ? groups : [];
indexGroups();
buildGroupSelect();
const firstGroup = state.groups[0];
if (firstGroup) {
await loadGroupData(firstGroup.id);
}
} catch (e) {
console.error(e);
}
} else if (viewMode === 'mobile_group') {
try {
const group = await fetchJson(`${apiBase}/groups/me`);
if (group && group.id) {
state.groups = [group];
state.currentGroupId = group.id;
indexGroups();
const nameEl = document.getElementById('groupNameDisplay');
if (nameEl) nameEl.textContent = group.aliasname || group.id || 'Gruppe';
await loadGroupData(group.id);
}
} catch (e) {
console.error(e);
}
}
startGeolocation();
connectWebSocket();
window.addEventListener('beforeunload', () => {
if (state.watchId !== null && navigator.geolocation) {
navigator.geolocation.clearWatch(state.watchId);
}
if (state.ws) state.ws.close();
});
}
function fetchJson(url, options={}) {
return fetch(url, {credentials:'same-origin', ...options}).then(r => {
if (!r.ok) throw new Error(r.status);
return r.json();
});
}
function loadSettings() {
try {
const raw = localStorage.getItem(storageKey);
if (raw) {
const saved = JSON.parse(raw);
state.settings.opacity = typeof saved.opacity === 'number' ? saved.opacity : DEFAULT_SETTINGS.opacity;
state.settings.weight = typeof saved.weight === 'number' ? saved.weight : DEFAULT_SETTINGS.weight;
state.settings.baseLayer = saved.baseLayer === 'aerial' ? 'aerial' : 'osm';
}
} catch(e) {}
}
function saveSettings() {
try {
localStorage.setItem(storageKey, JSON.stringify(state.settings));
} catch(e) {}
}
function initMap() {
map = L.map('mobileMap', {zoomControl: false, preferCanvas: true});
map.setView([51.0, 10.0], 6);
osmLayer = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {maxZoom: 19});
aerialLayer = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {maxZoom: 19});
setBaseLayer(state.settings.baseLayer, false);
map.on('zoomend', updateAllPolylineStyles);
}
function setBaseLayer(name, persist=true) {
if (currentBaseLayer) map.removeLayer(currentBaseLayer);
currentBaseLayer = name === 'aerial' ? aerialLayer : osmLayer;
currentBaseLayer.addTo(map);
state.settings.baseLayer = name === 'aerial' ? 'aerial' : 'osm';
const sel = document.getElementById('mobileBaseLayerSelect');
if (sel) sel.value = state.settings.baseLayer;
if (persist) saveSettings();
}
function bindTabs() {
document.querySelectorAll('.mobile-tab').forEach(btn => {
btn.addEventListener('click', () => {
document.querySelectorAll('.mobile-tab').forEach(b => {b.classList.remove('active'); b.setAttribute('aria-selected','false');});
document.querySelectorAll('.mobile-tab-panel').forEach(p => p.classList.remove('active'));
btn.classList.add('active');
btn.setAttribute('aria-selected','true');
const panel = document.getElementById(`tab-${btn.dataset.tab}`);
if (panel) panel.classList.add('active');
if (btn.dataset.tab === 'chat') {
const cont = document.getElementById('mobileChatMessages');
if (cont) cont.scrollTop = cont.scrollHeight;
}
});
});
}
function bindButtons() {
const logout = document.getElementById('mobileLogout');
if (logout) logout.addEventListener('click', () => {window.location.href = window.CMBNET_LOGOUT_URL || '/';});
const todoBtn = document.getElementById('mobileTodoBtn');
if (todoBtn) todoBtn.addEventListener('click', openStreetSelectDialog);
const settingsBtn = document.getElementById('mobileSettingsBtn');
if (settingsBtn) settingsBtn.addEventListener('click', openSettingsDialog);
const workBtn = document.getElementById('mobileWorkBtn');
if (workBtn) workBtn.addEventListener('click', openStreetStateDialog);
const chatForm = document.getElementById('mobileChatForm');
if (chatForm) {
chatForm.addEventListener('submit', (e) => {
e.preventDefault();
sendChat();
});
}
const groupSel = document.getElementById('mobileGroupSelect');
if (groupSel) {
groupSel.addEventListener('change', () => {
loadGroupData(groupSel.value);
});
}
// Settings
const opacitySlider = document.getElementById('mobileOpacitySlider');
if (opacitySlider) {
opacitySlider.addEventListener('input', (e) => {
state.settings.opacity = Number(e.target.value);
const out = document.getElementById('mobileOpacityValue');
if (out) out.textContent = state.settings.opacity.toFixed(2);
updateAllPolylineStyles();
saveSettings();
});
}
const weightSlider = document.getElementById('mobileWeightSlider');
if (weightSlider) {
weightSlider.addEventListener('input', (e) => {
state.settings.weight = Number(e.target.value);
const out = document.getElementById('mobileWeightValue');
if (out) out.textContent = `${state.settings.weight} m`;
updateAllPolylineStyles();
saveSettings();
});
}
const baseSel = document.getElementById('mobileBaseLayerSelect');
if (baseSel) {
baseSel.addEventListener('change', (e) => setBaseLayer(e.target.value));
}
}
function indexGroups() {
state.groupById.clear();
state.groups.forEach(g => {
g.id = Number(g.id);
state.groupById.set(g.id, g);
});
}
function buildGroupSelect() {
const sel = document.getElementById('mobileGroupSelect');
if (!sel) return;
sel.innerHTML = '';
state.groups.forEach(g => {
const opt = document.createElement('option');
opt.value = g.id;
opt.textContent = g.aliasname || g.id;
sel.appendChild(opt);
});
}
async function loadGroupData(groupId) {
groupId = Number(groupId);
state.currentGroupId = groupId;
const sel = document.getElementById('mobileGroupSelect');
if (sel && viewMode === 'mobile_dispatcher') sel.value = String(groupId);
clearPolylines();
if (state.currentPolyline) {
map.removeLayer(state.currentPolyline);
state.currentPolyline = null;
}
state.currentStreetId = null;
try {
const streets = await fetchJson(`${apiBase}/init/groups/${groupId}/streets`);
state.streets = Array.isArray(streets) ? streets : [];
indexStreets();
buildStreetList();
if (state.streets.length) {
const first = state.streets[0];
state.currentStreetId = first.id;
loadStreetPolyline(first.name);
fitToPositionAndPolyline();
updateWorkButton();
} else {
updateWorkButton();
}
} catch(e) {
console.error(e);
}
// Show all group positions like observer (only for dispatcher mobile)
if (viewMode === 'mobile_dispatcher') {
showAllGroupPositions();
}
}
function indexStreets() {
state.streetById.clear();
state.streets.forEach(s => {
s.id = Number(s.id);
state.streetById.set(s.id, s);
});
}
function buildStreetList() {
const list = document.getElementById('mobileStreetList');
if (!list) return;
list.innerHTML = '';
state.streets.forEach(street => {
const li = document.createElement('li');
const btn = document.createElement('button');
btn.type = 'button';
btn.className = 'mobile-street-item';
if (state.currentStreetId == street.id) btn.classList.add('active');
btn.textContent = `${street.name} (${street.state || 'unbearbeitet'})`;
btn.addEventListener('click', () => {
selectStreet(street);
closeMobileStreetSelect();
});
li.appendChild(btn);
list.appendChild(li);
});
}
function selectStreet(street) {
state.currentStreetId = street.id;
if (state.currentPolyline) {
map.removeLayer(state.currentPolyline);
state.currentPolyline = null;
}
loadStreetPolyline(street.name);
fitToPositionAndPolyline();
updateWorkButton();
buildStreetList();
}
function getStreetFragments() {
if (typeof STRASSE2POLYLINES !== 'undefined') return STRASSE2POLYLINES;
if (typeof Strasse2Polylines !== 'undefined') return Strasse2Polylines;
return window.STRASSE2POLYLINES || window.Strasse2Polylines || {};
}
function loadStreetPolyline(name) {
const fragments = getStreetFragments();
const segments = fragments[name];
if (!Array.isArray(segments)) return;
const latlngs = [];
segments.forEach(seg => {
if (!Array.isArray(seg)) return;
seg.forEach(pt => {
if (!Array.isArray(pt) || pt.length < 2) return;
// try lat,lng or lng,lat
const a = Number(pt[0]), b = Number(pt[1]);
if (!Number.isFinite(a) || !Number.isFinite(b)) return;
if (Math.abs(a) <= 90 && Math.abs(b) <= 180) latlngs.push([a,b]);
else if (Math.abs(b) <= 90 && Math.abs(a) <= 180) latlngs.push([b,a]);
});
});
if (latlngs.length < 2) return;
const street = state.streetById.get(Number(state.currentStreetId));
const color = STREET_COLORS[street?.state] || STREET_COLORS.unbearbeitet;
state.currentPolyline = L.polyline(latlngs, {
color, opacity: state.settings.opacity, weight: state.settings.weight, lineCap: 'round', lineJoin: 'round'
}).addTo(map);
}
function clearPolylines() {
state.polylinesByStreetId.forEach(lines => {
if (Array.isArray(lines)) lines.forEach(l => map.removeLayer(l));
});
state.polylinesByStreetId.clear();
}
function updateAllPolylineStyles() {
if (state.currentPolyline) {
state.currentPolyline.setStyle({opacity: state.settings.opacity, weight: state.settings.weight});
}
}
function fitToPositionAndPolyline() {
const bounds = L.latLngBounds([]);
if (state.currentPolyline) {
state.currentPolyline.getLatLngs().forEach(ll => {
if (Array.isArray(ll)) ll.forEach(p => bounds.extend(p));
else bounds.extend(ll);
});
}
if (state.userMarker) {
bounds.extend(state.userMarker.getLatLng());
}
if (bounds.isValid()) {
map.fitBounds(bounds, {padding: [40, 40], maxZoom: 17});
}
}
function updateWorkButton() {
const btn = document.getElementById('mobileWorkBtn');
if (!btn) return;
btn.disabled = !state.currentStreetId;
}
function openStreetSelectDialog() {
buildStreetList();
const dlg = document.getElementById('mobileStreetSelectDialog');
if (dlg && typeof dlg.showModal === 'function') dlg.showModal();
else if (dlg) dlg.show();
}
function closeMobileStreetSelect() {
const dlg = document.getElementById('mobileStreetSelectDialog');
if (dlg && dlg.open) dlg.close();
}
function openStreetStateDialog() {
const street = state.streetById.get(Number(state.currentStreetId));
if (!street) {
alert('Bitte erst eine Straße auswählen.');
return;
}
document.getElementById('mobileStreetStateTitle').textContent = `Straße: ${street.name}`;
document.getElementById('mobileStreetStateSelect').value = street.state || 'unbearbeitet';
fillMobileStreetGroupSelect(street.group_id);
updateMobileStreetGroupVisibility();
const dlg = document.getElementById('mobileStreetStateDialog');
if (dlg && typeof dlg.showModal === 'function') dlg.showModal();
else if (dlg) dlg.show();
}
function closeMobileStreetState() {
const dlg = document.getElementById('mobileStreetStateDialog');
if (dlg && dlg.open) dlg.close();
}
function fillMobileStreetGroupSelect(selected) {
const sel = document.getElementById('mobileStreetGroupSelect');
if (!sel) return;
sel.innerHTML = '';
const empty = document.createElement('option');
empty.value = '';
empty.textContent = '-';
sel.appendChild(empty);
state.groups.forEach(g => {
const opt = document.createElement('option');
opt.value = g.id;
opt.textContent = g.aliasname || g.id;
if (Number(selected) === g.id) opt.selected = true;
sel.appendChild(opt);
});
}
function updateMobileStreetGroupVisibility() {
const stateSel = document.getElementById('mobileStreetStateSelect');
const groupSel = document.getElementById('mobileStreetGroupSelect');
const label = document.getElementById('mobileStreetGroupLabel');
const enabled = stateSel && stateSel.value === 'zugewiesen';
if (groupSel) groupSel.disabled = !enabled;
if (label) label.style.opacity = enabled ? '1' : '0.5';
}
document.getElementById('mobileStreetStateSelect')?.addEventListener('change', updateMobileStreetGroupVisibility);
function saveMobileStreetState() {
const street = state.streetById.get(Number(state.currentStreetId));
if (!street) return;
const newState = document.getElementById('mobileStreetStateSelect').value;
if (!STREET_STATES.includes(newState)) return;
let groupId = null;
if (newState === 'zugewiesen') {
groupId = Number(document.getElementById('mobileStreetGroupSelect').value) || null;
if (!groupId) { alert('Bitte eine Gruppe auswählen.'); return; }
} else if (newState === 'erledigt' && street.group_id) {
groupId = Number(street.group_id);
}
if (state.ws && state.ws.readyState === WebSocket.OPEN && state.authenticated) {
state.ws.send(JSON.stringify({
code: 100,
msg: JSON.stringify({name: street.name, state: newState, actor: currentAccountId, street_id: street.id, group_id: groupId})
}));
}
closeMobileStreetState();
}
function openSettingsDialog() {
const opacitySlider = document.getElementById('mobileOpacitySlider');
const weightSlider = document.getElementById('mobileWeightSlider');
if (opacitySlider) { opacitySlider.value = state.settings.opacity; document.getElementById('mobileOpacityValue').textContent = state.settings.opacity.toFixed(2); }
if (weightSlider) { weightSlider.value = state.settings.weight; document.getElementById('mobileWeightValue').textContent = `${state.settings.weight} m`; }
const baseSel = document.getElementById('mobileBaseLayerSelect');
if (baseSel) baseSel.value = state.settings.baseLayer;
const dlg = document.getElementById('mobileSettingsDialog');
if (dlg && typeof dlg.showModal === 'function') dlg.showModal();
else if (dlg) dlg.show();
}
function closeMobileSettings() {
const dlg = document.getElementById('mobileSettingsDialog');
if (dlg && dlg.open) dlg.close();
}
function startGeolocation() {
if (!navigator.geolocation) return;
if (state.userMarker) {
map.removeLayer(state.userMarker);
state.userMarker = null;
}
if (state.userArrow) {
map.removeLayer(state.userArrow);
state.userArrow = null;
}
const icon = L.divIcon({
className: 'mobile-user-marker',
html: '<div class="mobile-user-dot"></div><div class="mobile-user-arrow" id="mobileUserArrow"></div>',
iconSize: [16, 16],
iconAnchor: [8, 8]
});
state.userMarker = L.marker(map.getCenter(), {icon, interactive: false}).addTo(map);
state.userArrow = document.getElementById('mobileUserArrow');
state.watchId = navigator.geolocation.watchPosition((pos) => {
const latlng = [pos.coords.latitude, pos.coords.longitude];
state.userMarker.setLatLng(latlng);
}, (err) => {
console.warn(err);
}, {enableHighAccuracy: true, maximumAge: 2000, timeout: 10000});
if (window.DeviceOrientationEvent) {
window.addEventListener('deviceorientationabsolute', handleOrientation, true);
window.addEventListener('deviceorientation', handleOrientation, true);
}
}
function handleOrientation(e) {
let heading = e.alpha;
if (typeof e.webkitCompassHeading === 'number') {
heading = e.webkitCompassHeading;
}
if (typeof heading !== 'number' || isNaN(heading)) return;
if (state.userArrow) {
state.userArrow.style.transform = `translate(-50%, -100%) rotate(${heading}deg)`;
}
}
function showAllGroupPositions() {
// Remove old markers
state.groupMarkers.forEach(m => map.removeLayer(m));
state.groupMarkers.clear();
state.groups.forEach(group => {
if (group.last_lat !== null && group.last_lat !== undefined && group.last_lon !== null && group.last_lon !== undefined) {
const lat = Number(group.last_lat), lon = Number(group.last_lon);
if (!isFinite(lat) || !isFinite(lon)) return;
const color = getGroupColor(group.id);
const icon = L.divIcon({
className: 'mobile-group-marker',
html: `<div class="mobile-group-dot" style="--marker-color:${color}"></div>`,
iconSize: [14, 14],
iconAnchor: [7, 7]
});
const marker = L.marker([lat, lon], {icon}).addTo(map);
marker.bindTooltip(group.aliasname || String(group.id));
state.groupMarkers.set(group.id, marker);
}
});
}
function getGroupColor(id) {
const hue = Math.round((Number(id) * 137.508) % 360);
return `hsl(${hue}, 72%, 45%)`;
}
function connectWebSocket() {
if (state.ws && (state.ws.readyState === WebSocket.OPEN || state.ws.readyState === WebSocket.CONNECTING)) return;
fetchJson(`${apiBase}/auth/ws-token`).then(res => {
const token = res.token;
const ws = new WebSocket(wsUrl);
state.ws = ws;
ws.addEventListener('open', () => {
ws.send(JSON.stringify({code: 0, msg: token}));
state.authenticated = true;
});
ws.addEventListener('message', handleWs);
ws.addEventListener('close', () => {
state.authenticated = false;
setTimeout(connectWebSocket, 3000);
});
}).catch(() => {
setTimeout(connectWebSocket, 3000);
});
}
function sendChat() {
const input = document.getElementById('mobileChatInput');
if (!input) return;
const text = input.value.trim();
if (!text) return;
if (!state.ws || state.ws.readyState !== WebSocket.OPEN || !state.authenticated) return;
if (viewMode === 'mobile_group' && state.currentGroupId) {
state.ws.send(JSON.stringify({code: 2000, msg: JSON.stringify({group_id: state.currentGroupId, text})}));
} else if (viewMode === 'mobile_dispatcher') {
// For dispatcher mobile, could send 1000 broadcast or 1100 - follow general behavior
state.ws.send(JSON.stringify({code: 1000, msg: JSON.stringify({text})}));
}
input.value = '';
}
function addChatEntry(entry) {
const key = `${entry.code}|${entry.sender_id}|${entry.ts}|${entry.text}`;
if (state.chatKeys.has(key)) return;
state.chatKeys.add(key);
state.chatMessages.push(entry);
renderChat();
}
function renderChat() {
const cont = document.getElementById('mobileChatMessages');
if (!cont) return;
cont.innerHTML = '';
state.chatMessages.slice().sort((a,b) => a.ts - b.ts).forEach(entry => {
const card = document.createElement('div');
card.className = 'mobile-chat-card';
if (entry.sender_id == currentAccountId) card.classList.add('own');
const meta = document.createElement('div');
meta.className = 'mobile-chat-meta';
meta.textContent = new Date(entry.ts).toLocaleString('de-DE');
const fromto = document.createElement('div');
fromto.className = 'mobile-chat-fromto';
fromto.textContent = entry.senderName || `ID ${entry.sender_id}`;
const text = document.createElement('div');
text.className = 'mobile-chat-text';
text.textContent = entry.text;
card.append(meta, fromto, text);
cont.appendChild(card);
});
cont.scrollTop = cont.scrollHeight;
}
function playSound() {
try {
if (audioCtx.state === 'suspended') audioCtx.resume();
const osc = audioCtx.createOscillator();
const gain = audioCtx.createGain();
osc.connect(gain);
gain.connect(audioCtx.destination);
osc.frequency.setValueAtTime(880, audioCtx.currentTime);
osc.frequency.exponentialRampToValueAtTime(440, audioCtx.currentTime + 0.15);
gain.gain.setValueAtTime(0.1, audioCtx.currentTime);
gain.gain.exponentialRampToValueAtTime(0.01, audioCtx.currentTime + 0.3);
osc.start(audioCtx.currentTime);
osc.stop(audioCtx.currentTime + 0.3);
} catch(e) {}
}
function showChatPopup(text) {
// Try to show notification if possible
if ('Notification' in window && Notification.permission === 'granted') {
try { new Notification('CMBNet Nachricht', {body: text}); } catch(e) {}
} else if ('Notification' in window && Notification.permission !== 'denied') {
Notification.requestPermission();
}
}
function extractText(msg) {
if (!msg) return '';
if (typeof msg === 'object') {
if (msg.text) return String(msg.text);
if (msg.msg) return extractText(msg.msg);
return '';
}
if (typeof msg === 'string') {
try {
const p = JSON.parse(msg);
if (typeof p === 'object') return extractText(p);
} catch(e) {}
const idx = msg.indexOf(':');
if (idx > 0 && idx < 80) return msg.slice(idx+1).trim();
return msg;
}
return String(msg);
}
function handleWs(event) {
let message;
try { message = JSON.parse(event.data); } catch(e) { return; }
if (message.code === 0) {
state.authenticated = true;
} else if (message.code === 1) {
if (state.ws && state.ws.readyState === WebSocket.OPEN) {
state.ws.send(JSON.stringify({code: 2, msg: 'pong'}));
}
} else if (message.code === 100) {
// Street update
try {
const p = typeof message.msg === 'string' ? JSON.parse(message.msg) : message.msg;
if (p && p.street_id) {
const street = state.streetById.get(Number(p.street_id));
if (street) {
if (p.state) street.state = p.state;
if (p.group_id !== undefined) street.group_id = p.group_id;
if (state.currentStreetId == street.id && state.currentPolyline) {
state.currentPolyline.setStyle({color: STREET_COLORS[street.state] || STREET_COLORS.unbearbeitet});
}
buildStreetList();
}
}
} catch(e) {}
} else if (message.code === 300) {
// Group position
try {
const p = typeof message.msg === 'string' ? JSON.parse(message.msg) : message.msg;
const gid = Number(p.group_id || message.receiver_id);
const g = state.groupById.get(gid);
if (g && p.lat && p.lon) {
g.last_lat = p.lat; g.last_lon = p.lon;
if (viewMode === 'mobile_dispatcher') showAllGroupPositions();
}
} catch(e) {}
} else if (message.code === 2000 || message.code === 1000 || message.code === 1100) {
// Chat messages
const text = extractText(message.msg);
const entry = {
sender_id: message.sender_id,
code: message.code,
ts: message.ts || Date.now(),
text,
senderName: undefined
};
// For gruppe view, broker should only send relevant messages; still check
if (viewMode === 'mobile_group') {
const p = typeof message.msg === 'string' ? JSON.parse(message.msg) : message.msg;
const gid = Number(p?.group_id || message.receiver_id);
if (message.code === 1100 && gid && gid !== state.currentGroupId) {
return; // should not happen if broker filters, but be safe
}
if (message.code === 2000 && gid && gid !== state.currentGroupId && message.sender_id !== currentAccountId) {
// Check if it's from our group
const isFromOurGroup = state.groups.some(g => g.account_id && false); // simplified
}
}
const wasEmpty = state.chatMessages.length === 0;
addChatEntry(entry);
if (Number(message.sender_id) !== currentAccountId) {
playSound();
showChatPopup(text);
// Switch to chat tab
document.querySelectorAll('.mobile-tab').forEach(b => {
if (b.dataset.tab === 'chat') b.click();
});
}
}
}
window.openMobileStreetSelect = openStreetSelectDialog;
window.closeMobileStreetSelect = closeMobileStreetSelect;
window.closeMobileStreetState = closeMobileStreetState;
window.saveMobileStreetState = saveMobileStreetState;
window.closeMobileSettings = closeMobileSettings;
+119 -3
View File
@@ -1,8 +1,124 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}Dispatcher Mobil - CMBNet{% endblock %} {% block title %}Dispatcher Mobil - {{ session.tenant_code }} - CMBNet{% endblock %}
{% block body_class %}mobile-page{% endblock %}
{% block head %}
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" href="{{ url_for('static', filename='css/pico.min.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/leaflet.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/mobile.css') }}">
{% endblock %}
{% block logo %}{% endblock %}
{% block content %} {% block content %}
<h1>Dispatcher Mobil View</h1> <div class="mobile-app">
<p>Wird später implementiert</p> <header class="mobile-header">
<div class="mobile-header-row">
<select id="mobileGroupSelect" class="mobile-group-select" aria-label="Gruppe auswählen"></select>
<button type="button" id="mobileLogout" class="mobile-icon-btn" aria-label="Abmelden" title="Abmelden">⏻</button>
</div>
</header>
<nav class="mobile-tabs" role="tablist">
<button type="button" class="mobile-tab active" data-tab="map" role="tab" aria-selected="true">Karte</button>
<button type="button" class="mobile-tab" data-tab="chat" role="tab" aria-selected="false">Chat</button>
</nav>
<main class="mobile-main">
<section id="tab-map" class="mobile-tab-panel active" role="tabpanel">
<div id="mobileMap" class="mobile-map"></div>
<button type="button" id="mobileTodoBtn" class="mobile-fab" title="ToDo-Liste" aria-label="ToDo-Liste">📋</button>
<button type="button" id="mobileSettingsBtn" class="mobile-fab mobile-fab-secondary" title="Einstellungen" aria-label="Einstellungen">⚙</button>
<button type="button" id="mobileWorkBtn" class="mobile-work-btn" title="Straße bearbeiten" aria-label="Straße bearbeiten">Bearbeiten</button>
</section>
<section id="tab-chat" class="mobile-tab-panel" role="tabpanel">
<div id="mobileChatMessages" class="mobile-chat-messages"></div>
<form id="mobileChatForm" class="mobile-chat-form">
<input type="text" id="mobileChatInput" class="mobile-chat-input" placeholder="Nachricht senden ..." autocomplete="off">
<button type="submit" class="mobile-chat-send">Senden</button>
</form>
</section>
</main>
</div>
<dialog id="mobileStreetSelectDialog">
<article>
<header>
<h3>Zugeteilte Straßen</h3>
</header>
<div class="dialog-body">
<p class="mobile-dialog-hint">Wähle eine Straße aus, um sie auf der Karte zu bearbeiten.</p>
<ul id="mobileStreetList" class="mobile-street-list"></ul>
</div>
<footer>
<button type="button" class="secondary" onclick="closeMobileStreetSelect()">Schließen</button>
</footer>
</article>
</dialog>
<dialog id="mobileStreetStateDialog">
<article>
<header>
<h3 id="mobileStreetStateTitle">Straße bearbeiten</h3>
</header>
<div class="dialog-body">
<label>Status
<select id="mobileStreetStateSelect">
<option value="unbearbeitet">unbearbeitet</option>
<option value="zugewiesen">zugewiesen</option>
<option value="erledigt">erledigt</option>
</select>
</label>
<label id="mobileStreetGroupLabel">Gruppe
<select id="mobileStreetGroupSelect"></select>
</label>
</div>
<footer>
<button type="button" class="secondary" onclick="closeMobileStreetState()">Abbrechen</button>
<button type="button" onclick="saveMobileStreetState()">Speichern</button>
</footer>
</article>
</dialog>
<dialog id="mobileSettingsDialog">
<article>
<header>
<h3>Einstellungen</h3>
</header>
<div class="dialog-body">
<label>Opazität <output id="mobileOpacityValue">0.70</output>
<input id="mobileOpacitySlider" type="range" min="0" max="1" step="0.05" value="0.7">
</label>
<label>Linienbreite (m) <output id="mobileWeightValue">20 m</output>
<input id="mobileWeightSlider" type="range" min="1" max="100" step="1" value="20">
</label>
<label>Hintergrundkarte
<select id="mobileBaseLayerSelect">
<option value="osm">OpenStreetMap</option>
<option value="aerial">Luftbild</option>
</select>
</label>
</div>
<footer>
<button type="button" onclick="closeMobileSettings()">Schließen</button>
</footer>
</article>
</dialog>
{% endblock %}
{% block scripts %}
<script>
window.CMBNET_TENANT = {{ session.tenant_code|tojson }};
window.CMBNET_ACCOUNT_ID = {{ session.account_id|tojson }};
window.CMBNET_ROLE = {{ session.role|tojson }};
window.CMBNET_LOGOUT_URL = {{ url_for('auth.logout', tenant=session.tenant_code)|tojson }};
window.CMBNET_VIEW_MODE = 'mobile_dispatcher';
</script>
<script src="{{ url_for('static', filename='js/leaflet.js') }}"></script>
<script src="{{ url_for('static', filename='js/str2pl.js') }}"></script>
<script src="{{ url_for('static', filename='js/views/mobile.js') }}"></script>
{% endblock %} {% endblock %}
+119 -4
View File
@@ -1,9 +1,124 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}Gruppen View - CMBNet{% endblock %} {% block title %}Gruppen View - {{ session.tenant_code }} - CMBNet{% endblock %}
{% block body_class %}mobile-page{% endblock %}
{% block head %}
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" href="{{ url_for('static', filename='css/pico.min.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/leaflet.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/mobile.css') }}">
{% endblock %}
{% block logo %}{% endblock %}
{% block content %} {% block content %}
<h1>Gruppen View</h1> <div class="mobile-app">
<p>Willkommen, {{ session.username }}</p> <header class="mobile-header">
<p><a href="{{ url_for('auth.logout', tenant=session.tenant_code) }}">Abmelden</a></p> <div class="mobile-header-row">
<div class="mobile-group-name" id="groupNameDisplay">Gruppe</div>
<button type="button" id="mobileLogout" class="mobile-icon-btn" aria-label="Abmelden" title="Abmelden">⏻</button>
</div>
</header>
<nav class="mobile-tabs" role="tablist">
<button type="button" class="mobile-tab active" data-tab="map" role="tab" aria-selected="true">Karte</button>
<button type="button" class="mobile-tab" data-tab="chat" role="tab" aria-selected="false">Chat</button>
</nav>
<main class="mobile-main">
<section id="tab-map" class="mobile-tab-panel active" role="tabpanel">
<div id="mobileMap" class="mobile-map"></div>
<button type="button" id="mobileTodoBtn" class="mobile-fab" title="ToDo-Liste" aria-label="ToDo-Liste">📋</button>
<button type="button" id="mobileSettingsBtn" class="mobile-fab mobile-fab-secondary" title="Einstellungen" aria-label="Einstellungen">⚙</button>
<button type="button" id="mobileWorkBtn" class="mobile-work-btn" title="Straße bearbeiten" aria-label="Straße bearbeiten">Bearbeiten</button>
</section>
<section id="tab-chat" class="mobile-tab-panel" role="tabpanel">
<div id="mobileChatMessages" class="mobile-chat-messages"></div>
<form id="mobileChatForm" class="mobile-chat-form">
<input type="text" id="mobileChatInput" class="mobile-chat-input" placeholder="Nachricht senden ..." autocomplete="off">
<button type="submit" class="mobile-chat-send">Senden</button>
</form>
</section>
</main>
</div>
<dialog id="mobileStreetSelectDialog">
<article>
<header>
<h3>Zugeteilte Straßen</h3>
</header>
<div class="dialog-body">
<p class="mobile-dialog-hint">Wähle eine Straße aus, um sie auf der Karte zu bearbeiten.</p>
<ul id="mobileStreetList" class="mobile-street-list"></ul>
</div>
<footer>
<button type="button" class="secondary" onclick="closeMobileStreetSelect()">Schließen</button>
</footer>
</article>
</dialog>
<dialog id="mobileStreetStateDialog">
<article>
<header>
<h3 id="mobileStreetStateTitle">Straße bearbeiten</h3>
</header>
<div class="dialog-body">
<label>Status
<select id="mobileStreetStateSelect">
<option value="unbearbeitet">unbearbeitet</option>
<option value="zugewiesen">zugewiesen</option>
<option value="erledigt">erledigt</option>
</select>
</label>
<label id="mobileStreetGroupLabel">Gruppe
<select id="mobileStreetGroupSelect"></select>
</label>
</div>
<footer>
<button type="button" class="secondary" onclick="closeMobileStreetState()">Abbrechen</button>
<button type="button" onclick="saveMobileStreetState()">Speichern</button>
</footer>
</article>
</dialog>
<dialog id="mobileSettingsDialog">
<article>
<header>
<h3>Einstellungen</h3>
</header>
<div class="dialog-body">
<label>Opazität <output id="mobileOpacityValue">0.70</output>
<input id="mobileOpacitySlider" type="range" min="0" max="1" step="0.05" value="0.7">
</label>
<label>Linienbreite (m) <output id="mobileWeightValue">20 m</output>
<input id="mobileWeightSlider" type="range" min="1" max="100" step="1" value="20">
</label>
<label>Hintergrundkarte
<select id="mobileBaseLayerSelect">
<option value="osm">OpenStreetMap</option>
<option value="aerial">Luftbild</option>
</select>
</label>
</div>
<footer>
<button type="button" onclick="closeMobileSettings()">Schließen</button>
</footer>
</article>
</dialog>
{% endblock %}
{% block scripts %}
<script>
window.CMBNET_TENANT = {{ session.tenant_code|tojson }};
window.CMBNET_ACCOUNT_ID = {{ session.account_id|tojson }};
window.CMBNET_ROLE = {{ session.role|tojson }};
window.CMBNET_LOGOUT_URL = {{ url_for('auth.logout', tenant=session.tenant_code)|tojson }};
window.CMBNET_VIEW_MODE = 'mobile_group';
</script>
<script src="{{ url_for('static', filename='js/leaflet.js') }}"></script>
<script src="{{ url_for('static', filename='js/str2pl.js') }}"></script>
<script src="{{ url_for('static', filename='js/views/mobile.js') }}"></script>
{% endblock %} {% endblock %}