I want to know Best Way to Handle User Input in PowerShell Universal Dashboard?
Hey everyone,
I am working on a dashboard using PowerShell Universal & want advice on improving how I handle user input. I have set up a basic form with a couple of text fields and a date picker—pretty standard stuff. The idea is for users to input a username and a date range, then the dashboard runs a script and shows some data in a table.
It is functional, but not very smooth. Sometimes the table does not update unless the page is refreshed & I feel such as the overall experience could be better. I have heard people mention using Set-UDElement or other dynamic components to make it more responsive—any tips or examples would be awesome.
Also, I am looking into building similar dashboards for internal teams that also use other tools such as Jira so I have been going through some jira online training just to understand how workflows translate. Hoping to bring some of those ideas here. Also i have check this The Best Ways to Use PowerShell Universal to Manage Huge Dashboards still want to know more.
Thank you…
If you are looking for dynamic updates, then take a look at
New-UDDynamic and Sync-UDElemet
Here is a basic example:
New-UDApp -Content {
New-UDCard -Title "Update" -Content {
New-UDButton -Text "Update Table" -OnClick {
Sync-UDElement 'tableData'
}
}
New-UDDynamic -Id "tableData" -Content {
$Data = @(
@{ Application = 'Web API'; Status = 'Running'; CPU = 12.5; MemoryMB = 204; LastChecked = (Get-Date).AddMinutes(-1) }
@{ Application = 'SQL Database'; Status = 'Warning'; CPU = 45.2; MemoryMB = 3072; LastChecked = (Get-Date).AddMinutes(-5) }
@{ Application = 'Redis Cache'; Status = 'Running'; CPU = 5.3; MemoryMB = 512; LastChecked = (Get-Date).AddMinutes(-3) }
@{ Application = 'Worker Service';Status = 'Stopped'; CPU = 0.0; MemoryMB = 0; LastChecked = (Get-Date).AddMinutes(-2) }
)
New-UDTable -Title "My Table Data" -Data $Data
} -AutoRefresh
}
Notice how the date changes when you click on Update table. You could also add -Autorefresh with an interval on New-UDDynamic, if you want it to update automatically.