Skip to content

Commit

Permalink
Fixes #1381 (#1388)
Browse files Browse the repository at this point in the history
Adds new param "scheduled" to target scheduled endpoints to invoke.
  • Loading branch information
BoSen29 authored and adamdriscoll committed Dec 17, 2019
1 parent d6d212c commit 346e102
Showing 1 changed file with 34 additions and 6 deletions.
40 changes: 34 additions & 6 deletions src/UniversalDashboard/Controls/src/event.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,51 @@ function Invoke-UDEvent {
[String]$Id,
[Parameter(
Mandatory = $true,
Position = 1
Position = 1,
ParameterSetName = "onClick"
)]
[ValidateSet("onClick")]
[string]$event
[string]$event,
[Parameter(
Mandatory = $true,
Position = 1,
ParameterSetName = "Scheduled"
)]
[switch]$scheduled
)

Begin {

}

Process {
Invoke-UDJavaScript -javaScript "
document.getElementById('$Id').click();
"
if ($PSCmdlet.ParameterSetName -eq "onClick") {
Invoke-UDJavaScript -javaScript "
document.getElementById('$Id').click();
"
}
elseif ($PSCmdlet.ParameterSetName -eq "Scheduled") {
$dashboard = Get-UDDashboard
$endpoint = $dashboard.DashboardService.EndpointService.ScheduledEndpoints | where-object Name -eq $Id

if ($endpoint) {
try {
$endpoint.ScriptBlock.Invoke() | Out-Null
}
catch {
throw ("Invoking endpoint $Id failed with: $($_.Exception.Message)")
}

}
else {
Write-UDLog "Attempting to trigger $Id failed, unable to locate endpoint."
}

}

}

End {

}
}
}

0 comments on commit 346e102

Please sign in to comment.