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
@@ -420,6 +420,21 @@ html[data-theme="dark"] .mobile-chat-card.own {
|
|||||||
overflow-wrap: anywhere;
|
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 {
|
.mobile-settings-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -447,10 +462,16 @@ html[data-theme="dark"] .mobile-chat-card.own {
|
|||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mobile-user-marker {
|
.mobile-user-marker,
|
||||||
|
.mobile-user-marker.leaflet-marker-icon,
|
||||||
|
.mobile-user-marker.leaflet-div-icon {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
|
overflow: visible;
|
||||||
|
border: 0 !important;
|
||||||
|
background: transparent !important;
|
||||||
|
box-shadow: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mobile-user-dot {
|
.mobile-user-dot {
|
||||||
@@ -474,9 +495,9 @@ html[data-theme="dark"] .mobile-chat-card.own {
|
|||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
background: #2563eb;
|
background: #2563eb;
|
||||||
box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.85);
|
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;
|
pointer-events: none;
|
||||||
|
transform: translate(-50%, -100%) rotate(var(--user-heading, 0deg));
|
||||||
|
transform-origin: 50% 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mobile-group-marker {
|
.mobile-group-marker {
|
||||||
|
|||||||
@@ -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-v18';
|
const VERSION = 'cmbnet-pwa-v19';
|
||||||
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`;
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ const DEFAULT_SETTINGS = {
|
|||||||
const AUTO_POSITION_INTERVAL_MS = 30000;
|
const AUTO_POSITION_INTERVAL_MS = 30000;
|
||||||
const NAVIGATION_MAX_AGE_MS = 30 * 60 * 1000;
|
const NAVIGATION_MAX_AGE_MS = 30 * 60 * 1000;
|
||||||
const NAVIGATION_REFRESH_MS = 15000;
|
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 WS_OUTBOX_LIMIT = 200;
|
||||||
|
|
||||||
const STREET_STATES = ['unbearbeitet', 'zugewiesen', 'erledigt'];
|
const STREET_STATES = ['unbearbeitet', 'zugewiesen', 'erledigt'];
|
||||||
@@ -52,7 +54,6 @@ const state = {
|
|||||||
chatMessages: [],
|
chatMessages: [],
|
||||||
chatKeys: new Set(),
|
chatKeys: new Set(),
|
||||||
userMarker: null,
|
userMarker: null,
|
||||||
userHeadingLine: null,
|
|
||||||
userHeading: null,
|
userHeading: null,
|
||||||
lastCompassHeading: null,
|
lastCompassHeading: null,
|
||||||
lastCompassAt: 0,
|
lastCompassAt: 0,
|
||||||
@@ -782,10 +783,8 @@ async function loadGroupData(groupId) {
|
|||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show all group positions like observer (only for dispatcher mobile)
|
// Gruppenpositionen in allen mobilen Ansichten anzeigen.
|
||||||
if (viewMode === 'mobile_dispatcher') {
|
showAllGroupPositions();
|
||||||
showAllGroupPositions();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function indexStreets() {
|
function indexStreets() {
|
||||||
@@ -1041,16 +1040,14 @@ function startGeolocation() {
|
|||||||
map.removeLayer(state.userMarker);
|
map.removeLayer(state.userMarker);
|
||||||
state.userMarker = null;
|
state.userMarker = null;
|
||||||
}
|
}
|
||||||
state.userHeadingLine = null;
|
|
||||||
|
|
||||||
const icon = L.divIcon({
|
const icon = L.divIcon({
|
||||||
className: 'mobile-user-marker',
|
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],
|
iconSize: [16, 16],
|
||||||
iconAnchor: [8, 8]
|
iconAnchor: [8, 8]
|
||||||
});
|
});
|
||||||
state.userMarker = L.marker(map.getCenter(), {icon, interactive: false}).addTo(map);
|
state.userMarker = L.marker(map.getCenter(), {icon, interactive: false}).addTo(map);
|
||||||
state.userHeadingLine = document.getElementById('mobileUserHeading');
|
|
||||||
applyUserHeading(state.userHeading);
|
applyUserHeading(state.userHeading);
|
||||||
|
|
||||||
state.watchId = navigator.geolocation.watchPosition((pos) => {
|
state.watchId = navigator.geolocation.watchPosition((pos) => {
|
||||||
@@ -1099,11 +1096,10 @@ function applyUserHeading(heading) {
|
|||||||
if (normalized === null) return;
|
if (normalized === null) return;
|
||||||
|
|
||||||
state.userHeading = normalized;
|
state.userHeading = normalized;
|
||||||
const line = state.userHeadingLine;
|
const markerElement = state.userMarker && state.userMarker.getElement();
|
||||||
if (!line) return;
|
if (markerElement) {
|
||||||
|
markerElement.style.setProperty('--user-heading', `${normalized}deg`);
|
||||||
line.hidden = false;
|
}
|
||||||
line.style.transform = `translate(-50%, -100%) rotate(${normalized}deg)`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function bearingBetween(from, to) {
|
function bearingBetween(from, to) {
|
||||||
@@ -1197,7 +1193,7 @@ function setupDeviceOrientation() {
|
|||||||
console.warn('Kompassfreigabe nicht erteilt.', error);
|
console.warn('Kompassfreigabe nicht erteilt.', error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
document.addEventListener('pointerdown', requestPermission, {once: true, passive: true});
|
document.addEventListener('click', requestPermission, {once: true, passive: true});
|
||||||
} else {
|
} else {
|
||||||
addListeners();
|
addListeners();
|
||||||
}
|
}
|
||||||
@@ -1220,9 +1216,7 @@ function showAllGroupPositions() {
|
|||||||
iconAnchor: [16, 16]
|
iconAnchor: [16, 16]
|
||||||
});
|
});
|
||||||
const marker = L.marker([lat, lon], {icon}).addTo(map);
|
const marker = L.marker([lat, lon], {icon}).addTo(map);
|
||||||
if (viewMode === 'mobile_dispatcher') {
|
marker.on('click', () => openMobileGroupInfo(group.id));
|
||||||
marker.on('click', () => focusGroupFromMarker(group.id));
|
|
||||||
}
|
|
||||||
state.groupMarkers.set(group.id, marker);
|
state.groupMarkers.set(group.id, marker);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1230,19 +1224,49 @@ function showAllGroupPositions() {
|
|||||||
updateNavigationButton();
|
updateNavigationButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function focusGroupFromMarker(groupId) {
|
function formatGroupPositionAge(group, now = Date.now()) {
|
||||||
if (viewMode !== 'mobile_dispatcher') return;
|
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));
|
const group = state.groupById.get(Number(groupId));
|
||||||
if (!group) return;
|
if (!group) return;
|
||||||
|
|
||||||
if (Number(state.currentGroupId) !== Number(group.id)) {
|
const alias = String(group.aliasname || '').trim();
|
||||||
await loadGroupData(group.id);
|
const aliasElement = document.getElementById('mobileGroupInfoAlias');
|
||||||
|
if (aliasElement) {
|
||||||
|
aliasElement.textContent = alias || `Gruppe ${group.id}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const coordinates = getGroupCoordinates(group);
|
const ageElement = document.getElementById('mobileGroupInfoAge');
|
||||||
if (!coordinates) return;
|
if (ageElement) {
|
||||||
map.setView([coordinates.lat, coordinates.lon], Math.max(map.getZoom(), 15));
|
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) {
|
function getGroupColor(id) {
|
||||||
@@ -1790,7 +1814,7 @@ function handleWs(event) {
|
|||||||
g.last_lon = lon;
|
g.last_lon = lon;
|
||||||
g.last_pos_ts = parseFlexibleTimestamp(p.ts) || Date.now();
|
g.last_pos_ts = parseFlexibleTimestamp(p.ts) || Date.now();
|
||||||
g.last_pos_at = new Date(g.last_pos_ts).toISOString();
|
g.last_pos_at = new Date(g.last_pos_ts).toISOString();
|
||||||
if (viewMode === 'mobile_dispatcher') showAllGroupPositions();
|
showAllGroupPositions();
|
||||||
} else if (!g) {
|
} else if (!g) {
|
||||||
console.warn('[WS] Code 300: Gruppe nicht im lokalen Zustand', p);
|
console.warn('[WS] Code 300: Gruppe nicht im lokalen Zustand', p);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<dialog id="mobileGroupInfoDialog" aria-labelledby="mobileGroupInfoTitle">
|
||||||
|
<article>
|
||||||
|
<header>
|
||||||
|
<button class="close" type="button" aria-label="Schließen" onclick="closeMobileGroupInfo()"></button>
|
||||||
|
<h3 id="mobileGroupInfoTitle">Gruppenposition</h3>
|
||||||
|
</header>
|
||||||
|
<div class="dialog-body">
|
||||||
|
<dl class="mobile-group-info-list">
|
||||||
|
<dt>Aliasname</dt>
|
||||||
|
<dd id="mobileGroupInfoAlias">–</dd>
|
||||||
|
<dt>Aktualität</dt>
|
||||||
|
<dd id="mobileGroupInfoAge">–</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
<footer>
|
||||||
|
<button type="button" onclick="closeMobileGroupInfo()">Schließen</button>
|
||||||
|
</footer>
|
||||||
|
</article>
|
||||||
|
</dialog>
|
||||||
@@ -136,6 +136,7 @@
|
|||||||
</article>
|
</article>
|
||||||
</dialog>
|
</dialog>
|
||||||
{% include "_mobile_notification_dialog.html" %}
|
{% include "_mobile_notification_dialog.html" %}
|
||||||
|
{% include "_mobile_group_info_dialog.html" %}
|
||||||
{% include "_pwa_install_dialog.html" %}
|
{% include "_pwa_install_dialog.html" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
@@ -141,6 +141,7 @@
|
|||||||
</article>
|
</article>
|
||||||
</dialog>
|
</dialog>
|
||||||
{% include "_mobile_notification_dialog.html" %}
|
{% include "_mobile_notification_dialog.html" %}
|
||||||
|
{% include "_mobile_group_info_dialog.html" %}
|
||||||
{% include "_pwa_install_dialog.html" %}
|
{% include "_pwa_install_dialog.html" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user