I see a lot of info on making things dynamic but not a whole lot on specifically making header objects dynamic. I’ve tried using a UDDynamic cmdlet with -HeaderContent and adding an -AutoRefreshInterval but it only works if i refresh the whole page, and i’m trying to avoid that. Basically what i have is a status dot in the header and I want to dynamically control it based on certain conditions. At the moment i’m just trying to get it to refresh on it’s own. Here’s what I have:
New-UDDashboard -Title 'Live Analytics' -Pages @(
New-UDPage -Name 'Home' -Content {
New-UDTypography -Text 'Server Status'
} -HeaderContent {
New-UDDynamic -Id 'dynamicStatusDot' -AutoRefreshInterval 5 -Content {
$logFile = "C:\dashboard_reporter.log"
if (Test-Path $logFile) {
$content = Get-Content $logFile -Raw
if ([string]::IsNullOrEmpty($content)) {
$color = 'red'
} else {
$color = 'green'
}
} else {
$color = 'red'
}
New-UDElement -Tag 'div' -Attributes @{
style = @{
width = '8px';
height = '8px';
borderRadius = '50%';
backgroundColor = $color;
float = 'right';
margin = '10px 15px 10px 10px';
}
}
}
New-UDElement -Tag 'div' -Attributes @{
style = @{
float = 'right';
margin = '10px 250px 10px 10px';
}
} -Content {
New-UDTypography 'MC Status'
}
} -NavigationLayout 'permanent'
)