Sync-udelement not working since move to IIS

Hi all,

I have the following code in dashboard.ps1

$endpoint2 = New-UDEndpoint -Schedule $Schedule1 -Id sql -Endpoint {
    Sync-UDElement -id 'appservercolumn2' -Broadcast
    Sync-UDElement -id 'appservercolumn4' -Broadcast
}

Then in my page.ps1

New-UDColumn -id 'appservercolumn2' -size 2 -Endpoint {
            New-UDCard -id 'appservercolumn2card' -TextAlignment center -Endpoint {
                $oldest = $cache:appservergrid2 | Sort-Object 'Last Change' | Select-Object -First 1
                $duration = (Get-Date) - $oldest.'Last Change'
                
                $running = $cache:appservergrid2 | Where-Object { $_.State -eq "RUNNING" }
				
				if ([math]::ceiling($duration.TotalMinutes) -ge 60){ 
				$oldest = 60} else { $oldest = [math]::ceiling($duration.TotalMinutes) }
                
				New-UDGauge -PaddingVertical 8 -Width 250 -id 'AppServerActiveServers' -MaxValue 15 -NeedleColor white -StartColor green -EndColor red -value ($cache:appserverobject.'Active Servers') -Segments 3 -ValueText $('Total servers: ' + $($cache:appserverobject.'Active Servers'))
				New-UDGauge -PaddingVertical 8 -Width 250 -id 'AppServerRunningServers' -MaxValue 15 -NeedleColor white -StartColor green -EndColor red -value (@($running).count)  -Segments 3 -ValueText $('Running servers: ' + $(@($running).count))
                New-UDGauge -PaddingVertical 8 -Width 250 -id 'AppServerOldestChange' -MaxValue 60 -NeedleColor white -StartColor green -EndColor red -value $oldest -Segments 6 -ValueText $('Oldest change: ' + $([string]$([math]::ceiling($duration.TotalMinutes)) + ' mins'))
            }
        }

The page loads fine initially - the guages are shown as expected, however when the schedule runs, the elements disappear from the screen. Chrome console shows the following:

image

I have also tried syncing the card but I get 404’s on refresh with this too. It’s worth noting that before I moved over to IIS, it was working fine.

Any ideas?

Many thanks

I don’t see a New-UDElement anywhere in your code, is that somewhere else? I have an IIS site and i am using Set-UDElement successfully.

As far as I am aware, you don’t have to use new-udelement as long as it is a control which uses the -endpoint param then it should work.

Hi @Alc
did you follow the guide on
https://docs.universaldashboard.io/webserver/running-dashboards/iis

Sounds like you forgot to install the websocket feature?

1 Like

Hello @Alc, I’m using the gauge control to, and there is no need to sync the element, I see you got it in an endpoint, and pretty sure if you scrub your sync element bits, and literally use the -AutoRefresh parameter on the endpoint holding your gauge components then they will automatically be refreshed…You did also include this custom component in the endpointinitilization script bit so that they can be used in an endpoint yeah?

@BoSen29 websocket is enabled :slight_smile:

@psDevUK from looking it seems I can only use autorefresh on the column? I’ve just tried it and found something strange. I set it to refreshinterval 1 to test. Here’s a video of what happens: 2020 01 10 09 31 27 - Gifyu (sorry it’s quite big so takes a while to load - watch to the end to see the oddity).

I’ve uploaded the log file here: https://floobits.com/PoshCode/PowerShell.Slack.com/file/log.txt

Hmmm no I haven’t done this. How do you include a component in there? I’ve used it to bring in all my modules containing my functions but this is not used in this case.

I have uploaded my dashboard here: GitHub - paulharman/dashboard the page in question is under pages\page4.ps1

Big thanks to everyone.

I will attempt to put a demo of how to do this on my github script pages…As I am using the gauge on a complaints dashboard which goes up everytime you raise a complaint which works without issues…but have a look at this link https://psdevuk.github.io/ud-flix/Animated-Number-Counter/
Then scroll near the bottom for the bit that says

More Dynamic

Then look at my script New-UDEndpointInitialization -Module and how I import the module to be used within endpoints throughout my dashboard.

Will try and get my head around it.

Not sure if I misunderstand but I don’t see an autorefresh parameter on new-udgauge, so is new-udcolumn where it should go?

