controls/job-rerun-modal.ps1
function New-JobReRunModal { param ( [Parameter(Mandatory = $true)] $Job ) Show-UDModal -Content { New-UDPageHeader -Text ("ReRunning Job: $($Job.ID)") New-UDParagraph -Text "Are you sure you wish to ReRun this Job, using the same feedback (if any) as the previous job?" New-UDParagraph -Text "NOTE: Job/Script Params NOT yet implemented!" New-UDElement -Tag div -Attributes @{ style = @{ textAlign = "right" } } -Content { New-UDButton -Text "Confirm" -Icon check -OnClick{ $Script = Get-UAScript -Id $($Job.Script.Id) $ScriptParameters = Get-UAScriptParameter -ScriptId $($Script.Id) $Parameters = $Job.Parameters #Old JOb $OldJobFeedBack = $Job | Get-UAJobFeedback #TODO Need TO CHECK ORIG SCRIPT PARAMS - NOT JUST FEEDBACK $NewJob = Invoke-UAScript -Id $($Job.Script.Id) -AppToken $Session:AppToken | Wait-UaJob #TODO Need to do a more sophisticated await here if ($OldJobFeedBack) { $NewJobFeedBack = (Get-UAJobFeedback -JobId $NewJob.Id) | Where-Object Complete -eq $false Set-UAJobFeedback -JobFeedback $NewJobFeedBack -Response $OldJobFeedBack.Data } Sync-UDElement -Id "JobRunningGrid" -Broadcast Sync-UDElement -Id "ScriptsGrid" -Broadcast Invoke-UDRedirect -Url "/job/$($NewJob.Id)" } } } } |