neo
February 3, 2020, 12:06pm
1
I have a dashboard (2.8.2) that uses pages that call scripts in endpoints:
New-UDPage -Name "Home" -Icon globe -Title "HOME" -Endpoint{}
This however affects the -Title on the dashboard and does not allow it to update for each page, it remains as the title defined in the line:
$Dashboard = New-UDDashboard -Title "BASIC" -Pages $Pages -Navigation $Navigation
Also the tab text remains ‘Powershell Universal Dashboard’.
If i then change the endpoint to -Content (New-UDPage -Name “Home” -Icon globe -Title “HOME” -Content{}) it all works as expected, the title and tabs all update…
Test code here (replace -Endpoint with -Content and it will work):
Get-UDDashboard | Stop-Uddashboard
# Create Dashboard - Pages
$Pages = @()
$Pages += New-UDPage -Name "Home" -Icon globe -Title "HOME" -Endpoint{
.("C:\inetpub\wwwroot\Data\Pages\Home.ps1")
}
$Pages += New-UDPage -Name "Test" -Icon globe -Title "Test" -Endpoint{
.("C:\inetpub\wwwroot\Data\Pages\Test.ps1")
}
# Create Dashboard - Navigation
$Navigation = New-UDSideNav -Fixed -Width 225 -Content {
New-UDSideNavItem -Text "Home" -PageName "Home" -Icon Home
New-UDSideNavItem -Text "Test" -PageName "Test" -Icon hourglass_half
}
# Dashboard Start
$Dashboard = New-UDDashboard -Title "BASIC" -Pages $Pages -Navigation $Navigation
Start-UdDashboard -Dashboard $Dashboard -Wait
This is running in IIS.
Any ideas?
@neo
I never dot sourced the page Endpoint/Content.
I cannot explain why your code is not working this way.
Maybe you can try my method and include the New-UDPage
in your ps1 pages (Home.psq & Test.ps1).
Sample Code:
Home.ps1
New-UDPage -Name "Home" -Icon globe -Title "HOME" -Endpoint {
#some logic
}
and this is your main function/script:
Get-UDDashboard | Stop-Uddashboard
# Create Dashboard - Pages
$Pages = Get-ChildItem "C:\inetpub\wwwroot\Data\Pages" -File | %{
& $_.FullName
}
# Create Dashboard - Navigation
$Navigation = New-UDSideNav -Fixed -Width 225 -Content {
New-UDSideNavItem -Text "Home" -PageName "Home" -Icon Home
New-UDSideNavItem -Text "Test" -PageName "Test" -Icon hourglass_half
}
# Dashboard Start
$Dashboard = New-UDDashboard -Title "BASIC" -Pages $Pages -Navigation $Navigation
Start-UdDashboard -Dashboard $Dashboard -Wait
neo
February 3, 2020, 1:20pm
3
Hi, thanks for the reply!
I have tried many ways of calling pages and dot sourced was just the easiest way at the time however that is not what is causing the issue (but thanks for the alternative)!
If you run the code with no reference to page source code it does the same thing which is where i get stuck:
Get-UDDashboard | Stop-Uddashboard
# Create Dashboard - Pages
$Pages = @()
$Pages += New-UDPage -Name "Home" -Icon globe -Title "HOME" -Endpoint{
}
$Pages += New-UDPage -Name "Test" -Icon globe -Title "Test" -Endpoint{
}
# Create Dashboard - Navigation
$Navigation = New-UDSideNav -Fixed -Width 225 -Content {
New-UDSideNavItem -Text "Home" -PageName "Home" -Icon Home
New-UDSideNavItem -Text "Test" -PageName "Test" -Icon hourglass_half
}
# Dashboard Start
$Dashboard = New-UDDashboard -Title "BASIC" -Pages $Pages -Navigation $Navigation
Start-UdDashboard -Dashboard $Dashboard -Wait
I see, seems to be a bug as I can reproduce this also in my project (v2.8.2).
Please open an issue on GH:
neo
February 3, 2020, 1:37pm
5
1 Like