Merge branch 'develop' into contribute

This commit is contained in:
veeck 2021-04-14 16:42:54 +02:00
commit e0a9c7d0bb
19 changed files with 9295 additions and 141 deletions

View File

@ -11,6 +11,10 @@ _This release is scheduled to be released on 2021-04-01._
### Added
- Added French translations for "MODULE_CONFIG_ERROR" and "PRECIP".
- Added German translation for "PRECIP".
- Added first test for Alert module.
- Added support for `dateFormat` when not using `timeFormat: "absolute"`
- Added `custom.css.sample` file for improved styling experience
### Updated
@ -24,6 +28,11 @@ _This release is scheduled to be released on 2021-04-01._
- Fix calendar start function logging inconsistency.
- Fix updatenotification start function logging inconsistency.
- Checks and applies the showDescription setting for the newsfeed module again
- Fix tests in weather module and add one for decimalPoint in forecast
- Fix decimalSymbol in the forcast part of the new weather module #2530
- Fix wrong treatment of `appendLocationNameToHeader` when using `ukmetofficedatahub`
- Fix alert not recognizing multiple alerts (#2522)
## [2.15.0] - 2021-04-01

View File

@ -1,7 +1,21 @@
{
"name": "magicmirror-fonts",
"lockfileVersion": 2,
"requires": true,
"lockfileVersion": 1,
"packages": {
"": {
"name": "magicmirror-fonts",
"license": "MIT",
"dependencies": {
"roboto-fontface": "^0.10.0"
}
},
"node_modules/roboto-fontface": {
"version": "0.10.0",
"resolved": "https://registry.npmjs.org/roboto-fontface/-/roboto-fontface-0.10.0.tgz",
"integrity": "sha512-OlwfYEgA2RdboZohpldlvJ1xngOins5d7ejqnIBWr9KaMxsnBqotpptRXTyfNRLnFpqzX6sTDt+X+a+6udnU8g=="
}
},
"dependencies": {
"roboto-fontface": {
"version": "0.10.0",

View File

@ -79,7 +79,7 @@ Module.register("alert", {
//If module already has an open alert close it
if (this.alerts[sender.name]) {
this.hide_alert(sender);
this.hide_alert(sender, false);
}
//Display title and message only if they are provided in notification parameters
@ -114,10 +114,10 @@ Module.register("alert", {
}, params.timer);
}
},
hide_alert: function (sender) {
hide_alert: function (sender, close = true) {
//Dismiss alert and remove from this.alerts
if (this.alerts[sender.name]) {
this.alerts[sender.name].dismiss();
this.alerts[sender.name].dismiss(close);
this.alerts[sender.name] = null;
//Remove overlay
const overlay = document.getElementById("overlay");

View File

@ -123,7 +123,7 @@
/**
* Dismiss the notification
*/
NotificationFx.prototype.dismiss = function () {
NotificationFx.prototype.dismiss = function (close = true) {
this.active = false;
clearTimeout(this.dismissttl);
this.ntf.classList.remove("ns-show");
@ -131,7 +131,7 @@
this.ntf.classList.add("ns-hide");
// callback
this.options.onClose();
if (close) this.options.onClose();
}, 25);
// after animation ends remove ntf from the DOM

View File

@ -366,13 +366,14 @@ Module.register("calendar", {
if (event.startDate >= now) {
// Use relative time
if (!this.config.hideTime) {
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").calendar());
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").calendar(null, { sameElse: this.config.dateFormat }));
} else {
timeWrapper.innerHTML = this.capFirst(
moment(event.startDate, "x").calendar(null, {
sameDay: "[" + this.translate("TODAY") + "]",
nextDay: "[" + this.translate("TOMORROW") + "]",
nextWeek: "dddd"
nextWeek: "dddd",
sameElse: this.config.dateFormat
})
);
}

View File

@ -13,6 +13,7 @@
<div class="newsfeed-title bright medium light{{ ' no-wrap' if not config.wrapTitle }}">
{{ title }}
</div>
{% if config.showDescription %}
<div class="newsfeed-desc small light{{ ' no-wrap' if not config.wrapDescription }}">
{% if config.truncDescription %}
{{ description | truncate(config.lengthDescription) }}
@ -20,6 +21,7 @@
{{ description }}
{% endif %}
</div>
{% endif %}
</div>
{% elseif error %}
<div class="small dimmed">

View File

@ -14,10 +14,10 @@
{% endif %}
<td class="bright weather-icon"><span class="wi weathericon wi-{{ f.weatherType }}"></span></td>
<td class="align-right bright max-temp">
{{ f.maxTemperature | roundValue | unit("temperature") }}
{{ f.maxTemperature | roundValue | unit("temperature") | decimalSymbol }}
</td>
<td class="align-right min-temp">
{{ f.minTemperature | roundValue | unit("temperature") }}
{{ f.minTemperature | roundValue | unit("temperature") | decimalSymbol }}
</td>
{% if config.showPrecipitationAmount %}
<td class="align-right bright precipitation">

View File

@ -59,9 +59,7 @@ WeatherProvider.register("ukmetofficedatahub", {
let queryStrings = "?";
queryStrings += "latitude=" + this.config.lat;
queryStrings += "&longitude=" + this.config.lon;
if (this.config.appendLocationNameToHeader) {
queryStrings += "&includeLocationName=" + true;
}
// Return URL, making sure there is a trailing "/" in the base URL.
return this.config.apiBase + (this.config.apiBase.endsWith("/") ? "" : "/") + forecastType + queryStrings;

9035
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -50,7 +50,7 @@
"eslint-plugin-prettier": "^3.3.1",
"express-basic-auth": "^1.2.0",
"husky": "^4.3.8",
"jsdom": "^16.5.1",
"jsdom": "^16.5.2",
"lodash": "^4.17.21",
"mocha": "^8.3.2",
"mocha-each": "^2.0.1",
@ -70,11 +70,11 @@
},
"dependencies": {
"colors": "^1.4.0",
"console-stamp": "^3.0.0-rc4.2",
"console-stamp": "^3.0.2",
"digest-fetch": "^1.1.6",
"eslint": "^7.23.0",
"eslint": "^7.24.0",
"express": "^4.17.1",
"express-ipfilter": "^1.1.2",
"express-ipfilter": "^1.2.0",
"feedme": "^2.0.2",
"helmet": "^4.4.1",
"iconv-lite": "^0.6.2",
@ -85,8 +85,7 @@
"rrule": "^2.6.8",
"rrule-alt": "^2.2.8",
"simple-git": "^2.37.0",
"socket.io": "^4.0.0",
"valid-url": "^1.0.9"
"socket.io": "^4.0.1"
},
"_moduleAliases": {
"node_helper": "js/node_helper.js",

View File

@ -0,0 +1,34 @@
/* Magic Mirror Test config sample module alert
*
* By rejas
* MIT Licensed.
*/
let config = {
port: 8080,
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],
language: "en",
timeFormat: 24,
units: "metric",
electronOptions: {
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true
}
},
modules: [
{
module: "alert",
config: {
display_time: 1000000,
welcome_message: true
}
}
]
};
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {
module.exports = config;
}

View File

@ -27,7 +27,8 @@ let config = {
url: "http://localhost:8080/tests/configs/data/feed_test_rodrigoramirez.xml"
}
],
prohibitedWords: ["QPanel"]
prohibitedWords: ["QPanel"],
showDescription: true
}
}
]

View File

@ -0,0 +1,39 @@
/* Magic Mirror Test config default weather
*
* By rejas
* MIT Licensed.
*/
let config = {
port: 8080,
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],
language: "en",
timeFormat: 24,
units: "imperial",
electronOptions: {
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true
}
},
modules: [
{
module: "weather",
position: "bottom_bar",
config: {
type: "forecast",
location: "Munich",
apiKey: "fake key",
weatherEndpoint: "/forecast/daily",
initialLoadDelay: 3000,
decimalSymbol: "_"
}
}
]
};
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {
module.exports = config;
}

View File

@ -0,0 +1,37 @@
const helpers = require("../global-setup");
const describe = global.describe;
const it = global.it;
const beforeEach = global.beforeEach;
const afterEach = global.afterEach;
describe("Alert module", function () {
helpers.setupTimeout(this);
let app = null;
beforeEach(function () {
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function (startedApp) {
app = startedApp;
});
});
afterEach(function () {
return helpers.stopApplication(app);
});
describe("Default configuration", function () {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/alert/default.js";
});
it("should show the welcome message", function () {
return app.client.waitUntilTextExists(".ns-box .ns-box-inner .light.bright.small", "Welcome, start was successful!", 10000);
});
});
});

View File

@ -1,4 +1,5 @@
const helpers = require("../global-setup");
const expect = require("chai").expect;
const describe = global.describe;
const it = global.it;
@ -36,6 +37,12 @@ describe("Newsfeed module", function () {
it("should show the newsfeed article", function () {
return app.client.waitUntilTextExists(".newsfeed .newsfeed-title", "QPanel", 10000);
});
it("should NOT show the newsfeed description", async () => {
await app.client.waitUntilTextExists(".newsfeed .newsfeed-title", "QPanel", 10000);
const events = await app.client.$$(".newsfeed .newsfeed-desc");
return expect(events.length).equals(0);
});
});
describe("Custom configuration", function () {
@ -46,6 +53,12 @@ describe("Newsfeed module", function () {
it("should not show articles with prohibited words", function () {
return app.client.waitUntilTextExists(".newsfeed .newsfeed-title", "Problema VirtualBox", 10000);
});
it("should show the newsfeed description", async () => {
await app.client.waitUntilTextExists(".newsfeed .newsfeed-title", "Problema VirtualBox", 10000);
const events = await app.client.$$(".newsfeed .newsfeed-desc");
return expect(events.length).equals(1);
});
});
describe("Invalid configuration", function () {

View File

@ -139,7 +139,7 @@ describe("Weather module", function () {
const weather = generateWeather();
await setup({ template, data: weather });
return getText(".weather .large.light span.bright", "1°C") && getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -6°C");
return (await getText(".weather .large.light span.bright", "1°C")) && (await getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -6°C"));
});
});
@ -161,10 +161,10 @@ describe("Weather module", function () {
});
await setup({ template, data: weather });
return getText(".weather .normal.medium span:nth-child(2)", "6 WSW") && getText(".weather .large.light span.bright", "34,7°") && getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 22,0°");
return (await getText(".weather .normal.medium span:nth-child(2)", "6 WSW")) && (await getText(".weather .large.light span.bright", "34,7°")) && getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 22,0°");
});
it("should render decimalSymbol = ','", async function () {
it("should render custom decimalSymbol = ','", async function () {
const weather = generateWeather({
main: {
temp: (1.49 * 9) / 5 + 32,
@ -177,7 +177,7 @@ describe("Weather module", function () {
});
await setup({ template, data: weather });
return getText(".weather .normal.medium span:nth-child(3)", "93,7") && getText(".weather .large.light span.bright", "34,7°") && getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 22,0°");
return (await getText(".weather .normal.medium span:nth-child(3)", "93,7")) && (await getText(".weather .large.light span.bright", "34,7°")) && getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 22,0°");
});
});
});
@ -201,7 +201,7 @@ describe("Weather module", function () {
const days = ["Today", "Tomorrow", "Sun", "Mon", "Tue"];
for (const [index, day] of days.entries()) {
getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day);
await getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day);
}
});
@ -212,7 +212,7 @@ describe("Weather module", function () {
const icons = ["day-cloudy", "rain", "day-sunny", "day-sunny", "day-sunny"];
for (const [index, icon] of icons.entries()) {
getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(2) span.wi-${icon}`);
await getElement(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(2) span.wi-${icon}`);
}
});
@ -223,7 +223,7 @@ describe("Weather module", function () {
const temperatures = ["24.4°", "21.0°", "22.9°", "23.4°", "20.6°"];
for (const [index, temp] of temperatures.entries()) {
getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp);
await getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp);
}
});
@ -234,7 +234,7 @@ describe("Weather module", function () {
const temperatures = ["15.3°", "13.6°", "13.8°", "13.9°", "10.9°"];
for (const [index, temp] of temperatures.entries()) {
getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(4)`, temp);
await getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(4)`, temp);
}
});
@ -274,5 +274,22 @@ describe("Weather module", function () {
expect(rows.length).to.be.equal(5);
});
});
describe("Forecast weather units", function () {
before(function () {
process.env.MM_CONFIG_FILE = "tests/configs/modules/weather/forecastweather_units.js";
});
it("should render custom decimalSymbol = '_'", async function () {
const weather = generateWeatherForecast();
await setup({ template, data: weather });
const temperatures = ["24_4°", "21_0°", "22_9°", "23_4°", "20_6°"];
for (const [index, temp] of temperatures.entries()) {
await getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp);
}
});
});
});
});

