rename gelocation, and move the request to nominatim server side

This commit is contained in:
sedum
2022-09-08 20:37:20 +02:00
parent dcdefec6de
commit 6e182b5de1
8 changed files with 28 additions and 28 deletions

View File

@@ -30,7 +30,7 @@ v-row
:label="$t('common.address')" :label="$t('common.address')"
@change="changeAddress" @change="changeAddress"
:value="value.address") :value="value.address")
v-combobox.mr-4(ref='detailsView' v-if='settings.allow_geolocalization' v-combobox.mr-4(ref='detailsView' v-if='settings.allow_geolocation'
:prepend-icon='mdiMapSearch' :prepend-icon='mdiMapSearch'
:disabled='disableDetails' :disabled='disableDetails'
@input.native='searchCoordinates' @input.native='searchCoordinates'
@@ -47,7 +47,7 @@ v-row
v-list-item-content(two-line v-if='item') v-list-item-content(two-line v-if='item')
v-list-item-title(v-text='item.display_name') v-list-item-title(v-text='item.display_name')
v-list-item-subtitle(v-text='`${item.lat}`+`,`+`${item.lon}`') v-list-item-subtitle(v-text='`${item.lat}`+`,`+`${item.lon}`')
v-text-field(ref='details' v-show='false' v-if='settings.allow_geolocalization') v-text-field(ref='details' v-show='false' v-if='settings.allow_geolocation')
</template> </template>
<script> <script>
@@ -110,7 +110,7 @@ export default {
if (typeof p === 'object' && !p.create) { if (typeof p === 'object' && !p.create) {
this.place.name = p.name.trim() this.place.name = p.name.trim()
this.place.address = p.address this.place.address = p.address
if (this.settings.allow_geolocalization) { if (this.settings.allow_geolocation) {
this.place.details = p.details this.place.details = p.details
} }
this.place.id = p.id this.place.id = p.id
@@ -128,7 +128,7 @@ export default {
} else { } else {
delete this.place.id delete this.place.id
this.place.address = '' this.place.address = ''
if (this.settings.allow_geolocalization) { if (this.settings.allow_geolocation) {
this.place.details = p.details this.place.details = p.details
} }
this.disableAddress = false this.disableAddress = false
@@ -158,9 +158,12 @@ export default {
}, },
searchCoordinates: debounce(async function(ev) { searchCoordinates: debounce(async function(ev) {
this.loading = true this.loading = true
const searchCoordinates = ev.target.value.trim().toLowerCase() const pre_searchCoordinates = ev.target.value.trim().toLowerCase()
// this.detailsList = await this.$axios.$get(`placeNominatim?search=${searchCoordinates}`) // allow pasting coordinates lat/lon
this.detailsList = await this.$axios.$get(`https://nominatim.openstreetmap.org/search?limit=3&format=json&namedetails=1&q=${searchCoordinates}` ) const searchCoordinates = pre_searchCoordinates.replace('/', ',')
if (searchCoordinates.length) {
this.detailsList = await this.$axios.$get(`placeNominatim/${searchCoordinates}`)
}
if (this.detailsList) { if (this.detailsList) {
this.loading = false; this.loading = false;
} }

View File

@@ -25,7 +25,7 @@ v-container
v-model='place.address' v-model='place.address'
:placeholder='$t("common.address")') :placeholder='$t("common.address")')
v-textarea(v-if="settings.allow_geolocalization" v-textarea(v-if="settings.allow_geolocation"
row-height="15" row-height="15"
:disabled="true" :disabled="true"
:label="$t('common.details')" :label="$t('common.details')"
@@ -83,7 +83,7 @@ export default {
editPlace (item) { editPlace (item) {
this.place.name = item.name this.place.name = item.name
this.place.address = item.address this.place.address = item.address
if (this.settings.allow_geolocalization) { if (this.settings.allow_geolocation) {
this.place.details = JSON.parse(item.details) this.place.details = JSON.parse(item.details)
} }
this.place.id = item.id this.place.id = item.id

View File

@@ -48,9 +48,9 @@ v-container
inset inset
:label="$t('admin.recurrent_event_visible')") :label="$t('admin.recurrent_event_visible')")
v-switch.mt-1(v-model='allow_geolocalization' v-switch.mt-1(v-model='allow_geolocation'
inset inset
:label="$t('admin.allow_geolocalization')") :label="$t('admin.allow_geolocation')")
v-dialog(v-model='showSMTP' destroy-on-close max-width='700px' :fullscreen='$vuetify.breakpoint.xsOnly') v-dialog(v-model='showSMTP' destroy-on-close max-width='700px' :fullscreen='$vuetify.breakpoint.xsOnly')
SMTP(@close='showSMTP = false') SMTP(@close='showSMTP = false')
@@ -111,9 +111,9 @@ export default {
get () { return this.settings.recurrent_event_visible }, get () { return this.settings.recurrent_event_visible },
set (value) { this.setSetting({ key: 'recurrent_event_visible', value }) } set (value) { this.setSetting({ key: 'recurrent_event_visible', value }) }
}, },
allow_geolocalization: { allow_geolocation: {
get () { return this.settings.allow_geolocalization }, get () { return this.settings.allow_geolocation },
set (value) { this.setSetting({ key: 'allow_geolocalization', value }) } set (value) { this.setSetting({ key: 'allow_geolocation', value }) }
}, },
filteredTimezones () { filteredTimezones () {
const current_timezone = moment.tz.guess() const current_timezone = moment.tz.guess()

View File

@@ -185,7 +185,7 @@
"allow_registration_description": "Allow open registrations?", "allow_registration_description": "Allow open registrations?",
"allow_anon_event": "Allow anonymous events (has to be confirmed)?", "allow_anon_event": "Allow anonymous events (has to be confirmed)?",
"allow_recurrent_event": "Allow recurring events", "allow_recurrent_event": "Allow recurring events",
"allow_geolocalization": "Allow geolocalization of events", "allow_geolocation": "Allow geolocation of events",
"recurrent_event_visible": "Show recurring events by default", "recurrent_event_visible": "Show recurring events by default",
"federation": "Federation / ActivityPub", "federation": "Federation / ActivityPub",
"enable_federation": "Turn on federation", "enable_federation": "Turn on federation",

View File

@@ -5,7 +5,8 @@ const exportController = require('./export')
const log = require('../../log') const log = require('../../log')
const { Op, where, col, fn, cast } = require('sequelize') const { Op, where, col, fn, cast } = require('sequelize')
const NOMINATIM_URL = 'https://nominatim.openstreetmap.org/search?limit=3&format=geocodejson&accept-language=it&q=' const NOMINATIM_URL = 'https://nominatim.openstreetmap.org/search?limit=3&format=json&namedetails=1&q='
const axios = require('axios')
module.exports = { module.exports = {
@@ -73,14 +74,10 @@ module.exports = {
return res.json(places.slice(0, 10)) return res.json(places.slice(0, 10))
}, },
// async _nominatim (req, res) { async _nominatim (req, res) {
// const details = req.params.place_details const details = req.params.place_details
// const ret = await axios.get(`${NOMINATIM_URL}${details}`, { headers: { 'User-Agent': 'gancio 0.20' } }) const ret = await axios.get(`${NOMINATIM_URL}${details}`, { headers: { 'User-Agent': 'gancio 0.20' } })
// debug(`${NOMINATIM_URL}${details}`) return res.json(ret.data)
// debug(ret.status) },
// debug(ret.statusText)
// debug(ret.data)
// return ret
// },
} }

View File

@@ -29,7 +29,7 @@ const defaultSettings = {
allow_anon_event: true, allow_anon_event: true,
allow_recurrent_event: false, allow_recurrent_event: false,
recurrent_event_visible: false, recurrent_event_visible: false,
allow_geolocalization: false, allow_geolocation: false,
enable_federation: true, enable_federation: true,
enable_resources: false, enable_resources: false,
hide_boosts: true, hide_boosts: true,

View File

@@ -161,7 +161,7 @@ if (config.status !== 'READY') {
api.get('/place/all', isAdmin, placeController.getAll) api.get('/place/all', isAdmin, placeController.getAll)
api.get('/place/:placeName', cors, placeController.getEvents) api.get('/place/:placeName', cors, placeController.getEvents)
api.get('/place', cors, placeController.search) api.get('/place', cors, placeController.search)
// api.get('/placeNominatim/:place_details', cors, placeController._nominatim) api.get('/placeNominatim/:place_details', cors, placeController._nominatim)
api.put('/place', isAdmin, placeController.updatePlace) api.put('/place', isAdmin, placeController.updatePlace)
api.get('/tag', cors, tagController.search) api.get('/tag', cors, tagController.search)

View File

@@ -8,7 +8,7 @@ export const state = () => ({
allow_anon_event: true, allow_anon_event: true,
allow_recurrent_event: true, allow_recurrent_event: true,
recurrent_event_visible: false, recurrent_event_visible: false,
allow_geolocalization: false, allow_geolocation: false,
enable_federation: false, enable_federation: false,
enable_resources: false, enable_resources: false,
hide_boosts: true, hide_boosts: true,