Skip to content

Commit

Permalink
#2551 Updating ProjectTracker code
Browse files Browse the repository at this point in the history
  • Loading branch information
rockfordlhotka committed Oct 1, 2024
1 parent 9b7892a commit 5748baf
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 85 deletions.
4 changes: 3 additions & 1 deletion Samples/ProjectTracker/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CslaVersion>9.0.0-alpha-g3aa97cd7dd</CslaVersion>
<CslaVersion>9.0.0-preview-g9b7892aedb</CslaVersion>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Csla" Version="$(CslaVersion)" />
<PackageVersion Include="Csla.AspNetCore" Version="$(CslaVersion)" />
<PackageVersion Include="Csla.Blazor" Version="$(CslaVersion)" />
<PackageVersion Include="Csla.Blazor.WebAssembly" Version="$(CslaVersion)" />
<PackageVersion Include="Marimer.Blazor.RenderMode" Version="1.0.2" />
<PackageVersion Include="Marimer.Blazor.RenderMode.WebAssembly" Version="1.0.2" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.7" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.7" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.7" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
@page "/editproject"
@page "/editproject/{id:int}"
@using Microsoft.AspNetCore.Components.Authorization

@rendermode InteractiveAuto

@using Marimer.Blazor.RenderMode
@using Microsoft.AspNetCore.Components.Authorization

@inject NavigationManager NavigationManager
@inject Csla.Blazor.State.StateManager StateManager
@inject ProjectTracker.Blazor.RenderModeProvider renderModeProvider
@inject RenderModeProvider renderModeProvider
@inject Csla.IDataPortal<ProjectEdit> projectEditPortal
@inject Csla.Blazor.ViewModel<ProjectEdit> vm
@inject Csla.ApplicationContext ApplicationContext
Expand All @@ -17,19 +20,14 @@
<p class="alert-danger">@vm.Exception.ToString()</p>
}

@if (!IsInteractive)
@if (!IsInteractive || vm.Model == null)
{
<h1>Edit Project</h1>
<p class="animated-box"></p>
<p class="animated-box"></p>
<p class="animated-box"></p>
<p class="animated-box"></p>
}
else if (vm.Model == null)
{
<h1>Edit Project</h1>
<p>Loading data...</p>
}
else
{
<h1>@vm.Model.Name</h1>
Expand Down Expand Up @@ -177,7 +175,7 @@ else
await StateManager.InitializeAsync();

var renderMode = renderModeProvider.GetRenderMode(this);
IsInteractive = renderMode == RenderModes.WasmInteractive || renderMode == RenderModes.ServerInteractive;
IsInteractive = renderMode.IsInteractive();
if (IsInteractive)
{
vm.Saved += () => NavigationManager.NavigateTo("projects");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
using Csla.Configuration;
using Marimer.Blazor.RenderMode.WebAssembly;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using ProjectTracker.Blazor;

var builder = WebAssemblyHostBuilder.CreateDefault(args);

builder.Services.AddAuthorizationCore();
builder.Services.AddCascadingAuthenticationState();

// Add render mode detection services
builder.Services.AddTransient<RenderModeProvider>();
builder.Services.AddScoped<ActiveCircuitState>();
builder.Services.AddRenderModeDetection();

builder.Services.AddMemoryCache();

builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

builder.Services.AddCsla(o => o
.AddBlazorWebAssembly(o => o.SyncContextWithServer = true)
.DataPortal(o => o.AddClientSideDataPortal(o => o
.UseHttpProxy(o => o.DataPortalUrl = "/api/dataportal"))));
builder.Services.AddCsla(_ => _
.AddBlazorWebAssembly(_ => _.SyncContextWithServer = true)
.DataPortal(_ => _.AddClientSideDataPortal(_ => _
.UseHttpProxy(_ => _.DataPortalUrl = "/api/dataportal"))));

await builder.Build().RunAsync();
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<ItemGroup>
<ProjectReference Include="..\..\ProjectTracker.BusinessLibrary\ProjectTracker.BusinessLibrary.csproj" />
<PackageReference Include="Marimer.Blazor.RenderMode.WebAssembly" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" />
<PackageReference Include="Csla.Blazor" />
<PackageReference Include="Csla.Blazor.WebAssembly" />
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using Csla;
using Csla.State;
using Csla.Blazor.State.Messages;

namespace ProjectTracker.Blazor.Controllers
{
Expand All @@ -12,7 +13,21 @@ namespace ProjectTracker.Blazor.Controllers
/// <param name="sessionManager"></param>
[ApiController]
[Route("[controller]")]
public class CslaStateController(ApplicationContext applicationContext, ISessionManager sessionManager) :
Csla.AspNetCore.Blazor.State.StateController(applicationContext, sessionManager)
{ }
public class CslaStateController : Csla.AspNetCore.Blazor.State.StateController
{
public CslaStateController(ApplicationContext applicationContext, ISessionManager sessionManager) :
base(applicationContext, sessionManager)
{
ApplicationContext = applicationContext;
}

private ApplicationContext ApplicationContext { get; set; }

public override StateResult Get(long lastTouched)
{
var user = ApplicationContext.User;
var result = base.Get(lastTouched);
return result;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Csla.Configuration;
using Marimer.Blazor.RenderMode;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Components.Server.Circuits;
using ProjectTracker.Blazor;
using ProjectTracker.Blazor.Components;
using ProjectTracker.Configuration;

Expand All @@ -20,9 +19,7 @@
builder.Services.AddCascadingAuthenticationState();

// Add render mode detection services
builder.Services.AddTransient<RenderModeProvider>();
builder.Services.AddScoped<ActiveCircuitState>();
builder.Services.AddScoped(typeof(CircuitHandler), typeof(ActiveCircuitHandler));
builder.Services.AddRenderModeDetection();

// CSLA requires AddHttpContextAccessor
builder.Services.AddHttpContextAccessor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,26 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Identity\**" />
<Content Remove="Identity\**" />
<EmbeddedResource Remove="Identity\**" />
<None Remove="Identity\**" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\ProjectTracker.BusinessLibrary\ProjectTracker.BusinessLibrary.csproj" />
<ProjectReference Include="..\..\ProjectTracker.DalEfCore\ProjectTracker.DalEfCore.csproj" />
<ProjectReference Include="..\..\ProjectTracker.DalMock\ProjectTracker.DalMock.csproj" />
<ProjectReference Include="..\..\ProjectTracker.Dal\ProjectTracker.Dal.csproj" />
<ProjectReference Include="..\ProjectTracker.Blazor.Client\ProjectTracker.Blazor.Client.csproj" />
<PackageReference Include="Marimer.Blazor.RenderMode" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" />
<PackageReference Include="Csla.AspNetCore" />
<PackageReference Include="Csla.Blazor" />
</ItemGroup>

<ItemGroup>
<Folder Include="Identity\" />
<Folder Include="wwwroot\images\" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public IPrincipal GetUser()
/// Not supported in Blazor.
/// </summary>
/// <param name="principal">Principal object.</param>
public virtual void SetUser(IPrincipal principal) => throw new NotSupportedException(nameof(SetUser));
public virtual void SetUser(IPrincipal principal) { /* noop */ } // => throw new NotSupportedException(nameof(SetUser));

/// <summary>
/// Gets the local context.
Expand Down

0 comments on commit 5748baf

Please sign in to comment.