Reload page on tab change

Hi, I have tried many methods of page refreshing and IIS timeouts but none seem to be perfect. I have around 300 users accessing my dashboard and it generally works, but still have a random CPU issue (Unresponsive Dashboard 2.9.0) which requires me to reset my dashboard. When i do reset, anyone with an existing connection gets errors.

I have tried using a timed refresh but this doesnt seem to work when a dashboard is not in focus, being used (Idle Timeout Issues)

I want to force the dashboard to reload on each tab change, so when a user goes away and comes back it reloads from the server. I believe i could do this with location.reload(true); but no idea how to implement this, i have tried with new-html and helmet but no joy. I noticed @psDevUK you used this in your sweetalert and i wondered if you (or anyone else) had any ideas?

Thanks!

Hey @neo I hope you keeping well…wow 300 end-users nice :sunglasses: I guess using the ADMIN tool that got built in should help you in resolving the CPU issues…or maybe process monitor from sysinternals…not using 2.9.0 myself yet, I find 2.8.1 nice and stable…ok so…

So I am thinking you probably have everything in an endpoint, and it should pull the latest data on a tab change if you put it in an endpoint…or is the problem the end-user opens the dashboard leaves it open but does other ‘things’ comes back to the dashboard 40+ mins later and components not responding or page has timed out correct?
I just want to fully understand the issue you are facing to see if I have encounted a similar issue…also if you are using cross-browsers as in IE,Chrome,FireFox etc is there a pattern with the browser that this is happening to? I am assuming you want in effect an F5 refresh for when they come back to the dashboard if it has been over ‘x’ amount of minutes…?

Hey! Thanks for the reply so quickly…! Hope you are also well in these challenging times!

I am using -adminmode but not really getting anyhting out of it that can determine my CPU. I also use sysinternals suite and can see the process that is causing the spike but its hard to dive into the thread detail inside UD as it manifests itself as a single process.

Every piece of data collection i do is in an endpoint - correct and you have it spot on that when a user leaves a tab it is unreliable if it will work when they come back. I do have the page refreshing every 10 mins via udhelmet and this really does refresh, but when i do a iisreset i see endpoint failures all over the place in udlog, this is from sessions that are stale to the dashboard. I have just done a test on this and the refresh page does actually do a proper refresh but the user has to wait 10 mins (or whatever time i set). I wanted to know if this can be triggered by the user changing focus to the browser tab.

I am using cross browsers, mainly Edge and Chrome but im sure some firefox is sneaking in - i have said we do not support IE.

All good down here in the south thanks :crazy_face: even physically driving into work tomorrow…anyways back to your problem, just so I got this straight if numerous people have ‘issues’ or ‘issues’ occur you stop and start the site in IIS to resolve the problem, but this then causes endpoint failures in the UDlog. And you in effect would like to be able for the UD site to stay active when the user is not using it. Or have a ‘magic’ button they can press if the page should become stale which will gather the latest information from the dashboard yeah?
I mean have you considered any plug-ins such as https://chrome.google.com/webstore/detail/staying-alive-for-google/lhobbakbeomfcgjallalccfhfcgleinm or plugins out the question?

I have similar issues.
The main one for me is if you leave the page open, then come back to it x hours later after the session has timed out you’ll hit errors or problems when clicking things on the page, but nothing is obvious to the end user about this.

I saw the following bugs/features were logged in git which would resolve the issue so I’m waiting until they’re implemented:


3 Likes

@psDevUK - Thanks as always for the replies. We cannot install addons for users as that would mean a lot of hoops to jump through to even stand a chance. I think @insomniacc has the correct link to the bug we are talking about here from @mylabonline -

Describe how this would improve your Universal Dashboard Quality of Life

End-user experience - if the session is expired redirecting back to the login page would stop end-users from trying to click buttons where the session is already expired and they receive a disconnected state error.

or -

Describe the solution you’d like

It would be nice to be able to popup a “Your Session Timed Out” page when the session times out, potentially with some verbiage that they should refresh the page.

@adam - got to love a looping chain! This does seem to be an issue. I know my user group are not happy with a F5 refresh as they dont know its timed out and just complain that x-y-z are not working…

We could use something like this? https://github.com/travishorn/session-timeout

Or something like this using jQuery: https://www.codeproject.com/Tips/1175658/Session-Expiration-Popup

I like the idea that as a user you get a message about the expired session. But in my opinion i would not log out directly, I would show a message that the session has expired and you have to log in again. After pressing OK you will be redirected to the login page.

