Mobiles UI verbessert

This commit is contained in:
concierge committed 2026-11-03 17:19:25 +01:00
1 parent f5b0c9509c
commit 95486c6737
6 files changed
+101 -18

No files matched your search

+61 -15
View File
@@ -788,9 +788,23 @@ function loadStreetPolyline(name) {
const fragments = getStreetFragments();
const segments = fragments[name];
if (!Array.isArray(segments)) return;
const latlngs = [];
const street = state.streetById.get(Number(state.currentStreetId));
const color = STREET_COLORS[street?.state] || STREET_COLORS.unbearbeitet;
const style = {
color,
opacity: state.settings.opacity,
weight: state.settings.weight,
lineCap: 'round',
lineJoin: 'round'
};
// Jedes Segment wird als eigene Polyline gezeichnet. Eine gemeinsame
// LatLng-Liste würde die Segmentgrenzen mit einer zusätzlichen Linie
// verbinden, die im Straßenverlauf nicht existiert.
const group = L.featureGroup();
segments.forEach(seg => {
if (!Array.isArray(seg)) return;
const latlngs = [];
seg.forEach(pt => {
if (!Array.isArray(pt) || pt.length < 2) return;
// try lat,lng or lng,lat
@@ -799,13 +813,12 @@ function loadStreetPolyline(name) {
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) {
L.polyline(latlngs, style).addTo(group);
}
});
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);
if (!group.getLayers().length) return;
state.currentPolyline = group.addTo(map);
}
function clearPolylines() {
@@ -824,10 +837,12 @@ function updateAllPolylineStyles() {
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);
});
// Seit der segmentweisen Darstellung ist currentPolyline eine
// FeatureGroup; getBounds() umfasst alle Teilpolylines.
const polylineBounds = typeof state.currentPolyline.getBounds === 'function'
? state.currentPolyline.getBounds()
: null;
if (polylineBounds && polylineBounds.isValid()) bounds.extend(polylineBounds);
}
if (state.userMarker) {
bounds.extend(state.userMarker.getLatLng());
@@ -1146,7 +1161,7 @@ function setMobileWsStatus(label, status) {
const element = document.getElementById('mobileWsStatus');
if (!element) return;
element.textContent = `WS: ${label}`;
element.textContent = `CMB ${label}`;
element.title = `WebSocket: ${label}`;
element.classList.remove('is-connected', 'is-connecting', 'is-disconnected', 'is-error');
element.classList.add(`is-${status}`);
@@ -1332,6 +1347,32 @@ async function showChatPopup(text, senderName) {
}
}
function showIncomingChatDialog(text, senderName) {
const dialog = document.getElementById('mobileNotificationDialog');
if (!dialog) return;
const title = document.getElementById('mobileNotificationTitle');
const body = document.getElementById('mobileNotificationText');
if (title) title.textContent = senderName || 'Neue Nachricht';
if (body) body.textContent = text || '';
if (!dialog.open) {
if (typeof dialog.showModal === 'function') dialog.showModal();
else if (typeof dialog.show === 'function') dialog.show();
}
}
function closeMobileNotification() {
const dialog = document.getElementById('mobileNotificationDialog');
if (dialog && dialog.open) dialog.close();
}
function openMobileChatFromNotification() {
closeMobileNotification();
const chatTab = document.querySelector('.mobile-tab[data-tab="chat"]');
if (chatTab) chatTab.click();
}
function extractText(msg) {
if (!msg) return '';
if (typeof msg === 'object') {
@@ -1551,7 +1592,7 @@ function handleWs(event) {
console.warn('[WS] Code 300: Gruppe nicht im lokalen Zustand', p);
}
} catch(e) {}
} else if (message.code === 2000 || message.code === 1000 || message.code === 1100) {
} else if (Number(message.code) >= 1000) {
// Chat messages
const payload = parseMessagePayload(message.msg);
const text = extractText(payload ?? message.msg);
@@ -1565,18 +1606,21 @@ function handleWs(event) {
}
}
const senderName = getSenderName(message, payload);
addChatEntry({
sender_id: message.sender_id,
code: message.code,
ts: normalizeTs(message.ts) || Date.now(),
text,
fromName: getSenderName(message, payload),
fromName: senderName,
toName: getReceiverName(message, payload)
});
if (Number(message.sender_id) !== currentAccountId) {
playSound();
showChatPopup(text, getSenderName(message, payload));
// In-App-Dialog und, sofern erlaubt, Systembenachrichtigung.
showIncomingChatDialog(text, senderName);
showChatPopup(text, senderName);
}
}
}
@@ -1587,3 +1631,5 @@ window.closeMobileStreetState = closeMobileStreetState;
window.saveMobileStreetState = saveMobileStreetState;
window.closeMobileSettings = closeMobileSettings;
window.closeMobileInstall = closeMobileInstall;
window.closeMobileNotification = closeMobileNotification;
window.openMobileChatFromNotification = openMobileChatFromNotification;