Skip to content

Instantly share code, notes, and snippets.

@adamdriscoll
Created October 2, 2019 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamdriscoll/c81694fc9a676189f030dc12965bbca5 to your computer and use it in GitHub Desktop.
Save adamdriscoll/c81694fc9a676189f030dc12965bbca5 to your computer and use it in GitHub Desktop.
Dynamically generate a diagram with PSWriteHtml and Universal Dashboard
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