Skip to content

Commit 15d19aa

Browse files
authored
Phase 7 — Implement Code311.Host demo portal
1 parent 77e443c commit 15d19aa

36 files changed

Lines changed: 579 additions & 0 deletions

Code311.sln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Code311.Licensing", "src\Co
5050
EndProject
5151
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Code311.Tests.Licensing", "tests\Code311.Tests.Licensing\Code311.Tests.Licensing.csproj", "{B2222222-2222-2222-2222-222222222233}"
5252
EndProject
53+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Code311.Host", "src\Code311.Host\Code311.Host.csproj", "{A1111111-1111-1111-1111-111111111123}"
54+
EndProject
55+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Code311.Tests.Host", "tests\Code311.Tests.Host\Code311.Tests.Host.csproj", "{B2222222-2222-2222-2222-222222222234}"
56+
EndProject
5357
Global
5458
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5559
Debug|Any CPU = Debug|Any CPU
@@ -152,6 +156,14 @@ Global
152156
{B2222222-2222-2222-2222-222222222233}.Debug|Any CPU.Build.0 = Debug|Any CPU
153157
{B2222222-2222-2222-2222-222222222233}.Release|Any CPU.ActiveCfg = Release|Any CPU
154158
{B2222222-2222-2222-2222-222222222233}.Release|Any CPU.Build.0 = Release|Any CPU
159+
{A1111111-1111-1111-1111-111111111123}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
160+
{A1111111-1111-1111-1111-111111111123}.Debug|Any CPU.Build.0 = Debug|Any CPU
161+
{A1111111-1111-1111-1111-111111111123}.Release|Any CPU.ActiveCfg = Release|Any CPU
162+
{A1111111-1111-1111-1111-111111111123}.Release|Any CPU.Build.0 = Release|Any CPU
163+
{B2222222-2222-2222-2222-222222222234}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
164+
{B2222222-2222-2222-2222-222222222234}.Debug|Any CPU.Build.0 = Debug|Any CPU
165+
{B2222222-2222-2222-2222-222222222234}.Release|Any CPU.ActiveCfg = Release|Any CPU
166+
{B2222222-2222-2222-2222-222222222234}.Release|Any CPU.Build.0 = Release|Any CPU
155167
EndGlobalSection
156168
GlobalSection(SolutionProperties) = preSolution
157169
HideSolutionNode = FALSE

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
99
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
1010
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.0" />
11+
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.0" />
1112
<PackageVersion Include="Microsoft.Extensions.Options" Version="9.0.0" />
1213
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
1314
<PackageVersion Include="xunit" Version="2.9.2" />
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
<PropertyGroup>
3+
<TargetFramework>net10.0</TargetFramework>
4+
<RootNamespace>Code311.Host</RootNamespace>
5+
<AssemblyName>Code311.Host</AssemblyName>
6+
<Description>Hybrid MVC + Razor demo host for Code311 framework packages.</Description>
7+
<Nullable>enable</Nullable>
8+
<ImplicitUsings>enable</ImplicitUsings>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<ProjectReference Include="..\Code311.Ui.Core\Code311.Ui.Core.csproj" />
13+
<ProjectReference Include="..\Code311.Tabler.Core\Code311.Tabler.Core.csproj" />
14+
<ProjectReference Include="..\Code311.Tabler.Components\Code311.Tabler.Components.csproj" />
15+
<ProjectReference Include="..\Code311.Tabler.Mvc\Code311.Tabler.Mvc.csproj" />
16+
<ProjectReference Include="..\Code311.Tabler.Razor\Code311.Tabler.Razor.csproj" />
17+
<ProjectReference Include="..\Code311.Tabler.Dashboard\Code311.Tabler.Dashboard.csproj" />
18+
<ProjectReference Include="..\Code311.Tabler.Widgets.DataTables\Code311.Tabler.Widgets.DataTables.csproj" />
19+
<ProjectReference Include="..\Code311.Tabler.Widgets.Calendar\Code311.Tabler.Widgets.Calendar.csproj" />
20+
<ProjectReference Include="..\Code311.Tabler.Widgets.Charts\Code311.Tabler.Widgets.Charts.csproj" />
21+
<ProjectReference Include="..\Code311.Persistence.EFCore\Code311.Persistence.EFCore.csproj" />
22+
<ProjectReference Include="..\Code311.Licensing\Code311.Licensing.csproj" />
23+
</ItemGroup>
24+
25+
<ItemGroup>
26+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" />
27+
</ItemGroup>
28+
</Project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
3+
namespace Code311.Host.Controllers;
4+
5+
public sealed class ArchitectureController : Controller
6+
{
7+
public IActionResult About() => View();
8+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
3+
namespace Code311.Host.Controllers;
4+
5+
public sealed class ComponentsDemoController : Controller
6+
{
7+
public IActionResult Forms() => View();
8+
public IActionResult Navigation() => View();
9+
public IActionResult Layout() => View();
10+
public IActionResult Feedback() => View();
11+
public IActionResult Data() => View();
12+
public IActionResult Media() => View();
13+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Code311.Host.Models;
2+
using Code311.Licensing.Validation;
3+
using Microsoft.AspNetCore.Mvc;
4+
5+
namespace Code311.Host.Controllers;
6+
7+
public sealed class DashboardController(ILicenseFeatureGate featureGate) : Controller
8+
{
9+
public async Task<IActionResult> Index(CancellationToken cancellationToken)
10+
{
11+
var check = await featureGate.CheckFeatureAsync("dashboard.advanced", cancellationToken);
12+
var model = new DashboardDemoViewModel(check.IsAllowed, check.Reason);
13+
return View(model);
14+
}
15+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
3+
namespace Code311.Host.Controllers;
4+
5+
public sealed class HomeController : Controller
6+
{
7+
public IActionResult Index() => View();
8+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Code311.Host.Models;
2+
using Code311.Host.Services;
3+
using Code311.Ui.Abstractions.Semantics;
4+
using Microsoft.AspNetCore.Mvc;
5+
6+
namespace Code311.Host.Controllers;
7+
8+
public sealed class PreferencesController(IPreferenceOrchestrator orchestrator) : Controller
9+
{
10+
[HttpGet]
11+
public async Task<IActionResult> Index(CancellationToken cancellationToken)
12+
{
13+
var current = await orchestrator.GetCurrentAsync(cancellationToken);
14+
return View(new PreferencesPageViewModel(current, string.Empty));
15+
}
16+
17+
[HttpPost]
18+
[ValidateAntiForgeryToken]
19+
public async Task<IActionResult> Save(string theme, UiDensity density, int defaultPageSize, bool sidebarCollapsed, CancellationToken cancellationToken)
20+
{
21+
await orchestrator.SaveAsync(new PreferenceInputModel(theme, density, defaultPageSize, sidebarCollapsed), cancellationToken);
22+
var current = await orchestrator.GetCurrentAsync(cancellationToken);
23+
return View("Index", new PreferencesPageViewModel(current, "Preferences saved for demo-tenant/demo-user."));
24+
}
25+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using Code311.Host.Models;
2+
using Code311.Tabler.Mvc.Assets;
3+
using Code311.Tabler.Widgets.Calendar.Options;
4+
using Code311.Tabler.Widgets.Calendar.Widgets;
5+
using Code311.Tabler.Widgets.Charts.Options;
6+
using Code311.Tabler.Widgets.Charts.Widgets;
7+
using Code311.Tabler.Widgets.DataTables.Options;
8+
using Code311.Tabler.Widgets.DataTables.Widgets;
9+
using Microsoft.AspNetCore.Mvc;
10+
11+
namespace Code311.Host.Controllers;
12+
13+
public sealed class WidgetsController(ICode311AssetRequestStore assets) : Controller
14+
{
15+
public IActionResult DataTables()
16+
{
17+
var widget = new DataTableWidgetSlot(
18+
"widget.datatables.incidents",
19+
"panel-body",
20+
new DataTableWidgetOptionsBuilder().WithPageLength(25).EnableSearch(true).Build());
21+
22+
assets.AddWidgetAssets(widget);
23+
var init = widget.CreateInitialization("datatable-demo");
24+
return View(new WidgetDemoViewModel("DataTables", init.ElementId, init.OptionsJson));
25+
}
26+
27+
public IActionResult Calendar()
28+
{
29+
var widget = new CalendarWidgetSlot(
30+
"widget.calendar.operations",
31+
"panel-body",
32+
new CalendarWidgetOptionsBuilder().WithInitialView("dayGridMonth").ShowWeekends(true).Build());
33+
34+
assets.AddWidgetAssets(widget);
35+
var init = widget.CreateInitialization("calendar-demo");
36+
return View("WidgetPage", new WidgetDemoViewModel("Calendar", init.ElementId, init.OptionsJson));
37+
}
38+
39+
public IActionResult Charts()
40+
{
41+
var widget = new ChartWidgetSlot(
42+
"widget.charts.kpi",
43+
"panel-body",
44+
new ChartWidgetOptionsBuilder().WithType("line").ShowLegend(true).Build());
45+
46+
assets.AddWidgetAssets(widget);
47+
var init = widget.CreateInitialization("charts-demo");
48+
return View("WidgetPage", new WidgetDemoViewModel("Charts", init.ElementId, init.OptionsJson));
49+
}
50+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Code311.Licensing.Models;
2+
using Code311.Ui.Abstractions.Preferences;
3+
4+
namespace Code311.Host.Models;
5+
6+
public sealed record DashboardDemoViewModel(bool AdvancedEnabled, string FeatureReason);
7+
8+
public sealed record WidgetDemoViewModel(string WidgetName, string ElementId, string InitializationJson);
9+
10+
public sealed record LicensingDiagnosticsViewModel(LicenseRuntimeStatus? Current, IReadOnlyList<LicenseRuntimeStatus> History);
11+
12+
public sealed record PreferencesPageViewModel(UserUiPreference Current, string Message);

0 commit comments

Comments
 (0)