Skip to content

Commit

Permalink
Added aspnet Blazor Server Webapp project using same UI classes. Webs…
Browse files Browse the repository at this point in the history
…ite!!!!
  • Loading branch information
stijuh committed May 21, 2023
1 parent 6739c30 commit 09c4e2a
Show file tree
Hide file tree
Showing 26 changed files with 327 additions and 41 deletions.
20 changes: 10 additions & 10 deletions GainsTracker.ClientNative/GainsTracker.ClientNative.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net7.0;net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
<OutputType Condition="'$(TargetFramework)' != 'net7.0'">Exe</OutputType>
<RootNamespace>GainsTracker.ClientNative</RootNamespace>
<UseMaui>true</UseMaui>
Expand Down Expand Up @@ -33,31 +33,31 @@

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4"/>

<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128"/>

<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />
<MauiImage Include="Resources\Images\*"/>
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208"/>

<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />
<MauiFont Include="Resources\Fonts\*"/>

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\GainsTracker.UI\GainsTracker.UI.csproj" />
<ProjectReference Include="..\GainsTracker.UI\GainsTracker.UI.csproj"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\GainsTracker.Common\GainsTracker.Common.csproj" />
<ProjectReference Include="..\GainsTracker.Common\GainsTracker.Common.csproj"/>
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions GainsTracker.ClientNative/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
@inject NavigationManager NavigationManager

@code {

protected override void OnInitialized()
{
NavigationManager.NavigateTo("/login");
}

}
8 changes: 4 additions & 4 deletions GainsTracker.ClientNative/wwwroot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
<link class="theme" href="_content/GainsTracker.UI/css/lightTheme.css" rel="stylesheet"/>

<link href="GainsTracker.ClientNative.styles.css" rel="stylesheet"/>

<script src="_content/GainsTracker.UI/script/ElementManipulator.js" type="text/javascript"></script>
</head>

<body>
<div id="app">Loading...</div>
<script autostart="false" src="_framework/blazor.webview.js"></script>
<div id="app">Loading...</div>

<script autostart="false" src="_framework/blazor.webview.js"></script>
</body>

</html>
14 changes: 14 additions & 0 deletions GainsTracker.ClientWeb/App.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@using GainsTracker.UI.Shared
<Router AppAssembly="@GetType().Assembly"
AdditionalAssemblies="new[] { typeof(MainLayout).Assembly }">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"/>
<FocusOnNavigate RouteData="@routeData" Selector="h1"/>
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
31 changes: 31 additions & 0 deletions GainsTracker.ClientWeb/GainsTracker.ClientWeb.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<_ContentIncludedByDefault Remove="Shared\MainLayout.razor"/>
<_ContentIncludedByDefault Remove="Shared\NavMenu.razor"/>
<_ContentIncludedByDefault Remove="Shared\SurveyPrompt.razor"/>
<_ContentIncludedByDefault Remove="wwwroot\css\bootstrap\bootstrap.min.css"/>
<_ContentIncludedByDefault Remove="wwwroot\css\bootstrap\bootstrap.min.css.map"/>
<_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\FONT-LICENSE"/>
<_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\font\css\open-iconic-bootstrap.min.css"/>
<_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\font\fonts\open-iconic.eot"/>
<_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\font\fonts\open-iconic.otf"/>
<_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\font\fonts\open-iconic.svg"/>
<_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\font\fonts\open-iconic.ttf"/>
<_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\font\fonts\open-iconic.woff"/>
<_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\ICON-LICENSE"/>
<_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\README.md"/>
<_ContentIncludedByDefault Remove="wwwroot\css\site.css"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\GainsTracker.UI\GainsTracker.UI.csproj"/>
</ItemGroup>

</Project>
45 changes: 45 additions & 0 deletions GainsTracker.ClientWeb/Pages/Error.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
@page
@model GainsTracker.ClientWeb.Pages.ErrorModel

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<title>Error</title>

<link href="_content/GainsTracker.UI/css/site.css" rel="stylesheet" asp-append-version="true"/>
<link class="theme" href="_content/GainsTracker.UI/css/lightTheme.css" rel="stylesheet"/>

