mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
Merge branch 'develop' into feature/add-error-to-callback
# Conflicts: # CHANGELOG.md
This commit is contained in:
commit
652e1a528f
@ -17,7 +17,9 @@ _This release is scheduled to be released on 2021-04-01._
|
||||
- Added `start:dev` command to the npm scripts for starting electron with devTools open.
|
||||
- Added logging when using deprecated modules weatherforecast or currentweather.
|
||||
- Portuguese translations for "MODULE_CONFIG_CHANGED" and PRECIP.
|
||||
- `module.show` has now the option for a callback on error.
|
||||
- Respect parameter ColoredSymbolOnly also for custom events
|
||||
- Added a new parameter to hide time portion on relative times
|
||||
- [`module.show` has now the option for a callback on error.](https://github.com/MichMich/MagicMirror/pull/2439)
|
||||
|
||||
### Updated
|
||||
|
||||
@ -30,6 +32,7 @@ _This release is scheduled to be released on 2021-04-01._
|
||||
- Moving weather provider specific code and configuration into each provider and making hourly part of the interface.
|
||||
- Bump electron to v11.
|
||||
- Dont update the DOM when a module is not displayed.
|
||||
- Cleaned up jsdoc.
|
||||
|
||||
### Removed
|
||||
|
||||
@ -45,6 +48,7 @@ _This release is scheduled to be released on 2021-04-01._
|
||||
- Fix issue with unencoded characters in translated strings when using nunjuck template (`Loading …` as an example)
|
||||
- Fix socket.io backward compatibility with socket v2 clients
|
||||
- 3rd party module language loading if language is English
|
||||
- Fix e2e tests after spectron update
|
||||
|
||||
## [2.14.0] - 2021-01-01
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
*
|
||||
* @param {string} key key to look for at the command line
|
||||
* @param {string} defaultValue value if no key is given at the command line
|
||||
*
|
||||
* @returns {string} the value of the parameter
|
||||
*/
|
||||
function getCommandLineParameter(key, defaultValue = undefined) {
|
||||
@ -36,7 +35,6 @@
|
||||
* Gets the config from the specified server url
|
||||
*
|
||||
* @param {string} url location where the server is running.
|
||||
*
|
||||
* @returns {Promise} the config
|
||||
*/
|
||||
function getServerConfig(url) {
|
||||
@ -66,7 +64,7 @@
|
||||
/**
|
||||
* Print a message to the console in case of errors
|
||||
*
|
||||
* @param {string} [message] error message to print
|
||||
* @param {string} message error message to print
|
||||
* @param {number} code error code for the exit call
|
||||
*/
|
||||
function fail(message, code = 1) {
|
||||
|
@ -443,7 +443,6 @@ var MM = (function () {
|
||||
* Removes a module instance from the collection.
|
||||
*
|
||||
* @param {object} module The module instance to remove from the collection.
|
||||
*
|
||||
* @returns {Module[]} Filtered collection of modules.
|
||||
*/
|
||||
var exceptModule = function (module) {
|
||||
|
@ -319,14 +319,16 @@ var Module = Class.extend({
|
||||
const fallbackLanguage = languages[0];
|
||||
|
||||
if (languages.length === 0) {
|
||||
return callback();
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
const translationFile = translations[language];
|
||||
const translationsFallbackFile = translations[fallbackLanguage];
|
||||
|
||||
if (!translationFile) {
|
||||
return Translator.load(this, translationsFallbackFile, true, callback);
|
||||
Translator.load(this, translationsFallbackFile, true, callback);
|
||||
return;
|
||||
}
|
||||
|
||||
Translator.load(this, translationFile, false, () => {
|
||||
|
@ -14,6 +14,13 @@ const helmet = require("helmet");
|
||||
const Log = require("./logger.js");
|
||||
const Utils = require("./utils.js");
|
||||
|
||||
/**
|
||||
* Server
|
||||
*
|
||||
* @param {object} config The MM config
|
||||
* @param {Function} callback Function called when done.
|
||||
* @class
|
||||
*/
|
||||
function Server(config, callback) {
|
||||
const port = process.env.MM_PORT || config.port;
|
||||
|
||||
|
@ -107,7 +107,8 @@ var Translator = (function () {
|
||||
Log.log(`${module.name} - Load translation${isFallback && " fallback"}: ${file}`);
|
||||
|
||||
if (this.translationsFallback[module.name]) {
|
||||
return callback();
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
loadJSON(module.file(file), (json) => {
|
||||
|
@ -36,6 +36,7 @@ Module.register("calendar", {
|
||||
fadePoint: 0.25, // Start on 1/4th of the list.
|
||||
hidePrivate: false,
|
||||
hideOngoing: false,
|
||||
hideTime: false,
|
||||
colored: false,
|
||||
coloredSymbolOnly: false,
|
||||
customEvents: [], // Array of {keyword: "", symbol: "", color: ""} where Keyword is a regexp and symbol/color are to be applied for matched
|
||||
@ -277,8 +278,11 @@ Module.register("calendar", {
|
||||
if (typeof this.config.customEvents[ev].color !== "undefined" && this.config.customEvents[ev].color !== "") {
|
||||
needle = new RegExp(this.config.customEvents[ev].keyword, "gi");
|
||||
if (needle.test(event.title)) {
|
||||
// Respect parameter ColoredSymbolOnly also for custom events
|
||||
if (!this.config.coloredSymbolOnly) {
|
||||
eventWrapper.style.cssText = "color:" + this.config.customEvents[ev].color;
|
||||
titleWrapper.style.cssText = "color:" + this.config.customEvents[ev].color;
|
||||
}
|
||||
if (this.config.displaySymbol) {
|
||||
symbolWrapper.style.cssText = "color:" + this.config.customEvents[ev].color;
|
||||
}
|
||||
@ -363,7 +367,17 @@ Module.register("calendar", {
|
||||
// Show relative times
|
||||
if (event.startDate >= now) {
|
||||
// Use relative time
|
||||
if (!this.config.hideTime) {
|
||||
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").calendar());
|
||||
} else {
|
||||
timeWrapper.innerHTML = this.capFirst(
|
||||
moment(event.startDate, "x").calendar(null, {
|
||||
sameDay: "[Today]",
|
||||
nextDay: "[Tomorrow]",
|
||||
nextWeek: "dddd"
|
||||
})
|
||||
);
|
||||
}
|
||||
if (event.startDate - now < this.config.getRelative * oneHour) {
|
||||
// If event is within getRelative hours, display 'in xxx' time format or moment.fromNow()
|
||||
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").fromNow());
|
||||
|
@ -63,7 +63,7 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if (config.showFeelsLike or config.showPrecipitationAmount) and not config.onlyTemp %}
|
||||
<div class="normal medium">
|
||||
<div class="normal medium feelslike">
|
||||
{% if config.showFeelsLike %}
|
||||
<span class="dimmed">
|
||||
{{ "FEELS" | translate({DEGREE: current.feelsLike() | roundValue | unit("temperature") | decimalSymbol }) }}
|
||||
|
953
package-lock.json
generated
953
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@ -20,7 +20,7 @@
|
||||
"test:calendar": "node ./modules/default/calendar/debug.js",
|
||||
"config:check": "node js/check_config.js",
|
||||
"lint:prettier": "prettier --write **/*.{js,css,json,md,yml}",
|
||||
"lint:js": "eslint *.js js/**/*.js modules/default/**/*.js clientonly/*.js serveronly/*.js translations/*.js vendor/*.js tests/**/*.js config/* --config .eslintrc.json --fix",
|
||||
"lint:js": "eslint js/**/*.js modules/default/**/*.js clientonly/*.js serveronly/*.js translations/*.js vendor/*.js tests/**/*.js config/* --config .eslintrc.json --fix",
|
||||
"lint:css": "stylelint css/main.css modules/default/**/*.css --config .stylelintrc.json --fix"
|
||||
},
|
||||
"repository": {
|
||||
@ -45,8 +45,8 @@
|
||||
"devDependencies": {
|
||||
"chai": "^4.2.0",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"eslint-config-prettier": "^7.1.0",
|
||||
"eslint-plugin-jsdoc": "^31.0.6",
|
||||
"eslint-config-prettier": "^7.2.0",
|
||||
"eslint-plugin-jsdoc": "^31.6.0",
|
||||
"eslint-plugin-prettier": "^3.3.1",
|
||||
"express-basic-auth": "^1.2.0",
|
||||
"husky": "^4.3.8",
|
||||
@ -60,7 +60,7 @@
|
||||
"pretty-quick": "^3.1.0",
|
||||
"sinon": "^9.2.4",
|
||||
"spectron": "^13.0.0",
|
||||
"stylelint": "^13.8.0",
|
||||
"stylelint": "^13.9.0",
|
||||
"stylelint-config-prettier": "^8.0.2",
|
||||
"stylelint-config-standard": "^20.0.0",
|
||||
"stylelint-prettier": "^1.1.2"
|
||||
@ -71,7 +71,7 @@
|
||||
"dependencies": {
|
||||
"colors": "^1.4.0",
|
||||
"console-stamp": "^3.0.0-rc4.2",
|
||||
"eslint": "^7.18.0",
|
||||
"eslint": "^7.19.0",
|
||||
"express": "^4.17.1",
|
||||
"express-ipfilter": "^1.1.2",
|
||||
"feedme": "^2.0.2",
|
||||
|
@ -34,23 +34,15 @@ describe("Electron app environment", function () {
|
||||
it("should open a browserwindow", async function () {
|
||||
await app.client.waitUntilWindowLoaded();
|
||||
app.browserWindow.focus();
|
||||
const cnt = await app.client.getWindowCount();
|
||||
const min = await app.browserWindow.isMinimized();
|
||||
const dev = await app.browserWindow.isDevToolsOpened();
|
||||
const vis = await app.browserWindow.isVisible();
|
||||
const foc = await app.browserWindow.isFocused();
|
||||
expect(await app.client.getWindowCount()).to.equal(1);
|
||||
expect(await app.browserWindow.isMinimized()).to.be.false;
|
||||
expect(await app.browserWindow.isDevToolsOpened()).to.be.false;
|
||||
expect(await app.browserWindow.isVisible()).to.be.true;
|
||||
expect(await app.browserWindow.isFocused()).to.be.true;
|
||||
const bounds = await app.browserWindow.getBounds();
|
||||
const title = await app.browserWindow.getTitle();
|
||||
return (
|
||||
cnt.should.equal(1) &&
|
||||
min.should.be.false &&
|
||||
dev.should.be.false &&
|
||||
vis.should.be.true &&
|
||||
foc.should.be.true &&
|
||||
bounds.should.have.property("width").and.be.above(0) &&
|
||||
bounds.should.have.property("height").and.be.above(0) &&
|
||||
title.should.equal("MagicMirror²")
|
||||
);
|
||||
expect(bounds.width).to.be.above(0);
|
||||
expect(bounds.height).to.be.above(0);
|
||||
expect(await app.browserWindow.getTitle()).to.equal("MagicMirror²");
|
||||
});
|
||||
|
||||
it("get request from http://localhost:8080 should return 200", function (done) {
|
||||
|
@ -31,7 +31,7 @@ describe("Clock set to spanish language module", function () {
|
||||
});
|
||||
|
||||
it("shows date with correct format", async function () {
|
||||
const dateRegex = /^(?:lunes|martes|mi rcoles|jueves|viernes|s bado|domingo), \d{1,2} de (?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre) de \d{4}$/;
|
||||
const dateRegex = /^(?:lunes|martes|miércoles|jueves|viernes|sábado|domingo), \d{1,2} de (?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre) de \d{4}$/;
|
||||
const elem = await app.client.$(".clock .date");
|
||||
return elem.getText(".clock .date").should.eventually.match(dateRegex);
|
||||
});
|
||||
|
@ -23,6 +23,17 @@ describe("Weather module", function () {
|
||||
app.client.setupStub();
|
||||
}
|
||||
|
||||
async function getElement(element) {
|
||||
return await app.client.$(element);
|
||||
}
|
||||
|
||||
async function getText(element, result) {
|
||||
const elem = await getElement(element);
|
||||
return await elem.getText(element).then(function (text) {
|
||||
expect(text.trim()).to.equal(result);
|
||||
});
|
||||
}
|
||||
|
||||
afterEach(function () {
|
||||
return helpers.stopApplication(app);
|
||||
});
|
||||
@ -43,7 +54,7 @@ describe("Weather module", function () {
|
||||
const weather = generateWeather();
|
||||
await setup({ template, data: weather });
|
||||
|
||||
return await app.client.$(".weather .normal.medium span:nth-child(2)", "6 WSW", 10000);
|
||||
return getText(".weather .normal.medium span:nth-child(2)", "6 WSW");
|
||||
});
|
||||
|
||||
it("should render sunrise", async function () {
|
||||
@ -53,9 +64,7 @@ describe("Weather module", function () {
|
||||
const weather = generateWeather({ sys: { sunrise, sunset } });
|
||||
await setup({ template, data: weather });
|
||||
|
||||
await app.client.$(".weather .normal.medium span.wi.dimmed.wi-sunrise", 10000);
|
||||
|
||||
return await app.client.$(".weather .normal.medium span:nth-child(4)", "12:00 am", 10000);
|
||||
return getText(".weather .normal.medium span:nth-child(4)", "12:00 am");
|
||||
});
|
||||
|
||||
it("should render sunset", async function () {
|
||||
@ -65,25 +74,21 @@ describe("Weather module", function () {
|
||||
const weather = generateWeather({ sys: { sunrise, sunset } });
|
||||
await setup({ template, data: weather });
|
||||
|
||||
await app.client.$(".weather .normal.medium span.wi.dimmed.wi-sunset", 10000);
|
||||
|
||||
return await app.client.$(".weather .normal.medium span:nth-child(4)", "11:59 pm", 10000);
|
||||
return getText(".weather .normal.medium span:nth-child(4)", "11:59 pm");
|
||||
});
|
||||
|
||||
it("should render temperature with icon", async function () {
|
||||
const weather = generateWeather();
|
||||
await setup({ template, data: weather });
|
||||
|
||||
await app.client.$(".weather .large.light span.wi.weathericon.wi-snow", 10000);
|
||||
|
||||
return await app.client.$(".weather .large.light span.bright", "1.5°", 10000);
|
||||
return getText(".weather .large.light span.bright", "1.5°");
|
||||
});
|
||||
|
||||
it("should render feels like temperature", async function () {
|
||||
const weather = generateWeather();
|
||||
await setup({ template, data: weather });
|
||||
|
||||
return await app.client.$(".weather .normal.medium span.dimmed", "Feels like -5.6°", 10000);
|
||||
return getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -5.6°");
|
||||
});
|
||||
});
|
||||
|
||||
@ -96,7 +101,16 @@ describe("Weather module", function () {
|
||||
const weather = generateWeather();
|
||||
await setup({ template, data: weather });
|
||||
|
||||
return await app.client.$(".compliments .module-content span", "snow", 10000);
|
||||
const wait = (time) => new Promise((resolve) => setTimeout(resolve, time));
|
||||
|
||||
var text = "";
|
||||
do {
|
||||
await wait(3000);
|
||||
elem = await app.client.$(".compliments");
|
||||
text = await elem.getText(".compliments .module-content span");
|
||||
} while (text === "");
|
||||
|
||||
return expect(text.trim()).to.equal("snow");
|
||||
});
|
||||
});
|
||||
|
||||
@ -109,34 +123,31 @@ describe("Weather module", function () {
|
||||
const weather = generateWeather();
|
||||
await setup({ template, data: weather });
|
||||
|
||||
return await app.client.$(".weather .normal.medium span:nth-child(2)", "12", 10000);
|
||||
return getText(".weather .normal.medium span:nth-child(2)", "12");
|
||||
});
|
||||
|
||||
it("should render showWindDirectionAsArrow = true", async function () {
|
||||
const weather = generateWeather();
|
||||
await setup({ template, data: weather });
|
||||
|
||||
const elem = await app.client.$(".weather .normal.medium sup i.fa-long-arrow-up", 10000);
|
||||
const element = await elem.getHTML(".weather .normal.medium sup i.fa-long-arrow-up");
|
||||
|
||||
expect(element).to.include("transform:rotate(250deg);");
|
||||
const elem = await getElement(".weather .normal.medium sup i.fa-long-arrow-up");
|
||||
return elem.getHTML(".weather .normal.medium sup i.fa-long-arrow-up").then(function (text) {
|
||||
expect(text).to.include("transform:rotate(250deg);");
|
||||
});
|
||||
});
|
||||
|
||||
it("should render showHumidity = true", async function () {
|
||||
const weather = generateWeather();
|
||||
await setup({ template, data: weather });
|
||||
|
||||
await app.client.$(".weather .normal.medium span:nth-child(3)", "93", 10000);
|
||||
return await app.client.$(".weather .normal.medium sup i.wi-humidity", 10000);
|
||||
return getText(".weather .normal.medium span:nth-child(3)", "93.7");
|
||||
});
|
||||
|
||||
it("should render degreeLabel = true", async function () {
|
||||
const weather = generateWeather();
|
||||
await setup({ template, data: weather });
|
||||
|
||||
await app.client.$(".weather .large.light span.bright", "1°C", 10000);
|
||||
|
||||
return await app.client.$(".weather .normal.medium span.dimmed", "Feels like -6°C", 10000);
|
||||
return getText(".weather .large.light span.bright", "1°C") && getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -6°C");
|
||||
});
|
||||
});
|
||||
|
||||
@ -158,9 +169,7 @@ describe("Weather module", function () {
|
||||
});
|
||||
await setup({ template, data: weather });
|
||||
|
||||
await app.client.$(".weather .normal.medium span:nth-child(2)", "6 WSW", 10000);
|
||||
await app.client.$(".weather .large.light span.bright", "34,7°", 10000);
|
||||
return await app.client.$(".weather .normal.medium span.dimmed", "22,0°", 10000);
|
||||
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°");
|
||||
});
|
||||
|
||||
it("should render decimalSymbol = ','", async function () {
|
||||
@ -176,9 +185,7 @@ describe("Weather module", function () {
|
||||
});
|
||||
await setup({ template, data: weather });
|
||||
|
||||
await app.client.$(".weather .normal.medium span:nth-child(3)", "93,7", 10000);
|
||||
await app.client.$(".weather .large.light span.bright", "34,7°", 10000);
|
||||
return await app.client.$(".weather .normal.medium span.dimmed", "22,0°", 10000);
|
||||
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°");
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -202,7 +209,7 @@ describe("Weather module", function () {
|
||||
const days = ["Today", "Tomorrow", "Sun", "Mon", "Tue"];
|
||||
|
||||
for (const [index, day] of days.entries()) {
|
||||
await app.client.$(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day, 10000);
|
||||
getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day);
|
||||
}
|
||||
});
|
||||
|
||||
@ -213,7 +220,7 @@ describe("Weather module", function () {
|
||||
const icons = ["day-cloudy", "rain", "day-sunny", "day-sunny", "day-sunny"];
|
||||
|
||||
for (const [index, icon] of icons.entries()) {
|
||||
await app.client.$(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(2) span.wi-${icon}`, 10000);
|
||||
getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(2) span.wi-${icon}`);
|
||||
}
|
||||
});
|
||||
|
||||
@ -224,7 +231,7 @@ describe("Weather module", function () {
|
||||
const temperatures = ["24.4°", "21.0°", "22.9°", "23.4°", "20.6°"];
|
||||
|
||||
for (const [index, temp] of temperatures.entries()) {
|
||||
await app.client.$(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp, 10000);
|
||||
getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp);
|
||||
}
|
||||
});
|
||||
|
||||
@ -235,7 +242,7 @@ describe("Weather module", function () {
|
||||
const temperatures = ["15.3°", "13.6°", "13.8°", "13.9°", "10.9°"];
|
||||
|
||||
for (const [index, temp] of temperatures.entries()) {
|
||||
await app.client.$(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(4)`, temp, 10000);
|
||||
getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(4)`, temp);
|
||||
}
|
||||
});
|
||||
|
||||
@ -245,7 +252,7 @@ describe("Weather module", function () {
|
||||
|
||||
const opacities = [1, 1, 0.8, 0.5333333333333333, 0.2666666666666667];
|
||||
|
||||
const elem = await app.client.$(".weather table.small", 10000);
|
||||
const elem = await getElement(".weather table.small");
|
||||
|
||||
for (const [index, opacity] of opacities.entries()) {
|
||||
const html = await elem.getHTML(`.weather table.small tr:nth-child(${index + 1})`);
|
||||
@ -263,15 +270,13 @@ describe("Weather module", function () {
|
||||
const weather = generateWeatherForecast();
|
||||
await setup({ template, data: weather });
|
||||
|
||||
await app.client.$(".weather table.myTableClass", 10000);
|
||||
await getElement(".weather table.myTableClass");
|
||||
});
|
||||
|
||||
it("should render colored rows", async function () {
|
||||
const weather = generateWeatherForecast();
|
||||
await setup({ template, data: weather });
|
||||
|
||||
await app.client.$(".weather table.myTableClass", 10000);
|
||||
|
||||
const rows = await app.client.$$(".weather table.myTableClass tr.colored");
|
||||
|
||||
expect(rows.length).to.be.equal(5);
|
||||
|
@ -33,8 +33,8 @@ describe("Position of modules", function () {
|
||||
position = positions[idx];
|
||||
className = position.replace("_", ".");
|
||||
it("show text in " + position, function () {
|
||||
app.client.$("." + className).then((result) => {
|
||||
return this.getText("." + className).should.eventually.equal("Text in " + position);
|
||||
return app.client.$("." + className).then((result) => {
|
||||
return result.getText("." + className).should.eventually.equal("Text in " + position);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user