Navigation Bar Logo

To add a logo to the navbar, you can specify a published folder to host you icon and then use -NavBarLogo to specify the icon.

$PublishedFolder = Publish-UDFolder -Path $PSScriptRoot -RequestPath "/images"
$Dashboard = New-UDDashboard -Title "Logo" -Content {} -NavBarLogo (New-UDImage -Url '/images/UDLogo.png' -Height 32 -Width 32) 
Start-UDDashboard -Dashboard $Dashboard -Port 10000 -PublishedFolder $PublishedFolder -Force

4 Likes

Using this exact code I cannot get this to work. It has a broken image link. I am putting the file in the .\images directory where the PS1 is located then running the PS1 just as you have above. Let me know what more details I can provide.

Try adding
Write-Host $PSScriptRoot

as your first line in the PS1, see what the console outputs for it.

The location of image is C:\repos\Dashboards\images\whatever.png

PS C:\repos\Dashboards> .\Icon.ps1
C:\repos\Dashboards

Name         Port Running DashboardService
----         ---- ------- ----------------
Dashboard21 10000    True UniversalDashboard.Services.DashboardService

PS C:\repos\Dashboards>

Current Script for troubleshooting purposes.

get-UDDASHboard | Stop-uddAshboard
Write-Host $PSScriptRoot
$PublishedFolder = Publish-UDFolder -Path $PSScriptRoot -RequestPath "/images"
$Dashboard = New-UDDashboard -Title "Logo" -Content {} -NavBarLogo (New-UDImage -Url '/images/UDLogo.png' -Height 32 -Width 32) 
Start-UDDashboard -Dashboard $Dashboard -Port 10000 -PublishedFolder $PublishedFolder -Force

So, this might just be a typo on your part… but you say the location of your image is

c:\repos\Dashboards\images\whatever.png

yet you are calling /images/UDLogo.png

Is the image named UDLogo.png or whatever.png ?

Yeah I didn’t remember what it was named when I put that up there but it is named UDLogo.png I just went and verified it is there and named UDLogo.png

Solved, Need to specify images in your path. This below works for me.

get-UDDASHboard | Stop-uddAshboard
$PublishedFolder = Publish-UDFolder -Path "$PSScriptroot\images" -RequestPath "/images"
$Dashboard = New-UDDashboard -Title "Logo" -Content {} -NavBarLogo (New-UDImage -Url '/images/UDLogo.png' -Width 32) 
Start-UDDashboard -Dashboard $Dashboard -Port 10000 -PublishedFolder $PublishedFolder -Force

Ah, he didn’t have an images folder in his original example. That would explain it.

He had the image file in the same directory as the .PS1

Ah… I took this as there was… #Noob LOL

Yeah, that -RequestPath “/images” makes that a virtual directory.

Does it support @psDevUK UDGhost? :wink:

1 Like