mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
Fix photos fetching with trip dates
This commit is contained in:
parent
9c102c1de8
commit
6e9c981329
3 changed files with 33 additions and 7 deletions
|
|
@ -43,7 +43,6 @@ export default class extends Controller {
|
|||
|
||||
// Add event listener for coordinates updates
|
||||
this.element.addEventListener('coordinates-updated', (event) => {
|
||||
console.log("Coordinates updated:", event.detail.coordinates)
|
||||
this.updateMapWithCoordinates(event.detail.coordinates)
|
||||
})
|
||||
}
|
||||
|
|
@ -84,6 +83,15 @@ export default class extends Controller {
|
|||
this.map.on('overlayadd', (e) => {
|
||||
if (e.name !== 'Photos') return;
|
||||
|
||||
const startedAt = this.element.dataset.started_at;
|
||||
const endedAt = this.element.dataset.ended_at;
|
||||
|
||||
console.log('Dataset values:', {
|
||||
startedAt,
|
||||
endedAt,
|
||||
path: this.element.dataset.path
|
||||
});
|
||||
|
||||
if ((!this.userSettings.immich_url || !this.userSettings.immich_api_key) && (!this.userSettings.photoprism_url || !this.userSettings.photoprism_api_key)) {
|
||||
showFlashMessage(
|
||||
'error',
|
||||
|
|
@ -92,13 +100,26 @@ export default class extends Controller {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!this.coordinates?.length) return;
|
||||
// Try to get dates from coordinates first, then fall back to path data
|
||||
let startDate, endDate;
|
||||
|
||||
const firstCoord = this.coordinates[0];
|
||||
const lastCoord = this.coordinates[this.coordinates.length - 1];
|
||||
|
||||
const startDate = new Date(firstCoord[4] * 1000).toISOString().split('T')[0];
|
||||
const endDate = new Date(lastCoord[4] * 1000).toISOString().split('T')[0];
|
||||
if (this.coordinates?.length) {
|
||||
const firstCoord = this.coordinates[0];
|
||||
const lastCoord = this.coordinates[this.coordinates.length - 1];
|
||||
startDate = new Date(firstCoord[4] * 1000).toISOString().split('T')[0];
|
||||
endDate = new Date(lastCoord[4] * 1000).toISOString().split('T')[0];
|
||||
} else if (startedAt && endedAt) {
|
||||
// Parse the dates and format them correctly
|
||||
startDate = new Date(startedAt).toISOString().split('T')[0];
|
||||
endDate = new Date(endedAt).toISOString().split('T')[0];
|
||||
} else {
|
||||
console.log('No date range available for photos');
|
||||
showFlashMessage(
|
||||
'error',
|
||||
'No date range available for photos. Please ensure the trip has start and end dates.'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
fetchAndDisplayPhotos({
|
||||
map: this.map,
|
||||
|
|
@ -174,6 +195,7 @@ export default class extends Controller {
|
|||
|
||||
const popupContent = createPopupContent(coord, this.timezone, this.distanceUnit)
|
||||
marker.bindPopup(popupContent)
|
||||
marker.addTo(this.polylinesLayer)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
data-api_key="<%= current_user.api_key %>"
|
||||
data-user_settings="<%= current_user.settings.to_json %>"
|
||||
data-path="<%= trip.path.to_json %>"
|
||||
data-started_at="<%= trip.started_at %>"
|
||||
data-ended_at="<%= trip.ended_at %>"
|
||||
data-timezone="<%= Rails.configuration.time_zone %>">
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
data-api_key="<%= current_user.api_key %>"
|
||||
data-user_settings="<%= current_user.settings.to_json %>"
|
||||
data-path="<%= @trip.path.to_json %>"
|
||||
data-started_at="<%= @trip.started_at %>"
|
||||
data-ended_at="<%= @trip.ended_at %>"
|
||||
data-timezone="<%= Rails.configuration.time_zone %>">
|
||||
<div data-trips-target="container" class="h-[25rem] w-full min-h-screen">
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue