From c6ef654c87d22b8ff6c46c19e4cd9a1e38e4b0bd Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Fri, 12 Jul 2024 12:45:42 +0200 Subject: [PATCH] Layout update (#98) --- .../AliasVault.WebApp.csproj | 15 --- src/AliasVault.WebApp/Auth/Pages/Login.razor | 2 +- src/AliasVault.WebApp/Auth/Pages/Unlock.razor | 12 +- .../Main/Components/Email/RecentEmails.razor | 105 ++++++++++-------- .../Main/Layout/TopMenu.razor | 3 - .../Main/Pages/Credentials/AddEdit.razor | 9 +- .../Main/Pages/Credentials/Home.razor | 86 ++++++++++++++ .../Main/Pages/Credentials/View.razor | 4 +- src/AliasVault.WebApp/Main/Pages/Home.razor | 62 +---------- src/AliasVault.WebApp/Program.cs | 3 +- .../wwwroot/css/tailwind.css | 29 +++++ .../AliasClientDb/AliasClientDbContext.cs | 3 +- .../AliasVault.E2ETests.csproj | 2 +- .../Common/PlaywrightTest.cs | 4 - .../Tests/DbPersistTest.cs | 2 +- 15 files changed, 189 insertions(+), 152 deletions(-) create mode 100644 src/AliasVault.WebApp/Main/Pages/Credentials/Home.razor diff --git a/src/AliasVault.WebApp/AliasVault.WebApp.csproj b/src/AliasVault.WebApp/AliasVault.WebApp.csproj index 39b37fcc6..ef9c92a49 100644 --- a/src/AliasVault.WebApp/AliasVault.WebApp.csproj +++ b/src/AliasVault.WebApp/AliasVault.WebApp.csproj @@ -60,9 +60,6 @@ - - - PreserveNewest @@ -83,16 +80,4 @@ - - - - Never - - - - - <_ContentIncludedByDefault Remove="Main\Layout\StatusMessages\ErrorVaultDecrypt.razor" /> - <_ContentIncludedByDefault Remove="Main\Layout\StatusMessages\PendingMigrations.razor" /> - <_ContentIncludedByDefault Remove="Main\Layout\StatusMessages\VaultDecryptionProgress.razor" /> - diff --git a/src/AliasVault.WebApp/Auth/Pages/Login.razor b/src/AliasVault.WebApp/Auth/Pages/Login.razor index 8a24c0c89..14d0bef17 100644 --- a/src/AliasVault.WebApp/Auth/Pages/Login.razor +++ b/src/AliasVault.WebApp/Auth/Pages/Login.razor @@ -80,7 +80,7 @@ catch { // If in release mode show a generic error. - _serverValidationErrors.AddError("An error occurred while processing the login request. Try again (later)."); + ServerValidationErrors.AddError("An error occurred while processing the login request. Try again (later)."); } #endif finally diff --git a/src/AliasVault.WebApp/Auth/Pages/Unlock.razor b/src/AliasVault.WebApp/Auth/Pages/Unlock.razor index 69576764f..7b9a21f3c 100644 --- a/src/AliasVault.WebApp/Auth/Pages/Unlock.razor +++ b/src/AliasVault.WebApp/Auth/Pages/Unlock.razor @@ -14,7 +14,7 @@

- + @@ -38,7 +38,7 @@ private string? Email { get; set; } private readonly UnlockModel UnlockModel = new(); private FullScreenLoadingIndicator LoadingIndicator = new(); - private ServerValidationErrors _serverValidationErrors = new(); + private ServerValidationErrors ServerValidationErrors = new(); /// protected override async Task OnInitializedAsync() @@ -71,14 +71,14 @@ } LoadingIndicator.Show(); - _serverValidationErrors.Clear(); + ServerValidationErrors.Clear(); try { var errors = await ProcessLoginAsync(Email, UnlockModel.Password); foreach (var error in errors) { - _serverValidationErrors.AddError(error); + ServerValidationErrors.AddError(error); } StateHasChanged(); } @@ -86,13 +86,13 @@ catch (Exception ex) { // If in debug mode show the actual exception. - _serverValidationErrors.AddError(ex.ToString()); + ServerValidationErrors.AddError(ex.ToString()); } #else catch { // If in release mode show a generic error. - _serverValidationErrors.AddError("An error occurred while processing the login request. Try again (later)."); + ServerValidationErrors.AddError("An error occurred while processing the login request. Try again (later)."); } #endif finally diff --git a/src/AliasVault.WebApp/Main/Components/Email/RecentEmails.razor b/src/AliasVault.WebApp/Main/Components/Email/RecentEmails.razor index b84eeeb86..ea6d0cff3 100644 --- a/src/AliasVault.WebApp/Main/Components/Email/RecentEmails.razor +++ b/src/AliasVault.WebApp/Main/Components/Email/RecentEmails.razor @@ -4,67 +4,73 @@ @if (ShowComponent) { -
-

Email

- -
+
+
+

Email

+ +
- @if (IsLoading) - { - - } - else if (MailboxEmails.Count == 0) - { -
No emails found.
- } - else - { -
-
-
-
- - - - - - - - - @foreach (var mail in MailboxEmails) - { - - - + @if (IsLoading) + { + + } + else if (MailboxEmails.Count == 0) + { +
No emails found.
+ } + else + { +
+
+
+
+
- Subject - - Date & Time -
- @(mail.Subject.Substring(0, mail.Subject.Length > 30 ? 30 : mail.Subject.Length))... - - @mail.DateSystem -
+ + + + - } - -
+ Subject + + Date & Time +
+ + + @foreach (var mail in MailboxEmails) + { + + + @(mail.Subject.Substring(0, mail.Subject.Length > 30 ? 30 : mail.Subject.Length))... + + + @mail.DateSystem + + + } + + +
-
- } + } + } @code { + /// + /// The email address to show recent emails for. + /// [Parameter] public string Email { get; set; } = string.Empty; - [Parameter] - public List MailboxEmails { get; set; } = new List(); - public bool IsLoading { get; set; } = true; + + private List MailboxEmails { get; set; } = new(); + private bool IsLoading { get; set; } = true; private bool ShowComponent { get; set; } = false; + /// protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); @@ -76,6 +82,7 @@ } } + /// protected override async Task OnAfterRenderAsync(bool firstRender) { await base.OnAfterRenderAsync(firstRender); diff --git a/src/AliasVault.WebApp/Main/Layout/TopMenu.razor b/src/AliasVault.WebApp/Main/Layout/TopMenu.razor index 5c96375c4..a10499e83 100644 --- a/src/AliasVault.WebApp/Main/Layout/TopMenu.razor +++ b/src/AliasVault.WebApp/Main/Layout/TopMenu.razor @@ -13,9 +13,6 @@ -
- -
+ @if (Alias.Notes != null && Alias.Notes.Length > 0) {
diff --git a/src/AliasVault.WebApp/Main/Pages/Home.razor b/src/AliasVault.WebApp/Main/Pages/Home.razor index 6d154f9f8..4b2d396de 100644 --- a/src/AliasVault.WebApp/Main/Pages/Home.razor +++ b/src/AliasVault.WebApp/Main/Pages/Home.razor @@ -1,67 +1,13 @@ @page "/" -@page "/credentials" @inherits MainBase -@inject CredentialService CredentialService - -Home - -
-
- -
-

Credentials

- - + Add new credentials - -
-

Find all of your credentials below.

-
-
- -@if (IsLoading) -{ - -} - -
- @foreach (var credential in Credentials) - { - - } -
- @code { - private bool IsLoading { get; set; } = true; - private List Credentials { get; set; } = new(); - /// - protected override async Task OnAfterRenderAsync(bool firstRender) + protected override async Task OnInitializedAsync() { - await base.OnAfterRenderAsync(firstRender); + await base.OnInitializedAsync(); - if (firstRender) - { - await LoadCredentialsAsync(); - } - } - - private async Task LoadCredentialsAsync() - { - IsLoading = true; - StateHasChanged(); - - // Load the aliases from the webapi via AliasService. - var credentialListEntries = await CredentialService.GetListAsync(); - if (credentialListEntries is null) - { - // Error loading aliases. - GlobalNotificationService.AddErrorMessage("Failed to load credentials.", true); - return; - } - - Credentials = credentialListEntries; - IsLoading = false; - StateHasChanged(); + // Redirect to /credentials. + NavigationManager.NavigateTo("/credentials"); } } diff --git a/src/AliasVault.WebApp/Program.cs b/src/AliasVault.WebApp/Program.cs index 69ba22814..4ddbd7334 100644 --- a/src/AliasVault.WebApp/Program.cs +++ b/src/AliasVault.WebApp/Program.cs @@ -7,7 +7,6 @@ using AliasVault.WebApp; using AliasVault.WebApp.Providers; -using AliasVault.WebApp.Services.Auth; using Blazored.LocalStorage; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.AspNetCore.Components.Web; @@ -17,7 +16,7 @@ var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.Services.AddLogging(logging => { - logging.SetMinimumLevel(LogLevel.Information); + logging.SetMinimumLevel(LogLevel.Warning); logging.AddFilter("Microsoft.AspNetCore.Identity.DataProtectorTokenProvider", LogLevel.Error); logging.AddFilter("Microsoft.AspNetCore.Identity.UserManager", LogLevel.Error); }); diff --git a/src/AliasVault.WebApp/wwwroot/css/tailwind.css b/src/AliasVault.WebApp/wwwroot/css/tailwind.css index 7d95f5a55..94fe579c9 100644 --- a/src/AliasVault.WebApp/wwwroot/css/tailwind.css +++ b/src/AliasVault.WebApp/wwwroot/css/tailwind.css @@ -631,6 +631,14 @@ video { grid-column: 1 / -1; } +.m-6 { + margin: 1.5rem; +} + +.m-4 { + margin: 1rem; +} + .mx-3 { margin-left: 0.75rem; margin-right: 0.75rem; @@ -646,6 +654,11 @@ video { margin-bottom: 1rem; } +.mx-4 { + margin-left: 1rem; + margin-right: 1rem; +} + .-ml-1 { margin-left: -0.25rem; } @@ -682,6 +695,10 @@ video { margin-left: 0.75rem; } +.ml-5 { + margin-left: 1.25rem; +} + .ml-auto { margin-left: auto; } @@ -726,6 +743,14 @@ video { margin-top: 2rem; } +.ml-4 { + margin-left: 1rem; +} + +.ml-6 { + margin-left: 1.5rem; +} + .block { display: block; } @@ -766,6 +791,10 @@ video { height: 3rem; } +.h-32 { + height: 8rem; +} + .h-4 { height: 1rem; } diff --git a/src/Databases/AliasClientDb/AliasClientDbContext.cs b/src/Databases/AliasClientDb/AliasClientDbContext.cs index 97ce02c62..519f71d4f 100644 --- a/src/Databases/AliasClientDb/AliasClientDbContext.cs +++ b/src/Databases/AliasClientDb/AliasClientDbContext.cs @@ -145,8 +145,7 @@ public class AliasClientDbContext : DbContext { var optionsBuilder = new DbContextOptionsBuilder(); optionsBuilder.UseSqlite(connection); - - optionsBuilder.LogTo(logAction, new[] { DbLoggerCategory.Database.Command.Name }, LogLevel.Information); + optionsBuilder.LogTo(logAction, new[] { DbLoggerCategory.Database.Command.Name }, LogLevel.Warning); return optionsBuilder.Options; } diff --git a/src/Tests/AliasVault.E2ETests/AliasVault.E2ETests.csproj b/src/Tests/AliasVault.E2ETests/AliasVault.E2ETests.csproj index fe69f59f6..4550445e5 100644 --- a/src/Tests/AliasVault.E2ETests/AliasVault.E2ETests.csproj +++ b/src/Tests/AliasVault.E2ETests/AliasVault.E2ETests.csproj @@ -53,7 +53,7 @@ PreserveNewest - + PreserveNewest diff --git a/src/Tests/AliasVault.E2ETests/Common/PlaywrightTest.cs b/src/Tests/AliasVault.E2ETests/Common/PlaywrightTest.cs index 814bdaa0d..c68716b46 100644 --- a/src/Tests/AliasVault.E2ETests/Common/PlaywrightTest.cs +++ b/src/Tests/AliasVault.E2ETests/Common/PlaywrightTest.cs @@ -241,10 +241,6 @@ public class PlaywrightTest // If password is not set by test explicitly, generate a random password. TestUserPassword = TestUserPassword.Length > 0 ? TestUserPassword : Guid.NewGuid().ToString(); - // Check that we get redirected to /user/login when accessing the root URL and not authenticated. - await Page.GotoAsync(AppBaseUrl); - await WaitForURLAsync("**/user/login"); - // Try to register a new account. var registerButton = Page.Locator("a[href='/user/register']"); await registerButton.ClickAsync(); diff --git a/src/Tests/AliasVault.E2ETests/Tests/DbPersistTest.cs b/src/Tests/AliasVault.E2ETests/Tests/DbPersistTest.cs index 3cb02c0a6..d7d3726b8 100644 --- a/src/Tests/AliasVault.E2ETests/Tests/DbPersistTest.cs +++ b/src/Tests/AliasVault.E2ETests/Tests/DbPersistTest.cs @@ -37,7 +37,7 @@ public class DbPersistTest : PlaywrightTest await RefreshPageAndUnlockVault(); // Wait for the credentials page to load again. - await WaitForURLAsync("**/credentials/**", "View credentials entry"); + await WaitForURLAsync("**/credentials"); // Check if the service name is still present in the content. pageContent = await Page.TextContentAsync("body");