Backup/Restore + Nadel mit QR, Debug Firebase
This commit is contained in:
1 parent
4c8b11c4d5
commit
c51ef02f88
16 files changed
+634
-7
No files matched your search
@@ -26,6 +26,9 @@ const DEFAULT_SETTINGS = {
|
||||
const STREET_STATES = ['unbearbeitet', 'zugewiesen', 'erledigt'];
|
||||
const GROUP_STATES = ['offen', 'unterwegs', 'online', 'pausierend', 'fertig'];
|
||||
const GROUP_MARKER_MAX_AGE_SECONDS = 30 * 60;
|
||||
const GROUP_POSITION_ZOOM_DEFAULT = 18;
|
||||
const GROUP_POSITION_ZOOM_MIN = 1;
|
||||
const GROUP_POSITION_ZOOM_MAX = 22;
|
||||
const GROUP_STREET_HOVER_COLOR = '#f5c518';
|
||||
const STREET_COLORS = {
|
||||
unbearbeitet: '#1f6feb',
|
||||
@@ -1417,10 +1420,119 @@ async function saveGroupAssignments() {
|
||||
}
|
||||
}
|
||||
|
||||
function groupPositionZoomLevel() {
|
||||
const configured = Number(window.CMBNET_GROUP_POSITION_ZOOM);
|
||||
if (!Number.isFinite(configured)) return GROUP_POSITION_ZOOM_DEFAULT;
|
||||
return Math.min(
|
||||
GROUP_POSITION_ZOOM_MAX,
|
||||
Math.max(GROUP_POSITION_ZOOM_MIN, Math.round(configured))
|
||||
);
|
||||
}
|
||||
|
||||
function buildGroupPositionShare(group) {
|
||||
const lat = Number(group.last_lat);
|
||||
const lon = Number(group.last_lon);
|
||||
const mapsUrl = `https://www.google.com/maps?q=${lat.toFixed(6)},${lon.toFixed(6)}`;
|
||||
const text = `Position von ${groupDisplayName(group)}: ${mapsUrl}`;
|
||||
return {
|
||||
lat,
|
||||
lon,
|
||||
mapsUrl,
|
||||
whatsappUrl: `https://api.whatsapp.com/send?text=${encodeURIComponent(text)}`
|
||||
};
|
||||
}
|
||||
|
||||
function openGroupPositionSharePopup(group) {
|
||||
let marker = dispatcherState.markersByGroupId.get(Number(group.id));
|
||||
if (!marker) {
|
||||
marker = createGroupMarker(group, [
|
||||
Number(group.last_lat),
|
||||
Number(group.last_lon)
|
||||
]);
|
||||
}
|
||||
if (!marker) return;
|
||||
|
||||
const share = buildGroupPositionShare(group);
|
||||
const container = document.createElement('div');
|
||||
container.className = 'group-position-share';
|
||||
|
||||
const title = document.createElement('div');
|
||||
title.className = 'group-position-share-title';
|
||||
title.textContent = groupDisplayName(group);
|
||||
|
||||
const coordinates = document.createElement('div');
|
||||
coordinates.className = 'group-position-share-coords';
|
||||
coordinates.textContent = `${share.lat.toFixed(5)}, ${share.lon.toFixed(5)}`;
|
||||
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.className = 'group-position-share-qr';
|
||||
canvas.width = 200;
|
||||
canvas.height = 200;
|
||||
canvas.setAttribute(
|
||||
'aria-label',
|
||||
`QR-Code zum Teilen der Position von ${groupDisplayName(group)} über WhatsApp`
|
||||
);
|
||||
|
||||
let qrRendered = false;
|
||||
if (typeof QRious !== 'undefined') {
|
||||
try {
|
||||
new QRious({
|
||||
element: canvas,
|
||||
value: share.whatsappUrl,
|
||||
size: 200,
|
||||
level: 'M'
|
||||
});
|
||||
qrRendered = true;
|
||||
} catch (error) {
|
||||
console.error('QRious error', error);
|
||||
}
|
||||
}
|
||||
|
||||
const links = document.createElement('div');
|
||||
links.className = 'group-position-share-links';
|
||||
const whatsappLink = document.createElement('a');
|
||||
whatsappLink.href = share.whatsappUrl;
|
||||
whatsappLink.target = '_blank';
|
||||
whatsappLink.rel = 'noopener';
|
||||
whatsappLink.textContent = 'Per WhatsApp teilen';
|
||||
const separator = document.createTextNode(' · ');
|
||||
const mapsLink = document.createElement('a');
|
||||
mapsLink.href = share.mapsUrl;
|
||||
mapsLink.target = '_blank';
|
||||
mapsLink.rel = 'noopener';
|
||||
mapsLink.textContent = 'Kartenlink';
|
||||
links.append(whatsappLink, separator, mapsLink);
|
||||
|
||||
container.append(title, coordinates);
|
||||
if (qrRendered) {
|
||||
container.appendChild(canvas);
|
||||
} else {
|
||||
const fallback = document.createElement('p');
|
||||
fallback.textContent = 'QR-Code nicht verfügbar.';
|
||||
container.appendChild(fallback);
|
||||
}
|
||||
container.appendChild(links);
|
||||
|
||||
marker.bindPopup(container, {
|
||||
className: 'group-position-share-popup',
|
||||
minWidth: 210,
|
||||
maxWidth: 250,
|
||||
autoClose: false,
|
||||
closeOnClick: false,
|
||||
closeButton: true,
|
||||
offset: [0, -6]
|
||||
});
|
||||
marker.openPopup();
|
||||
}
|
||||
|
||||
function locateGroup(groupId) {
|
||||
const group = dispatcherState.groupById.get(Number(groupId));
|
||||
if (!group || !hasPosition(group)) return;
|
||||
map.setView([Number(group.last_lat), Number(group.last_lon)], 15);
|
||||
map.setView(
|
||||
[Number(group.last_lat), Number(group.last_lon)],
|
||||
groupPositionZoomLevel()
|
||||
);
|
||||
openGroupPositionSharePopup(group);
|
||||
}
|
||||
|
||||
function toggleCrosshair(groupId) {
|
||||
|
||||
Reference in new issue
Block a user