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.

    Canteen-module // Mensa-Modul

    Scheduled Pinned Locked Moved Solved Requests
    15 Posts 4 Posters 5.1k Views 4 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.
    • lavolp3L Offline
      lavolp3 Module Developer @k-0
      last edited by

      @k-0 Hi k-0.
      So, I liked the idea.
      So sat down and, well, basically wrote a new module :-)
      I’ve sent a PR, let me know your comments.

      There’s still lots to do especially the readme :-)

      And lots of things to configure.
      I can’t use the module, my studies are 10 years back, but I think there may be some people who can benefit from it so I’m interested in bringing this forward.

      Ideas:

      • option to show the whole week
      • option to filter meals (leave out vegetarian food, LOL)

      Cheers,
      Dirk

      How to troubleshoot modules
      MMM-soccer v2, MMM-AVStock

      lavolp3L 1 Reply Last reply Reply Quote 0
      • lavolp3L Offline
        lavolp3 Module Developer @lavolp3
        last edited by

        0_1574430694203_12b674f2-ae5a-43e7-b136-9fcdf761dda5-image.png

        Doesn’t look too shabby but lots of styling to be done I guess

        How to troubleshoot modules
        MMM-soccer v2, MMM-AVStock

        1 Reply Last reply Reply Quote 0
        • K Offline
          k-0
          last edited by k-0

          Hi Dirk,

          I could test it today and I really love it! Thank you so much!

          0_1575297143322_mmm.PNG

          I already updated the ReadMe and added the “€” to the price in the .njk-file.

          It would be nice to have the date in the header on which the meal refers. :P

          Cheers,
          Kevin

          EDIT: I think that a option to show the whole week is nice, especially for ppl who have only one or two meals per day. Otherwise it will be to much informations to show.

          lavolp3L 1 Reply Last reply Reply Quote 0
          • lavolp3L Offline
            lavolp3 Module Developer @k-0
            last edited by

            @k-0
            The “header” from the config is nothing but a html element.
            You could leave the header column out of the module definition and include it separately in your .njk.
            Then you would need it to be given a name by the user (via the config) since it is not thrown out by the API.

            Then just put a

            tag above the rest and include the canteen name and a date.

            < header >{{ config.canteenName }}, {{ moment().format("dd, DD.MM.) }} < /header >
            

            How to troubleshoot modules
            MMM-soccer v2, MMM-AVStock

            1 Reply Last reply Reply Quote 0
            • K Offline
              k-0
              last edited by

              Hi @lavolp3 ,

              i added

              <header>{{ config.canteenName }}, {{ moment().format("dddd") }}</header>
              

              to my MMM-Canteen.njk. But I always get “undefined”.

              It works with

              {{ config.canteenName }}
              

              It seems there is a problem with moment() in the header. Do you have an idea?

              lavolp3L 1 Reply Last reply Reply Quote 0
              • lavolp3L Offline
                lavolp3 Module Developer @k-0
                last edited by

                @k-0 I am not 100% sure but I think moment() does not work in a nunjucks environment. So what I said above may have been very wrong, sorry!

                I can’t test it now, but you can confirm the error with the moment() function by opening the mirror in your browser, then opening the developers console (F12) and looking in the console for an error thrown out by the template.

                The nunjucks template works with

                • usual html code
                • variables you provide it with in the getTemplateData function
                • filters (which are functions that need to be bound to functions in the main js file)

                So what you can do is to include the variable in the getTemplatedata function

                today: moment().format("dddd")
                

                then call it in the template using

                < header >{{ config.canteenName }}, {{ today }} < /header >

                How to troubleshoot modules
                MMM-soccer v2, MMM-AVStock

                1 Reply Last reply Reply Quote 0
                • K Offline
                  k-0
                  last edited by

                  @lavolp3
                  Ah, i didn’t know this.

                  Now it works with your example! :)

                  Unfortunately he takes the current date and not the date of the actual meal. (keyword: switchingTime). If and else apparently don’t work in the getTemplateData function. Or am I wrong?

                  lavolp3L 1 Reply Last reply Reply Quote 0
                  • lavolp3L Offline
                    lavolp3 Module Developer @k-0
                    last edited by

                    @k-0 Of course they do. It is just a javascript function returning data that gets used by the nunjucks template.

                    This shortened and slightly more elegant if/else version should do the trick

                    today: (moment() < moment(this.config.switchTime, "HH:mm")) ? moment().format("dddd") : moment().add(1, "days").format("dddd")
                    

                    How to troubleshoot modules
                    MMM-soccer v2, MMM-AVStock

                    1 Reply Last reply Reply Quote 0
                    • 1
                    • 2
                    • 2 / 2
                    • First post
                      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