Interaction
Interaction features of Universal Dashboard
Last updated
Was this helpful?
Interaction features of Universal Dashboard
Last updated
Was this helpful?
Universal Dashboard enables the ability to create interactive websites with PowerShell. There are several cmdlets that have been implemented to provide feedback to the user, update components and read the state of components.
You can set string data into the user's clipboard with Set-UDClipboard
.
You can start a download within the user's browser by using Start-UDDownload
. Due to security of web browsers, the user will need to take an action (like click a button) to allow the download to take place. Start-UDDownload
is not suited for large file downloads.
Many components support event handlers in the form of script blocks. You may also see these referred to as endpoints as that is what they were called in Universal Dashboard v2. These event handlers allow you to invoke PowerShell scripts when certain actions take place on the page.
For example, you may have a button click that calls an event handler. This button will show a toast when clicked. You can include any valid PowerShell cmdlet within the event handler code.
Variables are automatically scoped into event handlers. You will be able to access variables that you define outside of the variable within the event handler.
Some event handlers handlers will provide data as a string or as a hashtable. This depends on the event handler you are using. For example, the New-UDButton
-OnClick
event handler does not provide any data. On the other hand, the New-UDSelect
-OnChange
will provider event data.
You can access the event data by using the $Body
variable to access the data as a string (sometimes formatted as JSON) or as a hashtable by using the $EventData
variable.
You can force a form to submit using the Invoke-UDForm
cmdlet. You can optionally chose to enforce validation by including the -Validate
parameter.
You can force a form to validate by using Test-UDForm
.
You can invoke JavaScript from PowerShell by using the Invoke-UDJavaScript
cmdlet.
You can use the Show-UDToast
cmdlet to create a toast message that will appear on the end user's webpage. It happens over a websocket and will show the toast immediately as it is called.
Toasts support icons as strings. You can use all the FontAwesome v5 icons.
Hides a toast based on the specified ID.
You can redirect users to different pages using the Invoke-UDRedirect
cmdlet. It happens over a websocket and will redirect as soon as the cmdlet is called.
You can open a modal using the Show-UDModal
cmdlet. It will open as soon as you call it. You can include whatever components you like within the modal.
You can manage component state dynamically by using the UDElement commands.
You can receive the state of an element using Get-UDElement
. The state will be returned as a hashtable. This is primarily useful for input components.
Alternatively, you can set component state using Set-UDElement
. You will need to specify an ID and a hashtable of properties to set on the component. All built in components support Set-UDElement.
You can remove components from the page using Remove-UDElement
. The component will no longer appear on the page.
Add a child component to an existing parent component.
You can remove all the children components from an component by using Clear-UDElement
.
Some components support reloading. You can trigger a reload of a component using Sync-UDElement
.
You can select a component with Select-UDElement
.
Read more about .