View File

@ -26,6 +26,7 @@
"NNW": "NNW",
"FEELS": "Gefühlt {DEGREE}",
"PRECIP": "Niederschlagswahrscheinlichkeit",
"MODULE_CONFIG_CHANGED": "Die Konfigurationsoptionen für das {MODULE_NAME} Modul haben sich geändert. \nBitte überprüfen Sie die Dokumentation.",
"MODULE_CONFIG_ERROR": "Fehler im {MODULE_NAME} Modul. {ERROR}",

View File

@ -26,8 +26,10 @@
"NNW": "NNO",
"FEELS": "Ressenti {DEGREE}",
"PRECIP": "Probabilité de précipitations",
"MODULE_CONFIG_CHANGED": "Les options de configuration du module {MODULE_NAME} ont changé. \nVeuillez consulter la documentation.",
"MODULE_CONFIG_ERROR": "Erreur dans le module {MODULE_NAME}. {ERROR}",
"UPDATE_NOTIFICATION": "Une mise à jour de MagicMirror² est disponible",
"UPDATE_NOTIFICATION_MODULE": "Une mise à jour est disponible pour le module {MODULE_NAME} .",

146
vendor/package-lock.json generated vendored Normal file
View File

@ -0,0 +1,146 @@
{
"name": "magicmirror-vendors",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "magicmirror-vendors",
"license": "MIT",
"dependencies": {
"@fortawesome/fontawesome-free": "^5.15.3",
"moment": "^2.29.1",
"moment-timezone": "^0.5.33",
"nunjucks": "^3.2.3",
"suncalc": "^1.8.0",
"weathericons": "^2.1.0"
}
},
"node_modules/@fortawesome/fontawesome-free": {
"version": "5.15.3",
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-5.15.3.tgz",
"integrity": "sha512-rFnSUN/QOtnOAgqFRooTA3H57JLDm0QEG/jPdk+tLQNL/eWd+Aok8g3qCI+Q1xuDPWpGW/i9JySpJVsq8Q0s9w==",
"hasInstallScript": true,
"engines": {
"node": ">=6"
}
},
"node_modules/a-sync-waterfall": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/a-sync-waterfall/-/a-sync-waterfall-1.0.1.tgz",
"integrity": "sha512-RYTOHHdWipFUliRFMCS4X2Yn2X8M87V/OpSqWzKKOGhzqyUxzyVmhHDH9sAvG+ZuQf/TAOFsLCpMw09I1ufUnA=="
},
"node_modules/asap": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
"integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY="
},
"node_modules/commander": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz",
"integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==",
"engines": {
"node": ">= 6"
}
},
"node_modules/moment": {
"version": "2.29.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==",
"engines": {
"node": "*"
}
},
"node_modules/moment-timezone": {
"version": "0.5.33",
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.33.tgz",
"integrity": "sha512-PTc2vcT8K9J5/9rDEPe5czSIKgLoGsH8UNpA4qZTVw0Vd/Uz19geE9abbIOQKaAQFcnQ3v5YEXrbSc5BpshH+w==",
"dependencies": {
"moment": ">= 2.9.0"
},
"engines": {
"node": "*"
}
},
"node_modules/nunjucks": {
"version": "3.2.3",
"resolved": "https://registry.npmjs.org/nunjucks/-/nunjucks-3.2.3.tgz",
"integrity": "sha512-psb6xjLj47+fE76JdZwskvwG4MYsQKXUtMsPh6U0YMvmyjRtKRFcxnlXGWglNybtNTNVmGdp94K62/+NjF5FDQ==",
"dependencies": {
"a-sync-waterfall": "^1.0.0",
"asap": "^2.0.3",
"commander": "^5.1.0"
},
"bin": {
"nunjucks-precompile": "bin/precompile"
},
"engines": {
"node": ">= 6.9.0"
}
},
"node_modules/suncalc": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/suncalc/-/suncalc-1.8.0.tgz",
"integrity": "sha1-HZiYEJVjB4dQ9JlKlZ5lTYdqy/U="
},
"node_modules/weathericons": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/weathericons/-/weathericons-2.1.0.tgz",
"integrity": "sha1-dFOho14gAkXjiftQd9Un7/MLc7Q="
}
},
"dependencies": {
"@fortawesome/fontawesome-free": {
"version": "5.15.3",
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-5.15.3.tgz",
"integrity": "sha512-rFnSUN/QOtnOAgqFRooTA3H57JLDm0QEG/jPdk+tLQNL/eWd+Aok8g3qCI+Q1xuDPWpGW/i9JySpJVsq8Q0s9w=="
},
"a-sync-waterfall": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/a-sync-waterfall/-/a-sync-waterfall-1.0.1.tgz",
"integrity": "sha512-RYTOHHdWipFUliRFMCS4X2Yn2X8M87V/OpSqWzKKOGhzqyUxzyVmhHDH9sAvG+ZuQf/TAOFsLCpMw09I1ufUnA=="
},
"asap": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
"integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY="
},
"commander": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz",
"integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg=="
},
"moment": {
"version": "2.29.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ=="
},
"moment-timezone": {
"version": "0.5.33",
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.33.tgz",
"integrity": "sha512-PTc2vcT8K9J5/9rDEPe5czSIKgLoGsH8UNpA4qZTVw0Vd/Uz19geE9abbIOQKaAQFcnQ3v5YEXrbSc5BpshH+w==",
"requires": {
"moment": ">= 2.9.0"
}
},
"nunjucks": {
"version": "3.2.3",
"resolved": "https://registry.npmjs.org/nunjucks/-/nunjucks-3.2.3.tgz",
"integrity": "sha512-psb6xjLj47+fE76JdZwskvwG4MYsQKXUtMsPh6U0YMvmyjRtKRFcxnlXGWglNybtNTNVmGdp94K62/+NjF5FDQ==",
"requires": {
"a-sync-waterfall": "^1.0.0",
"asap": "^2.0.3",
"commander": "^5.1.0"
}
},
"suncalc": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/suncalc/-/suncalc-1.8.0.tgz",
"integrity": "sha1-HZiYEJVjB4dQ9JlKlZ5lTYdqy/U="
},
"weathericons": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/weathericons/-/weathericons-2.1.0.tgz",
"integrity": "sha1-dFOho14gAkXjiftQd9Un7/MLc7Q="
}
}
}