img refresh
-
Hi there
I have a situation where an image in the mango file store is being over written by a script with a new image and obviously has the same file name.
On the UI the goal is I to render the new image, this doesn't happen until the page is refreshed. Which doesn't make for a very seamless UI as some ui-states are lost in the refresh.
I have tried a few things with buttons and ng-click to re-render the image but only a page refresh works. I noticed that the preview in the mango file store also doesn't change until there is a refresh.is there a way to manually refresh the mango file store manually with a global script?
Or could you give some advice on another route to accomplish the goal. -
Hi CraigWeb,
This is a very similar question to: https://forum.infiniteautomation.com/topic/3406/how-to-refresh-image-by-time-or-by-click
A possible solution would be adding a pointless parameter to the image's ng-src and avoid any caching issues / actually changing the ng-src and getting it to reload the image. Like,
<ma-now update-interval="1 SECONDS" output="to"></ma-now> <img ng-src='/images/bullet_delete.png?time={{to | maMoment:"format":"DDHHmmssSSS"}}'/>
Will poll the image every second.
-
Thank you for the help Phil. It was very helpful however I would like to rather do it on demand rather than on a timer. how ever I need a small delay on the change of the variable while the image is being changed. might not be the cleanest but I would like something to this effect but cant get it to work. I see $timeout is injected into the app.
<ma-fn expression="$timeout(function() {myvar=myvar+1}, 2000)" fn="myFunction" ready="" arg-names="myvar"> </ma-fn>
-
Delay between what? When you click does it perform some action to change the image? You will not be able to use
$timeout
in an expression like that. -
I want the expression to run a few seconds after a button is clicked, I need to wait for a script outside of mango to run. So I don't have a callback. The script replaces an image in the file store. Once it done I want to change a pointless parameter like Phil did above