Skip to content

Commit

Permalink
Merge branch 'develop' into feature/add-error-to-callback
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
fewieden committed Feb 13, 2021
2 parents 9d85bae + ef2fd16 commit 652e1a5
Show file tree
Hide file tree
Showing 14 changed files with 474 additions and 647 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down
4 changes: 1 addition & 3 deletions clientonly/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions js/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, () => {
Expand Down
7 changes: 7 additions & 0 deletions js/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion js/translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
20 changes: 17 additions & 3 deletions modules/default/calendar/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)) {
eventWrapper.style.cssText = "color:" + this.config.customEvents[ev].color;
titleWrapper.style.cssText = "color:" + this.config.customEvents[ev].color;
// 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;
}
Expand Down Expand Up @@ -363,7 +367,17 @@ Module.register("calendar", {
// Show relative times
if (event.startDate >= now) {
// Use relative time
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").calendar());
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());
Expand Down
2 changes: 1 addition & 1 deletion modules/default/weather/current.njk
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) }}
Expand Down
Loading

0 comments on commit 652e1a5

Please sign in to comment.