mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
Fix trips when Immich integration is not configured
This commit is contained in:
parent
d0c66b68ac
commit
ce88452be0
4 changed files with 45 additions and 14 deletions
10
CHANGELOG.md
10
CHANGELOG.md
|
|
@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
|
# 0.18.1 - 2024-11-29
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed a bug where the trips interface was breaking when Immich integration is not configured.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Flash messages are now being shown on the map when Immich integration is not configured.
|
||||||
|
|
||||||
# 0.18.0 - 2024-11-28
|
# 0.18.0 - 2024-11-28
|
||||||
|
|
||||||
## The Trips release
|
## The Trips release
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,14 @@ export default class extends Controller {
|
||||||
this.map.addControl(this.drawControl);
|
this.map.addControl(this.drawControl);
|
||||||
}
|
}
|
||||||
if (e.name === 'Photos') {
|
if (e.name === 'Photos') {
|
||||||
|
if (!this.userSettings.immich_url || !this.userSettings.immich_api_key) {
|
||||||
|
showFlashMessage(
|
||||||
|
'error',
|
||||||
|
'Immich integration is not configured. Please check your settings.'
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
const startDate = urlParams.get('start_at')?.split('T')[0] || new Date().toISOString().split('T')[0];
|
const startDate = urlParams.get('start_at')?.split('T')[0] || new Date().toISOString().split('T')[0];
|
||||||
const endDate = urlParams.get('end_at')?.split('T')[0] || new Date().toISOString().split('T')[0];
|
const endDate = urlParams.get('end_at')?.split('T')[0] || new Date().toISOString().split('T')[0];
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import { esriWorldTopoMapLayer } from "../maps/layers"
|
||||||
import { esriWorldImageryMapLayer } from "../maps/layers"
|
import { esriWorldImageryMapLayer } from "../maps/layers"
|
||||||
import { esriWorldGrayCanvasMapLayer } from "../maps/layers"
|
import { esriWorldGrayCanvasMapLayer } from "../maps/layers"
|
||||||
import { fetchAndDisplayPhotos } from '../maps/helpers';
|
import { fetchAndDisplayPhotos } from '../maps/helpers';
|
||||||
|
import { showFlashMessage } from "../maps/helpers";
|
||||||
|
|
||||||
export default class extends Controller {
|
export default class extends Controller {
|
||||||
static targets = ["container", "startedAt", "endedAt"]
|
static targets = ["container", "startedAt", "endedAt"]
|
||||||
|
|
@ -77,22 +78,32 @@ export default class extends Controller {
|
||||||
|
|
||||||
// Add event listener for layer changes
|
// Add event listener for layer changes
|
||||||
this.map.on('overlayadd', (e) => {
|
this.map.on('overlayadd', (e) => {
|
||||||
if (e.name === 'Photos' && this.coordinates?.length > 0) {
|
if (e.name !== 'Photos') return;
|
||||||
const firstCoord = this.coordinates[0];
|
|
||||||
const lastCoord = this.coordinates[this.coordinates.length - 1];
|
|
||||||
|
|
||||||
const startDate = new Date(firstCoord[4] * 1000).toISOString().split('T')[0];
|
if (!this.userSettings.immich_url || !this.userSettings.immich_api_key) {
|
||||||
const endDate = new Date(lastCoord[4] * 1000).toISOString().split('T')[0];
|
showFlashMessage(
|
||||||
|
'error',
|
||||||
fetchAndDisplayPhotos({
|
'Immich integration is not configured. Please check your settings.'
|
||||||
map: this.map,
|
);
|
||||||
photoMarkers: this.photoMarkers,
|
return;
|
||||||
apiKey: this.apiKey,
|
|
||||||
startDate: startDate,
|
|
||||||
endDate: endDate,
|
|
||||||
userSettings: this.userSettings
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.coordinates?.length) return;
|
||||||
|
|
||||||
|
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];
|
||||||
|
|
||||||
|
fetchAndDisplayPhotos({
|
||||||
|
map: this.map,
|
||||||
|
photoMarkers: this.photoMarkers,
|
||||||
|
apiKey: this.apiKey,
|
||||||
|
startDate: startDate,
|
||||||
|
endDate: endDate,
|
||||||
|
userSettings: this.userSettings
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add markers and route
|
// Add markers and route
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ class Trip < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def photos
|
def photos
|
||||||
|
return [] if user.settings['immich_url'].blank? || user.settings['immich_api_key'].blank?
|
||||||
|
|
||||||
immich_photos = Immich::RequestPhotos.new(
|
immich_photos = Immich::RequestPhotos.new(
|
||||||
user,
|
user,
|
||||||
start_date: started_at.to_date.to_s,
|
start_date: started_at.to_date.to_s,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue