Skip to content

Commit f558670

Browse files
committed
add navigatetourl and blank pages. shange publish to linux-arm64
1 parent d57073e commit f558670

13 files changed

+164
-19
lines changed

README.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,18 @@ That means that the remote web server does not allow rendering inside an iframe.
2626

2727
You won't have this problem, if you define just one Kiosk URL.
2828

29+
There is also a page http://x.x.x.x:5000/blank that shows a blank page.
30+
2931
There is also a (GET) rest api endpoint (http://x.x.x.x:5000/api/status) that returns a JSON object, containing system status data.
3032

3133
There are also (POST) rest api endpoints (http://x.x.x.x:5000/api/shutdown , http://x.x.x.x:5000/api/reboot , http://x.x.x.x:5000/api/screenoff and http://x.x.x.x:5000/api/screenon) NOTE that there is no authentication!
3234

35+
There is also a (POST) rest api endpoint http://x.x.x.x:5000/api/navigatetourl?url=xxxxxxx that ONLY works, when the kiosk screen is being displayed.
36+
37+
When this url is POSTed, with ANY url as query parameter (e.g. http://x.x.x.x:5000/api/navigatetourl?url=http://x.x.x.x:5000/blank) that page will be loaded into the kiosk iframe and the tab bar at the top is hidden.
38+
39+
When this url is POSTed, without any url as query parameter (e.g. http://x.x.x.x:5000/api/navigatetourl?url=) then the kiosk is reloaded and the tab bar at the top reappears.
40+
3341
![touch screen](https://i.imgur.com/Wzp5kqm.png)
3442

3543
![touch screen](https://i.imgur.com/cXrHx23.png)
@@ -109,7 +117,7 @@ Also see waveshare CM4-NANO-B wiki page.
109117

110118
https://github.com/raspberrypi/usbboot/raw/master/win32/rpiboot_setup.exe
111119

112-
- Install raspberry pi os lite 32 bit (bullseye / bookworm)
120+
- Install raspberry pi os lite 64 bit (bookworm)
113121
- Set up wifi
114122
- Set up ssh
115123
- Set up an account (The instructions and various configuration files assume pi/raspberry Adjust as required.)
@@ -129,7 +137,7 @@ sudo apt-get install -y --no-install-recommends xserver-xorg x11-xserver-utils x
129137
sudo apt-get install -y --no-install-recommends chromium-browser
130138
```
131139

132-
## Edit /boot/config.txt
140+
## Edit /boot/firmware/config.txt
133141

134142
For Touch Display 1920x480 (portrait orientation, default) :
135143
```

kiosk-server/Api/ApiController.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
using Microsoft.AspNetCore.Mvc;
55
using System.Diagnostics;
66
using System.Xml.Linq;
7+
using kiosk_server.Services;
78

89
namespace kiosk_server.Api
910
{
1011
[ApiController]
1112
[AllowAnonymous]
12-
public class ApiController : ControllerBase
13+
public class ApiController(MyEventService myEventService) : ControllerBase
1314
{
1415
private class StatusData
1516
{
@@ -71,5 +72,14 @@ public IActionResult ScreenOff()
7172

7273
return Ok();
7374
}
75+
76+
[Route("api/navigatetourl")]
77+
[HttpPost]
78+
public IActionResult NavigateToUrl([FromQuery]string? url = null)
79+
{
80+
myEventService.NavigateToUrl(url);
81+
82+
return Ok();
83+
}
7484
}
7585
}

kiosk-server/Pages/Blank.razor

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@page "/blank"
2+
@layout EmptyLayout
3+

kiosk-server/Pages/Blank.razor.cs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using kiosk_server.Model;
2+
using Microsoft.AspNetCore.Components;
3+
using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
4+
using Microsoft.AspNetCore.DataProtection.KeyManagement;
5+
using Microsoft.Extensions.Logging;
6+
using System.Diagnostics;
7+
using System.Diagnostics.Eventing.Reader;
8+
using static MudBlazor.Colors;
9+
using System.Text.Json;
10+
using kiosk_server.Shared;
11+
using Microsoft.AspNetCore.Components.Web;
12+
using System.Runtime.InteropServices;
13+
using System.IO;
14+
using kiosk_server.Metrics;
15+
using kiosk_server.Services;
16+
17+
namespace kiosk_server.Pages
18+
{
19+
public partial class Blank
20+
{
21+
22+
23+
24+
}
25+
}

kiosk-server/Pages/Blank.razor.css

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+


kiosk-server/Pages/Kiosk.razor

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<MudLayout Class="d-flex flex-grow-1" Style="">
55
<MudAppBar Elevation="0" Class="pa-0 ma-0 " Color="@(LayoutService.IsDarkMode ? @Color.Dark : @Color.Primary)">
6-
<MudTabs Class="pa-0 ma-0" Elevation="0" Rounded="false" Border="false" DisableRipple="true" DisableSliderAnimation="true" Color="@(LayoutService.IsDarkMode ? @Color.Dark : @Color.Primary)" ActivePanelIndexChanged="ActivePanelIndexChanged">
6+
<MudTabs Class="pa-0 ma-0" Elevation="0" Rounded="false" Border="false" DisableRipple="true" DisableSliderAnimation="true" Color="@(LayoutService.IsDarkMode ? @Color.Dark : @Color.Primary)" ActivePanelIndexChanged="ActivePanelIndexChanged" TabHeaderClass="@TabHeaderClass">
77
@foreach (var url in RedirectUrlList)
88
{
99
<MudTabPanel Text="@url.Name"/>

kiosk-server/Pages/Kiosk.razor.cs

+31-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@ namespace kiosk_server.Pages
1919
public partial class Kiosk
2020
{
2121
[Inject] private LayoutService LayoutService { get; set; } = null!;
22-
22+
[Inject] private MyEventService EventService { get; set; } = null!;
23+
[Inject] private NavigationManager NavigationManager { get; set; } = default!;
24+
2325
private List<RedirectItem> RedirectUrlList { get; set; } = default!;
2426

2527
private string? CurrentIframeUrl;
2628

29+
private string? TabHeaderClass;
30+
2731
protected override async Task OnAfterRenderAsync(bool firstRender)
2832
{
2933
await base.OnAfterRenderAsync(firstRender);
@@ -38,12 +42,37 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
3842

3943
protected override async Task OnInitializedAsync()
4044
{
41-
RedirectUrlList = Program.ConfigurationRoot.GetSection("RedirectUrl").Get<List<RedirectItem>>() ?? new List<RedirectItem>();
45+
EventService.OnUrlChange += NavigateToUrl;
4246

47+
RedirectUrlList = Program.ConfigurationRoot.GetSection("RedirectUrl").Get<List<RedirectItem>>() ?? new List<RedirectItem>();
48+
4349
await base.OnInitializedAsync();
4450

4551
}
4652

53+
public void Dispose()
54+
{
55+
EventService.OnUrlChange -= NavigateToUrl;
56+
57+
}
58+
59+
private void NavigateToUrl(string? url)
60+
{
61+
InvokeAsync(() =>
62+
{
63+
if (string.IsNullOrEmpty(url))
64+
{
65+
NavigationManager.NavigateTo(NavigationManager.Uri, true);
66+
}
67+
else
68+
{
69+
CurrentIframeUrl = url;
70+
TabHeaderClass = "hideme";
71+
StateHasChanged();
72+
}
73+
74+
});
75+
}
4776

4877
private void ActivePanelIndexChanged(int index)
4978
{

kiosk-server/Program.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static void Main(string[] args)
5353

5454
});
5555

56-
//builder.WebHost.UseStaticWebAssets(); // needs absolute path ??????????
56+
builder.WebHost.UseStaticWebAssets();
5757

5858

5959
// Add services to the container.
@@ -70,6 +70,8 @@ public static void Main(string[] args)
7070

7171
builder.Services.AddScoped<LayoutService>();
7272

73+
builder.Services.AddSingleton<MyEventService>();
74+
7375
builder.Services.AddResponseCompression(opts =>
7476
{
7577
opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(

kiosk-server/Properties/PublishProfiles/FolderProfile.pubxml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
1515
<_TargetId>Folder</_TargetId>
1616
<SiteUrlToLaunchAfterPublish />
1717
<TargetFramework>net8.0</TargetFramework>
18-
<RuntimeIdentifier>linux-arm</RuntimeIdentifier>
18+
<RuntimeIdentifier>linux-arm64</RuntimeIdentifier>
1919
<PublishTrimmed>false</PublishTrimmed>
2020
<ProjectGuid>2fb23800-8c51-41de-b9e9-ec0b28be1a28</ProjectGuid>
2121
<SelfContained>true</SelfContained>
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) MudBlazor 2021
2+
// MudBlazor licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
using System.Net.NetworkInformation;
7+
using System.Text.Json;
8+
using System.Threading.Tasks;
9+
using Microsoft.AspNetCore.Components;
10+
using MudBlazor;
11+
12+
namespace kiosk_server.Services
13+
{
14+
public class MyEventService
15+
{
16+
public event Action<string?> OnUrlChange = null!;
17+
18+
public void NavigateToUrl(string? url)
19+
{
20+
OnUrlChange?.Invoke(url);
21+
22+
}
23+
24+
25+
}
26+
27+
28+
}

kiosk-server/appsettings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"Port": 5000,
1111
"RedirectUrl": [
1212
{
13-
"Name": "Home",
13+
"Name": "home",
1414
"Url": "https://www.msn.com"
1515
}
1616
]

kiosk-server/kiosk-server.csproj

+43-10
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@
1212
<PreBuildEvent>
1313
</PreBuildEvent>
1414
<ApplicationIcon>wwwroot\favicon.ico</ApplicationIcon>
15-
<Version>0.0.1.3</Version>
16-
<Copyright>Copyright © 2023</Copyright>
15+
<Version>0.0.1.4</Version>
16+
<Copyright>Copyright © 2024</Copyright>
1717
<Company />
1818
<Authors />
19-
<AssemblyVersion>0.0.1.3</AssemblyVersion>
20-
<FileVersion>0.0.1.3</FileVersion>
19+
<AssemblyVersion>0.0.1.4</AssemblyVersion>
20+
<FileVersion>0.0.1.4</FileVersion>
2121
</PropertyGroup>
2222

2323
<Target Name="PiCopy" AfterTargets="AfterPublish">
24-
<Exec Command="&quot;C:\Program Files (x86)\WinSCP\WinSCP.com&quot; /command &quot;open sftp://pi:[email protected].44/&quot; &quot;synchronize remote C:\dotnet\projects\kiosk-server\kiosk-server\bin\Release\net8.0\publish /home/pi/kiosk-server/&quot; &quot;exit&quot;" />
24+
<Exec Command="&quot;C:\Program Files (x86)\WinSCP\WinSCP.com&quot; /command &quot;open sftp://pi:[email protected].52/&quot; &quot;synchronize remote C:\dotnet\projects\kiosk-server\kiosk-server\bin\Release\net8.0\publish /home/pi/kiosk-server/&quot; &quot;exit&quot;" />
2525
</Target>
2626

2727
<ItemGroup>
28-
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="8.0.0" />
29-
<PackageReference Include="Microsoft.AspNetCore.Components.Analyzers" Version="8.0.0" />
30-
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.0" />
28+
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="8.0.4" />
29+
<PackageReference Include="Microsoft.AspNetCore.Components.Analyzers" Version="8.0.4" />
30+
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.4" />
3131
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="8.0.0" />
32-
<PackageReference Include="Microsoft.JSInterop" Version="8.0.0" />
33-
<PackageReference Include="MudBlazor" Version="6.11.2" />
32+
<PackageReference Include="Microsoft.JSInterop" Version="8.0.4" />
33+
<PackageReference Include="MudBlazor" Version="6.19.1" />
3434
<PackageReference Include="System.IO.Pipelines" Version="8.0.0" />
3535
</ItemGroup>
3636

@@ -49,4 +49,37 @@
4949
<ItemGroup>
5050
<Folder Include="Data\" />
5151
</ItemGroup>
52+
53+
<ItemGroup>
54+
<Content Update="wwwroot\css\site.css">
55+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
56+
</Content>
57+
<Content Update="wwwroot\favicon.ico">
58+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
59+
</Content>
60+
<Content Update="wwwroot\icons\apple-touch-icon.png">
61+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
62+
</Content>
63+
<Content Update="wwwroot\icons\browserconfig.xml">
64+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
65+
</Content>
66+
<Content Update="wwwroot\icons\favicon-16x16.png">
67+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
68+
</Content>
69+
<Content Update="wwwroot\icons\favicon-32x32.png">
70+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
71+
</Content>
72+
<Content Update="wwwroot\icons\icon-192.png">
73+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
74+
</Content>
75+
<Content Update="wwwroot\icons\icon-512.png">
76+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
77+
</Content>
78+
<Content Update="wwwroot\icons\mstile-150x150.png">
79+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
80+
</Content>
81+
<Content Update="wwwroot\manifest.json">
82+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
83+
</Content>
84+
</ItemGroup>
5285
</Project>

kiosk-server/wwwroot/css/site.css

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
3+
4+
.hideme {
5+
display: none;
6+
}

0 commit comments

Comments
 (0)