mirror of
https://github.com/MarekWo/mc-webui.git
synced 2026-05-02 03:22:40 +02:00
feat(contacts): Add Map button to open GPS location in Google Maps
Add Map button between Copy Key and Delete buttons on existing contacts cards. Button appears only when contact has GPS coordinates (adv_lat/adv_lon != 0). Opens contact location in Google Maps in new tab. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -974,13 +974,23 @@ function createExistingContactCard(contact, index) {
|
||||
copyBtn.innerHTML = '<i class="bi bi-clipboard"></i> Copy Key';
|
||||
copyBtn.onclick = () => copyContactKey(contact.public_key_prefix, copyBtn);
|
||||
|
||||
actionsDiv.appendChild(copyBtn);
|
||||
|
||||
// Map button (only if GPS coordinates available)
|
||||
if (contact.adv_lat && contact.adv_lon && (contact.adv_lat !== 0 || contact.adv_lon !== 0)) {
|
||||
const mapBtn = document.createElement('button');
|
||||
mapBtn.className = 'btn btn-sm btn-outline-primary';
|
||||
mapBtn.innerHTML = '<i class="bi bi-geo-alt"></i> Map';
|
||||
mapBtn.onclick = () => openGoogleMaps(contact.adv_lat, contact.adv_lon);
|
||||
actionsDiv.appendChild(mapBtn);
|
||||
}
|
||||
|
||||
// Delete button
|
||||
const deleteBtn = document.createElement('button');
|
||||
deleteBtn.className = 'btn btn-sm btn-outline-danger';
|
||||
deleteBtn.innerHTML = '<i class="bi bi-trash"></i> Delete';
|
||||
deleteBtn.onclick = () => showDeleteModal(contact);
|
||||
|
||||
actionsDiv.appendChild(copyBtn);
|
||||
actionsDiv.appendChild(deleteBtn);
|
||||
|
||||
// Assemble card
|
||||
@@ -1014,6 +1024,14 @@ function copyContactKey(publicKeyPrefix, buttonEl) {
|
||||
});
|
||||
}
|
||||
|
||||
function openGoogleMaps(lat, lon) {
|
||||
// Create Google Maps URL with coordinates
|
||||
const mapsUrl = `https://www.google.com/maps?q=${lat},${lon}`;
|
||||
|
||||
// Open in new tab
|
||||
window.open(mapsUrl, '_blank');
|
||||
}
|
||||
|
||||
function showDeleteModal(contact) {
|
||||
contactToDelete = contact;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user