Purpose
The purpose of this article is to demonstrate how to install and use the Calendar component (module)
Background
Installation Procedure
1. In PSU, select Platform, Modules.
2. Select PSGallery as the package source from the drop-down menu.
3. Search for Universal.Components.Calendar.
4. Assuming there are results (as shown in the above animated gif), click 'Install' on the result to install the module.
5. Confirm that the module installed by checking selecting Platform, Modules again and then checking inside of the Univeral Modules folder (as shown in the above animated gif).
You now have the Calendar component installed to the Integrated environment which provides New-UDCalendar and New-UDCalendarEvent. Note that you must have this module installed in any PowerShell environment that you plan to build dashboards with that use the Calendar component.
Usage Example
[array]$calendar_events = 1..((Get-Date -Date ([string]((Get-Date).Year+1) + "-01-01"))-(Get-Date '00:00')).Days | `
ForEach-Object {(Get-Date '00:00').AddDays($_)} | Where-Object {$_.DayOfWeek -eq 'Monday'} | `
ForEach-Object { New-UDCalendarEvent -Title 'Happy Monday!' -Start $_ -BackgroundColor 'Green' -BorderColor 'Red' -AllDay }
New-UDDashboard -Title 'PSU Calendar Demo' -Pages @(
New-UDPage -Name 'PSU Calendar Demo' -Content {
New-UDCalendar -Id 'calendar_01' -Events $calendar_events -InitialDate (Get-Date).AddMonths(1) -DateClicked {
$EventData_string = $EventData | ConvertTo-Json -Compress
Show-UDToast -Message $EventData_string -Duration 5000
}
}
)
The above dashboard will render a calendar with each remaining Monday of the year marked with an event.
The above screenshot shows the example code rendered
Notes