moqui

How to auto-refresh a screen in Moqui?


Use case is a regularly updated display of vehicle tracking data retrieved through a REST call, onto a central office screen, with no user interaction.


Solution

  • There is no single answer for this, but some alternatives to consider:

    1. add some JavaScript to your screen that uses the JS setTimeout() method or something similar to reload the page
    2. for a smoother result but a lot more effort write the section of the screen that needs to auto-update as a Vue component and use the standard websocket interface to send data to the browser to update the data in the HTML; this is generally best done using the NotificationMessage interfaces and methods in the Moqui API where the JavaScript client registers on a topic and gets a notification along with any others registered (structure the topic ID as needed to differentiate different feeds) and have a scheduled service job feed the notification topic