From 4d9030e8fbe8dcfd53ec2251930d1a600fc68762 Mon Sep 17 00:00:00 2001 From: sedum Date: Thu, 1 Dec 2022 10:28:48 +0100 Subject: [PATCH 1/9] draft --- server/api/controller/settings.js | 2 ++ server/helpers.js | 2 ++ store/index.js | 2 ++ 3 files changed, 6 insertions(+) diff --git a/server/api/controller/settings.js b/server/api/controller/settings.js index b2f96bcc..f07acaa2 100644 --- a/server/api/controller/settings.js +++ b/server/api/controller/settings.js @@ -30,6 +30,8 @@ const defaultSettings = { allow_recurrent_event: false, recurrent_event_visible: false, allow_geolocation: true, + // geocoding_provider: '', + // tilelayer_provider: '', enable_federation: true, enable_resources: false, hide_boosts: true, diff --git a/server/helpers.js b/server/helpers.js index cc145b54..40508f8e 100644 --- a/server/helpers.js +++ b/server/helpers.js @@ -92,6 +92,8 @@ module.exports = { hide_thumbs: settings.hide_thumbs, hide_calendar: settings.hide_calendar, allow_geolocation: settings.allow_geolocation, + // geocoding_provider: settings.geocoding_provider, + // tilelayer_provider: settings.tilelayer_provider, footerLinks: settings.footerLinks, about: settings.about } diff --git a/store/index.js b/store/index.js index c4f58fa1..f90607d4 100644 --- a/store/index.js +++ b/store/index.js @@ -9,6 +9,8 @@ export const state = () => ({ allow_recurrent_event: true, recurrent_event_visible: false, allow_geolocation: false, + // geocoding_provider: '', + // tilelayer_provider: '', enable_federation: false, enable_resources: false, hide_boosts: true, From c096a616ba77b67bccb18a1b86722b43a2b6b215 Mon Sep 17 00:00:00 2001 From: sedum Date: Fri, 2 Dec 2022 11:25:43 +0100 Subject: [PATCH 2/9] add filter by countrycodes, and allow to change geolocation providers --- components/Map.vue | 4 +- components/admin/Geolocation.vue | 157 +++++ components/admin/Settings.vue | 17 +- locales/en.json | 15 +- locales/it.json | 15 +- server/api/controller/place.js | 13 +- server/api/controller/settings.js | 6 +- server/helpers.js | 6 +- server/helpers/geolocation.js | 987 ++++++++++++++++++++++++++++++ store/index.js | 6 +- 10 files changed, 1210 insertions(+), 16 deletions(-) create mode 100644 components/admin/Geolocation.vue create mode 100644 server/helpers/geolocation.js diff --git a/components/Map.vue b/components/Map.vue index 38ef097c..4cd0b778 100644 --- a/components/Map.vue +++ b/components/Map.vue @@ -50,8 +50,8 @@ export default { data ({ $store }) { return { mdiWalk, mdiBike, mdiCar, mdiMapMarker, - url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', - attribution: 'OpenStreetMap contributors', + url: $store.state.settings.tilelayer_provider || 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + attribution: $store.state.settings.tilelayer_provider_attribution || "OpenStreetMap contributors", zoom: 14, center: [this.event.place.latitude, this.event.place.longitude], marker: { diff --git a/components/admin/Geolocation.vue b/components/admin/Geolocation.vue new file mode 100644 index 00000000..f96f9cd9 --- /dev/null +++ b/components/admin/Geolocation.vue @@ -0,0 +1,157 @@ + + diff --git a/components/admin/Settings.vue b/components/admin/Settings.vue index 938609b4..82eb3fd0 100644 --- a/components/admin/Settings.vue +++ b/components/admin/Settings.vue @@ -57,32 +57,41 @@ v-container v-card-actions v-btn(text @click='showSMTP=true') - {{$t('admin.show_smtp_setup')}} + {{$t('admin.show_smtp_setup')}} v-btn(text @click='$emit("complete")' color='primary' v-if='setup') {{$t('common.next')}} v-icon(v-text='mdiArrowRight') + v-dialog(v-model='showGeolocationConfigs' destroy-on-close max-width='700px' :fullscreen='$vuetify.breakpoint.xsOnly') + Geolocation(@close='showGeolocationConfigs = false') + + v-card-actions + v-btn(text @click='showGeolocationConfigs=true') + {{$t('admin.show_geolocation_setup')}} + + + diff --git a/components/admin/Places.vue b/components/admin/Places.vue index 78a773f5..63e14ee5 100644 --- a/components/admin/Places.vue +++ b/components/admin/Places.vue @@ -84,7 +84,8 @@ export default { { value: 'address', text: this.$t('common.address') }, { value: 'map', text: 'Map' }, { value: 'actions', text: this.$t('common.actions'), align: 'right' } - ] + ], + geocoding_provider_type: $store.state.settings.geocoding_provider_type || 'Nominatim' } }, async fetch() { @@ -124,7 +125,7 @@ export default { this.place.latitude = this.place.longitude = null } this.$emit('input', { ...this.place }) - }, + }, searchAddress: debounce(async function(ev) { const pre_searchCoordinates = ev.target.value.trim().toLowerCase() // allow pasting coordinates lat/lon and lat,lon @@ -159,7 +160,7 @@ export default { if (searchCoordinates.length) { this.loading = true - const ret = await this.$axios.$get(`placeNominatim/${searchCoordinates}`) + const ret = await this.$axios.$get(`placeOSM/${this.geocoding_provider_type}/${searchCoordinates}`) if (ret && ret.length) { this.addressList = ret.map(v => { const name = get(v.namedetails, 'alt_name', get(v.namedetails, 'name')) @@ -176,7 +177,7 @@ export default { } this.loading = false } - }, 300) + }, 300) } } diff --git a/components/admin/Settings.vue b/components/admin/Settings.vue index 82eb3fd0..b8769034 100644 --- a/components/admin/Settings.vue +++ b/components/admin/Settings.vue @@ -54,20 +54,19 @@ v-container v-dialog(v-model='showSMTP' destroy-on-close max-width='700px' :fullscreen='$vuetify.breakpoint.xsOnly') SMTP(@close='showSMTP = false') - v-card-actions v-btn(text @click='showSMTP=true') {{$t('admin.show_smtp_setup')}} - v-btn(text @click='$emit("complete")' color='primary' v-if='setup') {{$t('common.next')}} - v-icon(v-text='mdiArrowRight') v-dialog(v-model='showGeolocationConfigs' destroy-on-close max-width='700px' :fullscreen='$vuetify.breakpoint.xsOnly') - Geolocation(@close='showGeolocationConfigs = false') - + Geolocation(setup, @close='showGeolocationConfigs = false') v-card-actions v-btn(text @click='showGeolocationConfigs=true') {{$t('admin.show_geolocation_setup')}} + v-btn(text @click='$emit("complete")' color='primary' v-if='setup') {{$t('common.next')}} + v-icon(v-text='mdiArrowRight') +