Skip to content

Commit a1d69b2

Browse files
authoredNov 12, 2022
Merge pull request #375 from Badgerati/develop
v0.8.2
2 parents fbbfba0 + 6b2e1d1 commit a1d69b2

30 files changed

+540
-39
lines changed
 

‎.build.ps1

+33
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
param (
2+
[string]
3+
$Version = ''
4+
)
15

26
$dest_path = './src/Templates/Public'
37
$src_path = './pode_modules'
@@ -267,6 +271,35 @@ task MoveLibs {
267271
}
268272

269273

274+
<#
275+
# Pack
276+
#>
277+
278+
# Synopsis: Package up the Module
279+
task Pack -If (Test-PodeBuildIsWindows) Build, {
280+
if (!$Version) {
281+
$Version = (Import-PowerShellDataFile -Path './src/Pode.Web.psd1').ModuleVersion
282+
}
283+
}, DockerPack
284+
285+
# Synopsis: Create docker tags
286+
task DockerPack {
287+
docker build -t badgerati/pode.web:$Version -f ./Dockerfile .
288+
docker build -t badgerati/pode.web:latest -f ./Dockerfile .
289+
docker build -t badgerati/pode.web:$Version-alpine -f ./alpine.dockerfile .
290+
docker build -t badgerati/pode.web:latest-alpine -f ./alpine.dockerfile .
291+
docker build -t badgerati/pode.web:$Version-arm32 -f ./arm32.dockerfile .
292+
docker build -t badgerati/pode.web:latest-arm32 -f ./arm32.dockerfile .
293+
294+
docker tag badgerati/pode.web:latest docker.pkg.github.com/badgerati/pode.web/pode.web:latest
295+
docker tag badgerati/pode.web:$Version docker.pkg.github.com/badgerati/pode.web/pode.web:$Version
296+
docker tag badgerati/pode.web:latest-alpine docker.pkg.github.com/badgerati/pode.web/pode.web:latest-alpine
297+
docker tag badgerati/pode.web:$Version-alpine docker.pkg.github.com/badgerati/pode.web/pode.web:$Version-alpine
298+
docker tag badgerati/pode.web:latest-arm32 docker.pkg.github.com/badgerati/pode.web/pode.web:latest-arm32
299+
docker tag badgerati/pode.web:$Version-arm32 docker.pkg.github.com/badgerati/pode.web/pode.web:$Version-arm32
300+
}
301+
302+
270303
<#
271304
# Docs
272305
#>

‎.github/ISSUE_TEMPLATE/bug-report.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
name: Bug Report
3+
about: Create a bug report to help us improve
4+
title: ''
5+
labels: 'bug :bug:'
6+
assignees: ''
7+
8+
---
9+
10+
### Describe the Bug
11+
A clear and concise description of what the bug is.
12+
13+
### Steps To Reproduce
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
### Expected Behavior
21+
A clear and concise description of what you expected to happen.
22+
23+
### Screenshots
24+
If applicable, add screenshots to help explain your problem.
25+
26+
### Platform
27+
- OS: [e.g. iOS, Windows]
28+
- Browser: [e.g. Chrome, Safari]
29+
- Versions:
30+
- Pode: [e.g. Pode v1.7.3]
31+
- Pode.Web: [e.g. Pode.Web v0.8.0]
32+
- PowerShell: [e.g. PS6.2.1]
33+
34+
### Additional Context
35+
Add any other context about the problem here.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
name: Documentation Request
3+
about: Suggest an edit to Pode.Web's documentation
4+
title: ''
5+
labels: 'documentation :book:'
6+
assignees: ''
7+
8+
---
9+
10+
### Describe the Change
11+
A clear and concise description of the edit.
12+
13+
### Additional Context
14+
Add any other context or screenshots about the enhancement request here.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Enhancement Request
3+
about: Suggest an enhancement for an existing feature.
4+
title: ''
5+
labels: 'enhancement :arrow_up:'
6+
assignees: ''
7+
8+
---
9+
10+
### Describe the Change
11+
A clear and concise description of what you want to happen.
12+
13+
### Related Issues
14+
A clear and concise description of what the problem is, or a link/reference to the issue.
15+
16+
### Additional Context
17+
Add any other context or screenshots about the enhancement request here.
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Feature Request
3+
about: Suggest a new feature for Pode.Web
4+
title: ''
5+
labels: 'feature :sunny:'
6+
assignees: ''
7+
8+
---
9+
10+
### Describe the Feature
11+
A clear and concise description of what you want to happen.
12+
13+
### Related Issues
14+
A clear and concise description of what the problem is, or a link/reference to the issue.
15+
16+
### Additional Context
17+
Add any other context or screenshots about the feature request here.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: Packaging Request
3+
about: Suggest an improvement for the packaging of Pode.Web, such as a new version of software.
4+
title: ''
5+
labels: 'packaging :package:'
6+
assignees: ''
7+
8+
---
9+
10+
### Describe the Change
11+
A clear and concise description of what you want to happen.

‎.github/ISSUE_TEMPLATE/question.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: Question
3+
about: Ask a question about Pode.Web's features, examples, or documentation
4+
title: ''
5+
labels: 'question :grey_question:'
6+
assignees: ''
7+
8+
---
9+
10+
### Question
11+
A clear and concise description of your question.

‎.github/workflows/ci.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
os: [ubuntu-latest]
2121

2222
steps:
23-
- uses: actions/checkout@v1
23+
- uses: actions/checkout@v2
2424