<script src="_content/GainsTracker.UI/script/ElementManipulator.js" type="text/javascript"></script>
</head>

<body>
<div class="main">
<div class="content px-4">
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>

@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}

<h3>Development Mode</h3>
<p>
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>
</div>
</div>
</body>

</html>
26 changes: 26 additions & 0 deletions GainsTracker.ClientWeb/Pages/Error.cshtml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace GainsTracker.ClientWeb.Pages;

[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
private readonly ILogger<ErrorModel> _logger;

public ErrorModel(ILogger<ErrorModel> logger)
{
_logger = logger;
}

public string? RequestId { get; set; }

public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);

public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}
11 changes: 11 additions & 0 deletions GainsTracker.ClientWeb/Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@page "/"
@inject NavigationManager NavigationManager

@code {

protected override void OnInitialized()
{
NavigationManager.NavigateTo("/login");
}

}
39 changes: 39 additions & 0 deletions GainsTracker.ClientWeb/Pages/_Host.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@page "/"
@using Microsoft.AspNetCore.Components.Web
@namespace GainsTracker.ClientWeb.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Jup</title>
<base href="~/"/>

<link href="_content/GainsTracker.UI/css/site.css" rel="stylesheet"/>
<link class="theme" href="_content/GainsTracker.UI/css/lightTheme.css" rel="stylesheet"/>

<link href="GainsTracker.ClientWeb.styles.css" rel="stylesheet"/>
<link rel="icon" type="image/png" href="favicon.png"/>
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered"/>

<script src="_content/GainsTracker.UI/script/ElementManipulator.js" type="text/javascript"></script>
</head>
<body>
<component type="typeof(App)" render-mode="ServerPrerendered"/>

<div id="blazor-error-ui">
<environment include="Staging,Production">
An error has occurred. This application may no longer respond until reloaded.
</environment>
<environment include="Development">
An unhandled exception has occurred. See browser dev tools for details.
</environment>
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>

<script src="_framework/blazor.server.js"></script>
</body>
</html>
34 changes: 34 additions & 0 deletions GainsTracker.ClientWeb/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using GainsTracker.UI.Services;

WebApplicationBuilder builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();

// Register dependencies for injection and create app.
builder.Services.AddScoped<IGainsTrackerService, GainsTrackerService>();
builder.Services.AddScoped<IGainsAuthService, GainsAuthService>();
builder.Services.AddSingleton<HttpClient>();

WebApplication app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");

// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}

app.UseHttpsRedirection();

app.UseStaticFiles();

app.UseRouting();

app.MapBlazorHub();
app.MapFallbackToPage("/_Host");

app.Run();
37 changes: 37 additions & 0 deletions GainsTracker.ClientWeb/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:28475",
"sslPort": 44360
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5027",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7093;http://localhost:5027",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
9 changes: 9 additions & 0 deletions GainsTracker.ClientWeb/_Imports.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@using System.Net.Http
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components.Authorization
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop
@using GainsTracker.ClientWeb
9 changes: 9 additions & 0 deletions GainsTracker.ClientWeb/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"DetailedErrors": true,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions GainsTracker.ClientWeb/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Binary file added GainsTracker.ClientWeb/wwwroot/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 10 additions & 10 deletions GainsTracker.CoreAPI/GainsTracker.CoreAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EFCore.NamingConventions" Version="7.0.2" />
<PackageReference Include="EntityFramework" Version="6.4.4" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.15" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.15" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.4" />
<PackageReference Include="EFCore.NamingConventions" Version="7.0.2"/>
<PackageReference Include="EntityFramework" Version="6.4.4"/>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.15"/>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.15"/>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.4"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.12" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.12"/>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3"/>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\GainsTracker.Common\GainsTracker.Common.csproj" />
<ProjectReference Include="..\GainsTracker.Common\GainsTracker.Common.csproj"/>
</ItemGroup>
</Project>
Loading

0 comments on commit 09c4e2a

Please sign in to comment.