• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Divide Config.js into modules

Scheduled Pinned Locked Moved Unsolved Feature Requests
21 Posts 7 Posters 7.4k Views 6 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    robiv8
    last edited by Feb 17, 2019, 3:20 PM

    Very interesting,
    its a good question.

    1 Reply Last reply Reply Quote 0
    • S Offline
      sdetweil
      last edited by sdetweil Feb 17, 2019, 3:38 PM Feb 17, 2019, 3:38 PM

      Well, there is one problem.

      Once u put the info in each module folder, you will lose the ability to order the modules differently

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      S 1 Reply Last reply Feb 18, 2019, 1:46 AM Reply Quote 0
      • S Offline
        stuartiannaylor @sdetweil
        last edited by stuartiannaylor Feb 18, 2019, 2:43 AM Feb 18, 2019, 1:46 AM

        @sdetweil said in Divide Config.js into modules:

        Well, there is one problem.

        Once u put the info in each module folder, you will lose the ability to order the modules differently

        Nope the modules are declared in /config/config.js not that I have much experience but my new noob experience of MM is that with complexity it starts to get a bit cumbersome.

        As an example would you really want to add compliments to your main config.js.
        I am just wondering if it could be split and presented slightly more cleanly and simpler for the likes of me.

        module: "calendar",
        			header: "Calendar",
        			position: "top_left",
        

        Would still be the same place and it would in essence just be the same but the bloat of

        config: {
        

        Would be elsewhere.

        Also if it was loaded serially as different objects declared by config.js then each module config could have some form of isolation and error checking?
        Gson gson = new Gson();
        JsonObject jsonObj = gson.fromJson (jsonStr, JsonElement.class).getAsJsonObject();
        jsonObj.add(“criterias”, “Location”);

        Dunno as really know naff about NodeJS but thinking you could even make it more robust with feedback to which module config error?

        1 Reply Last reply Reply Quote 0
        • S Offline
          sdetweil
          last edited by Feb 18, 2019, 3:24 AM

          So, you end up with two places to config …

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 0
          • S Offline
            stuartiannaylor
            last edited by stuartiannaylor Feb 18, 2019, 11:53 AM Feb 18, 2019, 3:39 AM

            Yes and actually multiple places as to which modules you installed as that is the whole point of dividing the config.js into smaller module based configs.
            I am presuming it could also pre-parse and raise errors to which module the error is located.

            Only starts getting relevant with complex setups as the base is extremely simple but rather than linux having a single file in /etc/… the config is divided to make working easier.

            1 Reply Last reply Reply Quote 0
            • A Offline
              artieikon
              last edited by Feb 21, 2019, 7:38 PM

              I also agree with this approach as it will allow us to script configuration/deployment easier. It would be similar to configurations done in other applications ie Nginx. For loadbalancing you just have a folder you can add all endpoints, ports, what have you and the system itself will read everything in there and make a master behind the scenes.

              I’ve tried to do something similar and stitch them together by hand but it seems that if i place any ‘require’ statement in the config.js file MM does not properly load my configs. I can monitor the logs and everything gets parsed and output properly, just when i go to the actual UI it just shows the standard “Please create a config file.” screen. I could not find any logs anywhere that show any additional errors of why this is not wanting to start.

              S 1 Reply Last reply Feb 21, 2019, 7:59 PM Reply Quote 0
              • S Offline
                sdetweil @artieikon
                last edited by sdetweil Feb 21, 2019, 8:03 PM Feb 21, 2019, 7:59 PM

                @artieikon require is not allowed in module.js, but you could use the getScripts function to load them

                Also

                Start mm in developers mode

                npm start dev
                

                Then select the console tab to see what’s going on in the modules
                Node_helpers display info in the terminal window

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                A 1 Reply Last reply Feb 21, 2019, 8:57 PM Reply Quote 0
                • ? Offline
                  A Former User
                  last edited by Feb 21, 2019, 8:12 PM

                  I always want Conditional Loading or Lazy Loading. I want programmable Pre-processor for which module should be loaded or not by just mention it.
                  And if configuration for each module be separated, PPL would make less mistakes on configuration step and at least, It could be easier to find which configuration wrong.

                  S A 2 Replies Last reply Feb 21, 2019, 8:41 PM Reply Quote 1
                  • E Offline
                    ejay-ibm Project Sponsor Module Developer
                    last edited by Feb 21, 2019, 8:28 PM

                    I can only agree 1 config file per module in the config folder and you can get rid of a lot of mistake

                    1 Reply Last reply Reply Quote 0
                    • S Offline
                      sdetweil @Guest
                      last edited by Feb 21, 2019, 8:41 PM

                      @sean thats all cool, but will take significant rewrite of the core services…

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

                      1 Reply Last reply Reply Quote 0
                      • 1
                      • 2
                      • 3
                      • 1 / 3
                      1 / 3
                      • First post
                        6/21
                        Last post
                      Enjoying MagicMirror? Please consider a donation!
                      MagicMirror created by Michael Teeuw.
                      Forum managed by Sam, technical setup by Karsten.
                      This forum is using NodeBB as its core | Contributors
                      Contact | Privacy Policy