Eigenposition mit Richtung und Gruppen Dialog im mobilen View

This commit is contained in:
concierge committed 2026-11-06 11:49:29 +01:00
1 parent 18278fdf43
commit 821461bc07
6 files changed
+95 -29

No files matched your search

+24 -3
View File
@@ -420,6 +420,21 @@ html[data-theme="dark"] .mobile-chat-card.own {
overflow-wrap: anywhere;
}
.mobile-group-info-list {
display: grid;
grid-template-columns: max-content 1fr;
gap: 0.35rem 1rem;
margin: 0;
}
.mobile-group-info-list dt {
font-weight: 600;
}
.mobile-group-info-list dd {
margin: 0;
}
.mobile-settings-row {
display: flex;
align-items: center;
@@ -447,10 +462,16 @@ html[data-theme="dark"] .mobile-chat-card.own {
color: #fff;
}
.mobile-user-marker {
.mobile-user-marker,
.mobile-user-marker.leaflet-marker-icon,
.mobile-user-marker.leaflet-div-icon {
position: relative;
width: 16px;
height: 16px;
overflow: visible;
border: 0 !important;
background: transparent !important;
box-shadow: none !important;
}
.mobile-user-dot {
@@ -474,9 +495,9 @@ html[data-theme="dark"] .mobile-chat-card.own {
border-radius: 999px;
background: #2563eb;
box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.85);
transform-origin: 50% 100%;
transform: translate(-50%, -100%) rotate(0deg);
pointer-events: none;
transform: translate(-50%, -100%) rotate(var(--user-heading, 0deg));
transform-origin: 50% 100%;
}
.mobile-group-marker {
+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-v18';
const VERSION = 'cmbnet-pwa-v19';
const BASE = new URL('./', self.location).href;
const SHELL_CACHE = `${VERSION}-shell`;
const TILE_CACHE = `${VERSION}-tiles`;
+49 -25
View File
@@ -21,6 +21,8 @@ const DEFAULT_SETTINGS = {
const AUTO_POSITION_INTERVAL_MS = 30000;
const NAVIGATION_MAX_AGE_MS = 30 * 60 * 1000;
const NAVIGATION_REFRESH_MS = 15000;
const GROUP_POSITION_LIVE_MS = 30 * 1000;
const GROUP_POSITION_RECENT_MS = 5 * 60 * 1000;
const WS_OUTBOX_LIMIT = 200;
const STREET_STATES = ['unbearbeitet', 'zugewiesen', 'erledigt'];
@@ -52,7 +54,6 @@ const state = {
chatMessages: [],
chatKeys: new Set(),
userMarker: null,
userHeadingLine: null,
userHeading: null,
lastCompassHeading: null,
lastCompassAt: 0,
@@ -782,10 +783,8 @@ async function loadGroupData(groupId) {
console.error(e);
}
// Show all group positions like observer (only for dispatcher mobile)
if (viewMode === 'mobile_dispatcher') {
showAllGroupPositions();
}
// Gruppenpositionen in allen mobilen Ansichten anzeigen.
showAllGroupPositions();
}
function indexStreets() {
@@ -1041,16 +1040,14 @@ function startGeolocation() {
map.removeLayer(state.userMarker);
state.userMarker = null;
}
state.userHeadingLine = null;
const icon = L.divIcon({
className: 'mobile-user-marker',
html: '<div class="mobile-user-heading" id="mobileUserHeading" hidden></div><div class="mobile-user-dot"></div>',
html: '<div class="mobile-user-heading"></div><div class="mobile-user-dot"></div>',
iconSize: [16, 16],
iconAnchor: [8, 8]
});
state.userMarker = L.marker(map.getCenter(), {icon, interactive: false}).addTo(map);
state.userHeadingLine = document.getElementById('mobileUserHeading');
applyUserHeading(state.userHeading);
state.watchId = navigator.geolocation.watchPosition((pos) => {
@@ -1099,11 +1096,10 @@ function applyUserHeading(heading) {
if (normalized === null) return;
state.userHeading = normalized;
const line = state.userHeadingLine;
if (!line) return;
line.hidden = false;
line.style.transform = `translate(-50%, -100%) rotate(${normalized}deg)`;
const markerElement = state.userMarker && state.userMarker.getElement();
if (markerElement) {
markerElement.style.setProperty('--user-heading', `${normalized}deg`);
}
}
function bearingBetween(from, to) {
@@ -1197,7 +1193,7 @@ function setupDeviceOrientation() {
console.warn('Kompassfreigabe nicht erteilt.', error);
});
};
document.addEventListener('pointerdown', requestPermission, {once: true, passive: true});
document.addEventListener('click', requestPermission, {once: true, passive: true});
} else {
addListeners();
}
@@ -1220,9 +1216,7 @@ function showAllGroupPositions() {
iconAnchor: [16, 16]
});
const marker = L.marker([lat, lon], {icon}).addTo(map);
if (viewMode === 'mobile_dispatcher') {
marker.on('click', () => focusGroupFromMarker(group.id));
}
marker.on('click', () => openMobileGroupInfo(group.id));
state.groupMarkers.set(group.id, marker);
}
});
@@ -1230,19 +1224,49 @@ function showAllGroupPositions() {
updateNavigationButton();
}
async function focusGroupFromMarker(groupId) {
if (viewMode !== 'mobile_dispatcher') return;
function formatGroupPositionAge(group, now = Date.now()) {
const timestamp = getGroupPositionTimestamp(group);
if (!timestamp) return 'unbekannt';
const age = Math.max(0, now - timestamp);
if (age <= GROUP_POSITION_LIVE_MS) return 'live';
if (age <= GROUP_POSITION_RECENT_MS) return 'aktuell';
const totalMinutes = Math.floor(age / 60000);
const hours = Math.floor(totalMinutes / 60);
const minutes = totalMinutes % 60;
return `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')} alt`;
}
function openMobileGroupInfo(groupId) {
const group = state.groupById.get(Number(groupId));
if (!group) return;
if (Number(state.currentGroupId) !== Number(group.id)) {
await loadGroupData(group.id);
const alias = String(group.aliasname || '').trim();
const aliasElement = document.getElementById('mobileGroupInfoAlias');
if (aliasElement) {
aliasElement.textContent = alias || `Gruppe ${group.id}`;
}
const coordinates = getGroupCoordinates(group);
if (!coordinates) return;
map.setView([coordinates.lat, coordinates.lon], Math.max(map.getZoom(), 15));
const ageElement = document.getElementById('mobileGroupInfoAge');
if (ageElement) {
ageElement.textContent = formatGroupPositionAge(group);
const timestamp = getGroupPositionTimestamp(group);
ageElement.title = timestamp
? `Letzte Positionsmeldung: ${new Date(timestamp).toLocaleString('de-DE')}`
: 'Keine Positionsmeldung vorhanden';
}
const dialog = document.getElementById('mobileGroupInfoDialog');
if (dialog && !dialog.open) {
if (typeof dialog.showModal === 'function') dialog.showModal();
else dialog.show();
}
}
function closeMobileGroupInfo() {
const dialog = document.getElementById('mobileGroupInfoDialog');
if (dialog && dialog.open) dialog.close();
}
function getGroupColor(id) {
@@ -1790,7 +1814,7 @@ function handleWs(event) {
g.last_lon = lon;
g.last_pos_ts = parseFlexibleTimestamp(p.ts) || Date.now();
g.last_pos_at = new Date(g.last_pos_ts).toISOString();
if (viewMode === 'mobile_dispatcher') showAllGroupPositions();
showAllGroupPositions();
} else if (!g) {
console.warn('[WS] Code 300: Gruppe nicht im lokalen Zustand', p);
}