controls/tag-grid.ps1
function New-TagGrid { param ( $Script ) New-UDGrid -Id "TagGrid" -Title "Script Tags" -Headers @("Id", "Tag", "Description", "Actions") -Properties @("Id", "Tag", "Description", "Actions") -Endpoint { if (!$Script -or $Script -eq "" -or $null -eq $Script) { $isScriptTag = $false }else { $isScriptTag = $true } if ($isScriptTag -eq $true) { $Tags = Get-UAScriptTag -Script $Script } else { $Tags = Get-UATag } $Tags | ForEach-Object { $Tag = $_ $Description = $_.Description $TagLabelData = New-UDElement -Tag div -Id "TagDiv" -Content { New-ScriptTagHTML -Tag $Tag } if ($isScriptTag -eq $true) { $RemoveButton = New-UDButton -Text "" -Icon ban -OnClick { New-RemoveScriptTagModal -Script $Script -Tag $ScriptTag } $EditButton = "" } else { $RemoveButton = New-UDButton -Text "" -Icon ban -OnClick { New-RemoveScriptTagModal -Tag $Tag } $EditButton = New-UDButton -Text "" -Icon edit -OnClick { Edit-UDTagModal -Tag $Tag } } if ($null -eq $Session:AuthorizationPolicies -or ($Session:UserRole -eq 'Administrator' -or $Session:UserRole -eq 'Operator')) { $ActionButtons = New-UDElement -Tag div -Content{ New-UDTooltip -Content{$EditButton} -TooltipContent {"Edit Tag"} " " New-UDTooltip -Content{$RemoveButton} -TooltipContent { if ($isScriptTag -eq $true) { "Remove Tag from Script" } else { "Remove Tag" } } } } else { "N/A" } [PSCustomObject]@{ Id = $Tag.Id Tag = $TagLabelData Description = $Description Actions = $ActionButtons } } | Out-UDGridData } -AutoRefresh -RefreshInterval 10 } |