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 } } $ActionControls = 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" } } } [PSCustomObject]@{ Id = $Tag.Id Tag = $TagLabelData Description = $Description Actions = $ActionControls } } | Out-UDGridData } -AutoRefresh -RefreshInterval 10 } |