Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add import/export page UI scaffolding (#542)
Leendert de Borsta20b0ed83ad1
diff --git a/src/AliasVault.Client/Main/Layout/TopMenu.razor b/src/AliasVault.Client/Main/Layout/TopMenu.razorindex 32b6c5acc..29dc4f5fa 100644--- a/src/AliasVault.Client/Main/Layout/TopMenu.razor+++ b/src/AliasVault.Client/Main/Layout/TopMenu.razor@@ -68,8 +68,8 @@</NavLink></li><li>- <NavLink href="/settings/vault" class="block py-2 px-4 text-sm hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-400 dark:hover:text-white" ActiveClass="text-primary-700 dark:text-primary-500" Match="NavLinkMatch.All">- Vault settings+ <NavLink href="/settings/import-export" class="block py-2 px-4 text-sm hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-400 dark:hover:text-white" ActiveClass="text-primary-700 dark:text-primary-500" Match="NavLinkMatch.All">+ Import / Export</NavLink></li><li class="border-t border-b border-gray-100 dark:border-gray-600">diff --git a/src/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceAliasVault.razor b/src/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceAliasVault.razornew file mode 100644index 000000000..65516719e--- /dev/null+++ b/src/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceAliasVault.razor@@ -0,0 +1,58 @@+@inherits ImportServiceCard+@inject ILogger<ImportServiceAliasVault> Logger++@{+ base.BuildRenderTree(__builder);+}++@code {+ protected override void OnInitialized()+ {+ ServiceName = "AliasVault";+ Description = "Import passwords from another AliasVault instance or manual back-up";+ LogoUrl = "img/logo.svg";++ // Define the modal content for LastPass+ ModalContent = builder =>+ {+ builder.OpenElement(0, "div");+ builder.AddAttribute(1, "class", "mb-4");++ builder.OpenElement(2, "p");+ builder.AddAttribute(3, "class", "mb-4 text-gray-700 dark:text-gray-300");+ builder.AddContent(4, "Upload your AliasVault export file:");+ builder.CloseElement(); // p++ builder.OpenComponent<InputFile>(5);+ builder.AddAttribute(6, "OnChange", EventCallback.Factory.Create<InputFileChangeEventArgs>(this, HandleFileUpload));+ builder.AddAttribute(7, "class", "dark:text-white text-sm");+ builder.CloseComponent(); // InputFile++ builder.CloseElement(); // div+ };+ }++ private async Task HandleFileUpload(InputFileChangeEventArgs e)+ {+ try {+ // AliasVault specific file upload and parsing logic+ Logger.LogInformation($"Processing AliasVault file: {e.File.Name}");++ // Process file contents here+ // ...++ // Once processing is complete, you can notify the parent+ await OnImportComplete.InvokeAsync();+ }+ catch (Exception ex)+ {+ Logger.LogError(ex, "Error handling AliasVault file upload");+ }+ }++ protected override async Task HandleModalConfirm()+ {+ // Override with AliasVault specific confirmation logic if needed+ await base.HandleModalConfirm();+ }+}\ No newline at end of filediff --git a/src/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceBitwarden.razor b/src/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceBitwarden.razornew file mode 100644index 000000000..6fdfa55d1--- /dev/null+++ b/src/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceBitwarden.razor@@ -0,0 +1,52 @@+@inherits ImportServiceCard+@inject ILogger<ImportServiceBitwarden> Logger++@{+ base.BuildRenderTree(__builder);+}++@code {+ protected override void OnInitialized()+ {+ ServiceName = "Bitwarden";+ Description = "Import passwords from your Bitwarden vault";+ LogoUrl = "img/importers/bitwarden.svg";++ // Define the modal content for Bitwarden+ ModalContent = builder =>+ {+ builder.OpenElement(0, "div");+ builder.AddAttribute(1, "class", "mb-4");++ builder.OpenElement(2, "p");+ builder.AddAttribute(3, "class", "mb-4 text-gray-700 dark:text-gray-300");+ builder.AddContent(4, "Upload your Bitwarden JSON export file:");+ builder.CloseElement(); // p++ builder.OpenComponent<InputFile>(5);+ builder.AddAttribute(6, "OnChange", EventCallback.Factory.Create<InputFileChangeEventArgs>(this, HandleFileUpload));+ builder.AddAttribute(7, "class", "dark:text-white text-sm");+ builder.CloseComponent(); // InputFile++ builder.CloseElement(); // div+ };+ }++ private async Task HandleFileUpload(InputFileChangeEventArgs e)+ {+ try {+ // Bitwarden specific file upload and parsing logic+ Logger.LogInformation($"Processing Bitwarden file: {e.File.Name}");++ // Process file contents here+ // ...++ // Once processing is complete, you can notify the parent+ await OnImportComplete.InvokeAsync();+ }+ catch (Exception ex)+ {+ Logger.LogError(ex, "Error handling Bitwarden file upload");+ }+ }+}\ No newline at end of filediff --git a/src/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceCard.razor b/src/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceCard.razornew file mode 100644index 000000000..74af9d7b9--- /dev/null+++ b/src/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceCard.razor@@ -0,0 +1,93 @@+@inject ILogger<ImportServiceCard> Logger+@inject IJSRuntime JSRuntime++<div class="flex flex-col p-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700">+ <div class="flex items-center mb-3">+ <div class="w-12 h-12 mr-3 flex-shrink-0">+ @if (!string.IsNullOrEmpty(LogoUrl))+ {+ <img src="@LogoUrl" alt="@ServiceName logo" class="w-full h-full object-contain" />+ }+ else+ {+ <div class="w-full h-full bg-gray-200 dark:bg-gray-700 rounded-md flex items-center justify-center">+ <span class="text-gray-500 dark:text-gray-400 text-xs">No logo</span>+ </div>+ }+ </div>+ <div>+ <h4 class="text-lg font-semibold dark:text-white">@ServiceName</h4>+ @if (!string.IsNullOrEmpty(Description))+ {+ <p class="text-sm text-gray-500 dark:text-gray-400">@Description</p>+ }+ </div>+ </div>+ <div class="mt-auto">+ <Button OnClick="@OpenImportModal">Import from @ServiceName</Button>+ </div>+</div>++@if (IsModalOpen)+{+ <ClickOutsideHandler OnClose="CloseModal" ContentId="importServiceModal">+ <ModalWrapper OnEnter="HandleModalConfirm">+ <div id="importServiceModal" class="relative top-20 mx-auto p-5 shadow-lg rounded-md bg-white dark:bg-gray-800 border-2 border-gray-300 dark:border-gray-400">+ <div class="bg-white dark:bg-gray-800 rounded-lg p-6 max-w-lg w-full mx-auto">+ <div class="flex justify-between items-center mb-4">+ <h3 class="text-xl font-semibold dark:text-white">Import from @ServiceName</h3>+ <button @onclick="CloseModal" class="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300">+ <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>+ </svg>+ </button>+ </div>++ @ModalContent++ <div class="flex justify-end mt-6 space-x-2">+ <Button OnClick="@CloseModal" Color="secondary">Cancel</Button>+ <Button OnClick="@HandleModalConfirm" Color="primary">Import</Button>+ </div>+ </div>+ </div>+ </ModalWrapper>+ </ClickOutsideHandler>+}++@code {+ [Parameter]+ public string ServiceName { get; set; } = string.Empty;++ [Parameter]+ public string Description { get; set; } = string.Empty;++ [Parameter]+ public string LogoUrl { get; set; } = string.Empty;++ [Parameter]+ public EventCallback OnImportComplete { get; set; }++ protected bool IsModalOpen { get; set; } = false;++ protected RenderFragment ModalContent { get; set; } = builder => { };++ protected virtual void OpenImportModal()+ {+ IsModalOpen = true;+ StateHasChanged();+ }++ protected virtual void CloseModal()+ {+ IsModalOpen = false;+ StateHasChanged();+ }++ protected virtual async Task HandleModalConfirm()+ {+ // Base implementation - may be overridden by derived components+ await OnImportComplete.InvokeAsync();+ CloseModal();+ }+}\ No newline at end of filediff --git a/src/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceKeePass.razor b/src/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceKeePass.razornew file mode 100644index 000000000..2473e5fb4--- /dev/null+++ b/src/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceKeePass.razor@@ -0,0 +1,58 @@+@inherits ImportServiceCard+@inject ILogger<ImportServiceKeePass> Logger++@{+ base.BuildRenderTree(__builder);+}++@code {+ protected override void OnInitialized()+ {+ ServiceName = "KeePass";+ Description = "Import passwords from your KeePass vault";+ LogoUrl = "img/importers/keepass.svg";++ // Define the modal content for KeePass+ ModalContent = builder =>+ {+ builder.OpenElement(0, "div");+ builder.AddAttribute(1, "class", "mb-4");++ builder.OpenElement(2, "p");+ builder.AddAttribute(3, "class", "mb-4 text-gray-700 dark:text-gray-300");+ builder.AddContent(4, "Upload your KeePass export file:");+ builder.CloseElement(); // p++ builder.OpenComponent<InputFile>(5);+ builder.AddAttribute(6, "OnChange", EventCallback.Factory.Create<InputFileChangeEventArgs>(this, HandleFileUpload));+ builder.AddAttribute(7, "class", "dark:text-white text-sm");+ builder.CloseComponent(); // InputFile++ builder.CloseElement(); // div+ };+ }++ private async Task HandleFileUpload(InputFileChangeEventArgs e)+ {+ try {+ // KeePass specific file upload and parsing logic+ Logger.LogInformation($"Processing KeePass file: {e.File.Name}");++ // Process file contents here+ // ...++ // Once processing is complete, you can notify the parent+ await OnImportComplete.InvokeAsync();+ }+ catch (Exception ex)+ {+ Logger.LogError(ex, "Error handling KeePass file upload");+ }+ }++ protected override async Task HandleModalConfirm()+ {+ // Override with KeePass specific confirmation logic if needed+ await base.HandleModalConfirm();+ }+}\ No newline at end of filediff --git a/src/AliasVault.Client/Main/Pages/Settings/Vault.razor b/src/AliasVault.Client/Main/Pages/Settings/ImportExport/ImportExport.razorsimilarity index 65%rename from src/AliasVault.Client/Main/Pages/Settings/Vault.razorrename to src/AliasVault.Client/Main/Pages/Settings/ImportExport/ImportExport.razorindex eddcfe36f..0e2b15679 100644--- a/src/AliasVault.Client/Main/Pages/Settings/Vault.razor+++ b/src/AliasVault.Client/Main/Pages/Settings/ImportExport/ImportExport.razor@@ -1,16 +1,30 @@-@page "/settings/vault"+@page "/settings/import-export"@inherits MainBase@inject CredentialService CredentialService-@inject ILogger<Vault> Logger+@inject ILogger<ImportExport> Logger+@using AliasVault.Client.Main.Components.Settings+@using AliasVault.Client.Main.Pages.Settings.ImportExport.Components-<LayoutPageTitle>Vault settings</LayoutPageTitle>+<LayoutPageTitle>Import / Export</LayoutPageTitle><PageHeaderBreadcrumbItems="@BreadcrumbItems"- Title="Vault settings"- Description="On this page you can configure your vault settings.">+ Title="Import / Export"+ Description="On this page you can import and export your vault."></PageHeader>+<div class="p-4 mx-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800">+ <h3 class="mb-4 text-xl font-semibold dark:text-white">Import vault</h3>+ <div class="mb-4 text-sm text-gray-500 dark:text-gray-400">+ Select a service to import from. If you are using a service that is not listed here, you can import from a CSV file manually. Or if you believe we are missing a popular service, please contact us and let us know.+ </div>+ <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">+ <ImportServiceBitwarden OnImportComplete="RefreshVault" />+ <ImportServiceKeePass OnImportComplete="RefreshVault" />+ <ImportServiceAliasVault OnImportComplete="RefreshVault" />+ </div>+</div>+<div class="p-4 mx-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800"><h3 class="mb-4 text-xl font-semibold dark:text-white">Export vault</h3><div class="mb-4">@@ -31,16 +45,6 @@</div></div>-<div class="p-4 mx-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800">- <h3 class="mb-4 text-xl font-semibold dark:text-white">Import vault</h3>- <div class="mb-4">- <div class="text-gray-900 dark:text-white">- Import unencrypted CSV file:- <InputFile class="dark:text-white" OnChange="@LoadFiles" />- </div>- </div>-</div>-@if (IsImporting){<p>Loading...</p>@@ -63,7 +67,7 @@ else if (!string.IsNullOrEmpty(ImportSuccessMessage))protected override async Task OnInitializedAsync(){await base.OnInitializedAsync();- BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = "Vault settings" });+ BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = "Import / Export" });}private async Task ExportVaultSqlite()@@ -154,4 +158,66 @@ else if (!string.IsNullOrEmpty(ImportSuccessMessage))StateHasChanged();}}++ // Placeholder methods for other import types+ private async Task LoadBitwardenFile(InputFileChangeEventArgs e)+ {+ // Implementation will be added later+ await NotImplementedImport("Bitwarden");+ }++ private async Task LoadLastPassFile(InputFileChangeEventArgs e)+ {+ // Implementation will be added later+ await NotImplementedImport("LastPass");+ }++ private async Task LoadKeePassFile(InputFileChangeEventArgs e)+ {+ // Implementation will be added later+ await NotImplementedImport("KeePass");+ }++ private async Task Load1PasswordFile(InputFileChangeEventArgs e)+ {+ // Implementation will be added later+ await NotImplementedImport("1Password");+ }++ private async Task LoadDashlaneFile(InputFileChangeEventArgs e)+ {+ // Implementation will be added later+ await NotImplementedImport("Dashlane");+ }++ private async Task LoadChromeFile(InputFileChangeEventArgs e)+ {+ // Implementation will be added later+ await NotImplementedImport("Chrome");+ }++ private async Task LoadFirefoxFile(InputFileChangeEventArgs e)+ {+ // Implementation will be added later+ await NotImplementedImport("Firefox");+ }++ private async Task LoadGenericCsvFile(InputFileChangeEventArgs e)+ {+ // Implementation will be added later+ await NotImplementedImport("Generic CSV");+ }++ private Task NotImplementedImport(string serviceName)+ {+ ImportErrorMessage = $"Import from {serviceName} is not implemented yet.";+ StateHasChanged();+ return Task.CompletedTask;+ }++ private void RefreshVault()+ {+ // Refresh vault data after import+ // ...+ }}diff --git a/src/AliasVault.Client/wwwroot/img/importers/bitwarden.svg b/src/AliasVault.Client/wwwroot/img/importers/bitwarden.svgnew file mode 100644index 000000000..7bdf174bd--- /dev/null+++ b/src/AliasVault.Client/wwwroot/img/importers/bitwarden.svg@@ -0,0 +1,5 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">+ <rect width="100" height="100" rx="10" fill="#175DDC" />+ <path d="M50 20 L80 35 L80 65 L50 80 L20 65 L20 35 Z" fill="white" />+ <path d="M50 30 L70 40 L70 60 L50 70 L30 60 L30 40 Z" fill="#175DDC" />+</svg>diff --git a/src/AliasVault.Client/wwwroot/img/importers/keepass.svg b/src/AliasVault.Client/wwwroot/img/importers/keepass.svgnew file mode 100644index 000000000..3f8f86b58--- /dev/null+++ b/src/AliasVault.Client/wwwroot/img/importers/keepass.svg@@ -0,0 +1,6 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">+ <rect width="100" height="100" rx="10" fill="#6CA2D7" />+ <circle cx="50" cy="40" r="15" fill="white" />+ <rect x="40" y="50" width="20" height="30" fill="white" />+ <rect x="30" y="60" width="40" height="10" fill="white" />+</svg>