rename gelocation, and move the request to nominatim server side
This commit is contained in:
@@ -30,7 +30,7 @@ v-row
|
||||
:label="$t('common.address')"
|
||||
@change="changeAddress"
|
||||
: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'
|
||||
:disabled='disableDetails'
|
||||
@input.native='searchCoordinates'
|
||||
@@ -47,7 +47,7 @@ v-row
|
||||
v-list-item-content(two-line v-if='item')
|
||||
v-list-item-title(v-text='item.display_name')
|
||||
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>
|
||||
<script>
|
||||
@@ -110,7 +110,7 @@ export default {
|
||||
if (typeof p === 'object' && !p.create) {
|
||||
this.place.name = p.name.trim()
|
||||
this.place.address = p.address
|
||||
if (this.settings.allow_geolocalization) {
|
||||
if (this.settings.allow_geolocation) {
|
||||
this.place.details = p.details
|
||||
}
|
||||
this.place.id = p.id
|
||||
@@ -128,7 +128,7 @@ export default {
|
||||
} else {
|
||||
delete this.place.id
|
||||
this.place.address = ''
|
||||
if (this.settings.allow_geolocalization) {
|
||||
if (this.settings.allow_geolocation) {
|
||||
this.place.details = p.details
|
||||
}
|
||||
this.disableAddress = false
|
||||
@@ -158,9 +158,12 @@ export default {
|
||||
},
|
||||
searchCoordinates: debounce(async function(ev) {
|
||||
this.loading = true
|
||||
const searchCoordinates = ev.target.value.trim().toLowerCase()
|
||||
// this.detailsList = await this.$axios.$get(`placeNominatim?search=${searchCoordinates}`)
|
||||
this.detailsList = await this.$axios.$get(`https://nominatim.openstreetmap.org/search?limit=3&format=json&namedetails=1&q=${searchCoordinates}` )
|
||||
const pre_searchCoordinates = ev.target.value.trim().toLowerCase()
|
||||
// allow pasting coordinates lat/lon
|
||||
const searchCoordinates = pre_searchCoordinates.replace('/', ',')
|
||||
if (searchCoordinates.length) {
|
||||
this.detailsList = await this.$axios.$get(`placeNominatim/${searchCoordinates}`)
|
||||
}
|
||||
if (this.detailsList) {
|
||||
this.loading = false;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ v-container
|
||||
v-model='place.address'
|
||||
:placeholder='$t("common.address")')
|
||||
|
||||
v-textarea(v-if="settings.allow_geolocalization"
|
||||
v-textarea(v-if="settings.allow_geolocation"
|
||||
row-height="15"
|
||||
:disabled="true"
|
||||
:label="$t('common.details')"
|
||||
@@ -83,7 +83,7 @@ export default {
|
||||
editPlace (item) {
|
||||
this.place.name = item.name
|
||||
this.place.address = item.address
|
||||
if (this.settings.allow_geolocalization) {
|
||||
if (this.settings.allow_geolocation) {
|
||||
this.place.details = JSON.parse(item.details)
|
||||
}
|
||||
this.place.id = item.id
|
||||
|
||||
@@ -48,9 +48,9 @@ v-container
|
||||
inset
|
||||
:label="$t('admin.recurrent_event_visible')")
|
||||
|
||||
v-switch.mt-1(v-model='allow_geolocalization'
|
||||
v-switch.mt-1(v-model='allow_geolocation'
|
||||
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')
|
||||
SMTP(@close='showSMTP = false')
|
||||
@@ -111,9 +111,9 @@ export default {
|
||||
get () { return this.settings.recurrent_event_visible },
|
||||
set (value) { this.setSetting({ key: 'recurrent_event_visible', value }) }
|
||||
},
|
||||
allow_geolocalization: {
|
||||
get () { return this.settings.allow_geolocalization },
|
||||
set (value) { this.setSetting({ key: 'allow_geolocalization', value }) }
|
||||
allow_geolocation: {
|
||||
get () { return this.settings.allow_geolocation },
|
||||
set (value) { this.setSetting({ key: 'allow_geolocation', value }) }
|
||||
},
|
||||
filteredTimezones () {
|
||||
const current_timezone = moment.tz.guess()
|
||||
|
||||
@@ -185,7 +185,7 @@
|
||||
"allow_registration_description": "Allow open registrations?",
|
||||
"allow_anon_event": "Allow anonymous events (has to be confirmed)?",
|
||||
"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",
|
||||
"federation": "Federation / ActivityPub",
|
||||
"enable_federation": "Turn on federation",
|
||||
|
||||
@@ -5,7 +5,8 @@ const exportController = require('./export')
|
||||
|
||||
const log = require('../../log')
|
||||
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 = {
|
||||
|
||||
@@ -73,14 +74,10 @@ module.exports = {
|
||||
return res.json(places.slice(0, 10))
|
||||
},
|
||||
|
||||
// async _nominatim (req, res) {
|
||||
// const details = req.params.place_details
|
||||
// const ret = await axios.get(`${NOMINATIM_URL}${details}`, { headers: { 'User-Agent': 'gancio 0.20' } })
|
||||
// debug(`${NOMINATIM_URL}${details}`)
|
||||
// debug(ret.status)
|
||||
// debug(ret.statusText)
|
||||
// debug(ret.data)
|
||||
// return ret
|
||||
// },
|
||||
async _nominatim (req, res) {
|
||||
const details = req.params.place_details
|
||||
const ret = await axios.get(`${NOMINATIM_URL}${details}`, { headers: { 'User-Agent': 'gancio 0.20' } })
|
||||
return res.json(ret.data)
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ const defaultSettings = {
|
||||
allow_anon_event: true,
|
||||
allow_recurrent_event: false,
|
||||
recurrent_event_visible: false,
|
||||
allow_geolocalization: false,
|
||||
allow_geolocation: false,
|
||||
enable_federation: true,
|
||||
enable_resources: false,
|
||||
hide_boosts: true,
|
||||
|
||||
@@ -161,7 +161,7 @@ if (config.status !== 'READY') {
|
||||
api.get('/place/all', isAdmin, placeController.getAll)
|
||||
api.get('/place/:placeName', cors, placeController.getEvents)
|
||||
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.get('/tag', cors, tagController.search)
|
||||
|
||||
@@ -8,7 +8,7 @@ export const state = () => ({
|
||||
allow_anon_event: true,
|
||||
allow_recurrent_event: true,
|
||||
recurrent_event_visible: false,
|
||||
allow_geolocalization: false,
|
||||
allow_geolocation: false,
|
||||
enable_federation: false,
|
||||
enable_resources: false,
|
||||
hide_boosts: true,
|
||||
|
||||
Reference in New Issue
Block a user