Skip to content

Commit

Permalink
Fix station errors (#75)
Browse files Browse the repository at this point in the history
* Turn off station callback hook

* Catch station with no observations error

* Update translations to no obs found

* Catch no obs error on dialog
  • Loading branch information
webb-ben committed Apr 9, 2024
1 parent 4f3e9a2 commit 00a3f21
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 19 deletions.
15 changes: 10 additions & 5 deletions src/components/data/DataNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,16 @@ export default {
})
.then(function (response) {
// handle success
self.fetchCollectionItems(
`${newC.id}`,
response.data.features[0].properties.resultTime,
response.data.numberMatched
);
var feature = response.data.features[0];
if (feature && feature.properties && feature.properties.resultTime){
self.fetchCollectionItems(
`${newC.id}`,
feature.properties.resultTime,
response.data.numberMatched
);
} else {
self.$root.catch(self.$t("chart.station") + self.$t("messages.no_observations_in_collection"));
}
})
.catch(this.$root.catch)
.then(function () {
Expand Down
2 changes: 1 addition & 1 deletion src/components/leaflet/WisMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export default defineComponent({
})
.then(function () {
self.loading = false;
setTimeout(self.loadStations, 900000);
// setTimeout(self.loadStations, 900000);
});
},
},
Expand Down
16 changes: 10 additions & 6 deletions src/components/station/StationHistory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,17 @@ export default defineComponent({
})
.then(function (response) {
// handle success
var ort = response.data.features[0].properties.resultTime;
self.oldestResultTime = new Date(ort);
var index = response.data.features[0].properties.index;
if (self.inDays(self.oldestResultTime, self.now) > 30) {
self.loadAllObservations(station, index);
var feature = response.data.features[0];
if (feature && feature.properties && feature.properties.resultTime){
self.oldestResultTime = new Date(feature.properties.resultTime);
var index = response.data.features[0].properties.index;
if (self.inDays(self.oldestResultTime, self.now) > 30) {
self.loadAllObservations(station, index);
} else {
self.loadDailyObservations(station, index);
}
} else {
self.loadDailyObservations(station, index);
self.$root.catch(self.$t("chart.station") + self.$t("messages.no_observations_in_collection"));
}
})
.catch(this.$root.catch);
Expand Down
10 changes: 7 additions & 3 deletions src/components/station/StationLatest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,13 @@ export default defineComponent({
})
.then(function (response) {
// handle success
self.latestResultTime =
response.data.features[0].properties.resultTime;
self.loadRecentObservations(station, response.data.numberMatched);
var feature = response.data.features[0];
if (feature && feature.properties && feature.properties.resultTime){
self.latestResultTime = feature.properties.resultTime;
self.loadRecentObservations(station, response.data.numberMatched);
} else {
self.$root.catch(self.$t("chart.station") + self.$t("messages.no_observations_in_collection"));
}
})
.catch(this.$root.catch)
.then(function () {
Expand Down
4 changes: 2 additions & 2 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"authorized": "Authorized",
"not_authorized": "Data requires authorization; Please add an authorization token",
"no_linked_collections": "has no linked collections",
"how_to_link_station": "To link a collection, republish the station(s) after wis2box has published an observation from the station",
"how_to_link_station": "Please associate stations with this dataset/topic to see their data displayed on the map",
"from": "from",
"no_of_observations": "Observations from the past 24 hours",
"does_not_exist": "Page not found"
Expand All @@ -45,7 +45,7 @@
"options": "Options",
"collection": "Collection",
"observed_property": "Observed Property",
"station": "Stations",
"station": "Station",
"data_source": "Data source",
"download": "Download"
},
Expand Down
2 changes: 1 addition & 1 deletion src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"authorized": "Autorizada",
"not_authorized": "El conjunto de datos requiere autorización; Agregar un token de autorización",
"no_linked_collections": "no tiene colecciones vinculadas",
"how_to_link_station": "Para vincular una colección, vuelva a publicar la(s) estación(es) después de que wis2box haya publicado una observación de la estación",
"how_to_link_station": "Asocie las estaciones con este conjunto de datos/tema para ver sus datos mostrados en el mapa.",
"from": "desde",
"no_of_observations": "Observaciones de las últimas 24 horas",
"does_not_exist": "Página no encontrada"
Expand Down
2 changes: 1 addition & 1 deletion src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"authorized": "Autorisée",
"not_authorized": "L'ensemble de données nécessite une autorisation ; Ajouter un jeton d'autorisationn",
"no_linked_collections": "n'a pas de collections liées",
"how_to_link_station": "Pour lier une collection, republiez la ou les stations après que wis2box a publié une observation de la station",
"how_to_link_station": "Veuillez associer les stations à cet ensemble de données/sujet pour voir leurs données affichées sur la carte",
"from": "depuis",
"no_of_observations": "Observations des dernières 24 heures",
"does_not_exist": "Page non trouvée"
Expand Down

0 comments on commit 00a3f21

Please sign in to comment.