2525
- name: Install Invoke-Build
2626
shell: pwsh
@@ -32,4 +32,10 @@ jobs:
3232
shell: pwsh
3333
run: |
3434
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
35-
Invoke-Build Build
35+
Invoke-Build Build
36+
37+
- name: Test docker builds
38+
shell: pwsh
39+
run: |
40+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
41+
Invoke-Build DockerPack
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Add labeled issues to project
2+
3+
on:
4+
issues:
5+
types:
6+
- labeled
7+
8+
jobs:
9+
add-to-project:
10+
name: Add issue to project
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/add-to-project@v0.3.0
14+
with:
15+
project-url: https://github.com/users/Badgerati/projects/3
16+
github-token: ${{ secrets.PROJECT_TOKEN }}
17+
labeled: 'roadmap :rocket:, backlog :scroll:'
18+
label-operator: OR
19+
20+
- uses: actions/add-to-project@v0.3.0
21+
with:
22+
project-url: https://github.com/users/Badgerati/projects/5
23+
github-token: ${{ secrets.PROJECT_TOKEN }}
24+
labeled: 'draft :pencil2:, idea :bulb:'
25+
label-operator: OR
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Add opened issues to project
2+
3+
on:
4+
issues:
5+
types:
6+
- opened
7+
8+
jobs:
9+
add-to-project:
10+
name: Add issue to project
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/add-to-project@v0.3.0
14+
with:
15+
project-url: https://github.com/users/Badgerati/projects/3
16+
github-token: ${{ secrets.PROJECT_TOKEN }}
17+
labeled: 'bug :bug:, documentation :book:, packaging :package:'
18+
label-operator: OR

‎Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM badgerati/pode:2.6.2
1+
FROM badgerati/pode:2.7.2
22
LABEL maintainer="Matthew Kelly (Badgerati)"
33
RUN mkdir -p /usr/local/share/powershell/Modules/Pode.Web
44
COPY ./src/ /usr/local/share/powershell/Modules/Pode.Web

‎README.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- omit in toc -->
12
# <img src="https://github.com/Badgerati/Pode/blob/develop/images/icon.png?raw=true" width="25" /> Pode.Web
23

34
> This is still a work in progress, until v1.0.0 expect possible breaking changes in some releases.
@@ -6,13 +7,24 @@
67
[![Documentation](https://img.shields.io/github/v/release/badgerati/pode.web?label=docs)](https://badgerati.github.io/Pode.Web)
78
[![GitHub Actions](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fbadgerati%2Fpode.web%2Fbadge&style=flat&label=GitHub)](https://actions-badge.atrox.dev/badgerati/pode.web/goto)
89
[![Discord](https://img.shields.io/discord/887398607727255642)](https://discord.gg/fRqeGcbF6h)
9-
[![GitHub Sponsors](https://img.shields.io/github/sponsors/Badgerati?color=%23ff69b4&logo=github&style=flat&label=Sponsers)](https://github.com/sponsors/Badgerati)
1010

1111
[![PowerShell](https://img.shields.io/powershellgallery/dt/pode.web.svg?label=PowerShell&colorB=085298)](https://www.powershellgallery.com/packages/Pode.Web)
1212
[![Docker](https://img.shields.io/docker/pulls/badgerati/pode.web.svg?label=Docker)](https://hub.docker.com/r/badgerati/pode.web/)
1313

14+
[![GitHub Sponsors](https://img.shields.io/github/sponsors/Badgerati?color=%23ff69b4&logo=github&style=flat&label=Sponsers)](https://github.com/sponsors/Badgerati)
15+
[![Ko-fi](https://img.shields.io/static/v1?logo=kofi&label=Ko-fi&logoColor=white&message=Buy+me+a+coffee&color=ff5f5f)](https://ko-fi.com/badgerati)
16+
[![PayPal](https://img.shields.io/static/v1?logo=paypal&label=PayPal&logoColor=white&message=Donate&color=00457C)](https://paypal.me/badgerati)
17+
1418
> 💝 A lot of my free time, evenings, and weekends goes into making Pode happen; please do consider sponsoring as it will really help! 😊
1519
20+
- [📦 Libraries](#-libraries)
21+
- [📘 Documentation](#-documentation)
22+
- [🚀 Features](#-features)
23+
- [📦 Install](#-install)
24+
- [🙌 Contributing](#-contributing)
25+
- [🔥 Quick Example](#-quick-example)
26+
- [🌎 Roadmap](#-roadmap)
27+
1628
This is a web template framework for use with the [Pode](https://github.com/Badgerati/Pode) PowerShell web server (v2.6.0+).
1729

1830
It allows you to build web pages purely with PowerShell - no HTML, CSS, or JavaScript knowledge required!
@@ -101,3 +113,9 @@ Start-PodeServer {
101113
```
102114

103115
![chart_processes](/images/chart_processes.png)
116+
117+
## 🌎 Roadmap
118+
119+
You can find a list of the features, enhancements and ideas that will hopefully one day make it into Pode.Web [here in the documentation](https://badgerati.github.io/Pode.Web/roadmap/).
120+
121+
There is also a [Project](https://github.com/users/Badgerati/projects/3) in the beginnings of being setup for Pode.Web, with milestone progression and current roadmap issues. Plus, there is a [Draft Board](https://github.com/users/Badgerati/projects/5) which contains a range of ideas for Pode.Web features/enhancements which are either brilliant, ludicrous, or down right insane! Draft Issues are purely ideas, and any in the design stage might one day make it in! If you see a Draft Issue you which to discuss, or have an idea for one, please dicuss it over on [Discord](https://discord.gg/fRqeGcbF6h) in the `#ideas` or `#pode-web` channel.

‎alpine.dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM badgerati/pode:2.6.2-alpine
1+
FROM badgerati/pode:2.7.2-alpine
22
LABEL maintainer="Matthew Kelly (Badgerati)"
33
RUN mkdir -p /usr/local/share/powershell/Modules/Pode.Web
44
COPY ./src/ /usr/local/share/powershell/Modules/Pode.Web

‎arm32.dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM badgerati/pode:2.6.2-arm32
1+
FROM badgerati/pode:2.7.2-arm32
22
LABEL maintainer="Matthew Kelly (Badgerati)"
33
RUN mkdir -p /usr/local/share/powershell/Modules/Pode.Web
44
COPY ./src/ /usr/local/share/powershell/Modules/Pode.Web

‎docs/Getting-Started/Installation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Install-Module -Name Pode.Web
3434
[![Docker](https://img.shields.io/docker/stars/badgerati/pode.web.svg?label=Stars)](https://hub.docker.com/r/badgerati/pode.web/)
3535
[![Docker](https://img.shields.io/docker/pulls/badgerati/pode.web.svg?label=Pulls)](https://hub.docker.com/r/badgerati/pode.web/)
3636

37-
Like Pode, Pode.Web also has Docker images available. The images use Pode v2.6.2 on either an Ubuntu Focal image (default), an Alpine image, or an ARM32 image (for Raspberry Pis).
37+
Like Pode, Pode.Web also has Docker images available. The images use Pode v2.7.2 on either an Ubuntu Focal image (default), an Alpine image, or an ARM32 image (for Raspberry Pis).
3838

3939
* To pull down the latest Pode.Web image you can do:
4040

‎docs/Hosting/Docker.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Pode.Web has a Docker image that you can use to host your server, for instructions on pulling these images you can [look here](../../Getting-Started/Installation).
44

5-
The images use Pode v2.6.2 on either an Ubuntu Focal (default), Alpine, or ARM32 image.
5+
The images use Pode v2.7.2 on either an Ubuntu Focal (default), Alpine, or ARM32 image.
66

77
## Images
88

@@ -11,7 +11,7 @@ The images use Pode v2.6.2 on either an Ubuntu Focal (default), Alpine, or ARM32
1111

1212
### Default
1313

14-
The default Pode.Web image is an Ubuntu Focal image with Pode v2.6.2 and Pode.Web installed. An example of using this image in your Dockerfile could be as follows:
14+
The default Pode.Web image is an Ubuntu Focal image with Pode v2.7.2 and Pode.Web installed. An example of using this image in your Dockerfile could be as follows:
1515

1616
```dockerfile
1717
# pull down the pode image

‎docs/release-notes.md

+25
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
# Release Notes
22

3+
## v0.8.2
4+
5+
```plain
6+
### Enhancements
7+
* #340: Add new `-MaxLength` for textboxes (thanks @thekamilpro!)
8+
* #361: Add `-DisplayName` for Tables/Charts, and also for Pages for their name in the sidebar
9+
10+
### Bugs
11+
* #255: Fixes page group names not allowing spaces
12+
* #331: Fixes encoding issue with values in textboxes (thanks @thekamilpro!)
13+
* #335: Fixes `New-PodeWebHidden` not allowing empty values (thanks @thekamilpro!)
14+
* #370: Fixes page group names not allowing special characters
15+
16+
### Packaging
17+
* #329: Bump chart.js to 3.9.1
18+
* #365: Bump monaco to 0.34.1
19+
* #333: Use RequiredModules in Pode.Web.psd1
20+
* #334: Bump jquery-ui to 1.13.2
21+
* #345: Bump jquery to 3.6.1
22+
* #350: Bump Pode to 2.7.2 in Dockerfiles
23+
24+
### Documentation
25+
* #371: Add Project workflow actions, and Roadmap
26+
```
27+
328
## v0.8.1
429

530
```plain

‎docs/roadmap.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Roadmap
2+
3+
This page lists the planned features and enhancements that will, hopefully, one day make it into Pode.Web. There is no timeframe on when to expect them, some could be in-progress right now, and others in the future.
4+
5+
Where possible items listed here will have a link to any relevant issues in GitHub.
6+
7+
There is also a [Project](https://github.com/users/Badgerati/projects/3) in the beginnings of being setup for Pode.Web, with milestone progression and current roadmap issues. Plus, there is a [Draft Board](https://github.com/users/Badgerati/projects/5) which contains a range of ideas for Pode.Web features/enhancements which are either brilliant, ludicrous, or down right insane! Draft Issues are purely ideas, and any in the design stage might one day make it in! If you see a Draft Issue you which to discuss, or have an idea for one, please dicuss it over on [Discord](https://discord.gg/fRqeGcbF6h) in the `#ideas` or `#pode-web` channel.
8+
9+
## 🎯 Goal
10+
11+
The main goal for Pode.Web is to make it easier for people who aren't familiar with frontend technologies, such as HTML, CSS, and JavaScript, to be able to build a website purely using PowerShell - and Pode, of course!
12+
13+
The style of the websites, such as Login pages, sidebars, etc. are all fairly static at present; but I'm hoping to loosen this up over time, to make building dynamic sites more feasible.
14+
15+
Pode.Web is still in it's infancy, once it's matured more a v1.0 will be looked into for releasing.
16+
17+
## 🚢 Releases
18+
19+
Under normal circumstanes Pode.Web releases approximately once every 2 months, where the following month is usually a Pode release.
20+
21+
Sometimes there could be more, if patch releases are needed. But sometimes there could be fewer if peronsal time constraints prevent releases.
22+
23+
## 📃 Plan
24+
25+
### Features
26+
27+
- [ ] Either stick with Bootstrap, move to another framework, or support toggling frameworks - allowing for custom ones
28+
- [ ] Looking into using React for the templates, so make building elements dynamically more possible
29+
- [ ] We have a login page, so why not a registration page! [#90](https://github.com/Badgerati/Pode.Web/issues/90)
30+
- [ ] Everything uses AJAX at present, if we move to using WebSockets then Output actions can happen on the fly
31+
- [ ] Support for custom element/layout templates, rather than Pode.Web's inbuilt ones
32+
- [ ] If the session cookie expires, then redirect to a session expired page
33+
- [ ] Add proper footer support - where socials, links, and other items can go (and move the "Powered By" as well)
34+
- [ ] Language templating system, to more easily support different langauges
35+
36+
## ⏩ Future
37+
38+
The Roadmap for now is the current future of Pode.Web, until mature enough to consider a v1.0 release.

‎examples/full.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Import-Module Pode -MaximumVersion 2.99.99 -Force
2-
Import-Module ..\src\Pode.Web.psm1 -Force
2+
Import-Module ..\src\Pode.Web.psd1 -Force
33

44
Start-PodeServer -StatusPageExceptions Show {
55
# add a simple endpoint

‎examples/inputs.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Import-Module Pode -MaximumVersion 2.99.99 -Force
2-
Import-Module ..\src\Pode.Web.psm1 -Force
2+
Import-Module ..\src\Pode.Web.psd1 -Force
33

44
Start-PodeServer {
55
# add a simple endpoint

‎examples/language.ps1

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
Import-Module Pode -MaximumVersion 2.99.99 -Force
2+
Import-Module ..\src\Pode.Web.psd1 -Force
3+
4+
Start-PodeServer -StatusPageExceptions Show {
5+
# add a simple endpoint
6+
Add-PodeEndpoint -Address * -Port 8090 -Protocol Http
7+
New-PodeLoggingMethod -Terminal | Enable-PodeErrorLogging
8+
9+
10+
# set the use of templates
11+
Use-PodeWebTemplates -Title 'Test' -Logo '/pode.web/images/icon.png' -Theme Dark
12+
13+
$chartData = {
14+
$count = 1
15+
if ($WebEvent.Data.FirstLoad -eq '1') {
16+
$count = 4
17+
}
18+
19+
return (1..$count | ForEach-Object {
20+
@{
21+
Key = $_
22+
Values = @(
23+
@{
24+
Key = 'Example1'
25+
Value = (Get-Random -Maximum 10)
26+
},
27+
@{
28+
Key = 'Example2'
29+
Value = (Get-Random -Maximum 10)
30+
}
31+
)
32+
}
33+
})
34+
}
35+
36+
$processData = {
37+
Get-Process |
38+
Sort-Object -Property CPU -Descending |
39+
Select-Object -First 10 |
40+
ConvertTo-PodeWebChartData -LabelProperty ProcessName -DatasetProperty CPU, Handles
41+
}
42+
43+
$grid1 = New-PodeWebGrid -Cells @(
44+
New-PodeWebCell -Content @(
45+
New-PodeWebChart -Name 'Line Example 1' -DisplayName '行の例' -Type Line -ScriptBlock $chartData -Append -TimeLabels -MaxItems 15 -AutoRefresh -AsCard
46+
)
47+
New-PodeWebCell -Content @(
48+
New-PodeWebChart -Name 'Top Processes' -DisplayName 'トッププロセス' -Type Bar -ScriptBlock $processData -AutoRefresh -RefreshInterval 10 -AsCard
49+
)
50+
New-PodeWebCell -Content @(
51+
New-PodeWebCounterChart -DisplayName 'プロセッサ時間' -Counter '\Processor(_Total)\% Processor Time' -MinY 0 -MaxY 100 -AsCard
52+
)
53+
)
54+
55+
Set-PodeWebHomePage -Layouts $grid1 -DisplayName ''
56+
57+
58+
# add a page to search and filter services (output in a new table element) [note: requires auth]
59+
$editModal = New-PodeWebModal -Name 'Edit Service' -Icon 'square-edit-outline' -Id 'modal_edit_svc' -AsForm -Content @(
60+
New-PodeWebAlert -Type Info -Value 'This does nothing, it is just an example'
61+
New-PodeWebCheckbox -Name Running -Id 'chk_svc_running' -AsSwitch
62+
) -ScriptBlock {
63+
$WebEvent.Data | Out-Default
64+
Hide-PodeWebModal
65+
}
66+
67+
$helpModal = New-PodeWebModal -Name 'Help' -Icon 'help' -Content @(
68+
New-PodeWebText -Value 'HELP!'
69+
)
70+
71+
$table = New-PodeWebTable -Name 'Services' -DisplayName 'サービス' -DataColumn Name -AsCard -Filter -SimpleSort -Click -Paginate -ScriptBlock {
72+
$stopBtn = New-PodeWebButton -Name 'Stop' -Icon 'stop-circle-outline' -IconOnly -ScriptBlock {
73+
Stop-Service -Name $WebEvent.Data.Value -Force | Out-Null
74+
Show-PodeWebToast -Message "$($WebEvent.Data.Value) stopped"
75+
Sync-PodeWebTable -Id $ElementData.Parent.ID
76+
}
77+
78+
$startBtn = New-PodeWebButton -Name 'Start' -Icon 'play-circle-outline' -IconOnly -ScriptBlock {
79+
Start-Service -Name $WebEvent.Data.Value | Out-Null
80+
Show-PodeWebToast -Message "$($WebEvent.Data.Value) started"
81+
Sync-PodeWebTable -Id $ElementData.Parent.ID
82+
}
83+
84+
$editBtn = New-PodeWebButton -Name 'Edit' -Icon 'square-edit-outline' -IconOnly -ScriptBlock {
85+
$svc = Get-Service -Name $WebEvent.Data.Value
86+
$checked = ($svc.Status -ieq 'running')
87+
88+
Show-PodeWebModal -Id 'modal_edit_svc' -DataValue $WebEvent.Data.Value -Actions @(
89+
Update-PodeWebCheckbox -Id 'chk_svc_running' -Checked:$checked
90+
)
91+
}
92+
93+
$filter = "*$($WebEvent.Data.Filter)*"
94+
95+
foreach ($svc in (Get-Service)) {
96+
if ($svc.Name -inotlike $filter) {
97+
continue
98+
}
99+
100+
$btns = @($editBtn)
101+
if ($svc.Status -ieq 'running') {
102+
$btns += $stopBtn
103+
}
104+
else {
105+
$btns += $startBtn
106+
}
107+
108+
[ordered]@{
109+
Name = $svc.Name
110+
Status = "$($svc.Status)"
111+
Actions = $btns
112+
}
113+
}
114+
}
115+
116+
Add-PodeWebPage -Name Services -DisplayName 'サービス' -Icon 'cogs' -Group Tools -Layouts $editModal, $helpModal, $table -ScriptBlock {
117+
$name = $WebEvent.Query['value']
118+
if ([string]::IsNullOrWhiteSpace($name)) {
119+
return
120+
}
121+
122+
$svc = Get-Service -Name $name | Out-String
123+
124+
New-PodeWebCard -Name "$($name) Details" -Content @(
125+
New-PodeWebCodeBlock -Value $svc -NoHighlight
126+
)
127+
} `
128+
-HelpScriptBlock {
129+
Show-PodeWebModal -Name 'Help'
130+
}
131+
132+
133+
# open twitter
134+
Add-PodeWebPageLink -Name Twitter -DisplayName 'Tweet' -Icon Twitter -Group Social -ScriptBlock {
135+
Move-PodeWebUrl -Url 'https://twitter.com' -NewTab
136+
}
137+
}

‎mkdocs.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ theme:
3030
markdown_extensions:
3131
- pymdownx.highlight
3232
- pymdownx.superfences
33+
- pymdownx.tasklist:
34+
custom_checkbox: true
3335
- admonition
3436
- meta
3537

@@ -38,7 +40,9 @@ repo_url: https://github.com/Badgerati/Pode.Web
3840

3941
extra:
4042
social:
41-
- icon: fontawesome/brands/github-alt
42-
link: https://github.com/badgerati
43+
- icon: fontawesome/brands/discord
44+
link: https://discord.gg/fRqeGcbF6h
45+
- icon: fontawesome/brands/github
46+
link: https://github.com/badgerati/pode
4347
- icon: fontawesome/brands/twitter
4448
link: https://twitter.com/badgerati

‎package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
"author": "Matthew Kelly <badgerati42@gmail.com>",
66
"license": "MIT",
77
"dependencies": {
8-
"jquery": "3.6.0",
9-
"jquery-ui-dist": "1.13.1",
8+
"jquery": "3.6.1",
9+
"jquery-ui-dist": "1.13.2",
1010
"popper.js": "1.16.1",
1111
"bootstrap": "4.6.1",
1212
"bs-stepper": "1.7.0",
1313
"@mdi/font": "7.0.96",
14-
"chart.js": "3.8.0",
14+
"chart.js": "3.9.1",
1515
"@highlightjs/cdn-assets": "11.6.0",
16-
"monaco-editor": "0.33.0",
16+
"monaco-editor": "0.34.1",
1717
"moment": "2.29.4"
1818
}
1919
}

‎src/Pode.Web.psd1

+9-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
RootModule = 'Pode.Web.psm1'
1212

1313
# Version number of this module.
14-
ModuleVersion = '0.8.1'
14+
ModuleVersion = '0.8.2'
1515

1616
# ID used to uniquely identify this module
1717
GUID = '5c6cae5a-8e62-48a4-c2e5-7511ffe2d439'
@@ -28,6 +28,14 @@
2828
# Minimum version of the Windows PowerShell engine required by this module
2929
PowerShellVersion = '5.0'
3030

31+
RequiredModules = @(
32+
@{
33+
ModuleName = 'Pode'
34+
ModuleVersion = '2.6.0'
35+
Guid = 'e3ea217c-fc3d-406b-95d5-4304ab06c6af'
36+
}
37+
)
38+
3139
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
3240
PrivateData = @{
3341
PSData = @{

‎src/Private/Helpers.ps1

+24
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,16 @@ function Get-PodeWebState
302302
return (Get-PodeState -Name "pode.web.$($Name)")
303303
}
304304

305+
function Get-PodeWebHomeName
306+
{
307+
$name = (Get-PodeWebState -Name 'pages')['/'].DisplayName
308+
if ([string]::IsNullOrWhiteSpace($name)) {
309+
return 'Home'
310+
}
311+
312+
return $name
313+
}
314+
305315
function Get-PodeWebCookie
306316
{
307317
param(
@@ -336,6 +346,17 @@ function Protect-PodeWebName
336346
return ($Name -ireplace '[^a-z0-9_]', '').Trim()
337347
}
338348

349+
function Protect-PodeWebSpecialCharacters
350+
{
351+
param(
352+
[Parameter()]
353+
[string]
354+
$Value
355+
)
356+
357+
return ($Value -replace "[\s!`"#\$%&'\(\)*+,\./:;<=>?@\[\\\]^``{\|}~]", '_')
358+
}
359+
339360
function Protect-PodeWebValue
340361
{
341362
param(
@@ -793,6 +814,9 @@ function Get-PodeWebPagePath
793814
$Group = $Page.Group
794815
}
795816

817+
$Name = Protect-PodeWebSpecialCharacters -Value $Name
818+
$Group = Protect-PodeWebSpecialCharacters -Value $Group
819+
796820
if (![string]::IsNullOrWhiteSpace($Group)) {
797821
$path += "/groups/$($Group)"
798822
}

‎src/Public/Elements.ps1

+25-4
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ function New-PodeWebTextbox
9797
$AutoFocus,
9898

9999
[switch]
100-
$DynamicLabel
100+
$DynamicLabel,
101+
102+
[ValidateRange(0, [int]::MaxValue)]
103+
[int]
104+
$MaxLength = 524288
101105
)
102106

103107
$Id = Get-PodeWebElementId -Tag Textbox -Id $Id -Name $Name
@@ -124,7 +128,7 @@ function New-PodeWebTextbox
124128
HelpText = [System.Net.WebUtility]::HtmlEncode($HelpText)
125129
ReadOnly = $ReadOnly.IsPresent
126130
IsAutoComplete = ($null -ne $AutoComplete)
127-
Value = $Value
131+
Value = [System.Net.WebUtility]::HtmlEncode($Value)
128132
CssClasses = ($CssClass -join ' ')
129133
CssStyles = (ConvertTo-PodeWebStyles -Style $CssStyle)
130134
Prepend = @{
@@ -142,6 +146,7 @@ function New-PodeWebTextbox
142146
Required = $Required.IsPresent
143147
AutoFocus = $AutoFocus.IsPresent
144148
DynamicLabel = $DynamicLabel.IsPresent
149+
MaxLength = $MaxLength
145150
}
146151

147152
# create autocomplete route
@@ -1163,6 +1168,7 @@ function New-PodeWebHidden
11631168
$Id,
11641169

11651170
[Parameter(Mandatory=$true)]
1171+
[AllowEmptyString()]
11661172
[string]
11671173
$Value,
11681174

@@ -1875,6 +1881,10 @@ function New-PodeWebChart
18751881
[string]
18761882
$Name,
18771883

1884+
[Parameter()]
1885+
[string]
1886+
$DisplayName,
1887+
18781888
[Parameter()]
18791889
[string]
18801890
$Id,
@@ -1987,6 +1997,7 @@ function New-PodeWebChart
19871997
ObjectType = 'Chart'
19881998
Parent = $ElementData
19891999
Name = $Name
2000+
DisplayName = (Protect-PodeWebValue -Value $DisplayName -Default $Name -Encode)
19902001
ID = $Id
19912002
Message = $Message
19922003
ChartType = $Type
@@ -2044,7 +2055,7 @@ function New-PodeWebChart
20442055
}
20452056

20462057
if ($AsCard) {
2047-
$element = New-PodeWebCard -Name $Name -Content $element
2058+
$element = New-PodeWebCard -Name $Name -DisplayName $DisplayName -Content $element
20482059
}
20492060

20502061
return $element
@@ -2062,6 +2073,10 @@ function New-PodeWebCounterChart
20622073
[string]
20632074
$Name,
20642075

2076+
[Parameter()]
2077+
[string]
2078+
$DisplayName,
2079+
20652080
[Parameter()]
20662081
[string[]]
20672082
$CssClass,
@@ -2116,6 +2131,7 @@ function New-PodeWebCounterChart
21162131

21172132
New-PodeWebChart `
21182133
-Name $Name `
2134+
-DisplayName $DisplayName `
21192135
-Type Line `
21202136
-MaxItems $MaxItems `
21212137
-ArgumentList $Counter `
@@ -2148,6 +2164,10 @@ function New-PodeWebTable
21482164
[string]
21492165
$Name,
21502166

2167+
[Parameter()]
2168+
[string]
2169+
$DisplayName,
2170+
21512171
[Parameter()]
21522172
[string]
21532173
$Id,
@@ -2261,6 +2281,7 @@ function New-PodeWebTable
22612281
ObjectType = 'Table'
22622282
Parent = $ElementData
22632283
Name = $Name
2284+
DisplayName = (Protect-PodeWebValue -Value $DisplayName -Default $Name -Encode)
22642285
ID = $Id
22652286
DataColumn = $DataColumn
22662287
Columns = $Columns
@@ -2360,7 +2381,7 @@ function New-PodeWebTable
23602381
}
23612382

23622383
if ($AsCard) {
2363-
$element = New-PodeWebCard -Name $Name -Content $element
2384+
$element = New-PodeWebCard -Name $Name -DisplayName $DisplayName -Content $element
23642385
}
23652386

23662387
return $element

‎src/Public/Pages.ps1

+34-3
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ function Set-PodeWebLoginPage
173173
Write-PodeWebViewResponse -Path 'index' -Data @{
174174
Page = @{
175175
Name = 'Home'
176+
Title = 'Home'
177+
DisplayName = 'Home'
176178
Path = '/'
177179
IsSystem = $true
178180
}
@@ -202,6 +204,10 @@ function Set-PodeWebHomePage
202204
[hashtable[]]
203205
$Layouts,
204206

207+
[Parameter()]
208+
[string]
209+
$DisplayName,
210+
205211
[Parameter()]
206212
[string]
207213
$Title,
@@ -228,8 +234,12 @@ function Set-PodeWebHomePage
228234
}
229235

230236
# set page title
237+
if ([string]::IsNullOrWhiteSpace($DisplayName)) {
238+
$DisplayName = 'Home'
239+
}
240+
231241
if ([string]::IsNullOrWhiteSpace($Title)) {
232-
$Title = 'Home'
242+
$Title = $DisplayName
233243
}
234244

235245
# route path
@@ -241,7 +251,8 @@ function Set-PodeWebHomePage
241251
ObjectType = 'Page'
242252
Path = $routePath
243253
Name = 'Home'
244-
Title = $Title
254+
Title = [System.Net.WebUtility]::HtmlEncode($Title)
255+
DisplayName = [System.Net.WebUtility]::HtmlEncode($DisplayName)
245256
NoTitle = $NoTitle.IsPresent
246257
Navigation = $Navigation
247258
Layouts = $Layouts
@@ -316,6 +327,10 @@ function Add-PodeWebPage
316327
[string]
317328
$Name,
318329

330+
[Parameter()]
331+
[string]
332+
$DisplayName,
333+
319334
[Parameter()]
320335
[string]
321336
$Title,
@@ -399,8 +414,12 @@ function Add-PodeWebPage
399414
}
400415

401416
# set page title
417+
if ([string]::IsNullOrWhiteSpace($DisplayName)) {
418+
$DisplayName = $Name
419+
}
420+
402421
if ([string]::IsNullOrWhiteSpace($Title)) {
403-
$Title = $Name
422+
$Title = $DisplayName
404423
}
405424

406425
# build the route path
@@ -413,6 +432,7 @@ function Add-PodeWebPage
413432
Path = $routePath
414433
Name = $Name
415434
Title = [System.Net.WebUtility]::HtmlEncode($Title)
435+
DisplayName = [System.Net.WebUtility]::HtmlEncode($DisplayName)
416436
NoTitle = $NoTitle.IsPresent
417437
NoBackArrow = $NoBackArrow.IsPresent
418438
NoBreadcrumb = $NoBreadcrumb.IsPresent
@@ -514,6 +534,7 @@ function Add-PodeWebPage
514534
Write-PodeWebViewResponse -Path 'index' -Data @{
515535
Page = $global:PageData
516536
Title = $global:PageData.Title
537+
DisplayName = $global:PageData.DisplayName
517538
Theme = $theme
518539
Navigation = $navigation
519540
Breadcrumb = $breadcrumb
@@ -576,6 +597,10 @@ function Add-PodeWebPageLink
576597
[string]
577598
$Name,
578599

600+
[Parameter()]
601+
[string]
602+
$DisplayName,
603+
579604
[Parameter()]
580605
[string]
581606
$Group,
@@ -627,11 +652,17 @@ function Add-PodeWebPageLink
627652
throw "Web page/link already exists: $($Name) [Group: $($Group)]"
628653
}
629654

655+
# set page title
656+
if ([string]::IsNullOrWhiteSpace($DisplayName)) {
657+
$DisplayName = $Name
658+
}
659+
630660
# setup page meta
631661
$pageMeta = @{
632662
ComponentType = 'Page'
633663
ObjectType = 'Link'
634664
Name = $Name
665+
DisplayName = [System.Net.WebUtility]::HtmlEncode($DisplayName)
635666
NewTab = $NewTab.IsPresent
636667
Icon = $Icon
637668
Group = $Group

‎src/Public/Utilities.ps1

+2-5
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ function Use-PodeWebTemplates
3838
$UseHsts
3939
)
4040

41-
$mod = (Get-Module -Name Pode -ErrorAction Ignore | Sort-Object -Property Version -Descending | Select-Object -First 1)
42-
if (($null -eq $mod) -or ($mod.Version -lt [version]'2.6.0')) {
43-
throw "The Pode module is not loaded. You need at least Pode v2.6.0 to use this version of the Pode.Web module."
44-
}
45-
4641
if ([string]::IsNullOrWhiteSpace($FavIcon)) {
4742
$FavIcon = '/pode.web/images/favicon.ico'
4843
}
@@ -88,6 +83,8 @@ function Use-PodeWebTemplates
8883
Page = @{
8984
Name = 'Home'
9085
Path = '/'
86+
TItle = 'Home'
87+
DisplayName = 'Home'
9188
IsSystem = $true
9289
}
9390
}

‎src/Templates/Views/elements/textbox.pode

+14-4
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,18 @@ $(
3838
}
3939

4040
$value = [string]::Empty
41-
if (![string]::IsNullOrWhiteSpace($data.Value)) {
42-
$value = "value='$($data.Value)'"
41+
if (![string]::IsNullOrWhitespace($data.Value)) {
42+
if ($data.Multiline) {
43+
$value = $data.Value
44+
}
45+
else {
46+
$value = "value='$($data.Value)'"
47+
}
48+
}
49+
50+
$maxLength = [string]::Empty
51+
if (![string]::IsNullOrWhiteSpace($data.maxLength)) {
52+
$maxLength = "maxlength='$($data.maxLength)'"
4353
}
4454

4555
$width = "width: $($data.Width);"
@@ -51,7 +61,7 @@ $(
5161
}
5262

5363
if ($data.Multiline) {
54-
$element = "<textarea class='form-control $(if ($data.NoForm) { 'no-form' })' id='$($data.ID)' name='$($data.Name)' pode-object='$($data.ObjectType)' placeholder='$($data.Placeholder)' rows='$($data.Size)' style='$($width) $($data.CssStyles)' $($describedBy) $($readOnly) $($required) $($autofocus) $($value) $($events)></textarea>"
64+
$element = "<textarea class='form-control $(if ($data.NoForm) { 'no-form' })' id='$($data.ID)' name='$($data.Name)' pode-object='$($data.ObjectType)' placeholder='$($data.Placeholder)' rows='$($data.Size)' style='$($width) $($data.CssStyles)' $($describedBy) $($readOnly) $($required) $($autofocus) $($events) $($maxLength)>$($value)</textarea>"
5565
}
5666
else {
5767
if ($data.Prepend.Enabled -or $data.Append.Enabled) {
@@ -72,7 +82,7 @@ $(
7282
$_type = 'datetime-local'
7383
}
7484

75-
$element += "<input type='$($_type.ToLowerInvariant())' class='form-control $(if ($data.NoForm) { 'no-form' })' id='$($data.ID)' name='$($data.Name)' pode-object='$($data.ObjectType)' style='$($width) $($data.CssStyles)' placeholder='$($data.Placeholder)' pode-autocomplete='$($data.IsAutoComplete)' $($describedBy) $($readOnly) $($required) $($autofocus) $($value) $($events)>"
85+
$element += "<input type='$($_type.ToLowerInvariant())' class='form-control $(if ($data.NoForm) { 'no-form' })' id='$($data.ID)' name='$($data.Name)' pode-object='$($data.ObjectType)' style='$($width) $($data.CssStyles)' placeholder='$($data.Placeholder)' pode-autocomplete='$($data.IsAutoComplete)' $($describedBy) $($readOnly) $($required) $($autofocus) $($value) $($events) $($maxLength)>"
7686

7787
if ($data.Append.Enabled) {
7888
if (![string]::IsNullOrWhiteSpace($data.Append.Text)) {

‎src/Templates/Views/index.pode

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<html>
22
$(Use-PodeWebPartialView -Path 'shared/head' -Data @{
3-
Title = $data.Page.Name
3+
Title = $data.Page.DisplayName
44
Theme = $data.Theme
55
AppPath = $data.AppPath
66
})
@@ -119,7 +119,7 @@
119119
<a class="nav-link $(if ($data.Page.Name -ieq 'home') { 'active' })" href="$($data.AppPath)/">
120120
<div>
121121
<span class="mdi mdi-home mdi-size-22 mRight02"></span>
122-
Home
122+
$(Get-PodeWebHomeName)
123123
</div>
124124
</a>
125125
</li>
@@ -143,14 +143,15 @@
143143
if (![string]::IsNullOrWhiteSpace($pageGroup.Name)) {
144144
$chevron = 'right'
145145
$show = [string]::Empty
146+
$safeGrpName = Protect-PodeWebSpecialCharacters -Value $pageGroup.Name
146147

147148
if ($data.Page.Group -ieq $pageGroup.Name) {
148149
$chevron = 'down'
149150
$show = 'show'
150151
}
151152

152153
"<li class='nav-item mTop1 nav-group-title'>
153-
<a class='nav-link' data-toggle='collapse' href='#nav-$($pageGroup.Name)' aria-expanded='$($data.Page.Group -ieq $pageGroup.Name)' aria-controls='nav-$($pageGroup.Name)'>
154+
<a class='nav-link' data-toggle='collapse' href='#nav-$($safeGrpName)' aria-expanded='$($data.Page.Group -ieq $pageGroup.Name)' aria-controls='nav-$($safeGrpName)'>
154155
<div>
155156
<span class='mdi mdi-chevron-$($chevron) mdi-size-22 mRight02'></span>
156157
<span class='h6'>$([System.Net.WebUtility]::HtmlEncode($pageGroup.Name))</span>
@@ -159,7 +160,7 @@
159160
</a>
160161
</li>"
161162

162-
"<div class='collapse $($show)' id='nav-$($pageGroup.Name)'>"
163+
"<div class='collapse $($show)' id='nav-$($safeGrpName)'>"
163164
}
164165

165166
foreach ($page in ($pages | Sort-Object -Property { $_.Name })) {
@@ -181,7 +182,7 @@
181182
<a class='nav-link $($activePage)' name='$($page.Name)' pode-page-group='$($pageGroup.Name)' pode-page-type='$($page.ObjectType)' pode-dynamic='$($page.IsDynamic)' $($href)>
182183
<div>
183184
<span class='mdi mdi-$($page.Icon.ToLowerInvariant()) mdi-size-22 mRight02'></span>
184-
$([System.Net.WebUtility]::HtmlEncode($page.Name))
185+
$([System.Net.WebUtility]::HtmlEncode($page.DisplayName))
185186
</div>
186187
</a>
187188
</li>"

0 commit comments

Comments
 (0)
Please sign in to comment.