diff --git a/frontend/src/app/pages/places.vue b/frontend/src/app/pages/places.vue index 9d07029a9..5cb50fd3d 100644 --- a/frontend/src/app/pages/places.vue +++ b/frontend/src/app/pages/places.vue @@ -42,13 +42,14 @@ return { zoom: 15, position: null, - center: L.latLng(52.5259279, 13.414496), + center: L.latLng(0, 0), url: 'https://{s}.tile.osm.org/{z}/{x}/{y}.png', attribution: '© OpenStreetMap contributors', options: { icon: { - iconSize: [40, 40] - } + iconSize: [50, 50] + }, + minZoom: 3, }, photos: [], results: [], @@ -57,7 +58,7 @@ q: q, }, offset: 0, - pageSize: 100, + pageSize: 101, lastQuery: {}, bounds: null, minLat: null, @@ -74,7 +75,7 @@ if ("geolocation" in navigator) { const self = this; this.$alert.success('Finding your position...'); - navigator.geolocation.getCurrentPosition(function(position) { + navigator.geolocation.getCurrentPosition(function (position) { self.center = L.latLng(position.coords.latitude, position.coords.longitude); self.position = L.latLng(position.coords.latitude, position.coords.longitude); }); @@ -96,19 +97,19 @@ this.maxLong = null; }, fitBoundingBox(lat, long) { - if(this.maxLat === null || lat > this.maxLat) { + if (this.maxLat === null || lat > this.maxLat) { this.maxLat = lat; } - if(this.minLat === null || lat < this.minLat) { + if (this.minLat === null || lat < this.minLat) { this.minLat = lat; } - if(this.maxLong === null || long > this.maxLong) { + if (this.maxLong === null || long > this.maxLong) { this.maxLong = long; } - if(this.minLong === null || long < this.minLong) { + if (this.minLong === null || long < this.minLong) { this.minLong = long; } }, @@ -152,8 +153,11 @@ this.center = photos[0].location; this.bounds = [[this.maxLat, this.minLong], [this.minLat, this.maxLong]]; - this.$alert.info(photos.length + ' photos found'); - + if (photos.length > 100) { + this.$alert.info('More than 100 photos found'); + } else { + this.$alert.info(photos.length + ' photos found'); + } }, refreshList() { @@ -169,6 +173,7 @@ const params = { count: this.pageSize, offset: this.offset, + location: 1, }; Object.assign(params, this.query); @@ -187,9 +192,5 @@ this.refreshList(); }, }; - - /* L.icon({ - html: '
', - className: 'leaflet-marker-photo' }), */ diff --git a/internal/forms/photo_search.go b/internal/forms/photo_search.go index fc37df176..b0288ee1a 100644 --- a/internal/forms/photo_search.go +++ b/internal/forms/photo_search.go @@ -7,6 +7,7 @@ import ( // Query parameters for GET /api/v1/photos type PhotoSearchForm struct { Query string `form:"q"` + Location bool `form:"location"` Tags string `form:"tags"` Cat string `form:"cat"` Country string `form:"country"` diff --git a/internal/photoprism/search.go b/internal/photoprism/search.go index 2f16ae7aa..d8d170453 100644 --- a/internal/photoprism/search.go +++ b/internal/photoprism/search.go @@ -118,7 +118,14 @@ func (s *Search) Photos(form forms.PhotoSearchForm) ([]PhotoSearchResult, error) Where("photos.deleted_at IS NULL AND files.file_missing = 0"). Group("photos.id, files.id") - if form.Query != "" { + if form.Location == true { + q = q.Where("location_id > 0") + + if form.Query != "" { + likeString := "%" + strings.ToLower(form.Query) + "%" + q = q.Where("LOWER(locations.loc_display_name) LIKE ?", likeString) + } + } else if form.Query != "" { likeString := "%" + strings.ToLower(form.Query) + "%" q = q.Where("tags.tag_label LIKE ? OR LOWER(photo_title) LIKE ? OR LOWER(files.file_main_color) LIKE ?", likeString, likeString, likeString) }