diff --git a/README.md b/README.md index e02fc10..33587f4 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ A lightweight web interface for meshcore-cli, providing browser-based access to - **Advanced sorting:** Sort contacts by name (A-Z/Z-A) or last advertisement time (newest/oldest) - **Smart filtering:** Search by name/key, filter by contact type (CLI, REP, ROOM, SENS) - **Activity indicators:** Visual status icons (🟢 active, 🟡 recent, 🔴 inactive) based on last advertisement + - **GPS location:** View contact location on Google Maps (when GPS coordinates available) - **Cleanup tool:** Remove inactive contacts with configurable threshold (moved from Settings) - 📦 **Message archiving** - Automatic daily archiving with browse-by-date selector - ⚡ **Efficient polling** - Lightweight update checks every 10s, UI refreshes only when needed diff --git a/app/static/js/contacts.js b/app/static/js/contacts.js index e2b1933..c4aa776 100644 --- a/app/static/js/contacts.js +++ b/app/static/js/contacts.js @@ -974,13 +974,23 @@ function createExistingContactCard(contact, index) { copyBtn.innerHTML = ' 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 = ' 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 = ' 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;