Created
October 2, 2019 17:35
-
-
Save adamdriscoll/c81694fc9a676189f030dc12965bbca5 to your computer and use it in GitHub Desktop.
Dynamically generate a diagram with PSWriteHtml and Universal Dashboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module PSWriteHTML | |
$DiagramPath = "$PSScriptRoot/pswritehtml" | |
$Folder = Publish-UDFolder -Path "$PSScriptRoot/pswritehtml" -RequestPath "/pswritehtml" | |
Start-UDDashboard -Dashboard (New-UDDashboard -Title 'Dashboard' -Content { | |
New-UDInput -Title "Generate Diagram" -Endpoint { | |
param($Color) | |
New-HTML -TitleText 'My diagram' -UseCssLinks -UseJavaScriptLinks -FilePath $DiagramPath\diagram.html { | |
New-HTMLPanel { | |
New-HTMLDiagram { | |
New-DiagramNode -Label 'One node' -To 'Second node','Third node' -ColorBackground $Color | |
New-DiagramNode -Label 'Second node' -ColorBackground $Color | |
New-DiagramNode -Label 'Third node' -ColorBackground $Color | |
} | |
} | |
} | |
New-UDInputAction -Content { | |
New-UDElement -Tag 'iframe' -Attributes @{ | |
style = @{ | |
height = '100ch' | |
width = '100%' | |
} | |
src = "/pswritehtml/diagram.html" | |
} | |
} | |
} | |
}) -Port 10000 -Force -PublishedFolder $Folder |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment