From f8d64daf00b90b66bd2f3ace52529a0bcbdf3c02 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Sat, 27 Nov 2021 09:30:29 +0100 Subject: [PATCH] Places: Reduce GeoJON response size --- assets/templates/minimal.tmpl | 4 ---- assets/templates/share.tmpl | 6 +----- frontend/src/model/thumb.js | 4 ++++ frontend/src/pages/places.vue | 2 +- internal/search/geojson.go | 2 +- internal/search/geojson_result.go | 11 +++-------- 6 files changed, 10 insertions(+), 19 deletions(-) diff --git a/assets/templates/minimal.tmpl b/assets/templates/minimal.tmpl index 120455251..ab44e0dd4 100644 --- a/assets/templates/minimal.tmpl +++ b/assets/templates/minimal.tmpl @@ -17,10 +17,6 @@ - {{template "app.tmpl" .}} diff --git a/assets/templates/share.tmpl b/assets/templates/share.tmpl index a4a9c410d..4747b9ce2 100644 --- a/assets/templates/share.tmpl +++ b/assets/templates/share.tmpl @@ -30,11 +30,7 @@ window.__CONFIG__ = {{ .config }}; - - + {{template "app.tmpl" .}} diff --git a/frontend/src/model/thumb.js b/frontend/src/model/thumb.js index 0541cedf4..df0a56464 100644 --- a/frontend/src/model/thumb.js +++ b/frontend/src/model/thumb.js @@ -171,6 +171,10 @@ export class Thumb extends Model { return new this(result); } + static wrap(data) { + return data.map((values) => new this(values)); + } + static fromFiles(photos) { let result = []; diff --git a/frontend/src/pages/places.vue b/frontend/src/pages/places.vue index 8730670c7..384a28acd 100644 --- a/frontend/src/pages/places.vue +++ b/frontend/src/pages/places.vue @@ -220,7 +220,7 @@ export default { return Api.get("geo/view", options).then((r) => { if (r && r.data && r.data.length > 0) { // Show photos. - this.$viewer.show(r.data, 0); + this.$viewer.show(Thumb.wrap(r.data), 0); } else { // Don't open viewer if nothing was found. this.$notify.warn(this.$gettext("No pictures found")); diff --git a/internal/search/geojson.go b/internal/search/geojson.go index 6395d52d4..0c9b4e99a 100644 --- a/internal/search/geojson.go +++ b/internal/search/geojson.go @@ -49,7 +49,7 @@ func Geo(f form.SearchGeo) (results GeoResults, err error) { s = s.Table("photos"). Select(`photos.id, photos.photo_uid, photos.photo_type, photos.photo_lat, photos.photo_lng, - photos.photo_title, photos.photo_description, photos.photo_favorite, photos.taken_at_local, + photos.photo_title, photos.photo_description, photos.photo_favorite, photos.taken_at, photos.taken_at_local, files.file_hash, files.file_width, files.file_height`). Joins(`JOIN files ON files.photo_id = photos.id AND files.file_missing = 0 AND files.file_primary AND files.deleted_at IS NULL`). diff --git a/internal/search/geojson_result.go b/internal/search/geojson_result.go index 55a420f0a..505f5ef2a 100644 --- a/internal/search/geojson_result.go +++ b/internal/search/geojson_result.go @@ -22,7 +22,8 @@ type GeoResult struct { FileHash string `json:"Hash"` FileWidth int `json:"Width"` FileHeight int `json:"Height"` - TakenAtLocal time.Time `json:"TakenAt"` + TakenAt time.Time `json:"TakenAt"` + TakenAtLocal time.Time `json:"TakenAtLocal"` } // Lat returns the position latitude. @@ -65,16 +66,10 @@ func (photos GeoResults) GeoJSON() ([]byte, error) { props := gin.H{ "UID": p.PhotoUID, "Hash": p.FileHash, - "Width": p.FileWidth, - "Height": p.FileHeight, - "TakenAt": p.TakenAtLocal, + "TakenAt": p.TakenAt, "Title": p.PhotoTitle, } - if p.PhotoDescription != "" { - props["Description"] = p.PhotoDescription - } - if p.PhotoType != entity.TypeImage && p.PhotoType != entity.TypeDefault { props["Type"] = p.PhotoType }