From 7198ae5eae466b01beb3f619328637cae08628bb Mon Sep 17 00:00:00 2001 From: Piotr Rajnisz <56397164+rajniszp@users.noreply.github.com> Date: Thu, 26 Jan 2023 13:00:49 +0100 Subject: [PATCH] Add (in Alert module) templateName parameter (#3009) This simple change allows to use your own templates (under "templates" directory). The parameter `templateName` is optional (ignored on falsy value - undefined, null, empty string, etc.) and independent of `type`. Co-authored-by: Veeck --- CHANGELOG.md | 1 + modules/default/alert/alert.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bb7d4bc..ea876fcd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ _This release is scheduled to be released on 2023-04-01._ - Added tests for hourly weather forecast - Added possibility to ignore MagicMirror repo in updatenotification module - Added Pirate Weather as new weather provider (#3005) +- Added possibility to use your own templates in Alert module - Added error message if `.js` file is missing in module folder to get a hint in the logs (#2403) ### Removed diff --git a/modules/default/alert/alert.js b/modules/default/alert/alert.js index 76bacc02..c2a68f75 100644 --- a/modules/default/alert/alert.js +++ b/modules/default/alert/alert.js @@ -69,7 +69,7 @@ Module.register("alert", { }, async showNotification(notification) { - const message = await this.renderMessage("notification", notification); + const message = await this.renderMessage(notification.templateName || "notification", notification); new NotificationFx({ message, @@ -90,7 +90,7 @@ Module.register("alert", { this.toggleBlur(true); } - const message = await this.renderMessage("alert", alert); + const message = await this.renderMessage(alert.templateName || "alert", alert); // Store alert in this.alerts this.alerts[sender.name] = new NotificationFx({