Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Refactor table to common SortableTable component (#220)
Leendert de Borstbbb168d764a3
diff --git a/src/AliasVault.Admin/Main/Pages/Logging/Auth.razor b/src/AliasVault.Admin/Main/Pages/Logging/Auth.razorindex 5981d1a29..ced490889 100644--- a/src/AliasVault.Admin/Main/Pages/Logging/Auth.razor+++ b/src/AliasVault.Admin/Main/Pages/Logging/Auth.razor@@ -1,4 +1,5 @@@page "/logging/auth"+@using AliasVault.RazorComponents.Tables@using AliasVault.Shared.Models.Enums@inherits MainBase@@ -39,6 +40,21 @@ else</div></div></div>++ <SortableTable TItem="Log" Columns="@_tableColumns" SortColumn="@SortColumn" SortDirection="@SortDirection" OnSortChanged="HandleSortChanged">+ @foreach (var log in LogList)+ {+ <tr class="bg-white border-b hover:bg-gray-50">+ <td class="px-4 py-3 font-medium text-gray-900">@log.Id</td>+ <td class="px-4 py-3">@log.Timestamp.ToString("yyyy-MM-dd HH:mm")</td>+ <td class="px-4 py-3">@log.Username</td>+ <td class="px-4 py-3">@log.EventType</td>+ <td class="px-4 py-3"><StatusPill Enabled="log.IsSuccess" TextTrue="Success" TextFalse="Failed" /></td>+ <td class="px-4 py-3">@log.IpAddress</td>+ </tr>+ }+ </SortableTable>+<table class="w-full text-sm text-left text-gray-500 shadow rounded border"><thead class="text-xs text-gray-700 uppercase bg-gray-50"><tr>@@ -68,6 +84,15 @@ else}@code {+ private readonly List<TableColumn> _tableColumns = [+ new TableColumn { Title = "ID", PropertyName = "Id" },+ new TableColumn { Title = "Time", PropertyName = "Timestamp" },+ new TableColumn { Title = "Username", PropertyName = "Username" },+ new TableColumn { Title = "Event", PropertyName = "EventType" },+ new TableColumn { Title = "Success", PropertyName = "IsSuccess" },+ new TableColumn { Title = "IP", PropertyName = "IpAddress" },+ ];+private List<AuthLog> LogList { get; set; } = [];private bool IsLoading { get; set; } = true;private int CurrentPage { get; set; } = 1;@@ -102,6 +127,16 @@ else}}+ private string SortColumn { get; set; } = "Id";+ private SortDirection SortDirection { get; set; } = SortDirection.Descending;++ private async Task HandleSortChanged((string column, SortDirection direction) sort)+ {+ SortColumn = sort.column;+ SortDirection = sort.direction;+ await RefreshData();+ }+/// <inheritdoc />protected override async Task OnAfterRenderAsync(bool firstRender){@@ -138,9 +173,43 @@ else}}+ // Apply sort.+ switch (SortColumn)+ {+ case "Timestamp":+ query = SortDirection == SortDirection.Ascending+ ? query.OrderBy(x => x.Timestamp)+ : query.OrderByDescending(x => x.Timestamp);+ break;+ case "Username":+ query = SortDirection == SortDirection.Ascending+ ? query.OrderBy(x => x.Username)+ : query.OrderByDescending(x => x.Username);+ break;+ case "EventType":+ query = SortDirection == SortDirection.Ascending+ ? query.OrderBy(x => x.EventType)+ : query.OrderByDescending(x => x.EventType);+ break;+ case "IsSuccess":+ query = SortDirection == SortDirection.Ascending+ ? query.OrderBy(x => x.IsSuccess)+ : query.OrderByDescending(x => x.IsSuccess);+ break;+ case "IpAddress":+ query = SortDirection == SortDirection.Ascending+ ? query.OrderBy(x => x.IpAddress)+ : query.OrderByDescending(x => x.IpAddress);+ break;+ default:+ query = SortDirection == SortDirection.Ascending+ ? query.OrderBy(x => x.Id)+ : query.OrderByDescending(x => x.Id);+ break;+ }+TotalRecords = await query.CountAsync();LogList = await query- .OrderByDescending(x => x.Timestamp).Skip((CurrentPage - 1) * PageSize).Take(PageSize).ToListAsync();diff --git a/src/AliasVault.Admin/Main/Pages/Logging/General.razor b/src/AliasVault.Admin/Main/Pages/Logging/General.razorindex 151729827..c5d7389aa 100644--- a/src/AliasVault.Admin/Main/Pages/Logging/General.razor+++ b/src/AliasVault.Admin/Main/Pages/Logging/General.razor@@ -1,4 +1,5 @@@page "/logging/general"+@using AliasVault.RazorComponents.Tables@inherits MainBase<LayoutPageTitle>System logs</LayoutPageTitle>@@ -32,60 +33,57 @@ else<option value="">All Services</option>@foreach (var service in ServiceNames){- <option value="@service">@service</option>+ <option value="@service">@service</option>}</select></div></div></div>- <table class="w-full text-sm text-left text-gray-500 shadow rounded border">- <thead class="text-xs text-gray-700 uppercase bg-gray-50">- <tr>- <th scope="col" class="px-4 py-3">ID</th>- <th scope="col" class="px-4 py-3">Time</th>- <th scope="col" class="px-4 py-3">Application</th>- <th scope="col" class="px-4 py-3">Level</th>- <th scope="col" class="px-4 py-3">Message</th>- </tr>- </thead>- <tbody>- @foreach (var log in LogList)- {- <tr class="bg-white border-b hover:bg-gray-50">- <td class="px-4 py-3 font-medium text-gray-900">@log.Id</td>- <td class="px-4 py-3">@log.TimeStamp.ToString("yyyy-MM-dd HH:mm")</td>- <td class="px-4 py-3">@log.Application</td>-- @{- string bgColor = log.Level switch- {- "Information" => "bg-blue-500",- "Error" => "bg-red-500",- "Warning" => "bg-yellow-500",- "Debug" => "bg-green-500",- _ => "bg-gray-500"- };++ <SortableTable TItem="Log" Columns="@_tableColumns" SortColumn="@SortColumn" SortDirection="@SortDirection" OnSortChanged="HandleSortChanged">+ @foreach (var log in LogList)+ {+ <tr class="bg-white border-b hover:bg-gray-50">+ <td class="px-4 py-3 font-medium text-gray-900">@log.Id</td>+ <td class="px-4 py-3">@log.TimeStamp.ToString("yyyy-MM-dd HH:mm")</td>+ <td class="px-4 py-3">@log.Application</td>+ @{+ string bgColor = log.Level switch+ {+ "Information" => "bg-blue-500",+ "Error" => "bg-red-500",+ "Warning" => "bg-yellow-500",+ "Debug" => "bg-green-500",+ _ => "bg-gray-500"+ };+ }+ <td class="px-4 py-3">+ <span class="px-2 py-1 rounded-full text-white @bgColor">+ @log.Level+ </span>+ </td>+ <td class="px-4 py-3" title="@log.Exception">+ @if (log.SourceContext.Length > 0)+ {+ <span>@log.SourceContext: </span>}- <td class="px-4 py-3">- <span class="px-2 py-1 rounded-full text-white @bgColor">- @log.Level- </span>- </td>- <td class="px-4 py-3" title="@log.Exception">- @if (log.SourceContext.Length > 0)- {- <span>@log.SourceContext: </span>- }- @log.Message- </td>- </tr>- }- </tbody>- </table>+ @log.Message+ </td>+ </tr>+ }+ </SortableTable></div>}@code {+ private readonly List<TableColumn> _tableColumns = [+ new TableColumn { Title = "ID", PropertyName = "Id" },+ new TableColumn { Title = "Time", PropertyName = "Timestamp" },+ new TableColumn { Title = "Application", PropertyName = "Application" },+ new TableColumn { Title = "Level", PropertyName = "Level" },+ new TableColumn { Title = "Message", PropertyName = "Message" },+ ];+private List<Log> LogList { get; set; } = [];private bool IsLoading { get; set; } = true;private int CurrentPage { get; set; } = 1;@@ -122,6 +120,16 @@ elseprivate List<string> ServiceNames { get; set; } = [];+ private string SortColumn { get; set; } = "Id";+ private SortDirection SortDirection { get; set; } = SortDirection.Descending;++ private async Task HandleSortChanged((string column, SortDirection direction) sort)+ {+ SortColumn = sort.column;+ SortDirection = sort.direction;+ await RefreshData();+ }+/// <inheritdoc />protected override async Task OnAfterRenderAsync(bool firstRender){@@ -132,7 +140,6 @@ else}}-private void HandlePageChanged(int newPage){CurrentPage = newPage;@@ -158,9 +165,38 @@ elsequery = query.Where(x => x.Application == SelectedServiceName);}+ // Apply sort.+ switch (SortColumn)+ {+ case "Application":+ query = SortDirection == SortDirection.Ascending+ ? query.OrderBy(x => x.Application)+ : query.OrderByDescending(x => x.Application);+ break;+ case "Message":+ query = SortDirection == SortDirection.Ascending+ ? query.OrderBy(x => x.Message)+ : query.OrderByDescending(x => x.Message);+ break;+ case "Level":+ query = SortDirection == SortDirection.Ascending+ ? query.OrderBy(x => x.Level)+ : query.OrderByDescending(x => x.Level);+ break;+ case "Timestamp":+ query = SortDirection == SortDirection.Ascending+ ? query.OrderBy(x => x.TimeStamp)+ : query.OrderByDescending(x => x.TimeStamp);+ break;+ default:+ query = SortDirection == SortDirection.Ascending+ ? query.OrderBy(x => x.Id)+ : query.OrderByDescending(x => x.Id);+ break;+ }+TotalRecords = await query.CountAsync();LogList = await query- .OrderByDescending(x => x.Id).Skip((CurrentPage - 1) * PageSize).Take(PageSize).ToListAsync();diff --git a/src/AliasVault.Admin/wwwroot/css/tailwind.css b/src/AliasVault.Admin/wwwroot/css/tailwind.cssindex 0f356110e..ea97227db 100644--- a/src/AliasVault.Admin/wwwroot/css/tailwind.css+++ b/src/AliasVault.Admin/wwwroot/css/tailwind.css@@ -751,6 +751,10 @@ video {margin-inline-start: 0.25rem;}+.ml-1 {+ margin-left: 0.25rem;+}+.line-clamp-1 {overflow: hidden;display: -webkit-box;@@ -822,6 +826,10 @@ video {height: 100%;}+.h-3 {+ height: 0.75rem;+}+.w-1\/2 {width: 50%;}@@ -874,6 +882,10 @@ video {width: 100%;}+.w-3 {+ width: 0.75rem;+}+.max-w-2xl {max-width: 42rem;}diff --git a/src/AliasVault.Client/wwwroot/css/tailwind.css b/src/AliasVault.Client/wwwroot/css/tailwind.cssindex 79e323daf..4b0fb961d 100644--- a/src/AliasVault.Client/wwwroot/css/tailwind.css+++ b/src/AliasVault.Client/wwwroot/css/tailwind.css@@ -763,6 +763,10 @@ video {margin-top: 2rem;}+.ml-1 {+ margin-left: 0.25rem;+}+.line-clamp-2 {overflow: hidden;display: -webkit-box;diff --git a/src/Databases/AliasServerDb/AliasServerDbContext.cs b/src/Databases/AliasServerDb/AliasServerDbContext.csindex 31e71426b..9309f30ab 100644--- a/src/Databases/AliasServerDb/AliasServerDbContext.cs+++ b/src/Databases/AliasServerDb/AliasServerDbContext.cs@@ -133,17 +133,20 @@ public class AliasServerDbContext : WorkerStatusDbContext, IDataProtectionKeyConprotected override void OnModelCreating(ModelBuilder modelBuilder){base.OnModelCreating(modelBuilder);- foreach (var entity in modelBuilder.Model.GetEntityTypes())++ // NOTE: This is a workaround for SQLite. Add conditional check if SQLite is used.+ // NOTE: SQL server doesn't need this override.+ if (Database.IsSqlite()){- foreach (var property in entity.GetProperties())+ foreach (var entity in modelBuilder.Model.GetEntityTypes()){- // NOTE: This is a workaround for SQLite. Add conditional check if SQLite is used.- // NOTE: SQL server doesn't need this override.-- // SQLite does not support varchar(max) so we use TEXT.- if (property.ClrType == typeof(string) && property.GetMaxLength() == null)+ foreach (var property in entity.GetProperties()){- property.SetColumnType("TEXT");+ // SQLite does not support varchar(max) so we use TEXT.+ if (property.ClrType == typeof(string) && property.GetMaxLength() == null)+ {+ property.SetColumnType("TEXT");+ }}}}diff --git a/src/Databases/AliasServerDb/Log.cs b/src/Databases/AliasServerDb/Log.csindex 6e0370660..90a22146b 100644--- a/src/Databases/AliasServerDb/Log.cs+++ b/src/Databases/AliasServerDb/Log.cs@@ -54,7 +54,7 @@ public class Log/// <summary>/// Gets or sets the timestamp of the log entry./// </summary>- public DateTimeOffset TimeStamp { get; set; }+ public DateTime TimeStamp { get; set; }/// <summary>/// Gets or sets the exception associated with the log entry.diff --git a/src/Databases/AliasServerDb/Migrations/20241007153012_DatetimeOffsetToDateTime.Designer.cs b/src/Databases/AliasServerDb/Migrations/20241007153012_DatetimeOffsetToDateTime.Designer.csnew file mode 100644index 000000000..2467b8299--- /dev/null+++ b/src/Databases/AliasServerDb/Migrations/20241007153012_DatetimeOffsetToDateTime.Designer.cs@@ -0,0 +1,831 @@+// <auto-generated />+using System;+using AliasServerDb;+using Microsoft.EntityFrameworkCore;+using Microsoft.EntityFrameworkCore.Infrastructure;+using Microsoft.EntityFrameworkCore.Migrations;+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;++#nullable disable++namespace AliasServerDb.Migrations+{+ [DbContext(typeof(AliasServerDbContext))]+ [Migration("20241007153012_DatetimeOffsetToDateTime")]+ partial class DatetimeOffsetToDateTime+ {+ /// <inheritdoc />+ protected override void BuildTargetModel(ModelBuilder modelBuilder)+ {+#pragma warning disable 612, 618+ modelBuilder+ .HasAnnotation("ProductVersion", "8.0.8")+ .HasAnnotation("Proxies:ChangeTracking", false)+ .HasAnnotation("Proxies:CheckEquality", false)+ .HasAnnotation("Proxies:LazyLoading", true);++ modelBuilder.Entity("AliasServerDb.AdminRole", b =>+ {+ b.Property<string>("Id")+ .HasColumnType("TEXT");++ b.Property<string>("ConcurrencyStamp")+ .HasColumnType("TEXT");++ b.Property<string>("Name")+ .HasColumnType("TEXT");++ b.Property<string>("NormalizedName")+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.ToTable("AdminRoles");+ });++ modelBuilder.Entity("AliasServerDb.AdminUser", b =>+ {+ b.Property<string>("Id")+ .HasColumnType("TEXT");++ b.Property<int>("AccessFailedCount")+ .HasColumnType("INTEGER");++ b.Property<string>("ConcurrencyStamp")+ .HasColumnType("TEXT");++ b.Property<string>("Email")+ .HasColumnType("TEXT");++ b.Property<bool>("EmailConfirmed")+ .HasColumnType("INTEGER");++ b.Property<DateTime?>("LastPasswordChanged")+ .HasColumnType("TEXT");++ b.Property<bool>("LockoutEnabled")+ .HasColumnType("INTEGER");++ b.Property<DateTimeOffset?>("LockoutEnd")+ .HasColumnType("TEXT");++ b.Property<string>("NormalizedEmail")+ .HasColumnType("TEXT");++ b.Property<string>("NormalizedUserName")+ .HasColumnType("TEXT");++ b.Property<string>("PasswordHash")+ .HasColumnType("TEXT");++ b.Property<string>("PhoneNumber")+ .HasColumnType("TEXT");++ b.Property<bool>("PhoneNumberConfirmed")+ .HasColumnType("INTEGER");++ b.Property<string>("SecurityStamp")+ .HasColumnType("TEXT");++ b.Property<bool>("TwoFactorEnabled")+ .HasColumnType("INTEGER");++ b.Property<string>("UserName")+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.ToTable("AdminUsers");+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultRole", b =>+ {+ b.Property<string>("Id")+ .HasColumnType("TEXT");++ b.Property<string>("ConcurrencyStamp")+ .HasColumnType("TEXT");++ b.Property<string>("Name")+ .HasColumnType("TEXT");++ b.Property<string>("NormalizedName")+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.ToTable("AliasVaultRoles");+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>+ {+ b.Property<string>("Id")+ .HasColumnType("TEXT");++ b.Property<int>("AccessFailedCount")+ .HasColumnType("INTEGER");++ b.Property<string>("ConcurrencyStamp")+ .HasColumnType("TEXT");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("TEXT");++ b.Property<string>("Email")+ .HasColumnType("TEXT");++ b.Property<bool>("EmailConfirmed")+ .HasColumnType("INTEGER");++ b.Property<bool>("LockoutEnabled")+ .HasColumnType("INTEGER");++ b.Property<DateTimeOffset?>("LockoutEnd")+ .HasColumnType("TEXT");++ b.Property<string>("NormalizedEmail")+ .HasColumnType("TEXT");++ b.Property<string>("NormalizedUserName")+ .HasColumnType("TEXT");++ b.Property<DateTime>("PasswordChangedAt")+ .HasColumnType("TEXT");++ b.Property<string>("PasswordHash")+ .HasColumnType("TEXT");++ b.Property<string>("PhoneNumber")+ .HasColumnType("TEXT");++ b.Property<bool>("PhoneNumberConfirmed")+ .HasColumnType("INTEGER");++ b.Property<string>("SecurityStamp")+ .HasColumnType("TEXT");++ b.Property<bool>("TwoFactorEnabled")+ .HasColumnType("INTEGER");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("TEXT");++ b.Property<string>("UserName")+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.ToTable("AliasVaultUsers");+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultUserRefreshToken", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("TEXT");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("TEXT");++ b.Property<string>("DeviceIdentifier")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.Property<DateTime>("ExpireDate")+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.Property<string>("IpAddress")+ .HasMaxLength(45)+ .HasColumnType("TEXT");++ b.Property<string>("PreviousTokenValue")+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.Property<string>("Value")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.HasIndex("UserId");++ b.ToTable("AliasVaultUserRefreshTokens");+ });++ modelBuilder.Entity("AliasServerDb.AuthLog", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<string>("AdditionalInfo")+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.Property<string>("Browser")+ .HasMaxLength(100)+ .HasColumnType("TEXT");++ b.Property<string>("Country")+ .HasMaxLength(50)+ .HasColumnType("TEXT");++ b.Property<string>("DeviceType")+ .HasMaxLength(100)+ .HasColumnType("TEXT");++ b.Property<int>("EventType")+ .HasColumnType("nvarchar(50)");++ b.Property<int?>("FailureReason")+ .HasColumnType("INTEGER");++ b.Property<string>("IpAddress")+ .HasMaxLength(50)+ .HasColumnType("TEXT");++ b.Property<bool>("IsSuccess")+ .HasColumnType("INTEGER");++ b.Property<bool>("IsSuspiciousActivity")+ .HasColumnType("INTEGER");++ b.Property<string>("OperatingSystem")+ .HasMaxLength(100)+ .HasColumnType("TEXT");++ b.Property<string>("RequestPath")+ .HasMaxLength(100)+ .HasColumnType("TEXT");++ b.Property<DateTime>("Timestamp")+ .HasColumnType("TEXT");++ b.Property<string>("UserAgent")+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.Property<string>("Username")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.HasIndex(new[] { "EventType" }, "IX_EventType");++ b.HasIndex(new[] { "IpAddress" }, "IX_IpAddress");++ b.HasIndex(new[] { "Timestamp" }, "IX_Timestamp");++ b.HasIndex(new[] { "Username", "IsSuccess", "Timestamp" }, "IX_Username_IsSuccess_Timestamp")+ .IsDescending(false, false, true);++ b.HasIndex(new[] { "Username", "Timestamp" }, "IX_Username_Timestamp")+ .IsDescending(false, true);++ b.ToTable("AuthLogs");+ });++ modelBuilder.Entity("AliasServerDb.Email", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<DateTime>("Date")+ .HasColumnType("TEXT");++ b.Property<DateTime>("DateSystem")+ .HasColumnType("TEXT");++ b.Property<string>("EncryptedSymmetricKey")+ .IsRequired()+ .HasColumnType("TEXT");++ b.Property<string>("From")+ .IsRequired()+ .HasColumnType("TEXT");++ b.Property<string>("FromDomain")+ .IsRequired()+ .HasColumnType("TEXT");++ b.Property<string>("FromLocal")+ .IsRequired()+ .HasColumnType("TEXT");++ b.Property<string>("MessageHtml")+ .HasColumnType("TEXT");++ b.Property<string>("MessagePlain")+ .HasColumnType("TEXT");++ b.Property<string>("MessagePreview")+ .HasColumnType("TEXT");++ b.Property<string>("MessageSource")+ .IsRequired()+ .HasColumnType("TEXT");++ b.Property<bool>("PushNotificationSent")+ .HasColumnType("INTEGER");++ b.Property<string>("Subject")+ .IsRequired()+ .HasColumnType("TEXT");++ b.Property<string>("To")+ .IsRequired()+ .HasColumnType("TEXT");++ b.Property<string>("ToDomain")+ .IsRequired()+ .HasColumnType("TEXT");++ b.Property<string>("ToLocal")+ .IsRequired()+ .HasColumnType("TEXT");++ b.Property<Guid>("UserEncryptionKeyId")+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.Property<bool>("Visible")+ .HasColumnType("INTEGER");++ b.HasKey("Id");++ b.HasIndex("Date");++ b.HasIndex("DateSystem");++ b.HasIndex("PushNotificationSent");++ b.HasIndex("ToLocal");++ b.HasIndex("UserEncryptionKeyId");++ b.HasIndex("Visible");++ b.ToTable("Emails");+ });++ modelBuilder.Entity("AliasServerDb.EmailAttachment", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<byte[]>("Bytes")+ .IsRequired()+ .HasColumnType("BLOB");++ b.Property<DateTime>("Date")+ .HasColumnType("TEXT");++ b.Property<int>("EmailId")+ .HasColumnType("INTEGER");++ b.Property<string>("Filename")+ .IsRequired()+ .HasColumnType("TEXT");++ b.Property<int>("Filesize")+ .HasColumnType("INTEGER");++ b.Property<string>("MimeType")+ .IsRequired()+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.HasIndex("EmailId");++ b.ToTable("EmailAttachments");+ });++ modelBuilder.Entity("AliasServerDb.Log", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<string>("Application")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("TEXT");++ b.Property<string>("Exception")+ .IsRequired()+ .HasColumnType("TEXT");++ b.Property<string>("Level")+ .IsRequired()+ .HasMaxLength(128)+ .HasColumnType("TEXT");++ b.Property<string>("LogEvent")+ .IsRequired()+ .HasColumnType("TEXT")+ .HasColumnName("LogEvent");++ b.Property<string>("Message")+ .IsRequired()+ .HasColumnType("TEXT");++ b.Property<string>("MessageTemplate")+ .IsRequired()+ .HasColumnType("TEXT");++ b.Property<string>("Properties")+ .IsRequired()+ .HasColumnType("TEXT");++ b.Property<string>("SourceContext")+ .IsRequired()+ .HasColumnType("TEXT");++ b.Property<DateTime>("TimeStamp")+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.HasIndex("Application");++ b.HasIndex("TimeStamp");++ b.ToTable("Logs", (string)null);+ });++ modelBuilder.Entity("AliasServerDb.UserEmailClaim", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("TEXT");++ b.Property<string>("Address")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.Property<string>("AddressDomain")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.Property<string>("AddressLocal")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("TEXT");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("TEXT");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.HasIndex("Address")+ .IsUnique();++ b.HasIndex("UserId");++ b.ToTable("UserEmailClaims");+ });++ modelBuilder.Entity("AliasServerDb.UserEncryptionKey", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("TEXT");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("TEXT");++ b.Property<bool>("IsPrimary")+ .HasColumnType("INTEGER");++ b.Property<string>("PublicKey")+ .IsRequired()+ .HasMaxLength(2000)+ .HasColumnType("TEXT");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("TEXT");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.HasIndex("UserId");++ b.ToTable("UserEncryptionKeys");+ });++ modelBuilder.Entity("AliasServerDb.Vault", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("TEXT");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("TEXT");++ b.Property<int>("CredentialsCount")+ .HasColumnType("INTEGER");++ b.Property<int>("EmailClaimsCount")+ .HasColumnType("INTEGER");++ b.Property<string>("EncryptionSettings")+ .IsRequired()+ .HasColumnType("TEXT");++ b.Property<string>("EncryptionType")+ .IsRequired()+ .HasColumnType("TEXT");++ b.Property<int>("FileSize")+ .HasColumnType("INTEGER");++ b.Property<long>("RevisionNumber")+ .HasColumnType("INTEGER");++ b.Property<string>("Salt")+ .IsRequired()+ .HasMaxLength(100)+ .HasColumnType("TEXT");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("TEXT");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.Property<string>("VaultBlob")+ .IsRequired()+ .HasColumnType("TEXT");++ b.Property<string>("Verifier")+ .IsRequired()+ .HasMaxLength(1000)+ .HasColumnType("TEXT");++ b.Property<string>("Version")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.HasIndex("UserId");++ b.ToTable("Vaults");+ });++ modelBuilder.Entity("AliasVault.WorkerStatus.Database.WorkerServiceStatus", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<string>("CurrentStatus")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("TEXT");++ b.Property<string>("DesiredStatus")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("TEXT");++ b.Property<DateTime>("Heartbeat")+ .HasColumnType("TEXT");++ b.Property<string>("ServiceName")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("varchar");++ b.HasKey("Id");++ b.ToTable("WorkerServiceStatuses");+ });++ modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<string>("FriendlyName")+ .HasColumnType("TEXT");++ b.Property<string>("Xml")+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.ToTable("DataProtectionKeys");+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<string>("ClaimType")+ .HasColumnType("TEXT");++ b.Property<string>("ClaimValue")+ .HasColumnType("TEXT");++ b.Property<string>("RoleId")+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.ToTable("RoleClaims", (string)null);+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<string>("ClaimType")+ .HasColumnType("TEXT");++ b.Property<string>("ClaimValue")+ .HasColumnType("TEXT");++ b.Property<string>("UserId")+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.ToTable("UserClaims", (string)null);+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>+ {+ b.Property<string>("LoginProvider")+ .HasColumnType("TEXT");++ b.Property<string>("ProviderKey")+ .HasColumnType("TEXT");++ b.Property<string>("ProviderDisplayName")+ .HasColumnType("TEXT");++ b.Property<string>("UserId")+ .HasColumnType("TEXT");++ b.HasKey("LoginProvider", "ProviderKey");++ b.ToTable("UserLogins", (string)null);+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>+ {+ b.Property<string>("UserId")+ .HasColumnType("TEXT");++ b.Property<string>("RoleId")+ .HasColumnType("TEXT");++ b.HasKey("UserId", "RoleId");++ b.ToTable("UserRoles", (string)null);+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>+ {+ b.Property<string>("UserId")+ .HasColumnType("TEXT");++ b.Property<string>("LoginProvider")+ .HasColumnType("TEXT");++ b.Property<string>("Name")+ .HasColumnType("TEXT");++ b.Property<string>("Value")+ .HasColumnType("TEXT");++ b.HasKey("UserId", "LoginProvider", "Name");++ b.ToTable("UserTokens", (string)null);+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultUserRefreshToken", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.Email", b =>+ {+ b.HasOne("AliasServerDb.UserEncryptionKey", "EncryptionKey")+ .WithMany("Emails")+ .HasForeignKey("UserEncryptionKeyId")+ .OnDelete(DeleteBehavior.NoAction)+ .IsRequired();++ b.Navigation("EncryptionKey");+ });++ modelBuilder.Entity("AliasServerDb.EmailAttachment", b =>+ {+ b.HasOne("AliasServerDb.Email", "Email")+ .WithMany("Attachments")+ .HasForeignKey("EmailId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Email");+ });++ modelBuilder.Entity("AliasServerDb.UserEmailClaim", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany("EmailClaims")+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.UserEncryptionKey", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany("EncryptionKeys")+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.Vault", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany("Vaults")+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>+ {+ b.Navigation("EmailClaims");++ b.Navigation("EncryptionKeys");++ b.Navigation("Vaults");+ });++ modelBuilder.Entity("AliasServerDb.Email", b =>+ {+ b.Navigation("Attachments");+ });++ modelBuilder.Entity("AliasServerDb.UserEncryptionKey", b =>+ {+ b.Navigation("Emails");+ });+#pragma warning restore 612, 618+ }+ }+}diff --git a/src/Databases/AliasServerDb/Migrations/20241007153012_DatetimeOffsetToDateTime.cs b/src/Databases/AliasServerDb/Migrations/20241007153012_DatetimeOffsetToDateTime.csnew file mode 100644index 000000000..483a37051--- /dev/null+++ b/src/Databases/AliasServerDb/Migrations/20241007153012_DatetimeOffsetToDateTime.cs@@ -0,0 +1,22 @@+using Microsoft.EntityFrameworkCore.Migrations;++#nullable disable++namespace AliasServerDb.Migrations+{+ /// <inheritdoc />+ public partial class DatetimeOffsetToDateTime : Migration+ {+ /// <inheritdoc />+ protected override void Up(MigrationBuilder migrationBuilder)+ {++ }++ /// <inheritdoc />+ protected override void Down(MigrationBuilder migrationBuilder)+ {++ }+ }+}diff --git a/src/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs b/src/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.csindex 1a09bd173..a31749918 100644--- a/src/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs+++ b/src/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs@@ -452,7 +452,7 @@ namespace AliasServerDb.Migrations.IsRequired().HasColumnType("TEXT");- b.Property<DateTimeOffset>("TimeStamp")+ b.Property<DateTime>("TimeStamp").HasColumnType("TEXT");b.HasKey("Id");diff --git a/src/Shared/AliasVault.RazorComponents/AliasVault.RazorComponents.csproj b/src/Shared/AliasVault.RazorComponents/AliasVault.RazorComponents.csprojindex ae089f7b6..0d2a96e6b 100644--- a/src/Shared/AliasVault.RazorComponents/AliasVault.RazorComponents.csproj+++ b/src/Shared/AliasVault.RazorComponents/AliasVault.RazorComponents.csproj@@ -18,7 +18,7 @@<ItemGroup>- <SupportedPlatform Include="browser"/>+ <SupportedPlatform Include="browser" /></ItemGroup><ItemGroup>diff --git a/src/Shared/AliasVault.RazorComponents/Tables/SortDirection.cs b/src/Shared/AliasVault.RazorComponents/Tables/SortDirection.csnew file mode 100644index 000000000..7b258556e--- /dev/null+++ b/src/Shared/AliasVault.RazorComponents/Tables/SortDirection.cs@@ -0,0 +1,24 @@+//-----------------------------------------------------------------------+// <copyright file="SortDirection.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------++namespace AliasVault.RazorComponents.Tables;++/// <summary>+/// An enum that represents the direction of a sort.+/// </summary>+public enum SortDirection+{+ /// <summary>+ /// The sort is ascending.+ /// </summary>+ Ascending,++ /// <summary>+ /// The sort is descending.+ /// </summary>+ Descending,+}diff --git a/src/Shared/AliasVault.RazorComponents/Tables/SortableTable.razor b/src/Shared/AliasVault.RazorComponents/Tables/SortableTable.razornew file mode 100644index 000000000..542f6503a--- /dev/null+++ b/src/Shared/AliasVault.RazorComponents/Tables/SortableTable.razor@@ -0,0 +1,87 @@+@typeparam TItem++<table class="w-full text-sm text-left text-gray-500 shadow rounded border">+ <thead class="text-xs text-gray-700 uppercase bg-gray-50">+ <tr>+ @foreach (var column in Columns)+ {+ <th scope="col" class="px-4 py-3">+ @if (column.Sortable)+ {+ <button class="flex items-center" @onclick="() => OnSort(column.PropertyName)">+ @column.Title+ <span class="ml-1">+ @if (SortColumn == column.PropertyName)+ {+ @if (SortDirection == SortDirection.Ascending)+ {+ <svg class="w-3 h-3" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">+ <path fill-rule="evenodd" d="M5.293 7.707a1 1 0 010-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 01-1.414 1.414L11 5.414V17a1 1 0 11-2 0V5.414L6.707 7.707a1 1 0 01-1.414 0z" clip-rule="evenodd"></path>+ </svg>+ }+ else+ {+ <svg class="w-3 h-3" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">+ <path fill-rule="evenodd" d="M14.707 12.293a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 111.414-1.414L9 14.586V3a1 1 0 012 0v11.586l2.293-2.293a1 1 0 011.414 0z" clip-rule="evenodd"></path>+ </svg>+ }+ }+ </span>+ </button>+ }+ else+ {+ @column.Title+ }+ </th>+ }+ </tr>+ </thead>+ <tbody>+ @ChildContent+ </tbody>+</table>++@code {+ /// <summary>+ /// Gets or sets the columns to display in the table.+ /// </summary>+ [Parameter] public List<TableColumn> Columns { get; set; } = new();++ /// <summary>+ /// Gets or sets the child content of the table.+ /// </summary>+ [Parameter] public RenderFragment ChildContent { get; set; } = null!;++ /// <summary>+ /// Gets or sets the column to sort by.+ /// </summary>+ [Parameter] public string SortColumn { get; set; } = string.Empty;++ /// <summary>+ /// Gets or sets the direction to sort by.+ /// </summary>+ [Parameter] public SortDirection SortDirection { get; set; }++ /// <summary>+ /// Gets or sets the event to invoke when the sort changes.+ /// </summary>+ [Parameter] public EventCallback<(string, SortDirection)> OnSortChanged { get; set; }++ private async Task OnSort(string columnName)+ {+ if (SortColumn == columnName)+ {+ SortDirection = SortDirection == SortDirection.Ascending+ ? SortDirection.Descending+ : SortDirection.Ascending;+ }+ else+ {+ SortColumn = columnName;+ SortDirection = SortDirection.Ascending;+ }++ await OnSortChanged.InvokeAsync((SortColumn, SortDirection));+ }+}diff --git a/src/Shared/AliasVault.RazorComponents/Tables/TableColumn.cs b/src/Shared/AliasVault.RazorComponents/Tables/TableColumn.csnew file mode 100644index 000000000..0ba5a6793--- /dev/null+++ b/src/Shared/AliasVault.RazorComponents/Tables/TableColumn.cs@@ -0,0 +1,29 @@+//-----------------------------------------------------------------------+// <copyright file="TableColumn.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------++namespace AliasVault.RazorComponents.Tables;++/// <summary>+/// A class that represents a column in a table.+/// </summary>+public class TableColumn+{+ /// <summary>+ /// Gets or sets the title of the column.+ /// </summary>+ public required string Title { get; set; }++ /// <summary>+ /// Gets or sets the name of the property to bind to.+ /// </summary>+ public required string PropertyName { get; set; }++ /// <summary>+ /// Gets or sets a value indicating whether the column is sortable.+ /// </summary>+ public bool Sortable { get; set; } = true;+}diff --git a/src/Shared/AliasVault.RazorComponents/_Imports.razor b/src/Shared/AliasVault.RazorComponents/_Imports.razorindex 1b7413bbb..d6862780f 100644--- a/src/Shared/AliasVault.RazorComponents/_Imports.razor+++ b/src/Shared/AliasVault.RazorComponents/_Imports.razor@@ -1,2 +1,3 @@@using AliasVault.RazorComponents.Models+@using AliasVault.RazorComponents.Tables@using Microsoft.AspNetCore.Components.Web