controls/variable-grid.ps1
function New-VariableGrid { param ([bool] $isEdit = $true) if($isEdit -eq $false) { New-UDGrid -Id "VariablesGrid" -Title "Variables" -Headers @("Id","Name", "Value", "PowerShell") -Properties @("Id", "Name", "Value", "PowerShell") -Endpoint { $Variables = Get-UAVariable $Variables | ForEach-Object { $ScriptHelpButton = New-UDButton -Text "Script" -Icon code -OnClick { New-PowerShellHelpModal -Object $_ } [PSCustomObject]@{ Id = $_.Id Name = $_.Name Value = $_.Value PowerShell = $ScriptHelpButton } } | Out-UDGridData } } else { New-UDGrid -Id "VariablesGrid" -Title "Variables" -Headers @("Id", "Name", "Value","Actions") -Properties @("Id", "Name", "Value","Actions") -Endpoint { $Variables = Get-UAVariable $Variables | ForEach-Object{ $Variable = $_ $ExistingValue = $_.Value $RemoveButton = New-UDButton -Text "" -Icon ban -OnClick { New-UDDeleteVariableModal -Variable $Variable } $EditButton = New-UDButton -Text "" -Icon edit -OnClick { New-UDEditVariableModal -Variable $Variable } 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 Variable"} " " New-UDTooltip -Content{$RemoveButton} -TooltipContent {"Remove Variable"} } } else { "N/A" } [PSCustomObject]@{ Id = $_.Id Name = $_.Name Value = $_.Value Actions = $ActionButtons } } | Out-UDGridData } } } |