From 4add7cd0b3602f5c72c50f50c6bdae2d221520fe Mon Sep 17 00:00:00 2001 From: Bas van Wetten Date: Thu, 27 Jul 2017 17:59:23 +0200 Subject: [PATCH 1/4] Fix calendar.js bug Fix bug where excludedEvents count towards maximumEntries displayed --- modules/default/calendar/calendar.js | 15 +-------------- modules/default/calendar/calendarfetcher.js | 15 ++++++++++++++- modules/default/calendar/node_helper.js | 6 +++--- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index a5716d77..661838f0 100644 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -153,20 +153,6 @@ Module.register("calendar", { for (var e in events) { var event = events[e]; - - var excluded = false; - for (var f in this.config.excludedEvents) { - var filter = this.config.excludedEvents[f]; - if (event.title.toLowerCase().includes(filter.toLowerCase())) { - excluded = true; - break; - } - } - - if (excluded) { - continue; - } - var eventWrapper = document.createElement("tr"); if (this.config.colored) { @@ -377,6 +363,7 @@ Module.register("calendar", { addCalendar: function (url, auth, calendarConfig) { this.sendSocketNotification("ADD_CALENDAR", { url: url, + excludedEvents: calendarConfig.excludedEvents || this.config.excludedEvents, maximumEntries: calendarConfig.maximumEntries || this.config.maximumEntries, maximumNumberOfDays: calendarConfig.maximumNumberOfDays || this.config.maximumNumberOfDays, fetchInterval: this.config.fetchInterval, diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index 9655f21e..12495f78 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -8,7 +8,7 @@ var ical = require("./vendor/ical.js"); var moment = require("moment"); -var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumberOfDays, auth) { +var CalendarFetcher = function(url, reloadInterval, excludedEvents, maximumEntries, maximumNumberOfDays, auth) { var self = this; var reloadTimer = null; @@ -113,6 +113,19 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe title = event.description; } + var excluded = false; + for (var f in excludedEvents) { + var filter = excludedEvents[f]; + if (title.toLowerCase().includes(filter.toLowerCase())) { + excluded = true; + break; + } + } + + if (excluded) { + continue; + } + var location = event.location || false; var geo = event.geo || false; var description = event.description || false; diff --git a/modules/default/calendar/node_helper.js b/modules/default/calendar/node_helper.js index 90c286c8..25e7f1f7 100644 --- a/modules/default/calendar/node_helper.js +++ b/modules/default/calendar/node_helper.js @@ -24,7 +24,7 @@ module.exports = NodeHelper.create({ socketNotificationReceived: function(notification, payload) { if (notification === "ADD_CALENDAR") { //console.log('ADD_CALENDAR: '); - this.createFetcher(payload.url, payload.fetchInterval, payload.maximumEntries, payload.maximumNumberOfDays, payload.auth); + this.createFetcher(payload.url, payload.fetchInterval, payload.excludedEvents, payload.maximumEntries, payload.maximumNumberOfDays, payload.auth); } }, @@ -36,7 +36,7 @@ module.exports = NodeHelper.create({ * attribute reloadInterval number - Reload interval in milliseconds. */ - createFetcher: function(url, fetchInterval, maximumEntries, maximumNumberOfDays, auth) { + createFetcher: function(url, fetchInterval, excludedEvents, maximumEntries, maximumNumberOfDays, auth) { var self = this; if (!validUrl.isUri(url)) { @@ -47,7 +47,7 @@ module.exports = NodeHelper.create({ var fetcher; if (typeof self.fetchers[url] === "undefined") { console.log("Create new calendar fetcher for url: " + url + " - Interval: " + fetchInterval); - fetcher = new CalendarFetcher(url, fetchInterval, maximumEntries, maximumNumberOfDays, auth); + fetcher = new CalendarFetcher(url, fetchInterval, excludedEvents, maximumEntries, maximumNumberOfDays, auth); fetcher.onReceive(function(fetcher) { //console.log('Broadcast events.'); From 7bd256c311a47ad552f4c6b4bbafe381c719dd0f Mon Sep 17 00:00:00 2001 From: Bas van Wetten Date: Fri, 28 Jul 2017 21:07:38 +0200 Subject: [PATCH 2/4] Fix calendar.js bug issue #963 Fixed calendar specific configuration settings maximumEntries and maximumNumberOfDays not overriding global setting --- modules/default/calendar/calendar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index a5716d77..c791e502 100644 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -366,7 +366,7 @@ Module.register("calendar", { return a.startDate - b.startDate; }); - return events.slice(0, this.config.maximumEntries); + return events; }, /* createEventList(url) From 12754ff13535eeb1b029e866aec26dd95f3c3953 Mon Sep 17 00:00:00 2001 From: Bas van Wetten Date: Fri, 28 Jul 2017 22:19:25 +0200 Subject: [PATCH 3/4] Updated changelog for calendar fix Updated changelog for calendar fix --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90bae37b..a5181cc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Fixed issue with incorrect allignment of analog clock when displayed in the center column of the MM - Fixed ipWhitelist behaviour to make empty whitelist ([]) allow any and all hosts access to the MM +- Fixed issue with calendar module where 'excludedEvents' count towards 'maximumEntries' +- Fixed issue with calendar module where global configuration of maximumEntries was not overridden by calendar specific config (see module doc) ## [2.1.2] - 2017-07-01 From 5ef6ba0258c9501150cad45f60de66015f57b7f3 Mon Sep 17 00:00:00 2001 From: Bas van Wetten Date: Sat, 29 Jul 2017 11:44:43 +0200 Subject: [PATCH 4/4] Small edit of CHANGELOG Added a period at the end of the CHANGELOG entries --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5181cc9..065a074a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,8 +18,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Fixed issue with incorrect allignment of analog clock when displayed in the center column of the MM - Fixed ipWhitelist behaviour to make empty whitelist ([]) allow any and all hosts access to the MM -- Fixed issue with calendar module where 'excludedEvents' count towards 'maximumEntries' -- Fixed issue with calendar module where global configuration of maximumEntries was not overridden by calendar specific config (see module doc) +- Fixed issue with calendar module where 'excludedEvents' count towards 'maximumEntries'. +- Fixed issue with calendar module where global configuration of maximumEntries was not overridden by calendar specific config (see module doc). ## [2.1.2] - 2017-07-01