From 76d8f98969a9b480f93f32ee96e47ae7097348b2 Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Thu, 1 Aug 2024 21:24:16 +0200 Subject: [PATCH] =?UTF-8?q?allow=20custom=20module=20positions=20by=20sett?= =?UTF-8?q?ing=20`allowCustomModulePositions`=E2=80=A6=20(#3506)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … in `config.js` fixes #3504, related to https://github.com/MagicMirrorOrg/MagicMirror/pull/3445 --- CHANGELOG.md | 3 ++- js/defaults.js | 1 + js/loader.js | 2 +- js/utils.js | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e9f3881..b0569cd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,8 +18,9 @@ _This release is scheduled to be released on 2024-10-01._ ### Updated -- [weather] Updated `apiVersion` default from 2.5 to 3.0 +- [weather] Updated `apiVersion` default from 2.5 to 3.0 (#3424) - [core] Updated dependencies +- [core] Allow custom module positions by setting `allowCustomModulePositions` in `config.js` (fixes #3504, related to https://github.com/MagicMirrorOrg/MagicMirror/pull/3445) ### Fixed diff --git a/js/defaults.js b/js/defaults.js index c4efa77e..1cbef635 100644 --- a/js/defaults.js +++ b/js/defaults.js @@ -27,6 +27,7 @@ const defaults = { // (interval 30 seconds). If startup-timestamp has changed the client reloads the magicmirror webpage. checkServerInterval: 30 * 1000, reloadAfterServerRestart: false, + allowCustomModulePositions: false, modules: [ { diff --git a/js/loader.js b/js/loader.js index e8dff190..1ce6f27b 100644 --- a/js/loader.js +++ b/js/loader.js @@ -50,7 +50,7 @@ const Loader = (function () { * @returns {object[]} module data as configured in config */ const getAllModules = function () { - const AllModules = config.modules.filter((module) => (module.module !== undefined) && (MM.getAvailableModulePositions.indexOf(module.position) > -1 || typeof (module.position) === "undefined")); + const AllModules = config.modules.filter((module) => (module.module !== undefined) && (MM.getAvailableModulePositions.indexOf(module.position) > -1 || typeof (module.position) === "undefined" || config.allowCustomModulePositions)); return AllModules; }; diff --git a/js/utils.js b/js/utils.js index 6e4b7eab..df2e9175 100644 --- a/js/utils.js +++ b/js/utils.js @@ -34,6 +34,7 @@ module.exports = { // return if postion is on modulePositions Array (true/false) moduleHasValidPosition (position) { + if (config.allowCustomModulePositions) return true; if (this.getAvailableModulePositions().indexOf(position) === -1) return false; return true; }