Skip to content
This repository has been archived by the owner on Nov 27, 2022. It is now read-only.

Commit

Permalink
Added web client
Browse files Browse the repository at this point in the history
Updated proxy config to mix appsettings.config with code config when computing routes and clusters (#20)
  • Loading branch information
candoumbe committed Jun 8, 2021
1 parent eea3b71 commit 3795520
Show file tree
Hide file tree
Showing 40 changed files with 1,460 additions and 27 deletions.
21 changes: 20 additions & 1 deletion MedEasy.sln
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Identity.DataStores.Postgre
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Identity.DataStores.Sqlite", "src\services\identity\Identity.DataStores.Sqlite\Identity.DataStores.Sqlite.csproj", "{09CA3FB8-2393-44E7-9643-02D529BFEB18}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Measures.DataStores.Postgres", "src\services\measures\Measures.DataStores.Postgres\Measures.DataStores.Postgres.csproj", "{B0C3A442-B355-4AF3-8ECF-968C7DEFEB7A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Measures.DataStores.Postgres", "src\services\measures\Measures.DataStores.Postgres\Measures.DataStores.Postgres.csproj", "{B0C3A442-B355-4AF3-8ECF-968C7DEFEB7A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MedEasy.Web", "src\clients\web\MedEasy.Web\MedEasy.Web.csproj", "{80A128B6-A890-40A3-BA2F-CA07B20C432B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -1966,6 +1968,22 @@ Global
{B0C3A442-B355-4AF3-8ECF-968C7DEFEB7A}.Release|x64.Build.0 = Release|Any CPU
{B0C3A442-B355-4AF3-8ECF-968C7DEFEB7A}.Release|x86.ActiveCfg = Release|Any CPU
{B0C3A442-B355-4AF3-8ECF-968C7DEFEB7A}.Release|x86.Build.0 = Release|Any CPU
{80A128B6-A890-40A3-BA2F-CA07B20C432B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{80A128B6-A890-40A3-BA2F-CA07B20C432B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{80A128B6-A890-40A3-BA2F-CA07B20C432B}.Debug|ARM.ActiveCfg = Debug|Any CPU
{80A128B6-A890-40A3-BA2F-CA07B20C432B}.Debug|ARM.Build.0 = Debug|Any CPU
{80A128B6-A890-40A3-BA2F-CA07B20C432B}.Debug|x64.ActiveCfg = Debug|Any CPU
{80A128B6-A890-40A3-BA2F-CA07B20C432B}.Debug|x64.Build.0 = Debug|Any CPU
{80A128B6-A890-40A3-BA2F-CA07B20C432B}.Debug|x86.ActiveCfg = Debug|Any CPU
{80A128B6-A890-40A3-BA2F-CA07B20C432B}.Debug|x86.Build.0 = Debug|Any CPU
{80A128B6-A890-40A3-BA2F-CA07B20C432B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{80A128B6-A890-40A3-BA2F-CA07B20C432B}.Release|Any CPU.Build.0 = Release|Any CPU
{80A128B6-A890-40A3-BA2F-CA07B20C432B}.Release|ARM.ActiveCfg = Release|Any CPU
{80A128B6-A890-40A3-BA2F-CA07B20C432B}.Release|ARM.Build.0 = Release|Any CPU
{80A128B6-A890-40A3-BA2F-CA07B20C432B}.Release|x64.ActiveCfg = Release|Any CPU
{80A128B6-A890-40A3-BA2F-CA07B20C432B}.Release|x64.Build.0 = Release|Any CPU
{80A128B6-A890-40A3-BA2F-CA07B20C432B}.Release|x86.ActiveCfg = Release|Any CPU
{80A128B6-A890-40A3-BA2F-CA07B20C432B}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -2095,6 +2113,7 @@ Global
{EFA6FC4A-83CC-4581-BE52-D9D6A08EDF41} = {A7A45B8F-B761-4DFF-8CC3-256613EA1089}
{09CA3FB8-2393-44E7-9643-02D529BFEB18} = {A7A45B8F-B761-4DFF-8CC3-256613EA1089}
{B0C3A442-B355-4AF3-8ECF-968C7DEFEB7A} = {40981BE2-68C4-499D-8DC3-F819594F9F04}
{80A128B6-A890-40A3-BA2F-CA07B20C432B} = {1F7CABDA-FD26-4F49-A9B6-E89FBCFD14C1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FA6D3311-F0AA-41BF-9204-1EACF82AF1AF}
Expand Down
10 changes: 10 additions & 0 deletions src/clients/web/MedEasy.Web/App.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Router AppAssembly="@typeof(Program).Assembly" PreferExactMatches="@true">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
18 changes: 18 additions & 0 deletions src/clients/web/MedEasy.Web/MedEasy.Web.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.6" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.6" PrivateAssets="all" />
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
<ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
</ItemGroup>

</Project>
16 changes: 16 additions & 0 deletions src/clients/web/MedEasy.Web/Pages/Counter.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@page "/counter"

<h1>Counter</h1>

<p>Current count: @currentCount</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

@code {
private int currentCount = 0;

private void IncrementCount()
{
currentCount++;
}
}
55 changes: 55 additions & 0 deletions src/clients/web/MedEasy.Web/Pages/FetchData.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
@page "/fetchdata"
@inject HttpClient Http

<h1>Weather forecast</h1>

<p>This component demonstrates fetching data from the server.</p>

@if (forecasts == null)
{
<p><em>Loading...</em></p>
}
else
{
<table class="table">
<thead>
<tr>
<th>Date</th>
<th>Temp. (C)</th>
<th>Temp. (F)</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
@foreach (var forecast in forecasts)
{
<tr>
<td>@forecast.Date.ToShortDateString()</td>
<td>@forecast.TemperatureC</td>
<td>@forecast.TemperatureF</td>
<td>@forecast.Summary</td>
</tr>
}
</tbody>
</table>
}

@code {
private WeatherForecast[] forecasts;

protected override async Task OnInitializedAsync()
{
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json");
}

public class WeatherForecast
{
public DateTime Date { get; set; }

public int TemperatureC { get; set; }

public string Summary { get; set; }

public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
}
7 changes: 7 additions & 0 deletions src/clients/web/MedEasy.Web/Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@page "/"

<h1>Hello, world!</h1>

Welcome to your new app.

<SurveyPrompt Title="How is Blazor working for you?" />
22 changes: 22 additions & 0 deletions src/clients/web/MedEasy.Web/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace MedEasy.Web
{
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.DependencyInjection;

using System;
using System.Net.Http;
using System.Threading.Tasks;

public class Program
{
public static async Task Main(string[] args)
{
WebAssemblyHostBuilder builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");

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

await builder.Build().RunAsync();
}
}
}
30 changes: 30 additions & 0 deletions src/clients/web/MedEasy.Web/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:20856",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"MedEasy.Web": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
17 changes: 17 additions & 0 deletions src/clients/web/MedEasy.Web/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@inherits LayoutComponentBase

<div class="page">
<div class="sidebar">
<NavMenu />
</div>

<div class="main">
<div class="top-row px-4">
<a href="http://blazor.net" target="_blank" class="ml-md-auto">About</a>
</div>

<div class="content px-4">
@Body
</div>
</div>
</div>
70 changes: 70 additions & 0 deletions src/clients/web/MedEasy.Web/Shared/MainLayout.razor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
.page {
position: relative;
display: flex;
flex-direction: column;
}

.main {
flex: 1;
}

.sidebar {
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
}

.top-row {
background-color: #f7f7f7;
border-bottom: 1px solid #d6d5d5;
justify-content: flex-end;
height: 3.5rem;
display: flex;
align-items: center;
}

.top-row ::deep a, .top-row .btn-link {
white-space: nowrap;
margin-left: 1.5rem;
}

.top-row a:first-child {
overflow: hidden;
text-overflow: ellipsis;
}

@media (max-width: 640.98px) {
.top-row:not(.auth) {
display: none;
}

.top-row.auth {
justify-content: space-between;
}

.top-row a, .top-row .btn-link {
margin-left: 0;
}
}

@media (min-width: 641px) {
.page {
flex-direction: row;
}

.sidebar {
width: 250px;
height: 100vh;
position: sticky;
top: 0;
}

.top-row {
position: sticky;
top: 0;
z-index: 1;
}

.main > div {
padding-left: 2rem !important;
padding-right: 1.5rem !important;
}
}
37 changes: 37 additions & 0 deletions src/clients/web/MedEasy.Web/Shared/NavMenu.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<div class="top-row pl-4 navbar navbar-dark">
<a class="navbar-brand" href="">MedEasy.Web</a>
<button class="navbar-toggler" @onclick="ToggleNavMenu">
<span class="navbar-toggler-icon"></span>
</button>
</div>

<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
<ul class="nav flex-column">
<li class="nav-item px-3">
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
<span class="oi oi-home" aria-hidden="true"></span> Home
</NavLink>
</li>
<li class="nav-item px-3">
<NavLink class="nav-link" href="counter">
<span class="oi oi-plus" aria-hidden="true"></span> Counter
</NavLink>
</li>
<li class="nav-item px-3">
<NavLink class="nav-link" href="fetchdata">
<span class="oi oi-list-rich" aria-hidden="true"></span> Fetch data
</NavLink>
</li>
</ul>
</div>

@code {
private bool collapseNavMenu = true;

private string NavMenuCssClass => collapseNavMenu ? "collapse" : null;

private void ToggleNavMenu()
{
collapseNavMenu = !collapseNavMenu;
}
}
62 changes: 62 additions & 0 deletions src/clients/web/MedEasy.Web/Shared/NavMenu.razor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.navbar-toggler {
background-color: rgba(255, 255, 255, 0.1);
}

.top-row {
height: 3.5rem;
background-color: rgba(0,0,0,0.4);
}

.navbar-brand {
font-size: 1.1rem;
}

.oi {
width: 2rem;
font-size: 1.1rem;
vertical-align: text-top;
top: -2px;
}

.nav-item {
font-size: 0.9rem;
padding-bottom: 0.5rem;
}

.nav-item:first-of-type {
padding-top: 1rem;
}

.nav-item:last-of-type {
padding-bottom: 1rem;
}

.nav-item ::deep a {
color: #d7d7d7;
border-radius: 4px;
height: 3rem;
display: flex;
align-items: center;
line-height: 3rem;
}

.nav-item ::deep a.active {
background-color: rgba(255,255,255,0.25);
color: white;
}

.nav-item ::deep a:hover {
background-color: rgba(255,255,255,0.1);
color: white;
}

@media (min-width: 641px) {
.navbar-toggler {
display: none;
}

.collapse {
/* Never collapse the sidebar for wide screens */
display: block;
}
}
Loading

0 comments on commit 3795520

Please sign in to comment.