itimpi Posted February 15 Share Posted February 15 I was wondering if anyone knows if there is a way to force the current GUI page to be refreshed from a script that has been initiated via cron or an Unraid event? The reason I want to be able to do this this is that if the GUI is sitting on the Main tab and the Parity Check Tuning plugin either pauses or resumes a parity operation the GUI does not enable the pause/resume buttons as I would like. Doing a manual refresh corrects this but it would be tidier if I could do it at an appropriate time from my code running in the background (i.e. not as part of a .page file). Quote Link to comment
Squid Posted February 16 Share Posted February 16 Don't think you can other than your javascript either via nchan or an intermittent post etc checks the status and then reloads the page itself Quote Link to comment
Rysz Posted February 16 Share Posted February 16 (edited) Why not do it via .page and JS, periodically checking the status of the parity operation and enabling/disabling buttons accordingly? There'd be no need to do a full page refresh with JS checking the parity operation's status and then enabling/disabling buttons via jQuery. Edited February 16 by Rysz Quote Link to comment
itimpi Posted February 16 Author Share Posted February 16 4 hours ago, Rysz said: Why not do it via .page and JS, periodically checking the status of the parity operation and enabling/disabling buttons accordingly? There'd be no need to do a full page refresh with JS checking the parity operation's status and then enabling/disabling buttons via jQuery. Because I do not own the .page file in question and did not want to try and modify the standard file. However I wonder if I can add a hidden section to that page that does a refresh - something to look into. Quote Link to comment
Rysz Posted February 16 Share Posted February 16 (edited) 6 hours ago, itimpi said: Because I do not own the .page file in question and did not want to try and modify the standard file. However I wonder if I can add a hidden section to that page that does a refresh - something to look into. That's what I meant, you can create a seperate .page file in your plugin for this, specifically by using the "Buttons" menu your hidden code will be available on all GUI pages. Then you can use PHP to make sure it is included only on the "Main" page where it is needed. Using JS you could then communicate with (for example) a PHP script of your plugin that returns the parity check status, afterwards parsing that result and then using jQuery to enable/disable the respective buttons on the fly. That checking function could be run periodically using a timer, say every 5 seconds or whatever time you set. There's no real need to cause a full page refresh, you could just update the relevant parts using jQuery. Here's an example .page file that would achieve such a hidden code insertion: Menu="Buttons:198" Link="nav-user" --- <?if(stripos($path, "main") !== false):?> <script type="text/javascript"> // this section gets added to all GUI pages where path has 'main' in the URL // could check for parity check status here, e.g. communicating with PHP script // or checking for file existence. could parse result and enable/disable parity // buttons using jQuery afterwards. a timer could run check function periodically. </script> <?endif;?> Edited February 16 by Rysz Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.