Product: PowerShell Universal
Version: 1.4.6
Recognizing that both are in the “inputs” section for PSU, can switches or check boxes be toggled by external data (we pull from Azure Tables but any data source) or are they only to retrieve decisions made by the user? Here is what we have thus far.
New-UDPage -Name 'Application Access Reviews' -Url accessreviews -Content {
$colors = Get-Colors
$common = $colors | Where-Object Mode -EQ common
$Session:ID = ($ClaimsPrincipal.Claims | Where-Object { $_.Type -eq 'http://schemas.microsoft.com/identity/claims/objectidentifier' }).value
New-UDElement -Tag 'div' -Id 'mainContainer' -Content {
New-UDRow -Columns {
New-UDColumn -LargeSize 8 -Content {
New-UDStyle -Content {
New-UDCard -TitleAlignment 'center' -Content {
New-UDElement -Tag div -Content {
$splat = @{
TableName = 'inactive'
Filter = "reviewerId eq '{0}'" -f $Session:ID
Property = @('Override', 'userDisplayName', 'appDisplayName', 'groupDisplayName')
ConnectionString = $Secret:GacTestStorage
}
$Data = Get-AzDataTableEntity @splat
$Columns = @(
New-UDTableColumn -Property 'Override' -Title 'Override' -Render {
New-UDSwitch -Color primary -Id 'oswitch'
}
New-UDTableColumn -Property 'userDisplayName' -Title 'userDisplayName' -IncludeInSearch
New-UDTableColumn -Property 'appDisplayName' -Title 'appDisplayName' -IncludeInSearch
New-UDTableColumn -Property 'groupDisplayName' -Title 'groupDisplayName' -IncludeInSearch
)
New-UDTable -Id 'service_table' -Data $Data -Title 'Assigned Access Reviews' -Columns $Columns -ShowSort -ShowSearch -ShowPagination -Dense -OnRowSelection {
$Item = $EventData
Show-UDToast -Message "$($Item | Out-String)"
}
New-UDButton -Text 'Override' -OnClick {
$value = Get-UDElement -Id 'service_table'
Show-UDToast -Message "$( $Session:ID )"
}
}
}
} -Style 'text-align: center;'
}
}
}
}
Basically, when the user chooses to toggle or check, We want that to persist between sessions based on data from the azure tables.
adam
November 9, 2022, 10:33pm
2
You should be able to. I would suggest something like:
New-UDTableColumn -Property 'Override' -Title 'Override' -Render {
New-UDSwitch -Color primary -Id 'oswitch' -Checked $EventData.Override -OnChange {
#Update Azure Tables
}
}
If you put your table in a Dynamic, you could even refresh the table after the change is made.
New-UDDynamic -Id 'table' -Content {
New-UDElement -Tag div -Content {
$splat = @{
# more table code here
New-UDTableColumn -Property 'Override' -Title 'Override' -Render {
New-UDSwitch -Color primary -Id 'oswitch' -Checked $EventData.Override -OnChange {
#Update Azure Tables
Sync-UDElement -Id 'table'
}
}
This is terrific. I am working on this now. Challenge I have is when the switch is thrown, I only have True or False thus I am not sure which row to update.
New-UDPage -Name 'Application Access Reviews' -Url accessreviews -Content {
$colors = Get-Colors
$common = $colors | Where-Object Mode -EQ common
$Session:ID = ($ClaimsPrincipal.Claims | Where-Object { $_.Type -eq 'http://schemas.microsoft.com/identity/claims/objectidentifier' }).value
New-UDElement -Tag 'div' -Id 'mainContainer' -Content {
New-UDRow -Columns {
New-UDColumn -LargeSize 8 -Content {
New-UDStyle -Content {
New-UDCard -TitleAlignment 'center' -Content {
New-UDDynamic -Id 'table' -Content {
New-UDElement -Tag 'div' -Content {
$splat = @{
TableName = 'inactive'
Filter = "reviewerId eq '{0}'" -f $Session:ID
Property = @('Override', 'userDisplayName', 'appDisplayName', 'groupDisplayName')
ConnectionString = $Secret:GacTestStorage
}
$Data = Get-AzDataTableEntity @splat
$Columns = @(
New-UDTableColumn -Property 'Override' -Title 'Override' -Render {
New-UDSwitch -Color primary -Id 'oswitch' -Checked $EventData.Override -OnChange {
#Update Azure Tables
# Sync-UDElement -Id 'table'
Show-UDToast -Message "$($EventData | Out-String)"
}
}
New-UDTableColumn -Property 'userDisplayName' -Title 'userDisplayName' -IncludeInSearch
New-UDTableColumn -Property 'appDisplayName' -Title 'appDisplayName' -IncludeInSearch
New-UDTableColumn -Property 'groupDisplayName' -Title 'groupDisplayName' -IncludeInSearch
New-UDTableColumn -Property 'userId' -Title 'userId' -Hidden
New-UDTableColumn -Property 'appId' -Title 'appId' -Hidden
)
New-UDTable -Id 'service_table' -Data $Data -Title 'Assigned Access Reviews' -Columns $Columns -ShowSort -ShowSearch -ShowPagination -Dense -OnRowSelection {
$Item = $EventData
Show-UDToast -Message "$($Item | Out-String)"
}
New-UDButton -Text 'Override' -OnClick {
$value = Get-UDElement -Id 'service_table'
# Show-UDToast -Message "$( $value.selectedRows | Out-String )"
Show-UDToast -Message "$( $Value | Out-String )"
}
}
}
}
} -Style 'text-align: center;'
}
}
}
}
adam
November 9, 2022, 11:31pm
4
That’s a scoping issue that you can resolve by storing the outer $EventData in another variable.
New-UDTableColumn -Property 'Override' -Title 'Override' -Render {
$Row = $EventData
New-UDSwitch -Color primary -Id 'oswitch' -Checked $EventData.Override -OnChange {
#Update Azure Tables
# Sync-UDElement -Id 'table'
Show-UDToast -Message ($Row.Override)
Show-UDToast -Message "$($EventData | Out-String)"
}
}
Thanks Adam.
Thank so much. It seems I only receive the last user in the table in the toasts
New-UDPage -Name 'Application Access Reviews' -Url accessreviews -Content {
$colors = Get-Colors
$common = $colors | Where-Object Mode -EQ common
$Session:ID = ($ClaimsPrincipal.Claims | Where-Object { $_.Type -eq 'http://schemas.microsoft.com/identity/claims/objectidentifier' }).value
New-UDElement -Tag 'div' -Id 'mainContainer' -Content {
New-UDRow -Columns {
New-UDColumn -LargeSize 8 -Content {
New-UDStyle -Content {
New-UDCard -TitleAlignment 'center' -Content {
New-UDDynamic -Id 'table' -Content {
New-UDElement -Tag 'div' -Content {
$splat = @{
TableName = 'inactive'
Filter = "reviewerId eq '{0}'" -f $Session:ID
Property = @('Override', 'userDisplayName', 'appDisplayName', 'groupDisplayName')
ConnectionString = $Secret:GacTestStorage
}
$Data = Get-AzDataTableEntity @splat
$Columns = @(
New-UDTableColumn -Property 'Override' -Title 'Override' -Render {
$Row = $EventData
New-UDSwitch -Color primary -Id 'oswitch' -Checked $EventData.Override -OnChange {
# Update Azure Tables
# Sync-UDElement -Id 'table'
Show-UDToast -Message ($Row.Override)
Show-UDToast -Message (@($Row.userDisplayName) -join ',')
}
}
New-UDTableColumn -Property 'userDisplayName' -Title 'userDisplayName' -IncludeInSearch
New-UDTableColumn -Property 'appDisplayName' -Title 'appDisplayName' -IncludeInSearch
New-UDTableColumn -Property 'groupDisplayName' -Title 'groupDisplayName' -IncludeInSearch
New-UDTableColumn -Property 'userId' -Title 'userId' -Hidden
New-UDTableColumn -Property 'appId' -Title 'appId' -Hidden
)
New-UDTable -Id 'service_table' -Data $Data -Title 'Assigned Access Reviews' -Columns $Columns -ShowSort -ShowSearch -ShowPagination -Dense -OnRowSelection {
$Item = $EventData
Show-UDToast -Message "$($Item | Out-String)"
}
New-UDButton -Text 'Override' -OnClick {
$value = Get-UDElement -Id 'service_table'
# Show-UDToast -Message "$( $value.selectedRows | Out-String )"
Show-UDToast -Message "$( $Value | Out-String )"
}
}
}
}
} -Style 'text-align: center;'
}
}
}
}
Making some progress!
$Columns = @(
New-UDTableColumn -Property 'Override' -Title 'Override' -Render {
$Row = $EventData
New-UDSwitch -OnChange { Show-UDToast "EventData: $($Row.values)" }
}
New-UDTableColumn -Property 'userDisplayName' -Title 'userDisplayName' -IncludeInSearch
New-UDTableColumn -Property 'appDisplayName' -Title 'appDisplayName' -IncludeInSearch
New-UDTableColumn -Property 'groupDisplayName' -Title 'groupDisplayName' -IncludeInSearch
New-UDTableColumn -Property 'userId' -Title 'userId' -Hidden
New-UDTableColumn -Property 'appId' -Title 'appId' -Hidden
)
Works perfectly!
New-UDPage -Name 'Application Access Reviews' -Url accessreviews -Content {
$colors = Get-Colors
$common = $colors | Where-Object Mode -EQ common
$Session:ID = ($ClaimsPrincipal.Claims | Where-Object { $_.Type -eq 'http://schemas.microsoft.com/identity/claims/objectidentifier' }).value
New-UDElement -Tag 'div' -Id 'mainContainer' -Content {
New-UDRow -Columns {
New-UDColumn -LargeSize 8 -Content {
New-UDStyle -Content {
New-UDCard -TitleAlignment 'center' -Content {
New-UDDynamic -Id 'table' -Content {
New-UDElement -Tag 'div' -Content {
$splat = @{
TableName = 'inactive'
Filter = "reviewerId eq '{0}'" -f $Session:ID
Property = @('Override', 'userDisplayName', 'appDisplayName', 'groupDisplayName', 'appId', 'userId')
ConnectionString = $Secret:GacTestStorage
}
$Data = Get-AzDataTableEntity @splat
$Columns = @(
New-UDTableColumn -Property 'Override' -Title 'Override' -Render {
$Row = $EventData
New-UDSwitch -Color primary -Checked $Row.Override -OnChange {
$Switch = $EventData
$RowKey = '{0}-{1}' -f $Row.appId, $Row.userId
Show-UDToast ('{0} - {1}' -f $Switch, $RowKey) -Duration 10000
$splat = @{
TableName = 'inactive'
Filter = "PartitionKey eq '{0}' and RowKey eq '{1}'" -f 'part1', $RowKey
ConnectionString = $Secret:GacTestStorage
}
$HashTable = Get-AzDataTableEntity @splat
$HashTable['Override'] = $Switch
$splat = @{
TableName = 'inactive'
Entity = $HashTable
ConnectionString = $Secret:GacTestStorage
Force = $true
CreateTableIfNotExists = $true
ErrorAction = 'Stop'
}
Add-AzDataTableEntity @splat
}
}
New-UDTableColumn -Property 'userDisplayName' -Title 'userDisplayName' -IncludeInSearch
New-UDTableColumn -Property 'appDisplayName' -Title 'appDisplayName' -IncludeInSearch
New-UDTableColumn -Property 'groupDisplayName' -Title 'groupDisplayName' -IncludeInSearch
New-UDTableColumn -Property 'userId' -Title 'userId' -Hidden -IncludeInExport
New-UDTableColumn -Property 'appId' -Title 'appId' -Hidden -IncludeInExport
)
New-UDTable -Id 'service_table' -Data $Data -Title 'Assigned Access Reviews' -Columns $Columns -ShowSort -ShowSearch -ShowPagination -Dense
}
}
}
} -Style 'text-align: center;'
}
}
}
}
1 Like
It seems when paging the switches revert back to their original state (pre-page, pre-change). Any ideas on this one?
have been trying -LoadData
but not having any luck.
I am noticing from this doc Table - PowerShell Universal that it might require a refresh button?
I guess I will need to use a submit and then it refreshes entire table or the page?
I am attempting something like this per the -loaddata sample
New-UDPage -Name 'Application Access Reviews' -Url accessreviews -Content {
$colors = Get-Colors
$common = $colors | Where-Object Mode -EQ common
$Session:ID = ($ClaimsPrincipal.Claims | Where-Object { $_.Type -eq 'http://schemas.microsoft.com/identity/claims/objectidentifier' }).value
New-UDElement -Tag 'div' -Id 'mainContainer' -Content {
New-UDRow -Columns {
New-UDColumn -LargeSize 8 -Content {
New-UDStyle -Content {
New-UDCard -TitleAlignment 'center' -Content {
New-UDButton -Text 'Table1' -OnClick { Sync-UDElement -Id 'Table1' }
$Columns = @(
New-UDTableColumn -Property 'Override' -Title 'Override' -Render {
$Row = $EventData
New-UDCheckBox -Color primary -Checked $Row.Override -OnChange {
$Status = $EventData
$RowKey = '{0}-{1}' -f $Row.appId, $Row.userId
if ($Status) {
Show-UDToast ('{0} will not be removed from {1}' -f $Row.userDisplayName, $Row.appDisplayName) -Duration 10000 -BackgroundColor "#658354" -MessageColor white
}
else {
Show-UDToast ('{0} has been marked for removal from {1}' -f $Row.userDisplayName, $Row.appDisplayName) -Duration 10000 -BackgroundColor "#ee6b6e" -MessageColor white
}
$splat = @{
TableName = 'inactive'
Filter = "PartitionKey eq '{0}' and RowKey eq '{1}'" -f 'part1', $RowKey
ConnectionString = $Secret:GacTestStorage
}
$HashTable = Get-AzDataTableEntity @splat
$HashTable['Override'] = $Status
$splat = @{
TableName = 'inactive'
Entity = $HashTable
ConnectionString = $Secret:GacTestStorage
Force = $true
CreateTableIfNotExists = $true
ErrorAction = 'Stop'
}
Add-AzDataTableEntity @splat
}
}
New-UDTableColumn -Property 'userDisplayName' -Title 'userDisplayName' -IncludeInSearch
New-UDTableColumn -Property 'appDisplayName' -Title 'appDisplayName' -IncludeInSearch
New-UDTableColumn -Property 'groupDisplayName' -Title 'groupDisplayName' -IncludeInSearch
New-UDTableColumn -Property 'userId' -Title 'userId' -Hidden -IncludeInExport
New-UDTableColumn -Property 'appId' -Title 'appId' -Hidden -IncludeInExport
)
New-UDTable -Columns $Columns -LoadData {
$splat = @{
TableName = 'inactive'
Filter = "reviewerId eq '{0}'" -f $Session:ID
Property = @('Override', 'userDisplayName', 'appDisplayName', 'groupDisplayName', 'appId', 'userId')
ConnectionString = $Secret:GacTestStorage
}
$Data = Get-AzDataTableEntity @splat
foreach ($Filter in $EventData.Filters) {
$Data = $Data | Where-Object -Property $Filter.Id -Match -Value $Filter.Value
}
$TotalCount = $Data.Count
if (-not [string]::IsNullOrEmpty($EventData.OrderBy)) {
$Descending = $EventData.OrderDirection -ne 'asc'
$Data = $Data | Sort-Object -Property $EventData.orderBy -Descending:$Descending
}
$Data = $Data | Select-Object -First $EventData.PageSize -Skip ($EventData.Page * $EventData.PageSize)
$Data | Out-UDTableData -Page $EventData.Page -TotalCount $TotalCount -Properties $EventData.Properties
} -ShowFilter -ShowSort -ShowPagination -Id 'Table1'
}
} -Style 'text-align: center;'
}
}
}
}
oh okay this might be pretty close if not all the way there
New-UDPage -Name 'Application Access Reviews' -Url accessreviews -Content {
$colors = Get-Colors
$common = $colors | Where-Object Mode -EQ common
$Session:ID = ($ClaimsPrincipal.Claims | Where-Object { $_.Type -eq 'http://schemas.microsoft.com/identity/claims/objectidentifier' }).value
New-UDElement -Tag 'div' -Id 'mainContainer' -Content {
New-UDRow -Columns {
New-UDColumn -LargeSize 8 -Content {
New-UDStyle -Content {
New-UDCard -TitleAlignment 'center' -Content {
New-UDButton -Text 'Table1' -OnClick { Sync-UDElement -Id 'Table1' }
$Columns = @(
New-UDTableColumn -Property 'Override' -Title 'Override' -ShowFilter -Render {
$Row = $EventData
New-UDCheckBox -Color primary -Checked $Row.Override -OnChange {
$Status = $EventData
$RowKey = '{0}-{1}' -f $Row.appId, $Row.userId
if ($Status) {
Show-UDToast ('{0} will not be removed from {1}' -f $Row.userDisplayName, $Row.appDisplayName) -Duration 10000 -BackgroundColor "#658354" -MessageColor white
}
else {
Show-UDToast ('{0} has been marked for removal from {1}' -f $Row.userDisplayName, $Row.appDisplayName) -Duration 10000 -BackgroundColor "#ee6b6e" -MessageColor white
}
$splat = @{
TableName = 'inactive'
Filter = "PartitionKey eq '{0}' and RowKey eq '{1}'" -f 'part1', $RowKey
ConnectionString = $Secret:GacTestStorage
}
$HashTable = Get-AzDataTableEntity @splat
$HashTable['Override'] = $Status
$splat = @{
TableName = 'inactive'
Entity = $HashTable
ConnectionString = $Secret:GacTestStorage
Force = $true
CreateTableIfNotExists = $true
ErrorAction = 'Stop'
}
Add-AzDataTableEntity @splat
}
}
New-UDTableColumn -Property 'userDisplayName' -Title 'userDisplayName' -IncludeInSearch -ShowFilter -Render { $EventData.userDisplayName }
New-UDTableColumn -Property 'appDisplayName' -Title 'appDisplayName' -IncludeInSearch -ShowFilter -Render { $EventData.appDisplayName }
New-UDTableColumn -Property 'groupDisplayName' -Title 'groupDisplayName' -IncludeInSearch -ShowFilter -Render { $EventData.groupDisplayName }
New-UDTableColumn -Property 'userId' -Title 'userId' -Hidden -IncludeInExport
New-UDTableColumn -Property 'appId' -Title 'appId' -Hidden -IncludeInExport
)
New-UDTable -Columns $Columns -LoadData {
$splat = @{
TableName = 'inactive'
Filter = "reviewerId eq '{0}'" -f $Session:ID
Property = @('Override', 'userDisplayName', 'appDisplayName', 'groupDisplayName', 'appId', 'userId')
ConnectionString = $Secret:GacTestStorage
}
$Data = Get-AzDataTableEntity @splat
foreach ($Filter in $EventData.Filters) {
$Data = $Data | Where-Object -Property $Filter.Id -Match -Value $Filter.Value
}
$TotalCount = $Data.Count
if (-not [string]::IsNullOrEmpty($EventData.OrderBy)) {
$Descending = $EventData.OrderDirection -ne 'asc'
$Data = $Data | Sort-Object -Property $EventData.orderBy -Descending:$Descending
}
$Data = $Data | Select-Object -First $EventData.PageSize -Skip ($EventData.Page * $EventData.PageSize)
$Data | Out-UDTableData -Page $EventData.Page -TotalCount $TotalCount -Properties $EventData.Properties
} -ShowFilter -ShowSort -ShowPagination -Id 'Table1'
}
} -Style 'text-align: center;'
}
}
}
}
adam
November 11, 2022, 4:36pm
16
You might be able to just refresh the table with Sync-UDElement after the checkbox is clicked.
Add-AzDataTableEntity @splat
Sync-UDElement -Id Table1
1 Like
Thanks @adam
Everything does work but the challenge for me is needing the “Select All” checkbox that comes with -ShowSelection -OnRowSelection {..
Thus I am using the below code where…
The table does not pick up the current state of the Azure Table
The $EventData
contains only “Selected” = True/False.
New-UDPage -Name 'Application Access Reviews' -Url accessreview -Content {
$colors = Get-Colors
$common = $colors | Where-Object Mode -EQ common
$Session:ID = ($ClaimsPrincipal.Claims | Where-Object { $_.Type -eq 'http://schemas.microsoft.com/identity/claims/objectidentifier' }).value
New-UDElement -Tag 'div' -Id 'mainContainer' -Content {
New-UDRow -Columns {
New-UDColumn -LargeSize 8 -Content {
New-UDStyle -Content {
New-UDCard -TitleAlignment 'center' -Content {
$splat = @{
TableName = 'inactive'
Filter = "reviewerId eq '{0}'" -f $Session:ID
Property = @('Override', 'userDisplayName', 'appDisplayName', 'groupDisplayName', 'appId', 'userId')
ConnectionString = $Secret:GacTestStorage
}
$Data = Get-AzDataTableEntity @splat
$Columns = @(
New-UDTableColumn -Property 'userDisplayName' -Title 'userDisplayName' -IncludeInSearch -ShowFilter -Render { $EventData.userDisplayName }
New-UDTableColumn -Property 'appDisplayName' -Title 'appDisplayName' -IncludeInSearch -ShowFilter -Render { $EventData.appDisplayName }
New-UDTableColumn -Property 'groupDisplayName' -Title 'groupDisplayName' -IncludeInSearch -ShowFilter -Render { $EventData.groupDisplayName }
New-UDTableColumn -Property 'userId' -Title 'userId' -Hidden -IncludeInExport
New-UDTableColumn -Property 'appId' -Title 'appId' -Hidden -IncludeInExport
)
New-UDTable -Columns $Columns -LoadData {
$Session:Load = $EventData
$splat = @{
TableName = 'inactive'
Filter = "reviewerId eq '{0}'" -f $Session:ID
Property = @('Override', 'userDisplayName', 'appDisplayName', 'groupDisplayName', 'appId', 'userId')
ConnectionString = $Secret:GacTestStorage
}
$Data = Get-AzDataTableEntity @splat
foreach ($Filter in $Session:Load.Filters) {
$Data = $Data | Where-Object -Property $Filter.Id -Match -Value $Filter.Value
}
$TotalCount = $Data.Count
if (-not [string]::IsNullOrEmpty($Session:Load.OrderBy)) {
$Descending = $Session:Load.OrderDirection -ne 'asc'
$Data = $Data | Sort-Object -Property $Session:Load.orderBy -Descending:$Descending
}
$Data = $Data | Select-Object -First $Session:Load.PageSize -Skip ($Session:Load.Page * $Session:Load.PageSize)
$Data | Out-UDTableData -Page $Session:Load.Page -TotalCount $TotalCount -Properties $Session:Load.Properties
} -ShowFilter -ShowSort -ShowPagination -Id 'Table1' -PageSize 5 -Dense -ShowSelection -OnRowSelection {
$Row = $EventData
$RowKey = '{0}-{1}' -f $Row.appId, $Row.userId
Show-UDToast "$($EventData | Out-String)" -Duration 10000
if ($Row.Selected) {
Show-UDToast ('{0} will not be removed from {1}' -f $Row.userDisplayName, $Row.appDisplayName) -Duration 10000 -BackgroundColor "#658354" -MessageColor white
}
else {
Show-UDToast ('{0} has been marked for removal from {1}' -f $Row.userDisplayName, $Row.appDisplayName) -Duration 10000 -BackgroundColor "#ee6b6e" -MessageColor white
}
$splat = @{
TableName = 'inactive'
Filter = "PartitionKey eq '{0}' and RowKey eq '{1}'" -f 'part1', $RowKey
ConnectionString = $Secret:GacTestStorage
}
$HashTable = Get-AzDataTableEntity @splat
$HashTable['Override'] = $Row.Selected
$splat = @{
TableName = 'inactive'
Entity = $HashTable
ConnectionString = $Secret:GacTestStorage
Force = $true
CreateTableIfNotExists = $true
ErrorAction = 'Stop'
}
Add-AzDataTableEntity @splat
Sync-UDElement -Id 'Table1'
}
}
} -Style 'text-align: center;'
}
}
}
}
This is the code that is only missing
Select All
Select All on page (if this exists)
New-UDPage -Name 'Application Access Reviews' -Url accessreview -Content {
$colors = Get-Colors
$common = $colors | Where-Object Mode -EQ common
$Session:ID = ($ClaimsPrincipal.Claims | Where-Object { $_.Type -eq 'http://schemas.microsoft.com/identity/claims/objectidentifier' }).value
New-UDElement -Tag 'div' -Id 'mainContainer' -Content {
New-UDRow -Columns {
New-UDColumn -LargeSize 8 -Content {
New-UDStyle -Content {
New-UDCard -TitleAlignment 'center' -Content {
$splat = @{
TableName = 'inactive'
Filter = "reviewerId eq '{0}'" -f $Session:ID
Property = @('Override', 'userDisplayName', 'appDisplayName', 'groupDisplayName', 'appId', 'userId')
ConnectionString = $Secret:GacTestStorage
}
$Data = Get-AzDataTableEntity @splat
$Columns = @(
New-UDTableColumn -Property 'userDisplayName' -Title 'userDisplayName' -IncludeInSearch -ShowFilter -Render { $EventData.userDisplayName }
New-UDTableColumn -Property 'appDisplayName' -Title 'appDisplayName' -IncludeInSearch -ShowFilter -Render { $EventData.appDisplayName }
New-UDTableColumn -Property 'groupDisplayName' -Title 'groupDisplayName' -IncludeInSearch -ShowFilter -Render { $EventData.groupDisplayName }
New-UDTableColumn -Property 'userId' -Title 'userId' -Hidden -IncludeInExport
New-UDTableColumn -Property 'appId' -Title 'appId' -Hidden -IncludeInExport
)
New-UDTable -Columns $Columns -LoadData {
$Session:Load = $EventData
$splat = @{
TableName = 'inactive'
Filter = "reviewerId eq '{0}'" -f $Session:ID
Property = @('Override', 'userDisplayName', 'appDisplayName', 'groupDisplayName', 'appId', 'userId')
ConnectionString = $Secret:GacTestStorage
}
$Data = Get-AzDataTableEntity @splat
foreach ($Filter in $Session:Load.Filters) {
$Data = $Data | Where-Object -Property $Filter.Id -Match -Value $Filter.Value
}
$TotalCount = $Data.Count
if (-not [string]::IsNullOrEmpty($Session:Load.OrderBy)) {
$Descending = $Session:Load.OrderDirection -ne 'asc'
$Data = $Data | Sort-Object -Property $Session:Load.orderBy -Descending:$Descending
}
$Data = $Data | Select-Object -First $Session:Load.PageSize -Skip ($Session:Load.Page * $Session:Load.PageSize)
$Data | Out-UDTableData -Page $Session:Load.Page -TotalCount $TotalCount -Properties $Session:Load.Properties
} -ShowFilter -ShowSort -ShowPagination -Id 'Table1' -PageSize 5 -Dense -ShowSelection -OnRowSelection {
$Row = $EventData
$RowKey = '{0}-{1}' -f $Row.appId, $Row.userId
Show-UDToast "$($EventData | Out-String)" -Duration 10000
if ($Row.Selected) {
Show-UDToast ('{0} will not be removed from {1}' -f $Row.userDisplayName, $Row.appDisplayName) -Duration 10000 -BackgroundColor "#658354" -MessageColor white
}
else {
Show-UDToast ('{0} has been marked for removal from {1}' -f $Row.userDisplayName, $Row.appDisplayName) -Duration 10000 -BackgroundColor "#ee6b6e" -MessageColor white
}
$splat = @{
TableName = 'inactive'
Filter = "PartitionKey eq '{0}' and RowKey eq '{1}'" -f 'part1', $RowKey
ConnectionString = $Secret:GacTestStorage
}
$HashTable = Get-AzDataTableEntity @splat
$HashTable['Override'] = $Row.Selected
$splat = @{
TableName = 'inactive'
Entity = $HashTable
ConnectionString = $Secret:GacTestStorage
Force = $true
CreateTableIfNotExists = $true
ErrorAction = 'Stop'
}
Add-AzDataTableEntity @splat
Sync-UDElement -Id 'Table1'
}
}
} -Style 'text-align: center;'
}
}
}
}
Thanks again Adam
Actually, and this is strange, now it is taking a full refresh of the page to update the checkboxes. I could have sworn this worked fine. So strange.
EDIT:
UDSwitch seems to work (without a Select All available)
New-UDPage -Name 'Application Access Reviews' -Url accessreviews -Content {
$colors = Get-Colors
$common = $colors | Where-Object Mode -EQ common
$Session:ID = ($ClaimsPrincipal.Claims | Where-Object { $_.Type -eq 'http://schemas.microsoft.com/identity/claims/objectidentifier' }).value
New-UDElement -Tag 'div' -Id 'mainContainer' -Content {
New-UDRow -Columns {
New-UDColumn -LargeSize 12 -Content {
New-UDStyle -Content {
New-UDCard -TitleAlignment 'center' -Content {
# New-UDButton -Text 'Table1' -OnClick { Sync-UDElement -Id 'Table1' }
$Columns = @(
New-UDTableColumn -Property 'Override' -Title 'Override' -Align center -Render {
$Row = $EventData
New-UDSwitch -Color primary -Checked $Row.Override -Size small -OnChange {
# New-UDCheckBox -Color primary -Checked $Row.Override -Size small -OnChange {
$Status = $EventData
$RowKey = '{0}-{1}' -f $Row.appId, $Row.userId
if ($Status) {
Show-UDToast ('{0} will not be removed from {1}' -f $Row.userDisplayName, $Row.appDisplayName) -Duration 10000 -BackgroundColor "#658354" -MessageColor white
}
else {
Show-UDToast ('{0} has been marked for removal from {1}' -f $Row.userDisplayName, $Row.appDisplayName) -Duration 10000 -BackgroundColor "#ee6b6e" -MessageColor white
}
$splat = @{
TableName = 'inactive'
Filter = "PartitionKey eq '{0}' and RowKey eq '{1}'" -f 'part1', $RowKey
ConnectionString = $Secret:GacTestStorage
}
$HashTable = Get-AzDataTableEntity @splat
$HashTable['Override'] = $Status
$splat = @{
TableName = 'inactive'
Entity = $HashTable
ConnectionString = $Secret:GacTestStorage
Force = $true
CreateTableIfNotExists = $true
ErrorAction = 'Stop'
}
Add-AzDataTableEntity @splat
}
}
New-UDTableColumn -Property 'userDisplayName' -Title 'userDisplayName' -IncludeInSearch -ShowFilter -Render { $EventData.userDisplayName }
New-UDTableColumn -Property 'appDisplayName' -Title 'appDisplayName' -IncludeInSearch -ShowFilter -Render { $EventData.appDisplayName }
New-UDTableColumn -Property 'groupDisplayName' -Title 'groupDisplayName' -IncludeInSearch -ShowFilter -Render { $EventData.groupDisplayName }
New-UDTableColumn -Property 'userId' -Title 'userId' -Hidden -IncludeInExport
New-UDTableColumn -Property 'appId' -Title 'appId' -Hidden -IncludeInExport
)
New-UDTable -Columns $Columns -LoadData {
$splat = @{
TableName = 'inactive'
Filter = "reviewerId eq '{0}'" -f $Session:ID
Property = @('Override', 'userDisplayName', 'appDisplayName', 'groupDisplayName', 'appId', 'userId')
ConnectionString = $Secret:GacTestStorage
}
$Data = Get-AzDataTableEntity @splat
foreach ($Filter in $EventData.Filters) {
$Data = $Data | Where-Object -Property $Filter.Id -Match -Value $Filter.Value
}
$TotalCount = $Data.Count
if (-not [string]::IsNullOrEmpty($EventData.OrderBy)) {
$Descending = $EventData.OrderDirection -ne 'asc'
$Data = $Data | Sort-Object -Property $EventData.orderBy -Descending:$Descending
}
$Data = $Data | Select-Object -First $EventData.PageSize -Skip ($EventData.Page * $EventData.PageSize)
$Data | Out-UDTableData -Page $EventData.Page -TotalCount $TotalCount -Properties $EventData.Properties
} -ShowFilter -ShowSort -ShowPagination -Id 'Table1' -PageSize 5
}
} -Style 'text-align: center;'
}
}
}
}
@adam So I think this is working however, sorting a column yields this error:
We had to recreate the array of hashtables where there was a Name key and Value key . Is that a prerequisite?
$colors = Get-Colors
$common = $colors | Where-Object Mode -EQ common
New-UDPage -Name 'Application Access Reviews' -Url accessreviews -Content {
$Session:ID = ($ClaimsPrincipal.Claims | Where-Object { $_.Type -eq 'http://schemas.microsoft.com/identity/claims/objectidentifier' }).value
$Columns = @(
New-UDTableColumn -Property 'Override' -Title 'Override' -Align center -Render {
$Row = $EventData
New-UDSwitch -Color primary -Checked $Row.Override -Size small -OnChange {
$Status = $EventData
$RowKey = '{0}-{1}' -f $Row.Name, $Row.userId
if ($Status) {
Show-UDToast ('{0} will not be removed from {1}' -f $Row.userDisplayName, $Row.appDisplayName) -Duration 10000 -BackgroundColor "#658354" -MessageColor white
}
else {
Show-UDToast ('{0} has been marked for removal from {1}' -f $Row.userDisplayName, $Row.appDisplayName) -Duration 10000 -BackgroundColor "#ee6b6e" -MessageColor white
}
$splat = @{
TableName = 'inactive'
Filter = "PartitionKey eq '{0}' and RowKey eq '{1}'" -f 'part1', $RowKey
ConnectionString = $Secret:GacTestStorage
}
$HashTable = Get-AzDataTableEntity @splat
$HashTable['Override'] = $Status
$splat = @{
TableName = 'inactive'
Entity = $HashTable
ConnectionString = $Secret:GacTestStorage
Force = $true
CreateTableIfNotExists = $true
ErrorAction = 'Stop'
}
Add-AzDataTableEntity @splat
}
}
New-UDTableColumn -Property 'userDisplayName' -Title 'userDisplayName' -Render { $EventData.userDisplayName } -IncludeInSearch -ShowFilter -ShowSort
New-UDTableColumn -Property 'appDisplayName' -Title 'appDisplayName' -Render { $EventData.appDisplayName } -IncludeInSearch -ShowFilter -FilterType select -ShowSort
New-UDTableColumn -Property 'groupDisplayName' -Title 'groupDisplayName' -Render { $EventData.groupDisplayName } -IncludeInSearch -ShowFilter -FilterType select -ShowSort
New-UDTableColumn -Property 'accountEnabled' -Title 'accountEnabled' -Render { $EventData.accountEnabled } -IncludeInSearch -ShowFilter -FilterType select -ShowSort
New-UDTableColumn -Property 'RowKey' -Title 'RowKey' -Render { $EventData.RowKey } -IncludeInSearch -Hidden
New-UDTableColumn -Property 'Name' -Title 'Name' -Render { $EventData.Name } -IncludeInSearch -Hidden
New-UDTableColumn -Property 'Value' -Title 'Value' -Render { $EventData.Value } -IncludeInSearch -Hidden
)
New-UDTable -Columns $Columns -LoadData {
$splat = @{
TableName = 'inactive'
Filter = "reviewerId eq '{0}'" -f $Session:ID
Property = @('accountEnabled', 'userDisplayName', 'RowKey', 'Override', 'groupId', 'userDisplayName', 'appDisplayName', 'groupDisplayName', 'appId', 'userId')
ConnectionString = $Secret:GacTestStorage
}
$Data = Get-AzDataTableEntity @splat
$Data = $Data | ForEach-Object {
@{
RowKey = $_.RowKey
Name = $_.appId
Value = $_.groupId
userId = $_.userId
appDisplayName = $_.appDisplayName
groupDisplayName = $_.groupDisplayName
userDisplayName = $_.userDisplayName
accountEnabled = $_.accountEnabled.ToString()
Override = $_.Override
}
}
foreach ($Filter in $EventData.Filters) {
$Data = $Data | Where-Object -Property $Filter.Id -Match -Value $Filter.Value
}
$TotalCount = $Data.Count
if (-not [string]::IsNullOrEmpty($EventData.OrderBy)) {
$Descending = $EventData.OrderDirection -ne 'asc'
$Data = $Data | Sort-Object -Property $EventData.orderBy -Descending:$Descending
}
$Data = $Data | Select-Object -First $EventData.PageSize -Skip ($EventData.Page * $EventData.PageSize)
$Data | Out-UDTableData -Page $EventData.Page -TotalCount $TotalCount -Properties $EventData.Properties
} -ShowFilter -ShowSort -ShowPagination -PageSize 5 -Id 'Table1'
}
Also Select All or Select Current View . I presume I need to look closely here? https://docs.powershelluniversal.com/userinterfaces/dashboards/components/data-display/table#retrieving-displayed-data
Thank you!
Kevin
Didn’t realize UDGrid existed. Moving to that for the time being
Will create a topic on filter we are seeing there