I’ve been hacking about with this for a day or two and I think I’ve reached a dead-end.
I would like to change the background colour of the title bar for a collapsible item based on the status of a service. I’ve managed to automate the colour of the title bar, but this code only runs when the dashboard starts up. So, although the content of the collapsible can be dynamic using an endpoint, the parent object doesn’t refresh even when the page is reloaded.
In the example below, the desired behaviour is for the title background colour of the last item to change from green to blue depending on the punchline.
Is there any way to achieve this?
$CustomHeaderTheme = New-UDTheme -Name "CH" -Definition @{
'li[id$="_blue"] .collapsible-header' = @{
'background-color' = 'blue'
'FontColor' = '#ffffff'
}
'li[id$="_red"] .collapsible-header' = @{
'background-color' = "red"
}
'li[id$="_orange"] .collapsible-header' = @{
'background-color' = "orange"
}
'li[id$="_yellow"] .collapsible-header' = @{
'background-color' = "yellow"
}
'li[id$="_green"] .collapsible-header' = @{
'background-color' = "green"
}
'.collapsible-header' = @{
'background-color' = "#999999"
}
} -Parent "Default"
$MyDashboard = New-UDDashboard -Theme $CustomHeaderTheme -Title "Coloured Collapsible headers" -Content{
New-UDCollapsible -Id 'collapse1' -Items {
New-UDCollapsibleItem -Id 'default' -Title 'What cheese do you use to get a Bear to follow you?' -Content {
New-UDHeading -Color '#000000' -Text 'Camembert!'
}
New-UDCollapsibleItem -Id 'manual_orange' -Title 'What was the Prize for the dentist of the year?' -Content {
New-UDHeading -Color '#000000' -Text 'A little plaque!'
}
$Cache:random1= get-random -Maximum 10
$Cache:random2= get-random -Maximum 10
New-UDCollapsibleItem -Id ($Cache:id + @{$true="_blue";$false="_green"}[$Cache:random1 -gt $Cache:random2]) -Title "$Cache:random1 $Cache:random2 Why did the cow cross the road?" -AutoRefresh -Endpoint {
$Cache:random1= get-random -Maximum 10
$Cache:random2= get-random -Maximum 10
New-UDHeading -Color '#000000' -Text (@{$true="To get to the udder side!";$false="To go to the mooooooovies!"}[$Cache:random1 -gt $Cache:random2])
} -RefreshInterval 1
}
}
Start-UDDashboard -Port 8083 -Dashboard $MyDashboard