Eigenposition mit Richtung und Gruppen Dialog im mobilen View
This commit is contained in:
1 parent
18278fdf43
commit
821461bc07
6 files changed
+95
-29
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user