allow custom module positions by setting allowCustomModulePositions… (#3506)

… in `config.js`

fixes #3504, related to
https://github.com/MagicMirrorOrg/MagicMirror/pull/3445
This commit is contained in:
Karsten Hassel 2024-08-01 21:24:16 +02:00 committed by GitHub
parent 4182c2129f
commit 76d8f98969
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 5 additions and 2 deletions

View File

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

View File

@ -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: [
{

View File

@ -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;
};

View File

@ -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;
}