-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Render HTML in a Grid? #466
Comments
You can't really customize the cells themselves at the moment. You should be able to use New-UDElement\New-UDHTML to render data within the cells. Similar to this but with custom formatting rather than a dropdown: https://forums.universaldashboard.io/t/dropdowns-in-new-udgrid/44/3?u=adam As mentioned in that post, there is abut in 2.1 that will prevent you from using New-UDElement from within a grid but you can use the latest AppVeyor build to play with that functionality. |
Any idea, in this code, why the table does not populate, but the grid does?
|
I'm not really sure why that wouldn't work. The only thing I can think is that we have a scoping issue with the variable for some reason. Can you verify that $RoomVEStatus is populated when you are within the UDTable Endpoint? Throw a Wait-Debugger in there and see if it has the correct value.
Then load your dashboard in the browser. Go back to the PS console and then run Get-Runspace and the Debug-Runspace the runspace that is InBreakpoint. Then you should be able to just dump the variable to the console: $RoomVEStatus |
It's null. Interestingly, with the variable named $RoomVEStatus, there is no error, but no output. I tried changing the name of the variable to $rvs and then the table displays a Cannot bind argument error. Maybe there are two issues in play... FYI, $Cache.VEStatus works fine... the issue only effects the new variable. |
What happens if you change it to use ArgumentList rather than implicit variable scoping?
|
My UDTable does not allow -ArgumentList, so that just errors out The Grid, however, now shows the this.state.events.map is not a function I suppose that brings up another (probably dumb) question... how does one properly install the appveyor versions? |
Ah, crap. That needs to be fixed. I will get a build put together with that change. See below. It needs to be updated here: From AppVeyor, if you go to the Artifacts tab, you can then download the ZIP and either unzip it to your PSModulePath or unzip it to a folder where you directly import the the PSD1. You will need to make sure to unblock the files: dir -recurse | Unblock-File https://ci.appveyor.com/project/adamdriscoll/universal-dashboard/build/artifacts If we get lucky, should be able to just add ArgumentList to New-UDTable and pass it onto the New-UDElement call.
|
I downloaded the file, expanded it, unblocked it, gave it a name, put it in a folder, edited the controls pms1 with what you have above, then ipmo'd the psd1 form the file location. get-module shows 2.2.0 -argumentlist was still not an option. Do I have to uninstall 2.1.0 entirely? I tried just unloading it... then impo'ing the new build. |
Ack. I'll have to look at what's going on with the latest build. |
Well, it sort of works in #476. The Sch Endpoint that gathers the data doesn't seem to be updating at all. And if I have the -autorefresh turned on on the udtable, some of the tables will refresh with nothing populated and some will. Randomly. If I then refresh the page in the browser over and over, randomly some tables will be populated, others will not. Without the autorefresh enabled, they all populate (refreshint is set to 10 sec). Probably just a buggy build, but at least I can confirm that the argumentlist works nicely. :) |
lol.... Yeah seems problematic. I'll throw together a test case that matches this scenario so that we can make sure it's right. This would include:
Right? |
Sounds right. Not that it should matter, but note that the scheduled endpoint is using a pssqlite query. However, it has been working fine under 2.1.0 to continuously query.
That db is fed from another script running from scheduled tasks. This is the latest page code I am using. Perhaps I am gumming something up trying to dynamically change the Title of the table? (it would be nice if the title could be refreshed on both grids and tables from within the new-udtable/new-udgrid, and/or accept the $ArgumentList object). I have not been able to get the grid title to update even on a page refresh, but the table does seem to.
|
PS - Ideally all that should work in Grids too, fwiw. |
PPS... after further testing I believe the scheduled endpoint continues working normally.
In either case, if I dynamically generate a bunch of tables or grids as I am doing above, they will not refresh.... even if directly passing the cached variable into -argumentlist. Pretty much as soon as I add a foreach, it seems to kill the refresh. Oh, and lastly... I cannot seem pass New-UDElement into a UDGrid cell in the latest .305. UDTable, yes, UDGrid, no. |
Ok. Thanks for the follow up. Glad that the scheduled endpoints are working. |
I think what's going on is that Page Autorefresh and Table autorefresh don't work. Grid autorefresh does. BUT, if a grid is using a variable that is set elsewhere in the page, it does not "appear" to refresh because page Autorefresh doesn't work. I've been playing a schedule endpoint that just caches the time... then I'm trying to use that in different ways in a page/table/grid, secondary variable, etc.... The above description seems to explain what I am seeing. Everything else appears to be a symptom. |
I think I have a handle on this issue. Here's the breakdown. UDPage auto-refresh was indeed broken. When using the
Another thing I realized is that, due to the nature of how variables work with endpoints, the value of the variables were actually being cache and even though auto-refresh was running, it was just getting the same data over and over again. So in this example, when the table and grid are created, they get the value of $Status. When they autorefresh, they are just getting the same value of status again that is stored with the endpoint. It's not executing all the code surrounding the New-UDTable\New-UDGrid, just what's in the Endpoint script block.
So after fixing that, I also realized that there were some issues with the client-side JavaScript React code that was preventing it from re-rendering even if it did get new data. Here's a working sample that I added to the integration tests. Rather than auto-refreshing the table\grid themselves, I'm just autorefreshing the entire page. Notice that I added a
Let me know how build 308 works for you. https://ci.appveyor.com/project/adamdriscoll/universal-dashboard/builds/20374299 |
Seems to be erroring out on the UDPage -Endpoint (object ref not set to an instance...etc) |
I should ask... is it ok to load both 2.1.0 (Enterprise) and the appveyor builds at the same time? Seems to work so far in giving me the login page, plus the new features in community... but I don't know if that's "sanitary".... I need to keep the ent features running. I've been starting my dash with this to keep it as clean as possible:
Is that an alright method? |
Hmmm that might be the problem. Since UD is a binary module, doing a Remove-Module doesn't actually remove the assemblies from PowerShell which means the enterprise version is still loaded in more. I have a test for this scenario here: It's passing on the builder and on my machine. https://ci.appveyor.com/project/adamdriscoll/universal-dashboard/builds/20374599#L1061 I will have to get this PR into the enterprise fork and get you a build. |
Can you please try the beta1 version? https://www.powershellgallery.com/packages/UniversalDashboard/2.2.0-beta1 |
Well... it works for a while anyways. At some point things stop updating and refreshing the page just spins until it fails. I'll see what I can learn about that. Works for about an hour or so |
I would suggest checking in the Network tab of the developer tools in your browser to see if it's giving errors there. Otherwise, Enable-UDLogging should be helpful. |
i know it have been a while but i am working in a similar project , appreciate if you can share the code of this dashboard. |
I may just be dense, but is there any way to render html inside a new-udgrid? This would be for feeding in markup that colors the background of the cell, changed font weight, etc... preferably based on markup embedded in a custom object.
Maybe I'm overthinking it...
The text was updated successfully, but these errors were encountered: