forked from Badgerati/Pode.Web
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic.ps1
More file actions
38 lines (30 loc) · 1.59 KB
/
basic.ps1
File metadata and controls
38 lines (30 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Import-Module Pode -MaximumVersion 2.99.99 -Force
Import-Module ..\src\Pode.Web.psm1 -Force
Start-PodeServer {
# add a simple endpoint
Add-PodeEndpoint -Address localhost -Port 8090 -Protocol Http
New-PodeLoggingMethod -Terminal | Enable-PodeErrorLogging
# set the use of templates, and set a login page
Use-PodeWebTemplates -Title 'Basic Example' -Theme Dark
# social
Set-PodeWebSocial -Type GitHub -Url 'https://github.com/badgerati'
Set-PodeWebSocial -Type Twitter -Url 'https://twitter.com/Badgerati' -Tooltip '@Badgerati'
# set the home page controls (just a simple paragraph)
$section = New-PodeWebCard -Name 'Welcome' -NoTitle -Content @(
New-PodeWebParagraph -Value 'This is an example homepage, with some example text'
New-PodeWebParagraph -Value 'Using some example paragraphs'
)
Add-PodeWebPage -Name 'Home' -Path '/' -HomePage -Content $section -Title 'Awesome Homepage'
# add a page to search process (output as json in an appended textbox)
$form = New-PodeWebForm -Name 'Search' -ButtonType Submit, Reset -SubmitText 'Search' -ResetText 'Clear' -AsCard -ScriptBlock {
$procs = @(Get-Process -Name $WebEvent.Data.Name -ErrorAction Ignore |
Select-Object Name, ID, WorkingSet, CPU)
$procs |
New-PodeWebTextbox -Name 'Output' -Multiline -Preformat -AsJson -Size ((6 * $procs.Length) + 2) |
Out-PodeWebElement
} -Content @(
New-PodeWebTextbox -Name 'Name'
)
Add-PodeWebPage -Name Processes -Icon 'chart-box-outline' -Content $form -Index 1
Use-PodeWebPages
}