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.

    Add module reference to alerts

    Scheduled Pinned Locked Moved Feature Requests
    alert
    7 Posts 3 Posters 5.5k Views 2 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.
    • strawberry 3.141S Offline
      strawberry 3.141 Project Sponsor Module Developer
      last edited by

      Hey guys,

      I recently worked on

      [card:fewieden/MMM-AlarmClock]

      and stumbled on a problem. I want to support normal devices and touch screen devices. Non touch screen is working fine already,
      but there’s a problem for the touch screen mode. I added a button but when I fire an alert from the default alert module, there will be an overlay, so my button will not be clickable. To get around this, I thought about adding a reference to an alert, so I can query the alert of my module and give it a click event.

      My thought was to change this https://github.com/MichMich/MagicMirror/blob/master/modules/default/alert/alert.js#L91 to

      message += "<span data-sender='" + sender.name + "' class='thin' style='font-size:22px;line-height: 30px;'>" + params.message + "</span>";
      

      What are your thoughts on this?

      Please create a github issue if you need help, so I can keep track

      1 Reply Last reply Reply Quote 1
      • MichMichM Offline
        MichMich
        last edited by

        Paging @paviro since he is te writer of the alert module.

        1 Reply Last reply Reply Quote 0
        • MichMichM Offline
          MichMich
          last edited by

          Can’t you just change the z-index of the button in your module’s CSS file?

          strawberry 3.141S 1 Reply Last reply Reply Quote 0
          • strawberry 3.141S Offline
            strawberry 3.141 Project Sponsor Module Developer @MichMich
            last edited by

            @MichMich z-Index didn’t work for me, but with the following code I could achieve what I was trying to do.

            MM.getModules().enumerate((module) => {
                if(module.name === 'alert'){
                    module.alerts["MMM-AlarmClock"].ntf.addEventListener("click", ()=>{this.resetAlarmClock();});
                }
            });
            

            Please create a github issue if you need help, so I can keep track

            1 Reply Last reply Reply Quote 0
            • MichMichM Offline
              MichMich
              last edited by

              So no more change to the core is required?

              strawberry 3.141S 1 Reply Last reply Reply Quote 0
              • strawberry 3.141S Offline
                strawberry 3.141 Project Sponsor Module Developer @MichMich
                last edited by

                @MichMich In my oppinion it’s not a good idea to mess around with other modules variables. If someone has a better approach just let me now, but it would work without changes to the core at the moment.

                Please create a github issue if you need help, so I can keep track

                1 Reply Last reply Reply Quote 1
                • paviroP Offline
                  paviro
                  last edited by

                  Well feel free to change things in the alert module since it should be rewritten at some point anyway… :D

                  We're all stories in the end. Just make it a good one, eh?

                  – The Doctor

                  1 Reply Last reply Reply Quote 0

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  • 1 / 1
                  • 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