I am getting started with universal dashboard, and as a proof of concept, I am building a services Dashboard.
(My Aim is to display all Services ‘live’ and be able to turn them on or off).
But I have become stuck on updating the New-UDParagraph after I change the Service.Status using a New-UDInput event, But the change is not reflected until I fully reload the dashboard.
I have made a New-UDInputAction -Toast to display the change, but I am unable to reflect the change to the New-UDParagraph.
And as such its not reflecting that back to the user (other than the Toast)
Is there a good way to get the reload the Dashboard or the update Service.Status?
There are 2 types of pages in play. Static pages won’t pickup any changes until the Web server is restarted. Dynamic pages pickup changes dynamically without restarting the web server. Review the references on how to create a dynamic web page and this will get you going in the right direction.
You would want to test this, but couldn’t you wrap the UDParagraphs in New-udelement? Then add a new UDInputAction to Sync-UDElement. Something like this;
But it looks like the update isn’t working, I’ll let you know if I find out anything else.
I have tried to simplify the question, I have added a $Test variable to see if we can update that from the New-UDInput and see if we can solve the simple issue first.
Some thing I did notice that was odd though, when your press the stop button twice I would Expect ‘foo’ ‘bar’ | ‘bar’ ‘bar’ but I get ‘foo’ ‘bar’ | ‘foo’ ‘bar’ in the pop Toast.
This is implying that the update $Test is getting reset back to ‘foo’ after each run.
Any ideas?
Maylife
@ maylife The link you referenced is where I started on dynamic pages. Just have to play with the example to get the experience. I put together a UDGrid showing the Windows Services with start and stop buttons. The buttons need a little more work to have them functional. The refresh icon in the bottom right corner does pickup the current status for each service.
You just beat me to the punch I got my dashboard working aswell,
(Yours also looks cleaner than mine though)
My issue was as you said I wasn’t using a dynamic page, so I was unable to call it New-UDInputAction -RedirectUrl "Dympage"
As well as what Guy said about I needed to reload the element New-UDInputAction -Content {Sync-UDElement -Id "Div1"}
As S.stauts is read-only ( as its a ServiceController )
I had to re-lookup Get-Service in my switch.
Switch ((Get-Service ($S.name)).Status) { (Get-Service (($S).name)).Status) -Color red
Etc. It’s not pretty, but it is working now.
I really like your layout and the use of the Else is a good call for screen space.
Thank you both so much for your help,
I think I know how to proceed from here, but any tips would be appreciated.
As I’m sure you can tell, I’m very new to UD (It’s fantastic) and I would very much like to improve my skills with it.