Skip to content

Commit 4ed670c

Browse files
committed
add pages for new UI, fix issues
1 parent 9a9424f commit 4ed670c

File tree

159 files changed

+19176
-10213
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+19176
-10213
lines changed

ColorControl.UI/Blazor.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1+
using ColorControl.Shared.Contracts;
12
using ColorControl.Shared.Services;
23

34
namespace ColorControl.UI;
45

56
public static class Blazor
67
{
7-
public static void Start()
8+
public static void Start(Config? config = null)
89
{
910
var builder = WebApplication.CreateBuilder();
1011

1112
// Add services to the container.
1213
builder.Services.AddRazorComponents()
1314
.AddInteractiveServerComponents();
1415

15-
builder.Services.AddSingleton<AppState>();
16-
builder.Services.AddSingleton<OptionsService>();
16+
builder.Services.AddSingleton<AppState>(new AppState { SelectedTheme = (config?.UseDarkMode ?? true) ? "dark" : "light" });
17+
builder.Services.AddTransient<RpcUiClientService>();
18+
builder.WebHost.ConfigureKestrel(o => o.ListenAnyIP(config?.UiPort > 0 ? config.UiPort : 5000));
1719

1820
var app = builder.Build();
1921

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
44
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
@@ -7,8 +7,51 @@
77
<OutputType>Library</OutputType>
88
</PropertyGroup>
99

10+
<ItemGroup>
11+
<PackageReference Include="NLog" Version="5.2.8" />
12+
</ItemGroup>
13+
1014
<ItemGroup>
1115
<ProjectReference Include="..\Shared\Shared.csproj" />
1216
</ItemGroup>
1317

18+
<ItemGroup>
19+
<Content Update="Components\Pages\Generic\FieldDefs.razor">
20+
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
21+
</Content>
22+
<Content Update="Components\Pages\Generic\ConfirmModal.razor">
23+
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
24+
</Content>
25+
<Content Update="Components\Pages\Game\GameSummary.razor">
26+
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
27+
</Content>
28+
<Content Update="Components\Pages\Generic\TriggerInput.razor">
29+
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
30+
</Content>
31+
<Content Update="Components\Pages\Info.razor">
32+
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
33+
</Content>
34+
<Content Update="Components\Pages\LG\LgExecuteActionModal.razor">
35+
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
36+
</Content>
37+
<Content Update="Components\Pages\Samsung\SamsungSummary.razor">
38+
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
39+
</Content>
40+
<Content Update="Components\Pages\Nvidia\NvidiaSettings.razor">
41+
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
42+
</Content>
43+
<Content Update="Components\Pages\Nvidia\NvidiaPreset.razor">
44+
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
45+
</Content>
46+
<Content Update="Components\Pages\Samsung\SamsungDevicePage.razor">
47+
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
48+
</Content>
49+
<Content Update="Components\Pages\Generic\StepsInput.razor">
50+
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
51+
</Content>
52+
<Content Update="Components\Pages\Samsung\SamsungServiceMenu.razor">
53+
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
54+
</Content>
55+
</ItemGroup>
56+
1457
</Project>

ColorControl.UI/Components/App.razor

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
@inject AppState AppState
1+
@using ColorControl.Shared.Contracts
2+
@using ColorControl.Shared.Services
3+
@inject AppState AppState
4+
@inject RpcUiClientService ClientService;
5+
@inject NavigationManager _navigationManager;
26
@implements IDisposable
37
@attribute [StreamRendering]
48

@@ -9,7 +13,8 @@
913
<meta charset="utf-8" />
1014
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
1115
<base href="/" />
12-
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-4bw+/aepP/YC94hEpVNVgiZdgIC5+VKNBQNGCHeKRQN+PtmoHDEXuppvnDJzQIu9" crossorigin="anonymous">
16+
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
17+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
1318
<link rel="stylesheet" href="app.css" />
1419
<link rel="stylesheet" href="ColorControl.UI.styles.css" />
1520
<link rel="icon" type="image/png" href="favicon.png" />
@@ -23,8 +28,18 @@
2328

2429
</html>
2530
@code {
26-
protected override void OnInitialized()
31+
protected override async Task OnInitializedAsync()
2732
{
33+
var config = await ClientService.CallAsync<Config>("OptionsService", "GetConfig");
34+
35+
var newTheme = config.UseDarkMode ? "dark" : "light";
36+
37+
if (newTheme != AppState.SelectedTheme)
38+
{
39+
AppState.SelectedTheme = config.UseDarkMode ? "dark" : "light";
40+
_navigationManager.Refresh();
41+
}
42+
2843
AppState.OnChange += StateHasChanged;
2944
}
3045

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
<div class="top-row ps-3 navbar navbar-dark">
1+
@using ColorControl.Shared.Contracts
2+
@using ColorControl.Shared.Services;
3+
4+
@rendermode InteractiveServer
5+
6+
@inject RpcUiClientService _rpcClientService
7+
@inject AppState AppState
8+
@inject NavigationManager _navigationManager;
9+
10+
<div class="top-row ps-3 navbar navbar-dark">
211
<div class="container-fluid">
312
<a class="navbar-brand" href="">ColorControl Web App</a>
413
</div>
@@ -9,29 +18,50 @@
918
<div class="nav-scrollable" onclick="document.querySelector('.navbar-toggler').click()">
1019
<nav class="flex-column">
1120
<div class="nav-item px-3">
12-
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
21+
<NavLink class="nav-link px-3" href="" Match="NavLinkMatch.All">
1322
<span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Home
1423
</NavLink>
1524
</div>
1625

26+
@if (modules != null)
27+
{
28+
@foreach (var module in modules.Where(m => m.IsActive))
29+
{
30+
<div class="nav-item px-3">
31+
<NavLink class="nav-link px-3" href="@module.Link">
32+
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> @module.DisplayName
33+
</NavLink>
34+
</div>
35+
}
36+
}
37+
1738
<div class="nav-item px-3">
18-
<NavLink class="nav-link" href="counter">
19-
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Counter
39+
<NavLink class="nav-link px-3" href="options">
40+
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Options
2041
</NavLink>
2142
</div>
2243

2344
<div class="nav-item px-3">
24-
<NavLink class="nav-link" href="weather">
25-
<span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> Weather
45+
<NavLink class="nav-link px-3" href="logging">
46+
<span class="bi bi-list-logging-nav-menu" aria-hidden="true"></span> Logging
2647
</NavLink>
2748
</div>
2849

2950
<div class="nav-item px-3">
30-
<NavLink class="nav-link" href="options">
31-
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Options
51+
<NavLink class="nav-link px-3" href="info">
52+
<span class="bi bi-list-logging-nav-menu" aria-hidden="true"></span> Info
3253
</NavLink>
3354
</div>
34-
3555
</nav>
3656
</div>
3757

58+
@code {
59+
private Config? config;
60+
private List<ModuleDto>? modules;
61+
62+
protected override async Task OnInitializedAsync()
63+
{
64+
config = await _rpcClientService.CallAsync<Config>("OptionsService", "GetConfig");
65+
modules = config?.Modules?.Select(m => new ModuleDto { DisplayName = m.DisplayName, IsActive = m.IsActive, Link = m.DisplayName.Split(' ')[0] }).ToList();
66+
}
67+
}

ColorControl.UI/Components/Layout/NavMenu.razor.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4.5 11.5A.5.5 0 0 1 5 11h10a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 1 3h10a.5.5 0 0 1 0 1H1a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E");
4747
}
4848

49+
.bi-list-logging-nav-menu {
50+
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="white" class="bi bi-card-text" viewBox="0 0 16 16"><path d="M14.5 3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-13a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5zm-13-1A1.5 1.5 0 0 0 0 3.5v9A1.5 1.5 0 0 0 1.5 14h13a1.5 1.5 0 0 0 1.5-1.5v-9A1.5 1.5 0 0 0 14.5 2z"/><path d="M3 5.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5M3 8a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9A.5.5 0 0 1 3 8m0 2.5a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5"/></svg>');
51+
}
52+
4953
.nav-item {
5054
font-size: 0.9rem;
5155
padding-bottom: 0.5rem;

ColorControl.UI/Components/Layout/TopMenu.razor

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
@inherits LayoutComponentBase
1+
@using ColorControl.Shared.Contracts
2+
@using ColorControl.Shared.Services
3+
@inherits LayoutComponentBase
24

35
@inject AppState AppState
46
@inject NavigationManager _navigationManager;
57
@rendermode InteractiveServer
68

7-
<div class="top-row px-4 pt-2">
8-
<button type="button" class="btn btn-primary me-2" @onclick="ChangeTheme">@ThemeTransitionName</button>
9+
<div class="top-row px-4 pt-3 text-end">
10+
@* <button type="button" class="btn btn-primary me-2" @onclick="ChangeTheme">@ThemeTransitionName</button> *@
911
<a href="https://github.com/Maassoft/ColorControl" target="_blank">GitHub</a>
1012
</div>
1113

0 commit comments

Comments
 (0)