controls/schedule-grid.ps1

function New-ScheduleGrid 
{
    param($Script)

    New-UDGrid -Id 'schedule-grid' -Title "Schedules" -Headers @("Id","Schedule", "Next Execution Time", "Script", "Actions") -Properties @("Id","Cron", "NextExecution", "Script","Actions") -Endpoint {
        if ($null -ne $Script)
        {
            Get-UASchedule -Script $Script |  ForEach-Object {

                $Schedule = $_

                $CancelButton = New-UDButton -Text "" -Icon ban -OnClick {
                    New-ScheduleRemoveModal -Schedule $Schedule
                }
    
                $ActionControls =  New-UDElement -Tag div -Content{
                    New-UDTooltip -Content{$CancelButton} -TooltipContent {"Remove Schedule"}
                }

                $NextExecution = $_.NextExecution
                if ($_.NextExecution -eq [DateTime]::MinValue.ToString())
                {
                    $NextExecution = "As soon as possible"
                }

                [PSCustomObject]@{
                    Id = $_.Id
                    Cron = $_.Description
                    NextExecution = $NextExecution
                    Script = (New-UDLink -Text $Script.Name -Url "/script/$($Script.Id)")
                    Actions = $ActionControls
                }
            } |  Out-UDGridData
        }
        else
        {
            Get-UASchedule | ForEach-Object {
                $Script = Get-UAScript -Id ($_.Script.Id)
                $NextExecution = $_.NextExecution
                if ($_.NextExecution -eq [DateTime]::MinValue.ToString())
                {
                    $NextExecution = "As soon as possible"
                }

                [PSCustomObject]@{
                    Id = $_.Id
                    Cron = $_.Description
                    NextExecution = $NextExecution
                    Script = New-UDLink -Text $Script.Name -Url "/script/$($Script.Id)"
                    Actions = ""
                }
            } |  Out-UDGridData
        }
    } -AutoRefresh -RefreshInterval 10
}