-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57a5d40
commit e1948ba
Showing
38 changed files
with
224 additions
and
3,421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 15 additions & 33 deletions
48
src/AzureIoTHub.Portal.Client/AzureIoTHub.Portal.Client.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,45 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | ||
<NoWarn>$(NoWarn)</NoWarn> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | ||
<NoWarn>$(NoWarn)</NoWarn> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<TypeScriptCompile Remove="assets\script.ts" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="assets\src\index.ts" /> | ||
<Content Include="assets\webpack.config.js" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Include="assets\src\index.ts" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="ChartJs.Blazor.Fork" Version="2.0.2" /> | ||
<PackageReference Include="Microsoft.AspNetCore.ClientAssets" Version="0.1.0-alpha.21528.2" /> | ||
<PackageReference Include="Blazored.LocalStorage" Version="4.2.0" /> | ||
<PackageReference Include="Blazored.Modal" Version="7.1.0" /> | ||
<PackageReference Include="FluentValidation" Version="11.3.0" /> | ||
<PackageReference Include="FluentValidation" Version="11.4.0" /> | ||
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.9" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.Web.Extensions" Version="5.0.0-preview9.20513.1" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.9" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="6.0.9" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.10" PrivateAssets="all" /> | ||
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0"> | ||
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.0-preview1.22518.1"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" /> | ||
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="4.8.4"> | ||
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" /> | ||
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="4.9.3"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="MudBlazor" Version="6.1.2" /> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | ||
<PackageReference Include="System.Net.Http.Json" Version="6.0.0" /> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" /> | ||
<PackageReference Include="System.Net.Http.Json" Version="7.0.0" /> | ||
<PackageReference Include="Tewr.Blazor.FileReader" Version="3.3.1.21360" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.DataAnnotations.Validation" Version="3.2.0-rc1.20223.4" /> | ||
|
||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.0" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.0" PrivateAssets="all" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="7.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" /> | ||
<PackageReference Include="Toolbelt.Blazor.LoadingBar" Version="13.1.2" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\AzureIoTHub.Portal.Shared\AzureIoTHub.Portal.Shared.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,119 +1,105 @@ | ||
// Copyright (c) CGI France. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace AzureIoTHub.Portal.Client | ||
using System.Net.Http.Json; | ||
using AzureIoTHub.Portal.Client; | ||
using AzureIoTHub.Portal.Client.Handlers; | ||
using AzureIoTHub.Portal.Client.Services; | ||
using AzureIoTHub.Portal.Models.v10; | ||
using AzureIoTHub.Portal.Settings; | ||
using Blazored.LocalStorage; | ||
using Blazored.Modal; | ||
using Microsoft.AspNetCore.Components.Web; | ||
using Microsoft.AspNetCore.Components.WebAssembly.Authentication; | ||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting; | ||
using MudBlazor; | ||
using MudBlazor.Services; | ||
using Tewr.Blazor.FileReader; | ||
using Toolbelt.Blazor.Extensions.DependencyInjection; | ||
|
||
var builder = WebAssemblyHostBuilder.CreateDefault(args); | ||
|
||
builder.RootComponents.Add<App>("#app"); | ||
builder.RootComponents.Add<HeadOutlet>("head::after"); | ||
|
||
_ = builder.Services.AddTransient<ProblemDetailsHandler>(); | ||
|
||
_ = builder.Services.AddHttpClient("api", (sp, client) => | ||
{ | ||
using System; | ||
using System.Net.Http; | ||
using System.Net.Http.Json; | ||
using System.Threading.Tasks; | ||
using Services; | ||
using AzureIoTHub.Portal.Models.v10; | ||
using Settings; | ||
using Blazored.LocalStorage; | ||
using Blazored.Modal; | ||
using Microsoft.AspNetCore.Components.WebAssembly.Authentication; | ||
using Handlers; | ||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using MudBlazor; | ||
using MudBlazor.Services; | ||
using Tewr.Blazor.FileReader; | ||
using Toolbelt.Blazor.Extensions.DependencyInjection; | ||
|
||
public static class Program | ||
{ | ||
public static async Task Main(string[] args) | ||
{ | ||
var builder = WebAssemblyHostBuilder.CreateDefault(args); | ||
builder.RootComponents.Add<App>("#app"); | ||
|
||
_ = builder.Services.AddTransient<ProblemDetailsHandler>(); | ||
|
||
_ = builder.Services.AddHttpClient("api", (sp, client) => | ||
{ | ||
client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress); | ||
client.DefaultRequestHeaders.Add("X-Version", "1.0"); | ||
_ = client.EnableIntercept(sp); | ||
}).AddHttpMessageHandler<BaseAddressAuthorizationMessageHandler>() | ||
.AddHttpMessageHandler<ProblemDetailsHandler>(); | ||
|
||
_ = builder.Services.AddFileReaderService(o => o.UseWasmSharedBuffer = true); | ||
|
||
// Supply HttpClient instances that include access tokens when making requests to the server project | ||
_ = builder.Services.AddScoped(sp => sp.GetRequiredService<IHttpClientFactory>().CreateClient("api")) | ||
.AddScoped<ClipboardService>(); | ||
|
||
_ = builder.Services.AddBlazoredLocalStorage(); | ||
_ = builder.Services.AddBlazoredModal(); | ||
_ = builder.Services.AddMudServices(config => | ||
{ | ||
config.SnackbarConfiguration.PositionClass = Defaults.Classes.Position.BottomLeft; | ||
config.SnackbarConfiguration.PreventDuplicates = false; | ||
}); | ||
|
||
_ = builder.Services.AddScoped<ILayoutService, LayoutService>(); | ||
_ = builder.Services.AddScoped<IDashboardLayoutService, DashboardLayoutService>(); | ||
_ = builder.Services.AddSingleton<IDeviceLayoutService, DeviceLayoutService>(); | ||
_ = builder.Services.AddSingleton<IEdgeDeviceLayoutService, EdgeDeviceLayoutService>(); | ||
|
||
_ = builder.Services.AddScoped<IEdgeModelClientService, EdgeModelClientService>(); | ||
_ = builder.Services.AddScoped<IEdgeDeviceClientService, EdgeDeviceClientService>(); | ||
_ = builder.Services.AddScoped<IDashboardMetricsClientService, DashboardMetricsClientService>(); | ||
_ = builder.Services.AddScoped<IDeviceConfigurationsClientService, DeviceConfigurationsClientService>(); | ||
_ = builder.Services.AddScoped<IDeviceModelsClientService, DeviceModelsClientService>(); | ||
_ = builder.Services.AddScoped<IDeviceTagSettingsClientService, DeviceTagSettingsClientService>(); | ||
_ = builder.Services.AddScoped<ILoRaWanConcentratorClientService, LoRaWanConcentratorClientService>(); | ||
_ = builder.Services.AddScoped<IDeviceClientService, DeviceClientService>(); | ||
_ = builder.Services.AddScoped<ILoRaWanDeviceModelsClientService, LoRaWanDeviceModelsClientService>(); | ||
_ = builder.Services.AddScoped<ILoRaWanDeviceClientService, LoRaWanDeviceClientService>(); | ||
_ = builder.Services.AddScoped<IEdgeDeviceConfigurationsClientService, EdgeDeviceConfigurationsClientService>(); | ||
_ = builder.Services.AddScoped<IIdeaClientService, IdeaClientService>(); | ||
|
||
await ConfigureOidc(builder); | ||
await ConfigurePortalSettings(builder); | ||
|
||
// Enable loading bar | ||
builder.Services.AddLoadingBar(options => | ||
{ | ||
options.LoadingBarColor = "#D3E24A"; | ||
}); | ||
_ = builder.UseLoadingBar(); | ||
|
||
await builder.Build().RunAsync(); | ||
} | ||
|
||
private static async Task ConfigureOidc(WebAssemblyHostBuilder builder) | ||
{ | ||
using var httpClient = new HttpClient() { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }; | ||
var settings = await httpClient.GetFromJsonAsync<OIDCSettings>("api/settings/oidc"); | ||
|
||
_ = builder.Services.AddOidcAuthentication(options => | ||
{ | ||
options.ProviderOptions.Authority = settings.Authority; | ||
options.ProviderOptions.MetadataUrl = settings.MetadataUrl.ToString(); | ||
options.ProviderOptions.ClientId = settings.ClientId; | ||
|
||
options.ProviderOptions.DefaultScopes.Add(settings.Scope); | ||
options.ProviderOptions.ResponseType = "code"; | ||
}); | ||
|
||
_ = builder.Services.Configure<OIDCSettings>(opts => | ||
{ | ||
opts.ClientId = settings.ClientId; | ||
opts.MetadataUrl = settings.MetadataUrl; | ||
opts.Authority = settings.Authority; | ||
opts.Scope = settings.Scope; | ||
}); | ||
} | ||
|
||
private static async Task ConfigurePortalSettings(WebAssemblyHostBuilder builder) | ||
{ | ||
using var httpClient = new HttpClient() { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }; | ||
var settings = await httpClient.GetFromJsonAsync<PortalSettings>("api/settings/portal"); | ||
|
||
_ = builder.Services.AddSingleton(settings); | ||
} | ||
|
||
} | ||
client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress); | ||
client.DefaultRequestHeaders.Add("X-Version", "1.0"); | ||
}).AddHttpMessageHandler<BaseAddressAuthorizationMessageHandler>() | ||
.AddHttpMessageHandler<ProblemDetailsHandler>(); | ||
|
||
_ = builder.Services.AddScoped(sp => sp.GetRequiredService<IHttpClientFactory>().CreateClient("api")); | ||
|
||
using var httpClient = new HttpClient() { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }; | ||
var settings = await httpClient.GetFromJsonAsync<OIDCSettings>("api/settings/oidc"); | ||
|
||
_ = builder.Services.Configure<OIDCSettings>(opts => | ||
{ | ||
opts.ClientId = settings.ClientId; | ||
opts.MetadataUrl = settings.MetadataUrl; | ||
opts.Authority = settings.Authority; | ||
opts.Scope = settings.Scope; | ||
}); | ||
|
||
builder.Services.AddOidcAuthentication(options => | ||
{ | ||
options.ProviderOptions.Authority = settings.Authority; | ||
options.ProviderOptions.MetadataUrl = settings.MetadataUrl.ToString(); | ||
options.ProviderOptions.ClientId = settings.ClientId; | ||
options.ProviderOptions.ResponseType = "code"; | ||
|
||
options.ProviderOptions.DefaultScopes.Add(settings.Scope); | ||
}); | ||
|
||
builder.Services.AddApiAuthorization(); | ||
|
||
_ = builder.Services.AddFileReaderService(o => o.UseWasmSharedBuffer = true); | ||
|
||
_ = builder.Services.AddBlazoredLocalStorage(); | ||
_ = builder.Services.AddBlazoredModal(); | ||
_ = builder.Services.AddMudServices(config => | ||
{ | ||
config.SnackbarConfiguration.PositionClass = Defaults.Classes.Position.BottomLeft; | ||
config.SnackbarConfiguration.PreventDuplicates = false; | ||
}); | ||
|
||
_ = builder.Services.AddScoped<ILayoutService, LayoutService>(); | ||
_ = builder.Services.AddScoped<IDashboardLayoutService, DashboardLayoutService>(); | ||
_ = builder.Services.AddSingleton<IDeviceLayoutService, DeviceLayoutService>(); | ||
_ = builder.Services.AddSingleton<IEdgeDeviceLayoutService, EdgeDeviceLayoutService>(); | ||
|
||
_ = builder.Services.AddScoped<IEdgeModelClientService, EdgeModelClientService>(); | ||
_ = builder.Services.AddScoped<IEdgeDeviceClientService, EdgeDeviceClientService>(); | ||
_ = builder.Services.AddScoped<IDashboardMetricsClientService, DashboardMetricsClientService>(); | ||
_ = builder.Services.AddScoped<IDeviceConfigurationsClientService, DeviceConfigurationsClientService>(); | ||
_ = builder.Services.AddScoped<IDeviceModelsClientService, DeviceModelsClientService>(); | ||
_ = builder.Services.AddScoped<IDeviceTagSettingsClientService, DeviceTagSettingsClientService>(); | ||
_ = builder.Services.AddScoped<ILoRaWanConcentratorClientService, LoRaWanConcentratorClientService>(); | ||
_ = builder.Services.AddScoped<IDeviceClientService, DeviceClientService>(); | ||
_ = builder.Services.AddScoped<ILoRaWanDeviceModelsClientService, LoRaWanDeviceModelsClientService>(); | ||
_ = builder.Services.AddScoped<ILoRaWanDeviceClientService, LoRaWanDeviceClientService>(); | ||
_ = builder.Services.AddScoped<IEdgeDeviceConfigurationsClientService, EdgeDeviceConfigurationsClientService>(); | ||
_ = builder.Services.AddScoped<IIdeaClientService, IdeaClientService>(); | ||
_ = builder.Services.AddScoped<ClipboardService>(); | ||
|
||
await ConfigurePortalSettings(builder); | ||
|
||
// Enable loading bar | ||
builder.Services.AddLoadingBar(options => | ||
{ | ||
options.LoadingBarColor = "#D3E24A"; | ||
}); | ||
_ = builder.UseLoadingBar(); | ||
|
||
await builder.Build().RunAsync(); | ||
|
||
static async Task ConfigurePortalSettings(WebAssemblyHostBuilder builder) | ||
{ | ||
using var httpClient = new HttpClient() { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }; | ||
var settings = await httpClient.GetFromJsonAsync<PortalSettings>("api/settings/portal"); | ||
|
||
_ = builder.Services.AddSingleton(settings); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
@inject NavigationManager Navigation | ||
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication | ||
@using Microsoft.Extensions.Options; | ||
|
||
@inject IOptionsSnapshot<RemoteAuthenticationOptions<ApiAuthorizationProviderOptions>> Options | ||
|
||
@code { | ||
protected override void OnInitialized() | ||
{ | ||
Navigation.NavigateTo($"authentication/login?returnUrl={Uri.EscapeDataString(Navigation.Uri)}"); | ||
Navigation.NavigateToLogin(Options.Get( | ||
Microsoft.Extensions.Options.Options.DefaultName) | ||
.AuthenticationPaths.LogInPath); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.