Conditional formatting New-UDCard

As the title suggests, can I take the conditional formatting from the Cookbook section and apply that to a Card. So if I query say the health of an object, the result is

{
  "value": "green"
}

SO it would be nice to be able to set the colour of the card based on the object value. I think I know what might need to do. Will try and rustle up a rough test

ultimately Iā€™m looking for something like this

the status of the card is based on the status of the service. I seem to recall there was an example of this on on Github, but for the life of me I cannot find it

Looking for this?


1 Like

And if you want to have a bit more control, you can step into the realm of CSS:

$Dashboard = New-UDDashboard -Title Services -Content {
    New-UDRow -Endpoint { 
        Get-Service | ForEach-Object {
            $BackgroundColor = '#B40404' #Red
            if ($_.Status -eq 'Running') {
                $BackgroundColor = '#088A29' #Green
            }

            New-UDElement -Tag 'div' -Content {
                New-UDElement -Tag 'h6' -Content {$_.Name}
                New-UDElement -Tag 'h4' -Content {$_.Status.tostring()}
            } -Attributes @{
                style = @{
                    backgroundColor = $BackgroundColor
                    color = 'white'
                    'min-height' = '100px'
                    width = '250px'
                    float = 'left'
                    margin = '5px'
                    display = 'inline-block'
                    'text-align' = 'center'
                }
            }
        } 
    } -AutoRefresh -RefreshInterval 60
}

Get-UDDashboard | where{$_.Port -eq 10000} | Stop-UDDashboard
Start-UDDashboard -Dashboard $Dashboard -Port 10000

1 Like