Key                 Value                                         
---                 -----                                         
Id                  System.Management.Automation.ParameterMetadata
MaxValue            System.Management.Automation.ParameterMetadata
Value               System.Management.Automation.ParameterMetadata
NeedleColor         System.Management.Automation.ParameterMetadata
StartColor          System.Management.Automation.ParameterMetadata
EndColor            System.Management.Automation.ParameterMetadata
Segments            System.Management.Automation.ParameterMetadata
SegmentLabels       System.Management.Automation.ParameterMetadata
NeedleHeight        System.Management.Automation.ParameterMetadata
NeedleTransition    System.Management.Automation.ParameterMetadata
LabelFontSize       System.Management.Automation.ParameterMetadata
ValueFontSize       System.Management.Automation.ParameterMetadata
PaddingHorizontal   System.Management.Automation.ParameterMetadata
PaddingVertical     System.Management.Automation.ParameterMetadata
ValueText           System.Management.Automation.ParameterMetadata
Width               System.Management.Automation.ParameterMetadata
Height              System.Management.Automation.ParameterMetadata
TextColor           System.Management.Automation.ParameterMetadata
Verbose             System.Management.Automation.ParameterMetadata
Debug               System.Management.Automation.ParameterMetadata
ErrorAction         System.Management.Automation.ParameterMetadata
WarningAction       System.Management.Automation.ParameterMetadata
InformationAction   System.Management.Automation.ParameterMetadata
ErrorVariable       System.Management.Automation.ParameterMetadata
WarningVariable     System.Management.Automation.ParameterMetadata
InformationVariable System.Management.Automation.ParameterMetadata
OutVariable         System.Management.Automation.ParameterMetadata
OutBuffer           System.Management.Automation.ParameterMetadata
PipelineVariable    System.Management.Automation.ParameterMetadata

Just noticed something else going strange in the diagnostics page - look how many endpoints and sessions there are!

each of these unnamed endpoints relate to this code:

New-UDColumn -id 'appservercolumn2' -size 2 -Endpoint {
            New-UDCard -id 'appservercolumn2card' -TextAlignment center -Endpoint {
                $oldest = $cache:appservergrid2 | Sort-Object 'Last Change' | Select-Object -First 1
                $duration = (Get-Date) - $oldest.'Last Change'
                
                $running = $cache:appservergrid2 | Where-Object { $_.State -eq "RUNNING" }
				
				if ([math]::ceiling($duration.TotalMinutes) -ge 60){ 
				$oldest = 60} else { $oldest = [math]::ceiling($duration.TotalMinutes) }
                
				New-UDGauge -PaddingVertical 8 -Width 250 -id 'AppServerActiveServers' -MaxValue 15 -NeedleColor white -StartColor green -EndColor red -value ($cache:appserverobject.'Active Servers') -Segments 3 -ValueText $('Total servers: ' + $($cache:appserverobject.'Active Servers'))
				New-UDGauge -PaddingVertical 8 -Width 250 -id 'AppServerRunningServers' -MaxValue 15 -NeedleColor white -StartColor green -EndColor red -value (@($running).count)  -Segments 3 -ValueText $('Running servers: ' + $(@($running).count))
                New-UDGauge -PaddingVertical 8 -Width 250 -id 'AppServerOldestChange' -MaxValue 60 -NeedleColor white -StartColor green -EndColor red -value $oldest -Segments 6 -ValueText $('Oldest change: ' + $([string]$([math]::ceiling($duration.TotalMinutes)) + ' mins'))
            }
        }

@adam any idea why it would be creating so many endpoints and why they would be unique using guid rather than id as per my code?

When you expand the endpoints in the diagnotsics view, is it one of the endpoints in your example in this post? I see IDs on all of you components so I’m surprised you have so many endpoints with GUID ids.

They are all the code above - New-UDColumn -id ‘appservercolumn2’

And those are just within a New-UDRow?

Yes - code here: https://github.com/paulharman/dashboard/blob/master/pages/page4.ps1

Ok. Thanks! That’s helpful. Checking it out.

Can’t get to the bottom of this one. Resorting to a chrome plugin to automatically refresh the page at the moment :confused:

You know New-UDPage has -RefreshInterval to auto refresh the page? You don’t need to use a chrome plugin.

Hi, yeah I do, but this would affect all users of the dashboard rather than just the one running on our tv screen in the office :slight_smile:

Hi, does anyone have any ideas about this please?

Hi @Alc

Could you verify Sync-UDElement working in a simpler implementation?

IE:


 New-UDElement -Id "SyncMe" -Tag span -Endpoint {
     New-UDHtml -Markup Get-Random
 }
 New-UDButton -Text "Update" -OnClick {
     Sync-UDElement -Id "SyncMe"
 }

As this might be a bug with either:
Sync-UDElement in scheduled endpoints
Broadcast parameter
UDGauge (probably not)