Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Refactor WASM project (#15)

Leendert de Borstb0b1a38151c7
diff --git a/src/AliasVault.WebApp/AliasVault.WebApp.csproj b/src/AliasVault.WebApp/AliasVault.WebApp.csproj
index 5fb654ef5..c821f52f8 100644
--- a/src/AliasVault.WebApp/AliasVault.WebApp.csproj
+++ b/src/AliasVault.WebApp/AliasVault.WebApp.csproj
@@ -15,14 +15,7 @@
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>true</DebugSymbols>
<DocumentationFile>bin\Release\net8.0\AliasVault.WebApp.xml</DocumentationFile>
- </PropertyGroup>
-
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
- <TreatWarningsAsErrors>True</TreatWarningsAsErrors>
- </PropertyGroup>
-
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
- <TreatWarningsAsErrors>True</TreatWarningsAsErrors>
+ <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Optimize>True</Optimize>
</PropertyGroup>
diff --git a/src/AliasVault.WebApp/Auth/Pages/Login.razor b/src/AliasVault.WebApp/Auth/Pages/Login.razor
index 31c1f725e..3c602c282 100644
--- a/src/AliasVault.WebApp/Auth/Pages/Login.razor
+++ b/src/AliasVault.WebApp/Auth/Pages/Login.razor
@@ -15,14 +15,14 @@
Sign in to AliasVault
</h2>
-<EditForm Model="user" OnSubmit="HandleLogin" class="mt-8 space-y-6">
+<EditForm Model="_user" OnSubmit="HandleLogin" class="mt-8 space-y-6">
<div>
<label asp-for="Input.Email" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Your email</label>
- <InputTextField id="email" @bind-Value="user.Email" placeholder="[email protected]" />
+ <InputTextField id="email" @bind-Value="_user.Email" placeholder="[email protected]" />
</div>
<div>
<label asp-for="Input.Password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Your password</label>
- <InputTextField id="password" @bind-Value="user.Password" type="password" placeholder="••••••••" />
+ <InputTextField id="password" @bind-Value="_user.Password" type="password" placeholder="••••••••" />
</div>
<div class="flex items-start">
@@ -42,12 +42,13 @@
</EditForm>
-<FullScreenLoadingIndicator @ref="loadingIndicator" />
+<FullScreenLoadingIndicator @ref="_loadingIndicator" />
@code {
- LoginModel user = new LoginModel();
- FullScreenLoadingIndicator loadingIndicator = new();
+ private LoginModel _user = new LoginModel();
+ private FullScreenLoadingIndicator _loadingIndicator = new();
+ /// <inheritdoc />
protected override async Task OnInitializedAsync()
{
await AuthStateProvider.GetAuthenticationStateAsync();
@@ -58,13 +59,13 @@
}
}
- async Task HandleLogin()
+ private async Task HandleLogin()
{
- loadingIndicator.Show();
+ _loadingIndicator.Show();
try
{
- var result = await Http.PostAsJsonAsync("api/Auth/login", user);
+ var result = await Http.PostAsJsonAsync("api/Auth/login", _user);
var responseContent = await result.Content.ReadAsStringAsync();
var tokenObject = JsonSerializer.Deserialize<TokenModel>(responseContent);
@@ -90,7 +91,7 @@
}
finally
{
- loadingIndicator.Hide();
+ _loadingIndicator.Hide();
}
}
}
diff --git a/src/AliasVault.WebApp/Auth/Pages/Logout.razor b/src/AliasVault.WebApp/Auth/Pages/Logout.razor
index 8f7ca2591..d8cf03e3c 100644
--- a/src/AliasVault.WebApp/Auth/Pages/Logout.razor
+++ b/src/AliasVault.WebApp/Auth/Pages/Logout.razor
@@ -7,6 +7,7 @@
@inject AuthService AuthService
@code {
+ /// <inheritdoc />
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
@@ -16,5 +17,4 @@
// Redirect to home page
NavigationManager.NavigateTo("/");
}
-
}
diff --git a/src/AliasVault.WebApp/Auth/Pages/Register.razor b/src/AliasVault.WebApp/Auth/Pages/Register.razor
index 083bca2fe..f0eccc770 100644
--- a/src/AliasVault.WebApp/Auth/Pages/Register.razor
+++ b/src/AliasVault.WebApp/Auth/Pages/Register.razor
@@ -3,7 +3,6 @@
@layout Auth.Layout.MainLayout
@inject HttpClient Http
@inject AuthenticationStateProvider AuthStateProvider
-@inject ILocalStorageService LocalStorage
@inject NavigationManager NavigationManager
@inject AuthService AuthService
@using System.Text.Json
@@ -59,9 +58,9 @@
<FullScreenLoadingIndicator @ref="loadingIndicator" />
@code {
- RegisterModel user = new RegisterModel();
+ RegisterModel user = new();
FullScreenLoadingIndicator loadingIndicator = new();
- List<string> validationErrors = new List<string>();
+ List<string> validationErrors = [];
async Task HandleRegister()
{
diff --git a/src/AliasVault.WebApp/Components/Alias/Alias.razor b/src/AliasVault.WebApp/Components/Alias/Alias.razor
index 422287698..fe00fc51d 100644
--- a/src/AliasVault.WebApp/Components/Alias/Alias.razor
+++ b/src/AliasVault.WebApp/Components/Alias/Alias.razor
@@ -10,8 +10,11 @@
</div>
@code {
+ /// <summary>
+ /// Gets or sets the alias object to show.
+ /// </summary>
[Parameter]
- public AliasVault.Shared.Models.WebApi.AliasListEntry Obj { get; set; } = new();
+ public AliasVault.Shared.Models.WebApi.AliasListEntry Obj { get; set; } = null!;
private void ShowDetails()
{
diff --git a/src/AliasVault.WebApp/Auth/Components/FullScreenLoadingIndicator.razor b/src/AliasVault.WebApp/Components/Loading/FullScreenLoadingIndicator.razor
similarity index 77%
rename from src/AliasVault.WebApp/Auth/Components/FullScreenLoadingIndicator.razor
rename to src/AliasVault.WebApp/Components/Loading/FullScreenLoadingIndicator.razor
index bb7a77cca..ac2305327 100644
--- a/src/AliasVault.WebApp/Auth/Components/FullScreenLoadingIndicator.razor
+++ b/src/AliasVault.WebApp/Components/Loading/FullScreenLoadingIndicator.razor
@@ -11,12 +11,18 @@
@code {
private bool IsVisible { get; set; }
+ /// <summary>
+ /// Shows the loading indicator.
+ /// </summary>
public void Show()
{
IsVisible = true;
StateHasChanged();
}
+ /// <summary>
+ /// Hides the loading indicator.
+ /// </summary>
public void Hide()
{
IsVisible = false;
diff --git a/src/AliasVault.WebApp/Auth/Components/FullScreenLoadingIndicator.razor.css b/src/AliasVault.WebApp/Components/Loading/FullScreenLoadingIndicator.razor.css
similarity index 100%
rename from src/AliasVault.WebApp/Auth/Components/FullScreenLoadingIndicator.razor.css
rename to src/AliasVault.WebApp/Components/Loading/FullScreenLoadingIndicator.razor.css
diff --git a/src/AliasVault.WebApp/Components/LoadingIndicator.razor b/src/AliasVault.WebApp/Components/Loading/LoadingIndicator.razor
similarity index 100%
rename from src/AliasVault.WebApp/Components/LoadingIndicator.razor
rename to src/AliasVault.WebApp/Components/Loading/LoadingIndicator.razor
diff --git a/src/AliasVault.WebApp/Components/LoginLogoutButton.razor b/src/AliasVault.WebApp/Components/LoginLogoutButton.razor
deleted file mode 100644
index ff163770f..000000000
--- a/src/AliasVault.WebApp/Components/LoginLogoutButton.razor
+++ /dev/null
@@ -1,25 +0,0 @@
-@inject NavigationManager NavigationManager
-@inject ILocalStorageService LocalStorage
-@inject AuthenticationStateProvider AuthStateProvider
-
-<AuthorizeView>
- <Authorized>
- <button @onclick="Logout" class="btn btn-danger">Logout</button>
- </Authorized>
- <NotAuthorized>
- <button @onclick="Login" class="btn btn-primary">Login</button>
- </NotAuthorized>
-</AuthorizeView>
-
-@code {
- void Login()
- {
- NavigationManager.NavigateTo("login");
- }
-
- async Task Logout()
- {
- await LocalStorage.RemoveItemAsync("token");
- await AuthStateProvider.GetAuthenticationStateAsync();
- }
-}
diff --git a/src/AliasVault.WebApp/Components/RedirectToLogin.razor b/src/AliasVault.WebApp/Components/RedirectToLogin.razor
index 885bbb063..251b29977 100644
--- a/src/AliasVault.WebApp/Components/RedirectToLogin.razor
+++ b/src/AliasVault.WebApp/Components/RedirectToLogin.razor
@@ -1,6 +1,7 @@
@inject NavigationManager Navigation
@code {
+ /// <inheritdoc />
protected override void OnInitialized()
{
Navigation.NavigateTo("/user/login");
diff --git a/src/AliasVault.WebApp/Pages/Aliases/AddEdit.razor b/src/AliasVault.WebApp/Pages/Aliases/AddEdit.razor
index aec47cc17..c0ced68f6 100644
--- a/src/AliasVault.WebApp/Pages/Aliases/AddEdit.razor
+++ b/src/AliasVault.WebApp/Pages/Aliases/AddEdit.razor
@@ -8,7 +8,6 @@
@using AliasGenerators.Password.Implementations
@using AliasVault.Shared.Models.WebApi
@using AliasVault.WebApp.Services
-@using Password = AliasDb.Password
@if (EditMode)
{
@@ -52,10 +51,10 @@ else
<h3 class="mb-4 text-xl font-semibold dark:text-white">Service</h3>
<div class="grid gap-6">
<div class="col-span-6 sm:col-span-3">
- <EditFormRow Label="Service Name" Value="@(obj.Service.Name)" ValueChanged="@(val => obj.Service.Name = val)"></EditFormRow>
+ <EditFormRow Label="Service Name" Value="@(Obj.Service.Name)" ValueChanged="@(val => Obj.Service.Name = val)"></EditFormRow>
</div>
<div class="col-span-6 sm:col-span-3">
- <EditFormRow Label="Service URL" Value="@(obj.Service.Url)" ValueChanged="@(val => obj.Service.Url = val)"></EditFormRow>
+ <EditFormRow Label="Service URL" Value="@(Obj.Service.Url)" ValueChanged="@(val => Obj.Service.Url = val)"></EditFormRow>
</div>
</div>
</div>
@@ -73,14 +72,14 @@ else
</div>
<div class="grid gap-6">
<div class="col-span-6 sm:col-span-3">
- <EditFormRow Label="Email" Value="@(obj.Identity.EmailPrefix)" ValueChanged="@(val => obj.Identity.EmailPrefix = val)"></EditFormRow>
+ <EditFormRow Label="Email" Value="@(Obj.Identity.EmailPrefix)" ValueChanged="@(val => Obj.Identity.EmailPrefix = val)"></EditFormRow>
</div>
<div class="col-span-6 sm:col-span-3">
- <EditFormRow Label="Username" Value="@(obj.Identity.NickName)" ValueChanged="@(val => obj.Identity.NickName = val)"></EditFormRow>
+ <EditFormRow Label="Username" Value="@(Obj.Identity.NickName)" ValueChanged="@(val => Obj.Identity.NickName = val)"></EditFormRow>
</div>
<div class="col-span-6 sm:col-span-3">
<div class="relative">
- <EditFormRow Label="Password" Value="@(obj.Password.Value)" ValueChanged="@(val => obj.Password.Value = val)"></EditFormRow>
+ <EditFormRow Label="Password" Value="@(Obj.Password.Value)" ValueChanged="@(val => Obj.Password.Value = val)"></EditFormRow>
<button type="submit" class="text-white absolute end-1 bottom-1 bg-gray-700 hover:bg-gray-800 focus:ring-4 focus:outline-none focus:ring-gray-300 font-medium rounded-lg text-sm px-4 py-2 dark:bg-gray-600 dark:hover:bg-gray-700 dark:focus:ring-gray-800" @onclick="GenerateRandomPassword">(Re)generate Random Password</button>
</div>
</div>
@@ -95,43 +94,43 @@ else
<h3 class="mb-4 text-xl font-semibold dark:text-white">Identity</h3>
<div class="grid gap-6">
<div class="col-span-6 sm:col-span-3">
- <EditFormRow Label="First Name" Value="@(obj.Identity.FirstName)" ValueChanged="@(val => obj.Identity.FirstName = val)"></EditFormRow>
+ <EditFormRow Label="First Name" Value="@(Obj.Identity.FirstName)" ValueChanged="@(val => Obj.Identity.FirstName = val)"></EditFormRow>
</div>
<div class="col-span-6 sm:col-span-3">
- <EditFormRow Label="Last Name" Value="@(obj.Identity.LastName)" ValueChanged="@(val => obj.Identity.LastName = val)"></EditFormRow>
+ <EditFormRow Label="Last Name" Value="@(Obj.Identity.LastName)" ValueChanged="@(val => Obj.Identity.LastName = val)"></EditFormRow>
</div>
<div class="col-span-6 sm:col-span-3">
- <EditFormRow Label="Gender" Value="@(obj.Identity.Gender)" ValueChanged="@(val => obj.Identity.Gender = val)"></EditFormRow>
+ <EditFormRow Label="Gender" Value="@(Obj.Identity.Gender)" ValueChanged="@(val => Obj.Identity.Gender = val)"></EditFormRow>
</div>
<div class="col-span-6 sm:col-span-3">
- <EditFormRow Label="Nick Name" Value="@(obj.Identity.NickName)" ValueChanged="@(val => obj.Identity.NickName = val)"></EditFormRow>
+ <EditFormRow Label="Nick Name" Value="@(Obj.Identity.NickName)" ValueChanged="@(val => Obj.Identity.NickName = val)"></EditFormRow>
</div>
<div class="col-span-6 sm:col-span-3">
- <EditFormRow Label="Birth Date" Value="@(obj.Identity.BirthDate)" ValueChanged="@(val => obj.Identity.BirthDate = val)"></EditFormRow>
+ <EditFormRow Label="Birth Date" Value="@(Obj.Identity.BirthDate)" ValueChanged="@(val => Obj.Identity.BirthDate = val)"></EditFormRow>
</div>
<div class="col-span-6 sm:col-span-3">
- <EditFormRow Label="Address Street" Value="@(obj.Identity.AddressStreet)" ValueChanged="@(val => obj.Identity.AddressStreet = val)"></EditFormRow>
+ <EditFormRow Label="Address Street" Value="@(Obj.Identity.AddressStreet)" ValueChanged="@(val => Obj.Identity.AddressStreet = val)"></EditFormRow>
</div>
<div class="col-span-6 sm:col-span-3">
- <EditFormRow Label="Address City" Value="@(obj.Identity.AddressCity)" ValueChanged="@(val => obj.Identity.AddressCity = val)"></EditFormRow>
+ <EditFormRow Label="Address City" Value="@(Obj.Identity.AddressCity)" ValueChanged="@(val => Obj.Identity.AddressCity = val)"></EditFormRow>
</div>
<div class="col-span-6 sm:col-span-3">
- <EditFormRow Label="Address State" Value="@(obj.Identity.AddressState)" ValueChanged="@(val => obj.Identity.AddressState = val)"></EditFormRow>
+ <EditFormRow Label="Address State" Value="@(Obj.Identity.AddressState)" ValueChanged="@(val => Obj.Identity.AddressState = val)"></EditFormRow>
</div>
<div class="col-span-6 sm:col-span-3">
- <EditFormRow Label="Address Zip Code" Value="@(obj.Identity.AddressZipCode)" ValueChanged="@(val => obj.Identity.AddressZipCode = val)"></EditFormRow>
+ <EditFormRow Label="Address Zip Code" Value="@(Obj.Identity.AddressZipCode)" ValueChanged="@(val => Obj.Identity.AddressZipCode = val)"></EditFormRow>
</div>
<div class="col-span-6 sm:col-span-3">
- <EditFormRow Label="Address Country" Value="@(obj.Identity.AddressCountry)" ValueChanged="@(val => obj.Identity.AddressCountry = val)"></EditFormRow>
+ <EditFormRow Label="Address Country" Value="@(Obj.Identity.AddressCountry)" ValueChanged="@(val => Obj.Identity.AddressCountry = val)"></EditFormRow>
</div>
<div class="col-span-6 sm:col-span-3">
- <EditFormRow Label="Hobbies" Value="@(obj.Identity.Hobbies)" ValueChanged="@(val => obj.Identity.Hobbies = val)"></EditFormRow>
+ <EditFormRow Label="Hobbies" Value="@(Obj.Identity.Hobbies)" ValueChanged="@(val => Obj.Identity.Hobbies = val)"></EditFormRow>
</div>
<div class="col-span-6 sm:col-span-3">
- <EditFormRow Label="Phone Mobile" Value="@(obj.Identity.PhoneMobile)" ValueChanged="@(val => obj.Identity.PhoneMobile = val)"></EditFormRow>
+ <EditFormRow Label="Phone Mobile" Value="@(Obj.Identity.PhoneMobile)" ValueChanged="@(val => Obj.Identity.PhoneMobile = val)"></EditFormRow>
</div>
<div class="col-span-6 sm:col-span-3">
- <EditFormRow Label="Bank Account IBAN" Value="@(obj.Identity.BankAccountIBAN)" ValueChanged="@(val => obj.Identity.BankAccountIBAN = val)"></EditFormRow>
+ <EditFormRow Label="Bank Account IBAN" Value="@(Obj.Identity.BankAccountIBAN)" ValueChanged="@(val => Obj.Identity.BankAccountIBAN = val)"></EditFormRow>
</div>
</div>
</div>
@@ -147,16 +146,19 @@ else
}
@code {
+ /// <summary>
+ /// Gets or sets the alias ID.
+ /// </summary>
[Parameter]
public Guid? Id { get; set; }
- private bool EditMode = false;
- private bool Loading = true;
- private Alias obj = new Alias();
-
+ private bool EditMode { get; set; }
+ private bool Loading { get; set; } = true;
+ private Alias Obj { get; set; } = new();
private bool IsIdentityLoading { get; set; }
private bool IsSaving { get; set; }
+ /// <inheritdoc />
protected override void OnInitialized()
{
if (Id.HasValue)
@@ -171,6 +173,7 @@ else
}
}
+ /// <inheritdoc />
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
@@ -185,6 +188,7 @@ else
}
}
+ /// <inheritdoc />
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
@@ -197,7 +201,7 @@ else
return;
}
- // Load existing obj, retrieve from service
+ // Load existing Obj, retrieve from service
var alias = await AliasService.LoadAliasAsync(Id.Value);
if (alias is null)
{
@@ -205,22 +209,21 @@ else
return;
}
- alias = obj;
+ Obj = alias;
}
else
{
- // Create new obj
- obj = new Alias();
- obj.Identity = new Shared.Models.WebApi.Identity();
- obj.Service = new Shared.Models.WebApi.Service();
- obj.Password = new Shared.Models.WebApi.Password();
+ // Create new Obj
+ Obj = new Alias();
+ Obj.Identity = new Shared.Models.WebApi.Identity();
+ Obj.Service = new Shared.Models.WebApi.Service();
+ Obj.Password = new Shared.Models.WebApi.Password();
}
// Hide loading spinner
Loading = false;
// Force re-render invoke so the charts can be rendered
StateHasChanged();
-
}
}
@@ -233,20 +236,20 @@ else
var identity = await AliasService.GenerateRandomIdentityAsync();
// Generate random values for the Identity properties
- obj.Identity.FirstName = identity.FirstName;
- obj.Identity.LastName = identity.LastName;
- obj.Identity.NickName = identity.NickName;
- obj.Identity.Gender = identity.Gender == 1 ? "Male" : "Female";
- obj.Identity.BirthDate = DateTime.Now.AddYears(-30).ToString("yyyy-MM-dd");
- obj.Identity.AddressStreet = identity.Address.Street;
- obj.Identity.AddressCity = identity.Address.City;
- obj.Identity.AddressState = identity.Address.State;
- obj.Identity.AddressZipCode = identity.Address.ZipCode;
- obj.Identity.AddressCountry = identity.Address.Country;
- obj.Identity.Hobbies = identity.Hobbies.First();
- obj.Identity.EmailPrefix = identity.EmailPrefix;
- obj.Identity.PhoneMobile = identity.PhoneMobile;
- obj.Identity.BankAccountIBAN = identity.BankAccountIBAN;
+ Obj.Identity.FirstName = identity.FirstName;
+ Obj.Identity.LastName = identity.LastName;
+ Obj.Identity.NickName = identity.NickName;
+ Obj.Identity.Gender = identity.Gender == 1 ? "Male" : "Female";
+ Obj.Identity.BirthDate = DateTime.Now.AddYears(-30).ToString("yyyy-MM-dd");
+ Obj.Identity.AddressStreet = identity.Address.Street;
+ Obj.Identity.AddressCity = identity.Address.City;
+ Obj.Identity.AddressState = identity.Address.State;
+ Obj.Identity.AddressZipCode = identity.Address.ZipCode;
+ Obj.Identity.AddressCountry = identity.Address.Country;
+ Obj.Identity.Hobbies = identity.Hobbies.First();
+ Obj.Identity.EmailPrefix = identity.EmailPrefix;
+ Obj.Identity.PhoneMobile = identity.PhoneMobile;
+ Obj.Identity.BankAccountIBAN = identity.BankAccountIBAN;
// Generate password
GenerateRandomPassword();
@@ -259,7 +262,7 @@ else
{
// Generate a random password using a IPasswordGenerator implementation.
IPasswordGenerator passwordGenerator = new SpamOkPasswordGenerator();
- obj.Password.Value = passwordGenerator.GenerateRandomPassword();
+ Obj.Password.Value = passwordGenerator.GenerateRandomPassword();
}
private async Task SaveAlias()
@@ -269,22 +272,22 @@ else
// Try to extract favicon from service URL
// TODO: Fix favicon extraction
- /*if (obj.Service.Url != null && !string.IsNullOrEmpty(obj.Service.Url))
+ /*if (Obj.Service.Url != null && !string.IsNullOrEmpty(Obj.Service.Url))
{
- obj.Service.Logo = await FaviconExtractor.FaviconService.GetFaviconAsync(obj.Service.Url);
+ Obj.Service.Logo = await FaviconExtractor.FaviconService.GetFaviconAsync(Obj.Service.Url);
} */
// Sanity check for unittest. Delete later if not needed.
// Try to parse birthdate as datetime. if it fails, set it to empty.
- if (obj.Identity.BirthDate != null)
+ if (Obj.Identity.BirthDate != null)
{
try
{
- DateTime.Parse(obj.Identity.BirthDate);
+ DateTime.Parse(Obj.Identity.BirthDate);
}
catch (Exception)
{
- obj.Identity.BirthDate = "1900-01-01";
+ Obj.Identity.BirthDate = "1900-01-01";
}
}
@@ -292,12 +295,12 @@ else
{
if (Id is not null)
{
- await AliasService.UpdateAliasAsync(obj, Id.Value);
+ await AliasService.UpdateAliasAsync(Obj, Id.Value);
}
}
else
{
- Id = await AliasService.InsertAliasAsync(obj);
+ Id = await AliasService.InsertAliasAsync(Obj);
}
IsSaving = false;
@@ -310,7 +313,5 @@ else
}
Navigation.NavigateTo("/alias/" + Id);
-
-
}
}
diff --git a/src/AliasVault.WebApp/Pages/Aliases/Delete.razor b/src/AliasVault.WebApp/Pages/Aliases/Delete.razor
index a2e60d2eb..66be0d5b5 100644
--- a/src/AliasVault.WebApp/Pages/Aliases/Delete.razor
+++ b/src/AliasVault.WebApp/Pages/Aliases/Delete.razor
@@ -32,7 +32,7 @@ else
</div>
<div class="mb-4">
<label class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Service name</label>
- <div>@obj?.Service.Name</div>
+ <div>@Obj?.Service.Name</div>
</div>
<button @onclick="DeleteConfirm" class="text-white bg-red-600 hover:bg-red-800 focus:ring-4 focus:ring-red-300 font-medium rounded-lg text-sm inline-flex items-center px-3 py-2.5 text-center mr-2 dark:focus:ring-red-900">
Yes, I'm sure
@@ -44,13 +44,17 @@ else
</div>
}
-
@code {
+ /// <summary>
+ /// Gets or sets the alias ID.
+ /// </summary>
[Parameter]
public Guid Id { get; set; }
+
private bool IsLoading { get; set; } = true;
- private Alias? obj;
+ private Alias? Obj { get; set; }
+ /// <inheritdoc />
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
@@ -58,30 +62,34 @@ else
BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = "Delete alias" });
}
+ /// <inheritdoc />
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
- // Load existing obj, retrieve from service
- obj = await AliasService.LoadAliasAsync(Id);
+ // Load existing Obj, retrieve from service
+ Obj = await AliasService.LoadAliasAsync(Id);
// Hide loading spinner
IsLoading = false;
+
// Force re-render invoke so the charts can be rendered
StateHasChanged();
-
}
}
private async void DeleteConfirm()
{
- if (obj != null)
+ if (Obj is null)
{
- await AliasService.DeleteAliasAsync(Id);
- NavigationManager.NavigateTo("/");
+ return;
}
+
+ await AliasService.DeleteAliasAsync(Id);
+ NavigationManager.NavigateTo("/");
}
- void Cancel()
+
+ private void Cancel()
{
NavigationManager.NavigateTo("/alias/" + Id);
}
diff --git a/src/AliasVault.WebApp/Pages/Aliases/View.razor b/src/AliasVault.WebApp/Pages/Aliases/View.razor
index 2164fa633..b1fa9007e 100644
--- a/src/AliasVault.WebApp/Pages/Aliases/View.razor
+++ b/src/AliasVault.WebApp/Pages/Aliases/View.razor
@@ -9,7 +9,7 @@
@if (IsLoading || Alias == null)
{
-<LoadingIndicator />
+ <LoadingIndicator />
}
else
{
diff --git a/src/AliasVault.WebApp/_Imports.razor b/src/AliasVault.WebApp/_Imports.razor
index 49d5dfa69..98b53de48 100644
--- a/src/AliasVault.WebApp/_Imports.razor
+++ b/src/AliasVault.WebApp/_Imports.razor
@@ -14,6 +14,7 @@
@using AliasVault.WebApp.Components
@using AliasVault.WebApp.Components.Models
@using AliasVault.WebApp.Components.Alerts
+@using AliasVault.WebApp.Components.Loading
@using AliasVault.WebApp.Pages.Base
@using Microsoft.AspNetCore.Components.Authorization
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
diff --git a/src/CSharpStyleguide.ruleset b/src/CSharpStyleguide.ruleset
index 54b7334f1..67949f086 100644
--- a/src/CSharpStyleguide.ruleset
+++ b/src/CSharpStyleguide.ruleset
@@ -20,7 +20,7 @@
<Rule Id="SA1303" Action="Error" /> <!-- Const field names must begin with upper case letter -->
<Rule Id="SA1309" Action="None" /> <!-- Field names must not begin with underscore -->
<Rule Id="SA1500" Action="Error" /> <!-- Curly brackets for multi line statements must not share line -->
- <Rule Id="SA1503" Action="None" /> <!-- Curly brackets must not be omitted -->
+ <Rule Id="SA1503" Action="Error" /> <!-- Curly brackets must not be omitted -->
<Rule Id="SA1507" Action="Error" /> <!-- Code must not contain multiple blank lines in a row -->
<Rule Id="SA1508" Action="Error" /> <!-- Closing curly brackets must not be preceded by blank line -->
<Rule Id="SA1509" Action="Error" /> <!-- Opening curly brackets must not be precededed by blank line -->