Mobiles UI verbessert
This commit is contained in:
1 parent
f5b0c9509c
commit
95486c6737
6 files changed
+101
-18
No files matched your search
@@ -413,6 +413,13 @@ html[data-theme="dark"] .mobile-chat-card.own {
|
|||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mobile-notification-text {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 1rem;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
|
||||||
.mobile-settings-row {
|
.mobile-settings-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* damit er sowohl die mobilen Views als auch die statischen Assets
|
* damit er sowohl die mobilen Views als auch die statischen Assets
|
||||||
* kontrolliert. Der Cache-Name wird pro App-Wurzel gebildet.
|
* 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 BASE = new URL('./', self.location).href;
|
||||||
const SHELL_CACHE = `${VERSION}-shell`;
|
const SHELL_CACHE = `${VERSION}-shell`;
|
||||||
const TILE_CACHE = `${VERSION}-tiles`;
|
const TILE_CACHE = `${VERSION}-tiles`;
|
||||||
|
|||||||
@@ -788,9 +788,23 @@ function loadStreetPolyline(name) {
|
|||||||
const fragments = getStreetFragments();
|
const fragments = getStreetFragments();
|
||||||
const segments = fragments[name];
|
const segments = fragments[name];
|
||||||
if (!Array.isArray(segments)) return;
|
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 => {
|
segments.forEach(seg => {
|
||||||
if (!Array.isArray(seg)) return;
|
if (!Array.isArray(seg)) return;
|
||||||
|
const latlngs = [];
|
||||||
seg.forEach(pt => {
|
seg.forEach(pt => {
|
||||||
if (!Array.isArray(pt) || pt.length < 2) return;
|
if (!Array.isArray(pt) || pt.length < 2) return;
|
||||||
// try lat,lng or lng,lat
|
// 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]);
|
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]);
|
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;
|
if (!group.getLayers().length) return;
|
||||||
const street = state.streetById.get(Number(state.currentStreetId));
|
state.currentPolyline = group.addTo(map);
|
||||||
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() {
|
function clearPolylines() {
|
||||||
@@ -824,10 +837,12 @@ function updateAllPolylineStyles() {
|
|||||||
function fitToPositionAndPolyline() {
|
function fitToPositionAndPolyline() {
|
||||||
const bounds = L.latLngBounds([]);
|
const bounds = L.latLngBounds([]);
|
||||||
if (state.currentPolyline) {
|
if (state.currentPolyline) {
|
||||||
state.currentPolyline.getLatLngs().forEach(ll => {
|
// Seit der segmentweisen Darstellung ist currentPolyline eine
|
||||||
if (Array.isArray(ll)) ll.forEach(p => bounds.extend(p));
|
// FeatureGroup; getBounds() umfasst alle Teilpolylines.
|
||||||
else bounds.extend(ll);
|
const polylineBounds = typeof state.currentPolyline.getBounds === 'function'
|
||||||
});
|
? state.currentPolyline.getBounds()
|
||||||
|
: null;
|
||||||
|
if (polylineBounds && polylineBounds.isValid()) bounds.extend(polylineBounds);
|
||||||
}
|
}
|
||||||
if (state.userMarker) {
|
if (state.userMarker) {
|
||||||
bounds.extend(state.userMarker.getLatLng());
|
bounds.extend(state.userMarker.getLatLng());
|
||||||
@@ -1146,7 +1161,7 @@ function setMobileWsStatus(label, status) {
|
|||||||
const element = document.getElementById('mobileWsStatus');
|
const element = document.getElementById('mobileWsStatus');
|
||||||
if (!element) return;
|
if (!element) return;
|
||||||
|
|
||||||
element.textContent = `WS: ${label}`;
|
element.textContent = `CMB ${label}`;
|
||||||
element.title = `WebSocket: ${label}`;
|
element.title = `WebSocket: ${label}`;
|
||||||
element.classList.remove('is-connected', 'is-connecting', 'is-disconnected', 'is-error');
|
element.classList.remove('is-connected', 'is-connecting', 'is-disconnected', 'is-error');
|
||||||
element.classList.add(`is-${status}`);
|
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) {
|
function extractText(msg) {
|
||||||
if (!msg) return '';
|
if (!msg) return '';
|
||||||
if (typeof msg === 'object') {
|
if (typeof msg === 'object') {
|
||||||
@@ -1551,7 +1592,7 @@ function handleWs(event) {
|
|||||||
console.warn('[WS] Code 300: Gruppe nicht im lokalen Zustand', p);
|
console.warn('[WS] Code 300: Gruppe nicht im lokalen Zustand', p);
|
||||||
}
|
}
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
} else if (message.code === 2000 || message.code === 1000 || message.code === 1100) {
|
} else if (Number(message.code) >= 1000) {
|
||||||
// Chat messages
|
// Chat messages
|
||||||
const payload = parseMessagePayload(message.msg);
|
const payload = parseMessagePayload(message.msg);
|
||||||
const text = extractText(payload ?? message.msg);
|
const text = extractText(payload ?? message.msg);
|
||||||
@@ -1565,18 +1606,21 @@ function handleWs(event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const senderName = getSenderName(message, payload);
|
||||||
addChatEntry({
|
addChatEntry({
|
||||||
sender_id: message.sender_id,
|
sender_id: message.sender_id,
|
||||||
code: message.code,
|
code: message.code,
|
||||||
ts: normalizeTs(message.ts) || Date.now(),
|
ts: normalizeTs(message.ts) || Date.now(),
|
||||||
text,
|
text,
|
||||||
fromName: getSenderName(message, payload),
|
fromName: senderName,
|
||||||
toName: getReceiverName(message, payload)
|
toName: getReceiverName(message, payload)
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Number(message.sender_id) !== currentAccountId) {
|
if (Number(message.sender_id) !== currentAccountId) {
|
||||||
playSound();
|
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.saveMobileStreetState = saveMobileStreetState;
|
||||||
window.closeMobileSettings = closeMobileSettings;
|
window.closeMobileSettings = closeMobileSettings;
|
||||||
window.closeMobileInstall = closeMobileInstall;
|
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>
|
||||||
@@ -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"/>
|
<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>
|
</svg>
|
||||||
</button>
|
</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="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>
|
<button type="button" id="mobileWorkBtn" class="mobile-work-btn" title="Straße bearbeiten" aria-label="Straße bearbeiten">Bearbeiten</button>
|
||||||
</section>
|
</section>
|
||||||
@@ -128,6 +135,7 @@
|
|||||||
</footer>
|
</footer>
|
||||||
</article>
|
</article>
|
||||||
</dialog>
|
</dialog>
|
||||||
|
{% include "_mobile_notification_dialog.html" %}
|
||||||
{% include "_pwa_install_dialog.html" %}
|
{% include "_pwa_install_dialog.html" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,14 @@
|
|||||||
<div id="mobileMap" class="mobile-map"></div>
|
<div id="mobileMap" class="mobile-map"></div>
|
||||||
<button type="button" id="mobileSendPositionBtn" class="mobile-position-btn"
|
<button type="button" id="mobileSendPositionBtn" class="mobile-position-btn"
|
||||||
title="Eigenposition jetzt senden" aria-label="Eigenposition jetzt senden" hidden>Position senden</button>
|
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="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>
|
<button type="button" id="mobileWorkBtn" class="mobile-work-btn" title="Straße bearbeiten" aria-label="Straße bearbeiten">Bearbeiten</button>
|
||||||
</section>
|
</section>
|
||||||
@@ -133,6 +140,7 @@
|
|||||||
</footer>
|
</footer>
|
||||||
</article>
|
</article>
|
||||||
</dialog>
|
</dialog>
|
||||||
|
{% include "_mobile_notification_dialog.html" %}
|
||||||
{% include "_pwa_install_dialog.html" %}
|
{% include "_pwa_install_dialog.html" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user