I really like this idea, and just attempted a mock-up of this where it brings up a modal after an expiry time which works and in my opinion is better than what i have no with udhelmet page refresh, but it does not work when iis is reset the udelement no longer runs…

   >  $Session:PageLoad = Get-Date
> $Session:TimeExpire = (get-date).AddSeconds(30)
> 
> New-UDElement -Tag 'div' -AutoRefresh -RefreshInterval 5 -Endpoint {
>     $TimeNow = Get-Date
>     if ($TimeNow -gt $Session:TimeExpire)
>     {
>         Show-UDModal -Header {New-UDHeading -Size 4 -Text "Session Expired"} -Content {
>             New-UDMuTypography -Variant h6 -Text "something useful"
>             New-UDParagraph -Text ""
>             New-UDMuButton -Id "BtnPageRefreshModal" -Text 'Refresh Page' -Variant outlined -FullWidth -OnClick {
>                 $URL = "https://test.me"
> 
>                 Invoke-UDRedirect -Url $URL
>             }
>         }
>     }
> }
1 Like

Once the session is reset and the endpoints are disposed of, you won’t be able to interact from PS. This needs to be implemented purely in JavaScript to check to see if it can access the server. It may be possible with New-UDHtml and by creating an <script> tag that pings the server but it’ll be tricky to make a nice notification.

I’ll make sure this is implemented in the next version. Both the redirect for a timed out login and a message box that pops up when the session is expired.

4 Likes

Cool, thanks adam!

Hi Adam, by next version, do you mean in v3 or in a v2.x version?

Thanks!

This will first go into the current master v3 branch and then I’ll see about porting it back to v2.

Just an FYI - This change has been merged into master. I’ll look at merging to the v2 branch (along with a couple other changes) in the next couple of days.

4 Likes

Wow you are good. Thanks

nice work man…seen you had some great feedback from other UD forum members…also seen @adam has this fully under-control and will be posting an update soon. However I was still interested in a solution for this myself, and stumbled upon:- https://www.npmjs.com/package/react-idle-timer so maybe could add this to the marketplace to allow custom timeout component :thinking:

3 Likes

Boom man! I managed to get react-idle-timer working with UD and binded…so I can set a prop for the timeout period…then that sets the isTimedOut to True or False depending on the time period set, and is the user is idle or not…Then if the user does become idle you can then program UD to do whatever


This GIF shows a modal as it has detected the user is idle…I will upload this to the marketplace for others but maybe save you having to implement this for V2 versions :thinking:
So hopefully this will help others but this is the code from the GIF

Import-Module -Name UniversalDashboard.Community -RequiredVersion 2.8.1
Import-Module -Name UniversalDashboard.UDTimeOut
Get-UDDashboard | Stop-UDDashboard
$init = New-UDEndpointInitialization -Module @('UniversalDashboard.UDTimeOut')
Start-UDDashboard -Port 10005 -Dashboard (
    New-UDDashboard -Title "Powershell UniversalDashboard" -EndpointInitialization $init -Content {
        New-UDRow -Columns {
            New-UDColumn -Size 12 -Endpoint {
                New-UDTimeOut -Id "TIMEOUT"

                New-UDButton -Text "TEST" -OnClick {
               
                 Show-UDToast -Message "Thank you" -Position topLeft -Duration 4000
               
                }
               
            }

        }
        New-UDRow -Columns {
            New-UDColumn -Id "Checker" -Size 12 -Endpoint {
                $Timeout2 = (Get-UDElement -Id 'TIMEOUT').Attributes.isTimedOut
                if ($Timeout2 -eq "True") {
                    Show-UDModal -Content { New-UDHeading -Size 5 -Text "Game Over" }
                }
            } -AutoRefresh -RefreshInterval 5
        }
    }
)

5 Likes

Ninja skills. I’ll be testing this out tomorrow, curiuos how this will work with iis reset rather than a timer… thanks!!!

Hey @neo @Mordecai @insomniacc @mylabonline I just put together a github repository here:-


I have now published this module to the powershellgallery which in-turn will sync to the marketplace, but at the moment it is here:-

Hopefully after reading the readme on the github repo you will have a good enough understanding to implement this component into your dashboard :crazy_face:
Now available on the marketplace:-
https://marketplace.universaldashboard.io/Dashboard/UniversalDashboard.UDTimeOut

2 Likes

I love the icon choice!

1 Like

The icon is so cool!
i will test it later :slight_smile:
Very cool, thanks @psDevUK

1 Like