mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
Merge branch 'develop' into istanbul
This commit is contained in:
commit
cd2fce56a6
@ -11,7 +11,9 @@ _This release is scheduled to be released on 2020-10-01._
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Test coverage with Istanbul, run it with `npm run test:coverage`
|
- Test coverage with Istanbul, run it with `npm run test:coverage`.
|
||||||
|
- Add lithuanian language.
|
||||||
|
- Added support in weatherforecast for OpenWeather onecall API.
|
||||||
|
|
||||||
### Updated
|
### Updated
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@ Module.register("weatherforecast", {
|
|||||||
defaults: {
|
defaults: {
|
||||||
location: false,
|
location: false,
|
||||||
locationID: false,
|
locationID: false,
|
||||||
|
lat: false,
|
||||||
|
lon: false,
|
||||||
appid: "",
|
appid: "",
|
||||||
units: config.units,
|
units: config.units,
|
||||||
maxNumberOfDays: 7,
|
maxNumberOfDays: 7,
|
||||||
@ -29,6 +31,7 @@ Module.register("weatherforecast", {
|
|||||||
apiVersion: "2.5",
|
apiVersion: "2.5",
|
||||||
apiBase: "https://api.openweathermap.org/data/",
|
apiBase: "https://api.openweathermap.org/data/",
|
||||||
forecastEndpoint: "forecast/daily",
|
forecastEndpoint: "forecast/daily",
|
||||||
|
excludes: false,
|
||||||
|
|
||||||
appendLocationNameToHeader: true,
|
appendLocationNameToHeader: true,
|
||||||
calendarClass: "calendar",
|
calendarClass: "calendar",
|
||||||
@ -283,6 +286,8 @@ Module.register("weatherforecast", {
|
|||||||
var params = "?";
|
var params = "?";
|
||||||
if (this.config.locationID) {
|
if (this.config.locationID) {
|
||||||
params += "id=" + this.config.locationID;
|
params += "id=" + this.config.locationID;
|
||||||
|
} else if (this.config.lat && this.config.lon) {
|
||||||
|
params += "lat=" + this.config.lat + "&lon=" + this.config.lon;
|
||||||
} else if (this.config.location) {
|
} else if (this.config.location) {
|
||||||
params += "q=" + this.config.location;
|
params += "q=" + this.config.location;
|
||||||
} else if (this.firstEvent && this.firstEvent.geo) {
|
} else if (this.firstEvent && this.firstEvent.geo) {
|
||||||
@ -297,13 +302,14 @@ Module.register("weatherforecast", {
|
|||||||
let numberOfDays;
|
let numberOfDays;
|
||||||
if (this.config.forecastEndpoint === "forecast") {
|
if (this.config.forecastEndpoint === "forecast") {
|
||||||
numberOfDays = this.config.maxNumberOfDays < 1 || this.config.maxNumberOfDays > 5 ? 5 : this.config.maxNumberOfDays;
|
numberOfDays = this.config.maxNumberOfDays < 1 || this.config.maxNumberOfDays > 5 ? 5 : this.config.maxNumberOfDays;
|
||||||
// don't get forecasts for the 6th day, as it would not represent the whole day
|
// don't get forecasts for the next day, as it would not represent the whole day
|
||||||
numberOfDays = numberOfDays * 8 - (Math.floor(new Date().getHours() / 3) % 8);
|
numberOfDays = numberOfDays * 8 - (Math.round(new Date().getHours() / 3) % 8);
|
||||||
} else {
|
} else {
|
||||||
numberOfDays = this.config.maxNumberOfDays < 1 || this.config.maxNumberOfDays > 17 ? 7 : this.config.maxNumberOfDays;
|
numberOfDays = this.config.maxNumberOfDays < 1 || this.config.maxNumberOfDays > 17 ? 7 : this.config.maxNumberOfDays;
|
||||||
}
|
}
|
||||||
params += "&cnt=" + numberOfDays;
|
params += "&cnt=" + numberOfDays;
|
||||||
|
|
||||||
|
params += "&exclude=" + this.config.excludes;
|
||||||
params += "&units=" + this.config.units;
|
params += "&units=" + this.config.units;
|
||||||
params += "&lang=" + this.config.lang;
|
params += "&lang=" + this.config.lang;
|
||||||
params += "&APPID=" + this.config.appid;
|
params += "&APPID=" + this.config.appid;
|
||||||
@ -331,15 +337,34 @@ Module.register("weatherforecast", {
|
|||||||
* argument data object - Weather information received form openweather.org.
|
* argument data object - Weather information received form openweather.org.
|
||||||
*/
|
*/
|
||||||
processWeather: function (data) {
|
processWeather: function (data) {
|
||||||
this.fetchedLocationName = data.city.name + ", " + data.city.country;
|
// Forcast16 (paid) API endpoint provides this data. Onecall endpoint
|
||||||
|
// does not.
|
||||||
|
if (data.city) {
|
||||||
|
this.fetchedLocationName = data.city.name + ", " + data.city.country;
|
||||||
|
} else if (this.config.location) {
|
||||||
|
this.fetchedLocationName = this.config.location;
|
||||||
|
} else {
|
||||||
|
this.fetchedLocationName = "Unknown";
|
||||||
|
}
|
||||||
|
|
||||||
this.forecast = [];
|
this.forecast = [];
|
||||||
var lastDay = null;
|
var lastDay = null;
|
||||||
var forecastData = {};
|
var forecastData = {};
|
||||||
|
|
||||||
for (var i = 0, count = data.list.length; i < count; i++) {
|
// Handle different structs between forecast16 and onecall endpoints
|
||||||
var forecast = data.list[i];
|
var forecastList = null;
|
||||||
this.parserDataWeather(forecast); // hack issue #1017
|
if (data.list) {
|
||||||
|
forecastList = data.list;
|
||||||
|
} else if (data.daily) {
|
||||||
|
forecastList = data.daily;
|
||||||
|
} else {
|
||||||
|
Log.error("Unexpected forecast data");
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0, count = forecastList.length; i < count; i++) {
|
||||||
|
var forecast = forecastList[i];
|
||||||
|
forecast = this.parserDataWeather(forecast); // hack issue #1017
|
||||||
|
|
||||||
var day;
|
var day;
|
||||||
var hour;
|
var hour;
|
||||||
@ -357,7 +382,7 @@ Module.register("weatherforecast", {
|
|||||||
icon: this.config.iconTable[forecast.weather[0].icon],
|
icon: this.config.iconTable[forecast.weather[0].icon],
|
||||||
maxTemp: this.roundValue(forecast.temp.max),
|
maxTemp: this.roundValue(forecast.temp.max),
|
||||||
minTemp: this.roundValue(forecast.temp.min),
|
minTemp: this.roundValue(forecast.temp.min),
|
||||||
rain: this.processRain(forecast, data.list)
|
rain: this.processRain(forecast, forecastList)
|
||||||
};
|
};
|
||||||
|
|
||||||
this.forecast.push(forecastData);
|
this.forecast.push(forecastData);
|
||||||
|
36
translations/lt.json
Normal file
36
translations/lt.json
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"LOADING": "Kraunasi …",
|
||||||
|
|
||||||
|
"TODAY": "Šiandien",
|
||||||
|
"TOMORROW": "Rytoj",
|
||||||
|
"DAYAFTERTOMORROW": "Už 2 dienų",
|
||||||
|
"RUNNING": "Pasibaigs už",
|
||||||
|
"EMPTY": "Nėra artimų įvykių.",
|
||||||
|
|
||||||
|
"WEEK": "{weekNumber} savaitė",
|
||||||
|
|
||||||
|
"N": "N",
|
||||||
|
"NNE": "NNE",
|
||||||
|
"NE": "NE",
|
||||||
|
"ENE": "ENE",
|
||||||
|
"E": "E",
|
||||||
|
"ESE": "ESE",
|
||||||
|
"SE": "SE",
|
||||||
|
"SSE": "SSE",
|
||||||
|
"S": "S",
|
||||||
|
"SSW": "SSW",
|
||||||
|
"SW": "SW",
|
||||||
|
"WSW": "WSW",
|
||||||
|
"W": "W",
|
||||||
|
"WNW": "WNW",
|
||||||
|
"NW": "NW",
|
||||||
|
"NNW": "NNW",
|
||||||
|
|
||||||
|
"UPDATE_NOTIFICATION": "Galimas MagicMirror² naujinimas.",
|
||||||
|
"UPDATE_NOTIFICATION_MODULE": "Galimas {MODULE_NAME} naujinimas.",
|
||||||
|
"UPDATE_INFO_SINGLE": "Šis įdiegimas atsilieka {COMMIT_COUNT} įsipareigojimu {BRANCH_NAME} šakoje.",
|
||||||
|
"UPDATE_INFO_MULTIPLE": "Šis įdiegimas atsilieka {COMMIT_COUNT} įsipareigojimais {BRANCH_NAME} šakoje.",
|
||||||
|
|
||||||
|
"FEELS": "Jaučiasi kaip",
|
||||||
|
"PRECIP": "Krituliai"
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user