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

+7
View File
@@ -413,6 +413,13 @@ html[data-theme="dark"] .mobile-chat-card.own {
font-size: 0.85rem;
}
.mobile-notification-text {
margin: 0;
font-size: 1rem;
white-space: pre-wrap;
overflow-wrap: anywhere;
}
.mobile-settings-row {
display: flex;
align-items: center;
+1 -1
View File
@@ -5,7 +5,7 @@
* damit er sowohl die mobilen Views als auch die statischen Assets
* kontrolliert. Der Cache-Name wird pro App-Wurzel gebildet.
*/
const VERSION = 'cmbnet-pwa-v11';
const VERSION = 'cmbnet-pwa-v12';
const BASE = new URL('./', self.location).href;
const SHELL_CACHE = `${VERSION}-shell`;
const TILE_CACHE = `${VERSION}-tiles`;
+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;
@@ -0,0 +1,14 @@
<dialog id="mobileNotificationDialog" aria-labelledby="mobileNotificationTitle">
<article>
<header>
<h3 id="mobileNotificationTitle">Neue Nachricht</h3>
</header>
<div class="dialog-body">
<p id="mobileNotificationText" class="mobile-notification-text"></p>
</div>
<footer>
<button type="button" class="secondary" onclick="closeMobileNotification()">Schließen</button>
<button type="button" onclick="openMobileChatFromNotification()">Zum Chat</button>
</footer>
</article>
</dialog>
+9 -1
View File
@@ -46,7 +46,14 @@
<path fill="currentColor" d="M21.71 2.29a1 1 0 0 0-1.05-.24l-18 7a1 1 0 0 0 .06 1.87l7.16 2.2 2.2 7.16a1 1 0 0 0 1.87.06l7-18a1 1 0 0 0-.24-1.05Z"/>
</svg>
</button>
<button type="button" id="mobileTodoBtn" class="mobile-fab" title="ToDo-Liste" aria-label="ToDo-Liste">📋</button>
<button type="button" id="mobileTodoBtn" class="mobile-fab" title="ToDo-Liste" aria-label="ToDo-Liste">
<svg viewBox="0 0 24 24" width="22" height="22" aria-hidden="true" focusable="false">
<rect x="3.5" y="3.5" width="17" height="17" rx="3"
fill="none" stroke="currentColor" stroke-width="2"/>
<path d="M7.5 12.5l3 3 6-6" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</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>
@@ -128,6 +135,7 @@
</footer>
</article>
</dialog>
{% include "_mobile_notification_dialog.html" %}
{% include "_pwa_install_dialog.html" %}
{% endblock %}
+9 -1
View File
@@ -42,7 +42,14 @@
<div id="mobileMap" class="mobile-map"></div>
<button type="button" id="mobileSendPositionBtn" class="mobile-position-btn"
title="Eigenposition jetzt senden" aria-label="Eigenposition jetzt senden" hidden>Position senden</button>
<button type="button" id="mobileTodoBtn" class="mobile-fab" title="ToDo-Liste" aria-label="ToDo-Liste">📋</button>
<button type="button" id="mobileTodoBtn" class="mobile-fab" title="ToDo-Liste" aria-label="ToDo-Liste">
<svg viewBox="0 0 24 24" width="22" height="22" aria-hidden="true" focusable="false">
<rect x="3.5" y="3.5" width="17" height="17" rx="3"
fill="none" stroke="currentColor" stroke-width="2"/>
<path d="M7.5 12.5l3 3 6-6" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</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>
@@ -133,6 +140,7 @@
</footer>
</article>
</dialog>
{% include "_mobile_notification_dialog.html" %}
{% include "_pwa_install_dialog.html" %}
{% endblock %}