I have a dynamic page that reaches out to another remote system and queries live data in order to build the page. So, the page can take anywhere from 3 to 10 seconds to load depending on the bandwidth/latency between my UD server and remote system. Is there any way to display a “Page Loading. Please wait…” message to the user while the endpoint scriptblock is being executed to build the dynamic page? Currently, the header/footer load but the body of the page is blank until endpoint execution completes. That’s not ideal. Thanks in advance for any tips or pointers!
There is a preloader element: New-UDPreloader.
Here is an example:
Thanks @psott. In that example, is $Cache:Loading a built-in variable created and updated by the module, or is it something I have to define/update?
I figured this out. This example was particularly helpful:
https://www.powershellgallery.com/packages/PUDAdminCenterPrototype/0.2.0/Content/Pages\Dynamic\StoragePage.ps1
Here’s the formula:
$PageEndpoint = {
param($sys)
#region Loading Indicator
$Session:DoneLoading = $false
New-UDRow -Columns {
New-UDColumn -Endpoint {
New-UDElement -Id 'LoadingMessage' -Tag div -Endpoint {
if ($Session:DoneLoading -ne $true) {
New-UDHeading -Text "Loading...Please wait..." -Size 5
New-UDPreloader -Size small
}
}
}
}
#endregion
New-UDColumn -Size 12 -Endpoint {
<#
Build your time-intensive page here.
#>
# Remove the Loading Indicator
$Session:DoneLoading = $true
Sync-UDElement -Id 'LoadingMessage' -Broadcast
}
}
$DynamicPage = New-UDPage -Url "/example/:sys" -Endpoint $PageEndpoint
3 Likes