I have a function that creates a data set like this
$Data = @(
@{ServerName = 'Server 1'; OS = New-UDIcon -Icon windows -Size 2x -Color 'blue'; Ram = '2000'; CPU = "Intel"; Status = New-UDIcon -Icon 'check_circle' -Color 'green' -Size 2x}
@{ServerName = 'Server 2'; OS = New-UDIcon -Icon windows -Size 2x -Color 'blue'; Ram = '4000'; CPU = "Intel"; Status = New-UDIcon -Icon 'check_circle' -Color 'green' -Size 2x}
@{ServerName = 'Server 3'; OS = New-UDIcon -Icon linux -Size 2x -Color 'yellow'; Ram = '8000'; CPU = "Intel"; Status = New-UDIcon -Icon 'check_circle' -Color 'green '-Size 2x}
@{ServerName = 'Server 4'; OS = New-UDIcon -Icon windows -Size 2x -Color 'blue'; Ram = '4000'; CPU = "Intel"; Status = New-UDIcon -Icon 'check_circle' -Color 'green' -Size 2x}
@{ServerName = 'Server 5'; OS = New-UDIcon -Icon windows -Size 2x -Color 'blue'; Ram = '2000'; CPU = "Intel"; Status = New-UDIcon -Icon 'check_circle'-Color 'green' -Size 2x}
@{ServerName = 'Server 6'; OS = New-UDIcon -Icon linux -Size 2x -Color 'yellow'; Ram = '4000'; CPU = "Intel"; Status = New-UDIcon -Icon 'check_circle' -Color 'green' -Size 2x}
)
Basically creates Icons with different colors based on a status or an OS. I then display the icons in a table like this.
$Session:Columns = @(
New-UDTableColumn -Property ServerName -Title 'Server Name'
New-UDTableColumn -Property os -Title 'OS' -Render {
$jData = $Body | ConvertFrom-Json
New-UDIcon -Icon $jData.OS.icon -Size 2x -Color $jData.OS.color
}
New-UDTableColumn -Property Ram -Title 'Installed RAM'
New-UDTableColumn -Property CPU -Title 'Installed CPU'
New-UDTableColumn -Property Status -Title 'Status' -Render {
$jData = $Body | ConvertFrom-Json
New-UDIcon -Icon $jData.Status.icon -Size 2x -Color $jData.Status.color
}
)
$Session:TotalPages = $Data.length
New-UDTable -Data $Data -Columns $Session:Columns -Pagesize 20 -PageSizeOptions @(5,20,$Session:TotalPages)
When I run this code the icons do not show at all and if I remove the -Color parameter the icons that do not have a _ in them will show. Any others generate an error similar to this
PS: Cannot process argument transformation on parameter ‘Icon’. Cannot convert value “CheckCircle” to type “UniversalDashboard.Models.FontAwesomeIcons”. Error: "Unable to match the identifier name CheckCircle to a valid enumerator name. Specify one of the following enumerator names and try again:
If I hard code the values in to the code it works fine. The JSON generated from the $Body looks like this.
{
"Status": {
"id": "cc19f530-5260-425f-9817-31b214fa6852",
"fixedWidth": "False",
"type": "icon",
"inverse": false,
"flip": "",
"style": null,
"className": "",
"transform": "",
"regular": false,
"pulse": false,
"color": "rgba(0, 128, 0, 1)",
"rotation": 0,
"border": false,
"size": "2x",
"title": "",
"listItem": false,
"icon": "CheckCircle",
"pull": "",
"spin": false
},
"ServerName": "Server 1",
"CPU": "Intel",
"Ram": "2000",
"OS": {
"id": "ef2db8e7-1d05-4fc0-bc71-ddf3350b3f47",
"fixedWidth": "False",
"type": "icon",
"inverse": false,
"flip": "",
"style": null,
"className": "",
"transform": "",
"regular": false,
"pulse": false,
"color": "rgba(0, 0, 255, 1)",
"rotation": 0,
"border": false,
"size": "2x",
"title": "",
"listItem": false,
"icon": "Windows",
"pull": "",
"spin": false
}
}
Is seems to be changing Color to “rgba(0, 0, 255, 1)” and ‘check_circle’ to CheckCircle, which Universal Dashboard is not happy about.