Location/Weather: using a different API to geocode location name + fixed weather display which was offseted by a day
This commit is contained in:
parent
5a1ebcd296
commit
0b5e2e86f0
3 changed files with 11 additions and 7 deletions
|
|
@ -216,10 +216,10 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeWidgetFromSection(section, index) {
|
function removeWidgetFromSection(section, index) {
|
||||||
// Logger.log("BarTab", "Removing widget from section", section, "at index", index)
|
// Logger.log("BarTab", "Removing widget from section", section, "at index", index)
|
||||||
var sectionArray = Settings.data.bar.widgets[section]
|
var sectionArray = Settings.data.bar.widgets[section]
|
||||||
//Logger.log("BarTab", "Current section array:", JSON.stringify(sectionArray))
|
|
||||||
|
|
||||||
|
//Logger.log("BarTab", "Current section array:", JSON.stringify(sectionArray))
|
||||||
if (sectionArray && index >= 0 && index < sectionArray.length) {
|
if (sectionArray && index >= 0 && index < sectionArray.length) {
|
||||||
// Create a new array to avoid modifying the original
|
// Create a new array to avoid modifying the original
|
||||||
var newArray = sectionArray.slice()
|
var newArray = sectionArray.slice()
|
||||||
|
|
@ -238,6 +238,7 @@ ColumnLayout {
|
||||||
//Logger.log("BarTab", "Verification - updated section array:", JSON.stringify(updatedArray))
|
//Logger.log("BarTab", "Verification - updated section array:", JSON.stringify(updatedArray))
|
||||||
}, 100)
|
}, 100)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
//Logger.log("BarTab", "Invalid section or index:", section, index, "array length:",
|
//Logger.log("BarTab", "Invalid section or index:", section, index, "array length:",
|
||||||
// sectionArray ? sectionArray.length : "null")
|
// sectionArray ? sectionArray.length : "null")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,10 @@ NBox {
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
spacing: Style.marginS * scaling
|
spacing: Style.marginS * scaling
|
||||||
NText {
|
NText {
|
||||||
text: Qt.formatDateTime(new Date(LocationService.data.weather.daily.time[index]), "ddd")
|
text: {
|
||||||
|
var weatherDate = new Date(LocationService.data.weather.daily.time[index].replace(/-/g, "/"))
|
||||||
|
return Qt.formatDateTime(weatherDate, "ddd")
|
||||||
|
}
|
||||||
color: Color.mOnSurface
|
color: Color.mOnSurface
|
||||||
}
|
}
|
||||||
NIcon {
|
NIcon {
|
||||||
|
|
|
||||||
|
|
@ -109,8 +109,8 @@ Singleton {
|
||||||
|
|
||||||
// --------------------------------
|
// --------------------------------
|
||||||
function _geocodeLocation(locationName, callback, errorCallback) {
|
function _geocodeLocation(locationName, callback, errorCallback) {
|
||||||
Logger.log("Location", "Geocoding from api.open-meteo.com")
|
Logger.log("Location", "Geocoding location name")
|
||||||
var geoUrl = "https://geocoding-api.open-meteo.com/v1/search?name=" + encodeURIComponent(
|
var geoUrl = "https://assets.noctalia.dev/geocode.php?city=" + encodeURIComponent(
|
||||||
locationName) + "&language=en&format=json"
|
locationName) + "&language=en&format=json"
|
||||||
var xhr = new XMLHttpRequest()
|
var xhr = new XMLHttpRequest()
|
||||||
xhr.onreadystatechange = function () {
|
xhr.onreadystatechange = function () {
|
||||||
|
|
@ -119,8 +119,8 @@ Singleton {
|
||||||
try {
|
try {
|
||||||
var geoData = JSON.parse(xhr.responseText)
|
var geoData = JSON.parse(xhr.responseText)
|
||||||
// Logger.logJSON.stringify(geoData))
|
// Logger.logJSON.stringify(geoData))
|
||||||
if (geoData.results && geoData.results.length > 0) {
|
if (geoData.lat != null) {
|
||||||
callback(geoData.results[0].latitude, geoData.results[0].longitude)
|
callback(geoData.lat, geoData.lng)
|
||||||
} else {
|
} else {
|
||||||
errorCallback("Location", "could not resolve location name")
|
errorCallback("Location", "could not resolve location name")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue