@using LANCommander.Server.Settings.Enums @using LANCommander.Server.Settings.Models @inject IJSRuntime JSRuntime @if (!Providers.Any()) { } @foreach (var externalProvider in Providers) { } @if (!String.IsNullOrWhiteSpace(externalProvider.Documentation)) { @code { [Parameter] public IEnumerable Values { get; set; } [Parameter] public EventCallback> ValuesChanged { get; set; } List Templates = new(); List Providers = new(); AuthenticationProvider SelectedTemplate; protected override async Task OnInitializedAsync() { Templates = await AuthenticationService.GetAuthenticationProviderTemplatesAsync(); } protected override void OnParametersSet() { Providers = Values.ToList(); } void OpenDocumentation(AuthenticationProvider authenticationProvider) { JSRuntime.InvokeVoidAsync("open", authenticationProvider.Documentation, "_blank"); } async Task Add() { Providers.Add(new AuthenticationProvider()); if (ValuesChanged.HasDelegate) await ValuesChanged.InvokeAsync(Providers); } async Task Remove(AuthenticationProvider authenticationProvider) { Providers.Remove(authenticationProvider); if (ValuesChanged.HasDelegate) await ValuesChanged.InvokeAsync(Providers); } async Task UseTemplate(AuthenticationProvider authenticationProvider, AuthenticationProvider template) { authenticationProvider.ClaimMappings = template.ClaimMappings; authenticationProvider.ClientId = template.ClientId; authenticationProvider.ClientSecret = template.ClientSecret; authenticationProvider.Color = template.Color; authenticationProvider.Documentation = template.Documentation; authenticationProvider.Icon = template.Icon; authenticationProvider.Name = template.Name; authenticationProvider.Scopes = template.Scopes; authenticationProvider.ConfigurationUrl = template.ConfigurationUrl; authenticationProvider.AuthorizationEndpoint = template.AuthorizationEndpoint; authenticationProvider.TokenEndpoint = template.TokenEndpoint; authenticationProvider.UserInfoEndpoint = template.UserInfoEndpoint; await InvokeAsync(StateHasChanged); } }