Skip to content

Commit

Permalink
Merge pull request #422 from NikitaMakovey/fixes
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
jamm1985 authored Oct 28, 2022
2 parents 9f136df + c683316 commit d4101ee
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/components/event/GeneralInformation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
this.items[8].value = data.processingMethod.long
this.items[9].value = agency(data.agency)
this.items[10].value = data.nearestCity.data.feltReportAnalysis ?
data.nearestCity.data.feltReportAnalysis.data.felt_reports_count : 0
data.nearestCity.data.feltReportAnalysis.data.felt_reports_count : data.felt_reports_count
}
},
watch: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/maps/GeneralInformation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
methods: {
syncFeltReportData: function(event) {
if (this.event.nearestCity.data.feltReportAnalysis) {
if (this.event.nearestCity.data.feltReportAnalysis || this.event.felt_reports_count) {
this.$http.get(apiSettings.endpointEventMeasuredIntensityAggregations(this.event.id))
.then(response => {
this.addData(event.data.data, response.data.feltReports)
Expand Down
2 changes: 1 addition & 1 deletion src/components/maps/Settlements.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
let feltReportsData = []
try {
if (this.event.nearestCity.data.feltReportAnalysis) {
if (this.event.nearestCity.data.feltReportAnalysis || this.event.felt_reports_count) {
const response = await this.$http.get(apiSettings.endpointEventMeasuredIntensityAggregations(this.event.id))
feltReportsData = response.data.feltReports
}
Expand Down
9 changes: 7 additions & 2 deletions src/components/poll/FeltReportPoll.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,20 @@
<script>
import apiSettings from '@/settings/api'
import EarthquakeQuestions from './EarthquakeQuestions'
import geolocation from './mixins/geolocation'
import timezone from './mixins/timezone'
import DateTimeQuestions from './DateTimeQuestions'
import LocationQuestions from './LocationQuestions'
export default {
name: 'FeltReportPoll',
components: {LocationQuestions, DateTimeQuestions, EarthquakeQuestions},
mixins: [geolocation],
mixins: [timezone],
data() {
return {
location: {
lat: null,
lon: null
},
localisations: [],
questions: [],
actions: {},
Expand Down Expand Up @@ -109,6 +113,7 @@ export default {
deep: true,
handler: function(value) {
this.requestData.location = value
this.getTimezone()
}
}
},
Expand Down
46 changes: 27 additions & 19 deletions src/components/poll/LocationQuestions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,36 @@ export default {
}
this.$emit('update', location)
this.marker = window.L.marker(event.latlng, {icon}).addTo(this.map.object)
},
getCurrentPosition() {
let vm = this
window.navigator.geolocation.getCurrentPosition(
function(position) {
vm.map.coordinates = [position.coords.latitude, position.coords.longitude]
vm.map.object = createMap(vm.map.id, vm.map.coordinates, {zoom: 10})
vm.addMarker({latlng: {lat: position.coords.latitude, lng: position.coords.longitude}})
vm.watchMapClick()
},
function(error) {
const errorTypes = {
1: 'PERMISSION_DENIED',
2: 'POSITION_UNAVAILABLE',
3: 'TIMEOUT'
}
console.error(error.message, {code: errorTypes[error.code]})
vm.map.object = createMap(vm.map.id, vm.map.coordinates, {zoom: 10})
vm.watchMapClick()
}
)
}
},
mounted() {
let vm = this
window.navigator.geolocation.getCurrentPosition(
function(position) {
vm.map.coordinates = [position.coords.latitude, position.coords.longitude]
vm.map.object = createMap(vm.map.id, vm.map.coordinates, {zoom: 10})
vm.addMarker({latlng: {lat: position.coords.latitude, lng: position.coords.longitude}})
vm.watchMapClick()
},
function(error) {
const errorTypes = {
1: 'PERMISSION_DENIED',
2: 'POSITION_UNAVAILABLE',
3: 'TIMEOUT'
}
console.error(error.message, {code: errorTypes[error.code]})
vm.map.object = createMap(vm.map.id, vm.map.coordinates, {zoom: 10})
vm.watchMapClick()
}
)
if (window.navigator.geolocation) {
this.getCurrentPosition()
}
else {
console.warn('GeoLocation API is unavailable for your browser')
}
}
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import ts from '@mapbox/timespace'
export default {
data() {
return {
location: {
lat: null,
lon: null
},
timezoneOffset: 0,
timezone: 'UTC'
}
Expand All @@ -29,32 +25,6 @@ export default {
const time = ts.getFuzzyLocalTimeFromPoint(timestamp, point)
this.timezoneOffset = time._d.getTimezoneOffset()
this.timezone = this.formatTimezone(this.timezoneOffset)
},
getCurrentLocation() {
let vm = this
window.navigator.geolocation.getCurrentPosition(
function(position) {
vm.location.lat = position.coords.latitude
vm.location.lon = position.coords.longitude
vm.getTimezone()
},
function(error) {
const errorTypes = {
1: 'PERMISSION_DENIED',
2: 'POSITION_UNAVAILABLE',
3: 'TIMEOUT'
}
console.error(error.message, {code: errorTypes[error.code]})
}
)
}
},
mounted() {
if (window.navigator.geolocation) {
this.getCurrentLocation()
}
else {
console.warn('GeoLocation API is unavailable for your browser')
}
}
}

0 comments on commit d4101ee

Please sign in to comment.