Exporting HTML Dashboards to file and re-ingest? #317
-
I'm using PSWriteHTML to make some reports, I have the scripts outputting the HTML files and I just recently found the Navigational Piece to make a full fledge dashboard with navigation. In the example provided in https://github.com/EvotecIT/PSWriteHTML/blob/master/Examples/Example41-NavigationTopMenu/Example41-Navigation03.ps1 In the code section
Would it be possible to ingest the existing HTML file, so instead of re-creating the pages for the sub-page. I was thinking something like a Get-Content to fetch the HTML from the file, but I'm not excatly sure how to get the HTML into the New-HTMLPage cmdlet. I tried the Add-HTML cmdlet, but it threw a error and completed. However, the content was all jumbled and non-working |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
I understand where you're coming from and there's a reason it was built - I guess similar to yours. While the code shown in example is mainly to show how you can build something from scratch - rebuilding existing reports all the time will be a problem and time consuming. Basically I have lots of modules that generate reports standalone and getting them to regenerate it for large domain would take hours and be inefficient. So I created another module which generates me the dashboard based on existing .HTML files And it would not use New-HTMLPage - but instead would just update links in the navigation to point to specific files. It works but once you click on the link you are pointed to a report - and you loose the navigation bar on the new page, and you would go back to the main page by just pressing back in the browser. This works, but is fairly inefficient and not user friendly, but could fit your project. The problem with loading existing HTML will be that the report already has all the CSS/JS in the headers/footers so before you could push it to New-HTMLPage to reuse it - you would first need to parse it and see what's there, what's missing for adding navbar and so on. Initially i planned to use my PSParseHTML module to do that - but it's going to be problematic (although I added some code in PSWriteHTML) that would help. But then some people could want to use reports created with something else then PSWriteHTML and conflicting libraries would be even messier. So I had another idea that instead of reimporting HTML I would just use HTML Frames. The way it works it creates an empty New-HTMLPage which just contains Navbar and the remaining part of the page is the frame that contains report. $FullPath = [io.path]::Combine($PathToSubReports, "$PageName.html")
New-HTMLPage -Name $MenuBuilder[$Menu][$MenuReport].Name {
New-HTMLFrame -SourcePath $MenuBuilder[$Menu][$MenuReport].Href -Scrolling Auto -Height 1500px
} -FilePath $FullPath New-HTMLFrame can be seen in examples: New-HTML {
New-HTMLSection {
New-HTMLFrame -SourcePath "$PSSCriptRoot\GPOZaurr.html" -Scrolling Auto
} -HeaderText 'Test'
New-HTMLSection {
New-HTMLFrame -SourcePath "$PSSCriptRoot\GPOZaurr.html" -Scrolling Auto -Height 1500px
} -HeaderText 'Test'
New-HTMLSection {
New-HTMLFrame -SourcePath "C:\Support\GitHub\PSWriteHTML\Examples\Example-Maps\Example-Maps.html"
} -HeaderText 'Test' -Height 100vh
} -Online -TitleText 'Test Inline' -ShowHTML -FilePath "$PSScriptRoot\Example-InlineHTML01.html" -AddComment This basically "inserts" existing HTML files as a frame, but the original needs to be there. The "Page" file is just a place holder for everything else. So my recommendation is - go with New-HTMLFrame - and make sure your reports from other apps/modules are "available" to the dashboard (probably in some readonly folder) to display to user when they go in thru IIS/Apache or whatever. I will probably release my Dashboard project that allows for just configuring stuff by telling it where the files are located - but not sure how useful it will be to others. |
Beta Was this translation helpful? Give feedback.
I understand where you're coming from and there's a reason it was built - I guess similar to yours. While the code shown in example is mainly to show how you can build something from scratch - rebuilding existing reports all the time will be a problem and time consuming.
Basically I have lots of modules that generate reports standalone and getting them to regenerate it for large domain would take hours and be inefficient.
So I created another module which generates me the dashboard based on existing .HTML files
And it would not use New-HTMLPage - but instead would just update links in the navigation to point to specific files. It works but once you click on the link you are pointed to a…