diff --git a/backend/model/DiskMangerTask.ts b/backend/model/DiskMangerTask.ts index e6f9dc93..12000da2 100644 --- a/backend/model/DiskMangerTask.ts +++ b/backend/model/DiskMangerTask.ts @@ -40,12 +40,7 @@ export const diskManagerTask = (input: DiskManagerTask.PoolInput, done) => { const metadata: PhotoMetadata = { keywords: {}, cameraData: {}, - positionData: { - GPSData: {}, - country: null, - state: null, - city: null - }, + positionData: null, size: {}, creationDate: {} }; @@ -63,12 +58,14 @@ export const diskManagerTask = (input: DiskManagerTask.PoolInput, done) => { focalLength: exif.tags.FocalLength, lens: exif.tags.LensModel, }; - metadata.positionData.GPSData = { - latitude: exif.tags.GPSLatitude, - longitude: exif.tags.GPSLongitude, - altitude: exif.tags.GPSAltitude - - }; + if (!isNaN(exif.tags.GPSLatitude) || exif.tags.GPSLongitude || exif.tags.GPSAltitude) { + metadata.positionData = metadata.positionData || {}; + metadata.positionData.GPSData = { + latitude: exif.tags.GPSLatitude, + longitude: exif.tags.GPSLongitude, + altitude: exif.tags.GPSAltitude + }; + } metadata.size = {width: exif.imageSize.width, height: exif.imageSize.height}; } catch (err) { @@ -89,9 +86,12 @@ export const diskManagerTask = (input: DiskManagerTask.PoolInput, done) => { return s.join(""); }; - metadata.positionData.country = iptcData.country_or_primary_location_name; - metadata.positionData.state = iptcData.province_or_state; - metadata.positionData.city = iptcData.city; + if (iptcData.country_or_primary_location_name || iptcData.province_or_state || iptcData.city) { + metadata.positionData = metadata.positionData || {}; + metadata.positionData.country = iptcData.country_or_primary_location_name; + metadata.positionData.state = iptcData.province_or_state; + metadata.positionData.city = iptcData.city; + } metadata.keywords = (iptcData.keywords || []).map((s: string) => decode(s)); diff --git a/frontend/app/gallery/gallery.component.html b/frontend/app/gallery/gallery.component.html index 9f50c87a..6c277217 100644 --- a/frontend/app/gallery/gallery.component.html +++ b/frontend/app/gallery/gallery.component.html @@ -11,7 +11,7 @@ - + @@ -29,7 +29,7 @@ - +
diff --git a/frontend/app/gallery/gallery.component.ts b/frontend/app/gallery/gallery.component.ts index 283b9e3d..175f954c 100644 --- a/frontend/app/gallery/gallery.component.ts +++ b/frontend/app/gallery/gallery.component.ts @@ -7,6 +7,7 @@ import {GallerySearchComponent} from "./search/search.gallery.component"; import {SearchTypes} from "../../../common/entities/AutoCompleteItem"; import {Config} from "../../../common/config/public/Config"; import {DirectoryDTO} from "../../../common/entities/DirectoryDTO"; +import {SearchResultDTO} from "../../../common/entities/SearchResult"; @Component({ selector: 'gallery', @@ -20,6 +21,7 @@ export class GalleryComponent implements OnInit { public showSearchBar: boolean = true; public directories: DirectoryDTO[] = []; + public isPhotoWithLocation = false; constructor(public _galleryService: GalleryService, private _authService: AuthenticationService, @@ -39,8 +41,23 @@ export class GalleryComponent implements OnInit { const dirSorter = (a: DirectoryDTO, b: DirectoryDTO) => { return a.name.localeCompare(b.name); }; - const dirs = (content.searchResult || content.directory || {directories: []}).directories; - this.directories = dirs.sort(dirSorter); + + const tmp = (content.searchResult || content.directory || { + directories: [], + photos: [] + }); + this.directories = tmp.directories.sort(dirSorter); + this.isPhotoWithLocation = false; + for (let i = 0; i < tmp.photos.length; i++) { + if (tmp.photos[i].metadata && + tmp.photos[i].metadata.positionData && + tmp.photos[i].metadata.positionData.GPSData && + tmp.photos[i].metadata.positionData.GPSData.longitude + ) { + this.isPhotoWithLocation = true; + break; + } + } }); this._route.params @@ -72,6 +89,7 @@ export class GalleryComponent implements OnInit { } + onLightboxLastElement() { this.grid.renderARow(); }