I have trying to figure out something i think should be pretty basic. I want to create an apps that will act as a dashboard and creates pages that act as standalone application “apps kinda” Like for reports etc.
But i cannot get it to work. each time i try to navigate to the pages it says Page Not found. Here is my code so far, i tried a lot of different codes and spent days on the Docs for V5. Any help would be appreciated.
You’re return 2 apps from the file and it’s using the first, which doesn’t have a test page. You can also avoid Invoke-UDRedirect if you use -Href because it just does local redirect.
Thanks. it’s pretty clean code and easy to understand.
Just want to make sure i understand how this works. The code for the pages, does it need to be in the CODE section of the apps?
My goal would be to store the code in the page i created in "/pages/test.ps1 inside the apps and just use the apps to navigate to it. But even now any code i put in the pages does not show up in the apps when i use it and navigate to the test button i created.
You can define the code for each page inside its own pagename.ps1 file with its own URL using the GUI. The pages are then programmatically separate and accessible from within their own page code. Then, at the end, you can do something programmatically similar to:
#testpage1.ps1
New-UDPage -Name "testpage1" -Url "/testpage1" -Content {
"Welcome to test page 1!"
}
#testpage2.ps1
New-UDPage -Name "testpage2" -Url "/testpage2" -Content {
"Welcome to test page 2!"
}
#testpageN.ps1
New-UDPage -Name "testpageN" -Url "/testpageN" -Content {
"Welcome to test page N!"
}
#app.ps1
New-UDApp -Pages @(
Get-UDPage -Name "testpage1.ps1"
Get-UDPage -Name "testpage2.ps1"
Get-UDPage -Name "testpageN.ps1"
)
If you head to the Pages section within the App’s code, it will allow you to define these pages and ensure they are in the correct location from right in the GUI. Then, you can adjust the pages’ code accordingly from within their respective code editors.
Please let me know if that’s what you mean - it seems almost like you are looking at dynamically creating pages, which is a different question entirely that I can attempt to address as well.
Hey Thanks for the answer. I am not trying to dynamically creating them. I am just trying to put the code in a page.ps1 that will generate some report i code. But to access it i want to navigate to it using the dashboard i create in the apps.
The dashboard app is like the hub that i can link the pages i created.
Yep. I did all of that. I have the .ps1
I am really not sure what i am doing wrong.
# Main dashboard.ps1
$Pages = @()
$Pages += New-UDPage -Name 'test' -url '/test' -Content {
#if i put the code here it works but i want to store the code in a page.
}
# Navigation
$Nav = New-UDList -Content {
New-UDListItem -Label "Test" -Href '/test' -Icon (New-UDIcon -Icon Cog -Size 1x)
}
# Create app with all components
New-UDApp -Title 'Navigation' -Pages $Pages -Navigation $Nav -NavigationLayout permanent
If i insert New-UDTypography (Get-Date) in the page’s content on the app code i see it exactly where i want it. but my goal is to store that code in the page’s .ps1