controls/job-upcoming-grid.ps1

function New-JobUpcomingGrid {
   
    New-UDGrid -Id "JobUpcomingGrid" -Title "Scheduled Script Jobs" -Headers @("Id","Script","Next Execution", "Schedule","Actions") -Properties @("Id","Script", "NextExecution", "Schedule","Actions") -Endpoint {
        $Schedules = Get-UASchedule
        
        $Schedules | ForEach-Object {
            $NextExecution = $_.NextExecution
            if ($_.NextExecution -eq [DateTime]::MinValue)
            {
                $NextExecution = "As soon as possible"
            }

            $Script = Get-UAScript -Id $_.Script.Id
            $Cron = $_.Description
            $Schedule = $_
            $ScheduleId = $Schedule.Id

            $CancelButton = New-UDButton -Text "" -Icon ban -OnClick {
                New-ScheduleRemoveModal -Schedule $Schedule
            }

            $ActionControls =  New-UDElement -Tag div -Content{
                New-UDTooltip -Content{$CancelButton} -TooltipContent {"Cancel the Schedule"}
            }


            [PSCustomObject]@{
                Id = $ScheduleId
                Script = New-UDLink -Text $Script.Name -Url "/script/$($Script.Id)"
                NextExecution = $NextExecution
                Schedule = $Cron
                Actions = $ActionControls
            }

        } | Out-UDGridData
    } -AutoRefresh
}