Mass rename to align planned codename
This commit is contained in:
@@ -14,7 +14,7 @@
|
|||||||
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="False" />
|
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="False" />
|
||||||
</ConditionalExpression>
|
</ConditionalExpression>
|
||||||
</ConditionAction.Condition>
|
</ConditionAction.Condition>
|
||||||
<NavigateAction Region="Main" Route="Container">
|
<NavigateAction Region="Main" Route="Locker">
|
||||||
<Parameter Key="Filter" Value="{Binding Filter}" />
|
<Parameter Key="Filter" Value="{Binding Filter}" />
|
||||||
</NavigateAction>
|
</NavigateAction>
|
||||||
</ConditionAction>
|
</ConditionAction>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ using Microsoft.Extensions.DependencyInjection.Extensions;
|
|||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Text.Json;
|
||||||
using Toolkit.Avalonia;
|
using Toolkit.Avalonia;
|
||||||
using Toolkit.Foundation;
|
using Toolkit.Foundation;
|
||||||
|
|
||||||
@@ -25,16 +26,16 @@ public partial class App : Application
|
|||||||
public override async void OnFrameworkInitializationCompleted()
|
public override async void OnFrameworkInitializationCompleted()
|
||||||
{
|
{
|
||||||
IHost? host = DefaultHostBuilder.Create()
|
IHost? host = DefaultHostBuilder.Create()
|
||||||
.AddConfiguration<ContainerConfiguration>("Locker:*")
|
.AddConfiguration<LockerConfiguration>("Locker:*")
|
||||||
.AddConfiguration<ItemConfiguration>("Item:*")
|
.AddConfiguration<ItemConfiguration>("Item:*")
|
||||||
.AddConfiguration<ItemConfiguration>(args => args.Name = "Bank Account", "Item:Bank Account")
|
//.AddConfiguration<ItemConfiguration>(args => args.Name = "Bank Account", "Item:Bank Account")
|
||||||
.AddConfiguration<ItemConfiguration>(args => args.Name = "Credit Card", "Item:Credit Card")
|
.AddConfiguration("Item:Credit Card", ItemConfiguration.CreditCard)
|
||||||
.AddConfiguration<ItemConfiguration>(args => args.Name = "Document", "Item:Document")
|
//.AddConfiguration<ItemConfiguration>(args => args.Name = "Document", "Item:Document")
|
||||||
.AddConfiguration<ItemConfiguration>(args => args.Name = "Driving Licence", "Item:Driving Licence")
|
//.AddConfiguration<ItemConfiguration>(args => args.Name = "Driving Licence", "Item:Driving Licence")
|
||||||
.AddConfiguration<ItemConfiguration>(args => args.Name = "Identity", "Item:Identity")
|
//.AddConfiguration<ItemConfiguration>(args => args.Name = "Identity", "Item:Identity")
|
||||||
.AddConfiguration<ItemConfiguration>(args => args.Name = "Login", "Item:Login")
|
//.AddConfiguration<ItemConfiguration>(args => args.Name = "Login", "Item:Login")
|
||||||
.AddConfiguration<ItemConfiguration>(args => args.Name = "Note", "Item:Note")
|
//.AddConfiguration<ItemConfiguration>(args => args.Name = "Note", "Item:Note")
|
||||||
.AddConfiguration<ItemConfiguration>(args => args.Name = "Password", "Item:Password")
|
//.AddConfiguration<ItemConfiguration>(args => args.Name = "Password", "Item:Password")
|
||||||
.ConfigureServices((context, services) =>
|
.ConfigureServices((context, services) =>
|
||||||
{
|
{
|
||||||
services.AddAvalonia();
|
services.AddAvalonia();
|
||||||
@@ -48,9 +49,9 @@ public partial class App : Application
|
|||||||
services.AddScoped<IProxyService<IEnumerable<ItemConfiguration>>>(provider =>
|
services.AddScoped<IProxyService<IEnumerable<ItemConfiguration>>>(provider =>
|
||||||
new ProxyService<IEnumerable<ItemConfiguration>>(provider.GetRequiredService<IEnumerable<ItemConfiguration>>()));
|
new ProxyService<IEnumerable<ItemConfiguration>>(provider.GetRequiredService<IEnumerable<ItemConfiguration>>()));
|
||||||
|
|
||||||
services.AddHandler<ContainerActivatedHandler>();
|
services.AddHandler<LockerActivatedHandler>();
|
||||||
|
|
||||||
services.AddTransient<IContainerComponent>(provider => Component.Create<ContainerComponent>(provider, args =>
|
services.AddTransient<ILockerComponent>(provider => Component.Create<LockerComponent>(provider, args =>
|
||||||
{
|
{
|
||||||
args.AddServices(services =>
|
args.AddServices(services =>
|
||||||
{
|
{
|
||||||
@@ -70,48 +71,48 @@ public partial class App : Application
|
|||||||
services.AddTransient<IKeyDeriver, KeyDeriver>();
|
services.AddTransient<IKeyDeriver, KeyDeriver>();
|
||||||
|
|
||||||
services.AddTransient<ISecurityKeyFactory, SecurityKeyFactory>();
|
services.AddTransient<ISecurityKeyFactory, SecurityKeyFactory>();
|
||||||
services.AddTransient<IContainerStorageFactory, ContainerStorageFactory>();
|
services.AddTransient<ILockerStorageFactory, LockerStorageFactory>();
|
||||||
services.TryAddSingleton<IValueStore<SecurityKey>, ValueStore<SecurityKey>>();
|
services.TryAddSingleton<IValueStore<SecurityKey>, ValueStore<SecurityKey>>();
|
||||||
services.TryAddSingleton<IValueStore<ContainerConnection>, ValueStore<ContainerConnection>>();
|
services.TryAddSingleton<IValueStore<LockerConnection>, ValueStore<LockerConnection>>();
|
||||||
|
|
||||||
services.AddDbContextFactory<ContainerDbContext>((provider, args) =>
|
services.AddDbContextFactory<LockerContext>((provider, args) =>
|
||||||
{
|
{
|
||||||
if (provider.GetRequiredService<IValueStore<ContainerConnection>>()
|
if (provider.GetRequiredService<IValueStore<LockerConnection>>()
|
||||||
is IValueStore<ContainerConnection> connection)
|
is IValueStore<LockerConnection> connection)
|
||||||
{
|
{
|
||||||
args.UseSqlite($"{connection.Value}");
|
args.UseSqlite($"{connection.Value}");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
services.AddHandler<QueryContainerHandler>();
|
services.AddHandler<QueryLockerHandler>();
|
||||||
services.AddHandler<CreateItemHandler>();
|
services.AddHandler<CreateItemHandler>();
|
||||||
services.AddHandler<UpdateItemHander>();
|
services.AddHandler<UpdateItemHander>();
|
||||||
services.AddHandler<UpdateItemStateHandler>();
|
services.AddHandler<UpdateItemStateHandler>();
|
||||||
|
|
||||||
services.AddHandler<OpenContainerHandler>();
|
services.AddHandler<OpenLockerHandler>();
|
||||||
|
|
||||||
services.AddTemplate<ContainerNavigationViewModel, ContainerNavigationView>();
|
services.AddTemplate<LockerNavigationViewModel, LockerNavigationView>();
|
||||||
services.AddTemplate<AllNavigationViewModel, AllNavigationView>();
|
services.AddTemplate<AllNavigationViewModel, AllNavigationView>();
|
||||||
services.AddTemplate<StarredNavigationViewModel, StarredNavigationView>();
|
services.AddTemplate<StarredNavigationViewModel, StarredNavigationView>();
|
||||||
services.AddTemplate<CategoriesNavigationViewModel, CategoriesNavigationView>();
|
services.AddTemplate<CategoriesNavigationViewModel, CategoriesNavigationView>();
|
||||||
services.AddTemplate<ArchiveNavigationViewModel, ArchiveNavigationView>();
|
services.AddTemplate<ArchiveNavigationViewModel, ArchiveNavigationView>();
|
||||||
|
|
||||||
services.AddTemplate<OpenContainerViewModel, OpenView>("OpenContainer");
|
services.AddTemplate<OpenLockerViewModel, OpenView>("OpenLocker");
|
||||||
|
|
||||||
services.AddScoped<ContainerViewModelConfiguration>();
|
services.AddScoped<LockerViewModelConfiguration>();
|
||||||
|
|
||||||
services.AddTemplate<ContainerViewModel, ContainerView>("Container");
|
services.AddTemplate<LockerViewModel, LockerView>("Locker");
|
||||||
services.AddTemplate<ItemCollectionViewModel, ItemCollectionView>("ContentItemCollection");
|
services.AddTemplate<ItemCollectionViewModel, ItemCollectionView>("ContentItemCollection");
|
||||||
services.AddHandler<AggerateContainerItemViewModelHandler>();
|
services.AddHandler<AggerateLockerItemViewModelHandler>();
|
||||||
|
|
||||||
services.AddTemplate<SearchContainerActionViewModel, SearchContainerActionView>();
|
services.AddTemplate<SearchLockerActionViewModel, SearchLockerActionView>();
|
||||||
services.AddTemplate<ContainerHeaderViewModel, ContainerHeaderView>("ContainerHeader");
|
services.AddTemplate<LockerHeaderViewModel, LockerHeaderView>("LockerHeader");
|
||||||
|
|
||||||
services.AddTemplate<CreateItemActionViewModel, CreateItemActionView>();
|
services.AddTemplate<CreateItemActionViewModel, CreateItemActionView>();
|
||||||
services.AddTemplate<ItemCategoryCollectionViewModel, ItemCategoryCollectionView>("ContainerItemCategoryCollection");
|
services.AddTemplate<ItemCategoryCollectionViewModel, ItemCategoryCollectionView>("LockerItemCategoryCollection");
|
||||||
services.AddTemplate<ItemCategoryNavigationViewModel, ItemCategoryNavigationView>();
|
services.AddTemplate<ItemCategoryNavigationViewModel, ItemCategoryNavigationView>();
|
||||||
|
|
||||||
services.AddHandler<AggerateContainerCategoryViewModelHandler>();
|
services.AddHandler<AggerateLockerCategoryViewModelHandler>();
|
||||||
|
|
||||||
services.AddTemplate<ItemNavigationViewModel, ItemNavigationView>();
|
services.AddTemplate<ItemNavigationViewModel, ItemNavigationView>();
|
||||||
services.AddTemplate<ItemViewModel, ItemView>("Item");
|
services.AddTemplate<ItemViewModel, ItemView>("Item");
|
||||||
@@ -144,11 +145,11 @@ public partial class App : Application
|
|||||||
});
|
});
|
||||||
})!);
|
})!);
|
||||||
|
|
||||||
services.AddTransient<IContainerFactory, ContainerFactory>();
|
services.AddTransient<ILockerFactory, LockerFactory>();
|
||||||
services.AddHandler<CreateContainerHandler>();
|
services.AddHandler<CreateLockerHandler>();
|
||||||
|
|
||||||
services.AddSingleton<IContainerHostCollection, ContainerHostCollection>();
|
services.AddSingleton<ILockerHostCollection, LockerHostCollection>();
|
||||||
services.AddInitializer<ContainerInitializer>();
|
services.AddInitializer<LockerInitializer>();
|
||||||
|
|
||||||
services.AddTemplate<MainViewModel, MainView>("Main");
|
services.AddTemplate<MainViewModel, MainView>("Main");
|
||||||
services.AddHandler<AggerateMainViewModelHandler>();
|
services.AddHandler<AggerateMainViewModelHandler>();
|
||||||
@@ -158,8 +159,8 @@ public partial class App : Application
|
|||||||
services.AddTemplate<ManageNavigationViewModel, ManageNavigationView>();
|
services.AddTemplate<ManageNavigationViewModel, ManageNavigationView>();
|
||||||
services.AddTemplate<ManageViewModel, ManageView>("Manage");
|
services.AddTemplate<ManageViewModel, ManageView>("Manage");
|
||||||
|
|
||||||
services.AddTemplate<CreateContainerNavigationViewModel, CreateContainerNavigationView>();
|
services.AddTemplate<CreateLockerNavigationViewModel, CreateLockerNavigationView>();
|
||||||
services.AddTemplate<CreateContainerViewModel, CreateContainerView>("CreateContainer");
|
services.AddTemplate<CreateLockerViewModel, CreateLockerView>("CreateLocker");
|
||||||
})
|
})
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="False" />
|
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="False" />
|
||||||
</ConditionalExpression>
|
</ConditionalExpression>
|
||||||
</ConditionAction.Condition>
|
</ConditionAction.Condition>
|
||||||
<NavigateAction Region="Main" Route="Container">
|
<NavigateAction Region="Main" Route="Locker">
|
||||||
<Parameter Key="Filter" Value="{Binding Filter}" />
|
<Parameter Key="Filter" Value="{Binding Filter}" />
|
||||||
</NavigateAction>
|
</NavigateAction>
|
||||||
</ConditionAction>
|
</ConditionAction>
|
||||||
|
|||||||
@@ -61,11 +61,11 @@
|
|||||||
<Compile Update="ConfirmItemActionView.axaml.cs">
|
<Compile Update="ConfirmItemActionView.axaml.cs">
|
||||||
<DependentUpon>ConfirmItemActionView.axaml</DependentUpon>
|
<DependentUpon>ConfirmItemActionView.axaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Update="CreateContainerNavigationView.axaml.cs">
|
<Compile Update="CreateLockerNavigationView.axaml.cs">
|
||||||
<DependentUpon>CreateContainerNavigationView.axaml</DependentUpon>
|
<DependentUpon>CreateLockerNavigationView.axaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Update="CreateContainerView.axaml.cs">
|
<Compile Update="CreateLockerView.axaml.cs">
|
||||||
<DependentUpon>CreateContainerView.axaml</DependentUpon>
|
<DependentUpon>CreateLockerView.axaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Update="DismissItemActionView.axaml.cs">
|
<Compile Update="DismissItemActionView.axaml.cs">
|
||||||
<DependentUpon>DismissItemActionView.axaml</DependentUpon>
|
<DependentUpon>DismissItemActionView.axaml</DependentUpon>
|
||||||
@@ -82,8 +82,8 @@
|
|||||||
<Compile Update="ManageNavigationView.axaml.cs">
|
<Compile Update="ManageNavigationView.axaml.cs">
|
||||||
<DependentUpon>ManageNavigationView.axaml</DependentUpon>
|
<DependentUpon>ManageNavigationView.axaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Update="ContainerHeaderView.axaml.cs">
|
<Compile Update="LockerHeaderView.axaml.cs">
|
||||||
<DependentUpon>ContainerHeaderView.axaml</DependentUpon>
|
<DependentUpon>LockerHeaderView.axaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Update="ItemNavigationView.axaml.cs">
|
<Compile Update="ItemNavigationView.axaml.cs">
|
||||||
<DependentUpon>ItemNavigationView.axaml</DependentUpon>
|
<DependentUpon>ItemNavigationView.axaml</DependentUpon>
|
||||||
@@ -91,11 +91,14 @@
|
|||||||
<Compile Update="ItemView.axaml.cs">
|
<Compile Update="ItemView.axaml.cs">
|
||||||
<DependentUpon>ItemView.axaml</DependentUpon>
|
<DependentUpon>ItemView.axaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Update="ContainerNavigationView.axaml.cs">
|
<Compile Update="LockerNavigationView.axaml.cs">
|
||||||
<DependentUpon>ContainerNavigationView.axaml</DependentUpon>
|
<DependentUpon>LockerNavigationView.axaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Update="ContainerView.axaml.cs">
|
<Compile Update="LockerView.axaml.cs">
|
||||||
<DependentUpon>ContainerView.axaml</DependentUpon>
|
<DependentUpon>LockerView.axaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Update="SearchLockerActionView.axaml.cs">
|
||||||
|
<DependentUpon>SearchLockerActionView.axaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
using Avalonia.Controls;
|
|
||||||
|
|
||||||
namespace Bitvault.Avalonia;
|
|
||||||
|
|
||||||
public partial class ContainerHeaderView : UserControl
|
|
||||||
{
|
|
||||||
public ContainerHeaderView() => InitializeComponent();
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
using Toolkit.UI.Controls.Avalonia;
|
|
||||||
|
|
||||||
namespace Bitvault.Avalonia;
|
|
||||||
|
|
||||||
public partial class ContainerNavigationView : NavigationViewItem
|
|
||||||
{
|
|
||||||
public ContainerNavigationView() => InitializeComponent();
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
using Toolkit.UI.Controls.Avalonia;
|
|
||||||
|
|
||||||
namespace Bitvault.Avalonia;
|
|
||||||
|
|
||||||
public partial class CreateContainerNavigationView : SettingsExpander
|
|
||||||
{
|
|
||||||
public CreateContainerNavigationView() =>
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
using Toolkit.UI.Controls.Avalonia;
|
|
||||||
|
|
||||||
namespace Bitvault.Avalonia;
|
|
||||||
|
|
||||||
public partial class CreateContainerView : ContentDialog
|
|
||||||
{
|
|
||||||
public CreateContainerView() => InitializeComponent();
|
|
||||||
}
|
|
||||||
@@ -28,9 +28,9 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
<Interaction.Behaviors>
|
<Interaction.Behaviors>
|
||||||
<EventTriggerBehavior EventName="Click">
|
<EventTriggerBehavior EventName="Click">
|
||||||
<NavigateAction Region="Left" Route="ContainerItemCategoryCollection">
|
<NavigateAction Region="Left" Route="LockerItemCategoryCollection">
|
||||||
<Parameter Key="Transition" Value="FromRight" />
|
<Parameter Key="Transition" Value="FromRight" />
|
||||||
</NavigateAction>
|
</NavigateAction>
|
||||||
</EventTriggerBehavior>
|
</EventTriggerBehavior>
|
||||||
</Interaction.Behaviors>
|
</Interaction.Behaviors>
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
<SettingsExpander
|
<SettingsExpander
|
||||||
x:Class="Bitvault.Avalonia.CreateContainerNavigationView"
|
x:Class="Bitvault.Avalonia.CreateLockerNavigationView"
|
||||||
xmlns="https://github.com/avaloniaui"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
Description="Keep organized by separating your things into vaults."
|
Description="Keep organized by separating your things into vaults."
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
<Button MinWidth="132" Content="Create vault">
|
<Button MinWidth="132" Content="Create vault">
|
||||||
<Interaction.Behaviors>
|
<Interaction.Behaviors>
|
||||||
<EventTriggerBehavior EventName="Click">
|
<EventTriggerBehavior EventName="Click">
|
||||||
<NavigateAction Region="self" Route="CreateContainer" />
|
<NavigateAction Region="self" Route="CreateLocker" />
|
||||||
</EventTriggerBehavior>
|
</EventTriggerBehavior>
|
||||||
</Interaction.Behaviors>
|
</Interaction.Behaviors>
|
||||||
</Button>
|
</Button>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using Toolkit.UI.Controls.Avalonia;
|
||||||
|
|
||||||
|
namespace Bitvault.Avalonia;
|
||||||
|
|
||||||
|
public partial class CreateLockerNavigationView : SettingsExpander
|
||||||
|
{
|
||||||
|
public CreateLockerNavigationView() =>
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
+2
-2
@@ -1,10 +1,10 @@
|
|||||||
<ContentDialog
|
<ContentDialog
|
||||||
x:Class="Bitvault.Avalonia.CreateContainerView"
|
x:Class="Bitvault.Avalonia.CreateLockerView"
|
||||||
xmlns="https://github.com/avaloniaui"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:vm="using:Bitvault"
|
xmlns:vm="using:Bitvault"
|
||||||
Title="Create vault"
|
Title="Create vault"
|
||||||
x:DataType="vm:CreateContainerViewModel"
|
x:DataType="vm:CreateLockerViewModel"
|
||||||
CloseButtonText="Cancel"
|
CloseButtonText="Cancel"
|
||||||
PrimaryButtonText="Create">
|
PrimaryButtonText="Create">
|
||||||
<StackPanel Width="400">
|
<StackPanel Width="400">
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using Toolkit.UI.Controls.Avalonia;
|
||||||
|
|
||||||
|
namespace Bitvault.Avalonia;
|
||||||
|
|
||||||
|
public partial class CreateLockerView : ContentDialog
|
||||||
|
{
|
||||||
|
public CreateLockerView() =>
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
+2
-2
@@ -1,9 +1,9 @@
|
|||||||
<UserControl
|
<UserControl
|
||||||
x:Class="Bitvault.Avalonia.ContainerHeaderView"
|
x:Class="Bitvault.Avalonia.LockerHeaderView"
|
||||||
xmlns="https://github.com/avaloniaui"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:vm="using:Bitvault"
|
xmlns:vm="using:Bitvault"
|
||||||
x:DataType="vm:ContainerHeaderViewModel">
|
x:DataType="vm:LockerHeaderViewModel">
|
||||||
<ItemsControl ItemTemplate="{ReflectionBinding Template}" ItemsSource="{Binding}">
|
<ItemsControl ItemTemplate="{ReflectionBinding Template}" ItemsSource="{Binding}">
|
||||||
<ItemsControl.ItemsPanel>
|
<ItemsControl.ItemsPanel>
|
||||||
<ItemsPanelTemplate>
|
<ItemsPanelTemplate>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
|
||||||
|
namespace Bitvault.Avalonia;
|
||||||
|
|
||||||
|
public partial class LockerHeaderView : UserControl
|
||||||
|
{
|
||||||
|
public LockerHeaderView() =>
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
+5
-5
@@ -1,10 +1,10 @@
|
|||||||
<NavigationViewItem
|
<NavigationViewItem
|
||||||
x:Class="Bitvault.Avalonia.ContainerNavigationView"
|
x:Class="Bitvault.Avalonia.LockerNavigationView"
|
||||||
xmlns="https://github.com/avaloniaui"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:vm="using:Bitvault"
|
xmlns:vm="using:Bitvault"
|
||||||
x:Name="NavigationViewItem"
|
x:Name="NavigationViewItem"
|
||||||
x:DataType="vm:ContainerNavigationViewModel"
|
x:DataType="vm:LockerNavigationViewModel"
|
||||||
Content="{Binding Name}"
|
Content="{Binding Name}"
|
||||||
IsExpanded="{Binding Expanded}"
|
IsExpanded="{Binding Expanded}"
|
||||||
IsSelected="{Binding Selected}"
|
IsSelected="{Binding Selected}"
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
<ComparisonCondition LeftOperand="{Binding Selected}" RightOperand="True" />
|
<ComparisonCondition LeftOperand="{Binding Selected}" RightOperand="True" />
|
||||||
</ConditionalExpression>
|
</ConditionalExpression>
|
||||||
</ConditionAction.Condition>
|
</ConditionAction.Condition>
|
||||||
<NavigateAction Region="Main" Route="OpenContainer" />
|
<NavigateAction Region="Main" Route="OpenLocker" />
|
||||||
<ChangePropertyAction
|
<ChangePropertyAction
|
||||||
PropertyName="SelectsOnInvoked"
|
PropertyName="SelectsOnInvoked"
|
||||||
TargetObject="{Binding #NavigationViewItem}"
|
TargetObject="{Binding #NavigationViewItem}"
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
<ComparisonCondition LeftOperand="{Binding Opened}" RightOperand="False" />
|
<ComparisonCondition LeftOperand="{Binding Opened}" RightOperand="False" />
|
||||||
</ConditionalExpression>
|
</ConditionalExpression>
|
||||||
</ConditionAction.Condition>
|
</ConditionAction.Condition>
|
||||||
<NavigateAction Region="Main" Route="OpenContainer" />
|
<NavigateAction Region="Main" Route="OpenLocker" />
|
||||||
</ConditionAction>
|
</ConditionAction>
|
||||||
<ConditionAction>
|
<ConditionAction>
|
||||||
<ConditionAction.Condition>
|
<ConditionAction.Condition>
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="False" />
|
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="False" />
|
||||||
</ConditionalExpression>
|
</ConditionalExpression>
|
||||||
</ConditionAction.Condition>
|
</ConditionAction.Condition>
|
||||||
<NavigateAction Region="Main" Route="Container" />
|
<NavigateAction Region="Main" Route="Locker" />
|
||||||
<InvokeNavigationViewItemAction />
|
<InvokeNavigationViewItemAction />
|
||||||
</ConditionAction>
|
</ConditionAction>
|
||||||
</AttachedEventTriggerBehaviour>
|
</AttachedEventTriggerBehaviour>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using Toolkit.UI.Controls.Avalonia;
|
||||||
|
|
||||||
|
namespace Bitvault.Avalonia;
|
||||||
|
|
||||||
|
public partial class LockerNavigationView : NavigationViewItem
|
||||||
|
{
|
||||||
|
public LockerNavigationView() =>
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
<UserControl
|
<UserControl
|
||||||
x:Class="Bitvault.Avalonia.ContainerView"
|
x:Class="Bitvault.Avalonia.LockerView"
|
||||||
xmlns="https://github.com/avaloniaui"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:vm="using:Bitvault"
|
xmlns:vm="using:Bitvault"
|
||||||
x:DataType="vm:ContainerViewModel">
|
x:DataType="vm:LockerViewModel">
|
||||||
<Grid
|
<Grid
|
||||||
x:Name="Container"
|
x:Name="Container"
|
||||||
ColumnDefinitions="320,Auto,*,Auto"
|
ColumnDefinitions="320,Auto,*,Auto"
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
<ContentControl VerticalAlignment="Center">
|
<ContentControl VerticalAlignment="Center">
|
||||||
<Interaction.Behaviors>
|
<Interaction.Behaviors>
|
||||||
<AttachedBehaviour>
|
<AttachedBehaviour>
|
||||||
<NavigateAction Region="{Binding $self}" Route="ContainerHeader" />
|
<NavigateAction Region="{Binding $self}" Route="LockerHeader" />
|
||||||
</AttachedBehaviour>
|
</AttachedBehaviour>
|
||||||
</Interaction.Behaviors>
|
</Interaction.Behaviors>
|
||||||
</ContentControl>
|
</ContentControl>
|
||||||
@@ -4,9 +4,9 @@ using FluentAvalonia.UI.Windowing;
|
|||||||
|
|
||||||
namespace Bitvault.Avalonia;
|
namespace Bitvault.Avalonia;
|
||||||
|
|
||||||
public partial class ContainerView : UserControl
|
public partial class LockerView : UserControl
|
||||||
{
|
{
|
||||||
public ContainerView() => InitializeComponent();
|
public LockerView() => InitializeComponent();
|
||||||
|
|
||||||
protected override void OnLoaded(RoutedEventArgs args)
|
protected override void OnLoaded(RoutedEventArgs args)
|
||||||
{
|
{
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
<Interaction.Behaviors>
|
<Interaction.Behaviors>
|
||||||
<AttachedBehaviour>
|
<AttachedBehaviour>
|
||||||
<NavigateRegionAction Name="Main">
|
<NavigateRegionAction Name="Main">
|
||||||
<NavigateAction Region="Main" Route="Container" />
|
<NavigateAction Region="Main" Route="Locker" />
|
||||||
</NavigateRegionAction>
|
</NavigateRegionAction>
|
||||||
</AttachedBehaviour>
|
</AttachedBehaviour>
|
||||||
</Interaction.Behaviors>
|
</Interaction.Behaviors>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
x:Class="Bitvault.Avalonia.ManageNavigationView"
|
x:Class="Bitvault.Avalonia.ManageNavigationView"
|
||||||
xmlns="https://github.com/avaloniaui"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
Content="Manage Vaults">
|
Content="Manage Lockers">
|
||||||
<Interaction.Behaviors>
|
<Interaction.Behaviors>
|
||||||
<EventTriggerBehavior EventName="Tapped">
|
<EventTriggerBehavior EventName="Tapped">
|
||||||
<NavigateAction Region="Main" Route="Manage" />
|
<NavigateAction Region="Main" Route="Manage" />
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
xmlns="https://github.com/avaloniaui"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:vm="using:Bitvault"
|
xmlns:vm="using:Bitvault"
|
||||||
x:DataType="vm:OpenContainerViewModel">
|
x:DataType="vm:OpenLockerViewModel">
|
||||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||||
<TextBox
|
<TextBox
|
||||||
Width="300"
|
Width="300"
|
||||||
@@ -11,9 +11,9 @@
|
|||||||
PasswordChar="●"
|
PasswordChar="●"
|
||||||
Text="{Binding Password}">
|
Text="{Binding Password}">
|
||||||
<Interaction.Behaviors>
|
<Interaction.Behaviors>
|
||||||
<KeyBindingTriggerBehaviour Gesture="Enter">
|
<KeyBindingTriggerBehaviour Gesture="Enter">
|
||||||
<InvokeCommandAction Command="{Binding InvokeCommand}" />
|
<InvokeCommandAction Command="{Binding InvokeCommand}" />
|
||||||
</KeyBindingTriggerBehaviour>
|
</KeyBindingTriggerBehaviour>
|
||||||
</Interaction.Behaviors>
|
</Interaction.Behaviors>
|
||||||
</TextBox>
|
</TextBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
using Avalonia.Controls;
|
|
||||||
|
|
||||||
namespace Bitvault.Avalonia;
|
|
||||||
|
|
||||||
public partial class SearchContainerActionView : UserControl
|
|
||||||
{
|
|
||||||
public SearchContainerActionView() => InitializeComponent();
|
|
||||||
}
|
|
||||||
+2
-2
@@ -1,9 +1,9 @@
|
|||||||
<UserControl
|
<UserControl
|
||||||
x:Class="Bitvault.Avalonia.SearchContainerActionView"
|
x:Class="Bitvault.Avalonia.SearchLockerActionView"
|
||||||
xmlns="https://github.com/avaloniaui"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:vm="using:Bitvault"
|
xmlns:vm="using:Bitvault"
|
||||||
x:DataType="vm:SearchContainerActionViewModel">
|
x:DataType="vm:SearchLockerActionViewModel">
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ResourceDictionary.ThemeDictionaries>
|
<ResourceDictionary.ThemeDictionaries>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
|
||||||
|
namespace Bitvault.Avalonia;
|
||||||
|
|
||||||
|
public partial class SearchLockerActionView : UserControl
|
||||||
|
{
|
||||||
|
public SearchLockerActionView() =>
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="False" />
|
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="False" />
|
||||||
</ConditionalExpression>
|
</ConditionalExpression>
|
||||||
</ConditionAction.Condition>
|
</ConditionAction.Condition>
|
||||||
<NavigateAction Region="Main" Route="Container">
|
<NavigateAction Region="Main" Route="Locker">
|
||||||
<Parameter Key="Filter" Value="{Binding Filter}" />
|
<Parameter Key="Filter" Value="{Binding Filter}" />
|
||||||
</NavigateAction>
|
</NavigateAction>
|
||||||
</ConditionAction>
|
</ConditionAction>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Bitvault.Data;
|
namespace Bitvault.Data;
|
||||||
|
|
||||||
public class ContainerDbContext(DbContextOptions<ContainerDbContext> options) :
|
public class LockerContext(DbContextOptions<LockerContext> options) :
|
||||||
DbContext(options)
|
DbContext(options)
|
||||||
{
|
{
|
||||||
public DbSet<BlobEntry> Blobs { get; set; }
|
public DbSet<BlobEntry> Blobs { get; set; }
|
||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public class AggerateContainerCategoryViewModelHandler(IProxyService<IEnumerable<ItemConfiguration>> proxyConfigurations,
|
public class AggerateLockerCategoryViewModelHandler(IProxyService<IEnumerable<ItemConfiguration>> proxyConfigurations,
|
||||||
IServiceFactory serviceFactory,
|
IServiceFactory serviceFactory,
|
||||||
IPublisher publisher) :
|
IPublisher publisher) :
|
||||||
INotificationHandler<AggerateEventArgs<ItemCategoryNavigationViewModel>>
|
INotificationHandler<AggerateEventArgs<ItemCategoryNavigationViewModel>>
|
||||||
+6
-6
@@ -3,23 +3,23 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public class AggerateContainerItemViewModelHandler(IMediator mediator,
|
public class AggerateLockerItemViewModelHandler(IMediator mediator,
|
||||||
IServiceProvider serviceProvider,
|
IServiceProvider serviceProvider,
|
||||||
ICache<Item> cache,
|
ICache<Item> cache,
|
||||||
IPublisher publisher) :
|
IPublisher publisher) :
|
||||||
INotificationHandler<AggerateEventArgs<ItemNavigationViewModel,
|
INotificationHandler<AggerateEventArgs<ItemNavigationViewModel,
|
||||||
ContainerViewModelConfiguration>>
|
LockerViewModelConfiguration>>
|
||||||
{
|
{
|
||||||
public async Task Handle(AggerateEventArgs<ItemNavigationViewModel,
|
public async Task Handle(AggerateEventArgs<ItemNavigationViewModel,
|
||||||
ContainerViewModelConfiguration> args)
|
LockerViewModelConfiguration> args)
|
||||||
{
|
{
|
||||||
if (args.Options is ContainerViewModelConfiguration configuration)
|
if (args.Options is LockerViewModelConfiguration configuration)
|
||||||
{
|
{
|
||||||
cache.Clear();
|
cache.Clear();
|
||||||
bool selected = true;
|
bool selected = true;
|
||||||
|
|
||||||
if (await mediator.Handle<RequestEventArgs<QueryContainerConfiguration>,
|
if (await mediator.Handle<RequestEventArgs<QueryLockerConfiguration>,
|
||||||
IReadOnlyCollection<(Guid Id, string Name, bool Favourite, bool Archived)>>(Request.As(new QueryContainerConfiguration
|
IReadOnlyCollection<(Guid Id, string Name, bool Favourite, bool Archived)>>(Request.As(new QueryLockerConfiguration
|
||||||
{
|
{
|
||||||
Filter = configuration.Filter,
|
Filter = configuration.Filter,
|
||||||
Query = configuration.Query
|
Query = configuration.Query
|
||||||
@@ -4,19 +4,19 @@ using Toolkit.Foundation;
|
|||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public class AggerateMainViewModelHandler(IPublisher publisher,
|
public class AggerateMainViewModelHandler(IPublisher publisher,
|
||||||
IContainerHostCollection containers) :
|
ILockerHostCollection lockers) :
|
||||||
INotificationHandler<AggerateEventArgs<IMainNavigationViewModel>>
|
INotificationHandler<AggerateEventArgs<IMainNavigationViewModel>>
|
||||||
{
|
{
|
||||||
public Task Handle(AggerateEventArgs<IMainNavigationViewModel> args)
|
public Task Handle(AggerateEventArgs<IMainNavigationViewModel> args)
|
||||||
{
|
{
|
||||||
foreach (IComponentHost container in containers.OrderBy(x => x.GetConfiguration<ContainerConfiguration>()
|
foreach (IComponentHost locker in lockers.OrderBy(x => x.GetConfiguration<LockerConfiguration>()
|
||||||
is ContainerConfiguration configuration ? configuration.Name : null))
|
is LockerConfiguration configuration ? configuration.Name : null))
|
||||||
{
|
{
|
||||||
if (container.Services.GetRequiredService<ContainerConfiguration>() is ContainerConfiguration configuration)
|
if (locker.Services.GetRequiredService<LockerConfiguration>() is LockerConfiguration configuration)
|
||||||
{
|
{
|
||||||
if (container.Services.GetRequiredService<IServiceFactory>() is IServiceFactory factory)
|
if (locker.Services.GetRequiredService<IServiceFactory>() is IServiceFactory factory)
|
||||||
{
|
{
|
||||||
if (factory.Create<ContainerNavigationViewModel>(configuration.Name) is ContainerNavigationViewModel viewModel)
|
if (factory.Create<LockerNavigationViewModel>(configuration.Name) is LockerNavigationViewModel viewModel)
|
||||||
{
|
{
|
||||||
publisher.Publish(Create.As<IMainNavigationViewModel>(viewModel),
|
publisher.Publish(Create.As<IMainNavigationViewModel>(viewModel),
|
||||||
nameof(MainViewModel));
|
nameof(MainViewModel));
|
||||||
|
|||||||
@@ -8,4 +8,4 @@ public partial class AllNavigationViewModel(IServiceProvider provider,
|
|||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
string filter) : FilterContainerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, filter);
|
string filter) : FilterLockerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, filter);
|
||||||
@@ -8,4 +8,4 @@ public partial class ArchiveNavigationViewModel(IServiceProvider provider,
|
|||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
string name) : FilterContainerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
string name) : FilterLockerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||||
@@ -8,4 +8,4 @@ public partial class CategoriesNavigationViewModel(IServiceProvider provider,
|
|||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
string name) : FilterContainerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
string name) : FilterLockerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
using System.Collections.ObjectModel;
|
|
||||||
|
|
||||||
namespace Bitvault;
|
|
||||||
|
|
||||||
public class CommandCollection(IList<IDisposable> list) :
|
|
||||||
ReadOnlyCollection<IDisposable>(list)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Toolkit.Foundation;
|
|
||||||
|
|
||||||
namespace Bitvault;
|
|
||||||
|
|
||||||
public class ContainerActivatedHandler(IContainerHostCollection containers,
|
|
||||||
IPublisher publisher) :
|
|
||||||
INotificationHandler<ActivatedEventArgs<IComponentHost>>
|
|
||||||
{
|
|
||||||
public Task Handle(ActivatedEventArgs<IComponentHost> args)
|
|
||||||
{
|
|
||||||
if (args.Value is IComponentHost container)
|
|
||||||
{
|
|
||||||
List<IComponentHost> sortedContainers = [.. containers, container];
|
|
||||||
sortedContainers = [.. sortedContainers.OrderBy(x => x.GetConfiguration<ContainerConfiguration>() is ContainerConfiguration configuration ? configuration.Name : null)];
|
|
||||||
|
|
||||||
int index = sortedContainers.IndexOf(container);
|
|
||||||
|
|
||||||
if (container.Services.GetRequiredService<ContainerConfiguration>() is ContainerConfiguration configuration)
|
|
||||||
{
|
|
||||||
if (container.Services.GetRequiredService<IServiceFactory>() is IServiceFactory serviceFactory)
|
|
||||||
{
|
|
||||||
if (serviceFactory.Create<ContainerNavigationViewModel>(configuration.Name) is ContainerNavigationViewModel viewModel)
|
|
||||||
{
|
|
||||||
publisher.Publish(new InsertEventArgs<IMainNavigationViewModel>(index, viewModel),
|
|
||||||
nameof(MainViewModel));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
using Toolkit.Foundation;
|
|
||||||
|
|
||||||
namespace Bitvault;
|
|
||||||
|
|
||||||
public class ContainerComponent(IComponentBuilder builder) : Component(builder),
|
|
||||||
IContainerComponent;
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
using Toolkit.Foundation;
|
|
||||||
|
|
||||||
namespace Bitvault;
|
|
||||||
|
|
||||||
public class ContainerFactory(IComponentFactory componentFactory) :
|
|
||||||
IContainerFactory
|
|
||||||
{
|
|
||||||
public IComponentHost? Create(string name)
|
|
||||||
{
|
|
||||||
if (componentFactory.Create<IContainerComponent, ContainerConfiguration>($"Locker:{name}",
|
|
||||||
new ContainerConfiguration { Name = name }) is IComponentHost host)
|
|
||||||
{
|
|
||||||
return host;
|
|
||||||
}
|
|
||||||
|
|
||||||
return default;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
using Toolkit.Foundation;
|
|
||||||
|
|
||||||
namespace Bitvault;
|
|
||||||
|
|
||||||
public partial class ContainerHeaderViewModel :
|
|
||||||
ObservableCollection
|
|
||||||
{
|
|
||||||
public ContainerHeaderViewModel(IServiceProvider provider,
|
|
||||||
IServiceFactory factory,
|
|
||||||
IMediator mediator,
|
|
||||||
IPublisher publisher,
|
|
||||||
ISubscription subscriber,
|
|
||||||
IDisposer disposer,
|
|
||||||
IContentTemplate template) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
|
||||||
{
|
|
||||||
Template = template;
|
|
||||||
|
|
||||||
Add<CreateItemActionViewModel>(0);
|
|
||||||
Add<SearchContainerActionViewModel>(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IContentTemplate Template { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
using Toolkit.Foundation;
|
|
||||||
|
|
||||||
namespace Bitvault;
|
|
||||||
|
|
||||||
public class ContainerInitializer(IEnumerable<IConfigurationDescriptor<ContainerConfiguration>> configurations,
|
|
||||||
IComponentFactory componentFactory,
|
|
||||||
IContainerHostCollection vaults) : IInitializer
|
|
||||||
{
|
|
||||||
public async Task Initialize()
|
|
||||||
{
|
|
||||||
foreach (IConfigurationDescriptor<ContainerConfiguration> configuration in configurations)
|
|
||||||
{
|
|
||||||
if (componentFactory.Create<IContainerComponent,
|
|
||||||
ContainerConfiguration>(configuration.Section, configuration.Value)
|
|
||||||
is IComponentHost host)
|
|
||||||
{
|
|
||||||
vaults.Add(host);
|
|
||||||
await host.StartAsync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,11 +9,10 @@ public partial class CreateItemActionViewModel(IServiceProvider provider,
|
|||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
NamedComponent named,
|
NamedComponent named) : Observable(provider, factory, mediator, publisher, subscriber, disposer)
|
||||||
int index) : Observable(provider, factory, mediator, publisher, subscriber, disposer)
|
|
||||||
{
|
{
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private int index = index;
|
private int index = 0;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string named = $"{named}";
|
private string named = $"{named}";
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public class CreateItemHandler(IDbContextFactory<ContainerDbContext> dbContextFactory) :
|
public class CreateItemHandler(IDbContextFactory<LockerContext> dbContextFactory) :
|
||||||
IHandler<CreateEventArgs<(Guid, ItemConfiguration)>, bool>
|
IHandler<CreateEventArgs<(Guid, ItemConfiguration)>, bool>
|
||||||
{
|
{
|
||||||
public async Task<bool> Handle(CreateEventArgs<(Guid, ItemConfiguration)> args,
|
public async Task<bool> Handle(CreateEventArgs<(Guid, ItemConfiguration)> args,
|
||||||
@@ -17,7 +17,7 @@ public class CreateItemHandler(IDbContextFactory<ContainerDbContext> dbContextFa
|
|||||||
{
|
{
|
||||||
string? name = configuration.Name;
|
string? name = configuration.Name;
|
||||||
|
|
||||||
using ContainerDbContext context = dbContextFactory.CreateDbContext();
|
using LockerContext context = dbContextFactory.CreateDbContext();
|
||||||
EntityEntry<ItemEntry>? result = null;
|
EntityEntry<ItemEntry>? result = null;
|
||||||
|
|
||||||
await Task.Run(async () =>
|
await Task.Run(async () =>
|
||||||
|
|||||||
@@ -5,30 +5,30 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public class CreateContainerHandler(IContainerFactory componentFactory,
|
public class CreateLockerHandler(ILockerFactory componentFactory,
|
||||||
IPublisher publisher) :
|
IPublisher publisher) :
|
||||||
IHandler<CreateEventArgs<Container>, bool>
|
IHandler<CreateEventArgs<Locker>, bool>
|
||||||
{
|
{
|
||||||
public async Task<bool> Handle(CreateEventArgs<Container> args,
|
public async Task<bool> Handle(CreateEventArgs<Locker> args,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (args.Value is Container container && container.Name is { Length: > 0 } name &&
|
if (args.Value is Locker locker && locker.Name is { Length: > 0 } name &&
|
||||||
container.Password is { Length: > 0 } password)
|
locker.Password is { Length: > 0 } password)
|
||||||
{
|
{
|
||||||
if (componentFactory.Create(name) is IComponentHost host)
|
if (componentFactory.Create(name) is IComponentHost host)
|
||||||
{
|
{
|
||||||
ISecurityKeyFactory keyVaultFactory = host.Services.GetRequiredService<ISecurityKeyFactory>();
|
ISecurityKeyFactory keyVaultFactory = host.Services.GetRequiredService<ISecurityKeyFactory>();
|
||||||
IValueStore<SecurityKey> secureKeyStore = host.Services.GetRequiredService<IValueStore<SecurityKey>>();
|
IValueStore<SecurityKey> secureKeyStore = host.Services.GetRequiredService<IValueStore<SecurityKey>>();
|
||||||
IContainerStorageFactory containerFactory = host.Services.GetRequiredService<IContainerStorageFactory>();
|
ILockerStorageFactory lockerStorageFactory = host.Services.GetRequiredService<ILockerStorageFactory>();
|
||||||
|
|
||||||
if (keyVaultFactory.Create(Encoding.UTF8.GetBytes(password)) is SecurityKey key)
|
if (keyVaultFactory.Create(Encoding.UTF8.GetBytes(password)) is SecurityKey key)
|
||||||
{
|
{
|
||||||
secureKeyStore.Set(key);
|
secureKeyStore.Set(key);
|
||||||
|
|
||||||
if (await containerFactory.Create(name, key))
|
if (await lockerStorageFactory.Create(name, key))
|
||||||
{
|
{
|
||||||
IWritableConfiguration<ContainerConfiguration> configuration =
|
IWritableConfiguration<LockerConfiguration> configuration =
|
||||||
host.Services.GetRequiredService<IWritableConfiguration<ContainerConfiguration>>();
|
host.Services.GetRequiredService<IWritableConfiguration<LockerConfiguration>>();
|
||||||
|
|
||||||
configuration.Write(args => args.Key = $"{Convert.ToBase64String(key.Salt)}:{Convert.ToBase64String(key.EncryptedKey)}:{Convert.ToBase64String(key.DecryptedKey)}");
|
configuration.Write(args => args.Key = $"{Convert.ToBase64String(key.Salt)}:{Convert.ToBase64String(key.EncryptedKey)}:{Convert.ToBase64String(key.DecryptedKey)}");
|
||||||
host.Start();
|
host.Start();
|
||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public partial class CreateContainerNavigationViewModel(IServiceProvider provider,
|
public partial class CreateLockerNavigationViewModel(IServiceProvider provider,
|
||||||
IServiceFactory factory,
|
IServiceFactory factory,
|
||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public partial class CreateContainerViewModel(IServiceProvider provider,
|
public partial class CreateLockerViewModel(IServiceProvider provider,
|
||||||
IServiceFactory factory,
|
IServiceFactory factory,
|
||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
@@ -22,5 +22,5 @@ public partial class CreateContainerViewModel(IServiceProvider provider,
|
|||||||
private string password;
|
private string password;
|
||||||
|
|
||||||
public async Task<bool> Confirm() =>
|
public async Task<bool> Confirm() =>
|
||||||
await Mediator.Handle<CreateEventArgs<Container>, bool>(Create.As(new Container(Name, Password)));
|
await Mediator.Handle<CreateEventArgs<Locker>, bool>(Create.As(new Locker(Name, Password)));
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ public class CreatedItemHandler(IServiceProvider serviceProvider,
|
|||||||
int index = cache.IndexOf(item);
|
int index = cache.IndexOf(item);
|
||||||
valueStore.Set(item);
|
valueStore.Set(item);
|
||||||
|
|
||||||
publisher.Publish(Insert.As(index, viewModel), nameof(ContainerViewModel));
|
publisher.Publish(Insert.As(index, viewModel), nameof(LockerViewModel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public record DropdownEntryConfiguration :
|
||||||
|
ItemEntryConfiguration
|
||||||
|
{
|
||||||
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||||
|
public string[]? Values { get; set; }
|
||||||
|
}
|
||||||
+7
-7
@@ -4,10 +4,10 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public partial class FilterContainerNavigationViewModel : Observable,
|
public partial class FilterLockerNavigationViewModel : Observable,
|
||||||
IContainerNavigationViewModel,
|
ILockerNavigationViewModel,
|
||||||
INotificationHandler<ActivatedEventArgs<Container>>,
|
INotificationHandler<ActivatedEventArgs<Locker>>,
|
||||||
INotificationHandler<DeactivatedEventArgs<Container>>
|
INotificationHandler<DeactivatedEventArgs<Locker>>
|
||||||
{
|
{
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool activated;
|
private bool activated;
|
||||||
@@ -18,7 +18,7 @@ public partial class FilterContainerNavigationViewModel : Observable,
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool selected;
|
private bool selected;
|
||||||
|
|
||||||
public FilterContainerNavigationViewModel(IServiceProvider provider,
|
public FilterLockerNavigationViewModel(IServiceProvider provider,
|
||||||
IServiceFactory factory,
|
IServiceFactory factory,
|
||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
@@ -29,10 +29,10 @@ public partial class FilterContainerNavigationViewModel : Observable,
|
|||||||
Filter = filter;
|
Filter = filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task Handle(DeactivatedEventArgs<Container> args) =>
|
public Task Handle(DeactivatedEventArgs<Locker> args) =>
|
||||||
Task.FromResult(Activated = false);
|
Task.FromResult(Activated = false);
|
||||||
|
|
||||||
public Task Handle(ActivatedEventArgs<Container> args) =>
|
public Task Handle(ActivatedEventArgs<Locker> args) =>
|
||||||
Task.FromResult(Activated = true);
|
Task.FromResult(Activated = true);
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
namespace Bitvault;
|
|
||||||
|
|
||||||
public record Form
|
|
||||||
{
|
|
||||||
public ICollection<FormEntry>? Entries { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
namespace Bitvault;
|
|
||||||
|
|
||||||
public record FormEntry;
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
namespace Bitvault;
|
|
||||||
|
|
||||||
public record FormField : FormEntry
|
|
||||||
{
|
|
||||||
public string? Name { get; set; }
|
|
||||||
|
|
||||||
public string? Description { get; set; }
|
|
||||||
|
|
||||||
public object? Value { get; set; }
|
|
||||||
|
|
||||||
public FormFieldType Type { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
namespace Bitvault;
|
|
||||||
|
|
||||||
public enum FormFieldType
|
|
||||||
{
|
|
||||||
Attachments,
|
|
||||||
Date,
|
|
||||||
Masked,
|
|
||||||
Note,
|
|
||||||
Number,
|
|
||||||
Options,
|
|
||||||
Password,
|
|
||||||
Phone,
|
|
||||||
Text,
|
|
||||||
Time,
|
|
||||||
Url
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
namespace Bitvault;
|
|
||||||
|
|
||||||
public record FormGroup : FormEntry
|
|
||||||
{
|
|
||||||
public string? Name { get; set; }
|
|
||||||
|
|
||||||
public ICollection<FormField>? Fields { get; set; }
|
|
||||||
}
|
|
||||||
@@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public interface IContainerHost : IComponentHost;
|
public interface ILockerComponent : IComponent;
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Bitvault
|
namespace Bitvault
|
||||||
{
|
{
|
||||||
public interface IContainerFactory
|
public interface ILockerFactory
|
||||||
{
|
{
|
||||||
IComponentHost? Create(string name);
|
IComponentHost? Create(string name);
|
||||||
}
|
}
|
||||||
@@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public interface IContainerComponent : IComponent;
|
public interface ILockerHost : IComponentHost;
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public interface IContainerHostCollection :
|
public interface ILockerHostCollection :
|
||||||
IEnumerable<IComponentHost>
|
IEnumerable<IComponentHost>
|
||||||
{
|
{
|
||||||
void Add(IComponentHost host);
|
void Add(IComponentHost host);
|
||||||
@@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public interface IContainerNavigationViewModel :
|
public interface ILockerNavigationViewModel :
|
||||||
ISelectable,
|
ISelectable,
|
||||||
IDisposable;
|
IDisposable;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public interface IContainerStorageFactory
|
public interface ILockerStorageFactory
|
||||||
{
|
{
|
||||||
Task<bool> Create(string name, SecurityKey key);
|
Task<bool> Create(string name, SecurityKey key);
|
||||||
}
|
}
|
||||||
@@ -14,4 +14,14 @@ public partial class ItemCategoryCollectionViewModel(IServiceProvider provider,
|
|||||||
{
|
{
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private IContentTemplate template = template;
|
private IContentTemplate template = template;
|
||||||
|
|
||||||
|
public override Task OnActivated()
|
||||||
|
{
|
||||||
|
Publisher.Publish(Notify.As(Factory.Create<LockerCommandHeaderCollection>(new List<IDisposable>
|
||||||
|
{
|
||||||
|
|
||||||
|
})));
|
||||||
|
|
||||||
|
return base.OnActivated();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public partial class ItemCollectionViewModel :
|
|||||||
INotificationHandler<NotifyEventArgs<Filter>>,
|
INotificationHandler<NotifyEventArgs<Filter>>,
|
||||||
INotificationHandler<NotifyEventArgs<Search>>
|
INotificationHandler<NotifyEventArgs<Search>>
|
||||||
{
|
{
|
||||||
private ContainerViewModelConfiguration configuration;
|
private LockerViewModelConfiguration configuration;
|
||||||
|
|
||||||
public ItemCollectionViewModel(IServiceProvider provider,
|
public ItemCollectionViewModel(IServiceProvider provider,
|
||||||
IServiceFactory factory,
|
IServiceFactory factory,
|
||||||
@@ -17,7 +17,7 @@ public partial class ItemCollectionViewModel :
|
|||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
IContentTemplate template,
|
IContentTemplate template,
|
||||||
ContainerViewModelConfiguration configuration,
|
LockerViewModelConfiguration configuration,
|
||||||
string? filter = null) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
string? filter = null) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||||
{
|
{
|
||||||
Template = template;
|
Template = template;
|
||||||
@@ -48,7 +48,18 @@ public partial class ItemCollectionViewModel :
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IAggerate OnPrepareAggregation(object? key) =>
|
public override Task OnActivated()
|
||||||
Aggerate.With<ItemNavigationViewModel, ContainerViewModelConfiguration>(configuration)
|
{
|
||||||
|
Publisher.Publish(Notify.As(Factory.Create<LockerCommandHeaderCollection>(new List<IDisposable>
|
||||||
|
{
|
||||||
|
Factory.Create<CreateItemActionViewModel>(),
|
||||||
|
Factory.Create<SearchLockerActionViewModel>(),
|
||||||
|
})));
|
||||||
|
|
||||||
|
return base.OnActivated();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IAggerate OnAggerate(object? key) =>
|
||||||
|
Aggerate.With<ItemNavigationViewModel, LockerViewModelConfiguration>(configuration)
|
||||||
with { Key = key };
|
with { Key = key };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public class ItemCommandHeaderCollection(IList<IDisposable> list) :
|
||||||
|
ReadOnlyCollection<IDisposable>(list);
|
||||||
@@ -10,14 +10,15 @@ public partial class ItemCommandHeaderViewModel(IServiceProvider provider,
|
|||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
IContentTemplate template) :
|
IContentTemplate template) :
|
||||||
ObservableCollection(provider, factory, mediator, publisher, subscriber, disposer),
|
ObservableCollection(provider, factory, mediator, publisher, subscriber, disposer),
|
||||||
INotificationHandler<NotifyEventArgs<CommandCollection>>
|
INotificationHandler<NotifyEventArgs<ItemCommandHeaderCollection>>
|
||||||
{
|
{
|
||||||
public IContentTemplate Template { get; set; } = template;
|
public IContentTemplate Template { get; set; } = template;
|
||||||
|
|
||||||
public Task Handle(NotifyEventArgs<CommandCollection> args)
|
public Task Handle(NotifyEventArgs<ItemCommandHeaderCollection> args)
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
if (args.Value is CommandCollection commandCollection)
|
|
||||||
|
if (args.Value is ItemCommandHeaderCollection commandCollection)
|
||||||
{
|
{
|
||||||
foreach (IDisposable command in commandCollection)
|
foreach (IDisposable command in commandCollection)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,4 +3,40 @@
|
|||||||
public record ItemConfiguration
|
public record ItemConfiguration
|
||||||
{
|
{
|
||||||
public string Name { get; set; } = "";
|
public string Name { get; set; } = "";
|
||||||
|
|
||||||
|
public IList<ItemSectionConfiguration>? Sections { get; set; }
|
||||||
|
|
||||||
|
public static ItemConfiguration CreditCard => new()
|
||||||
|
{
|
||||||
|
Name = "Credit Card",
|
||||||
|
Sections = new List<ItemSectionConfiguration>
|
||||||
|
{
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Entries = new List<ItemEntryConfiguration>
|
||||||
|
{
|
||||||
|
new TextEntryConfiguration
|
||||||
|
{
|
||||||
|
Label = "Cardholder name"
|
||||||
|
},
|
||||||
|
new DropdownEntryConfiguration
|
||||||
|
{
|
||||||
|
Label = "Type",
|
||||||
|
},
|
||||||
|
new MaskedTextEntryConfiguration
|
||||||
|
{
|
||||||
|
Label = "Card number"
|
||||||
|
},
|
||||||
|
new MaskedTextEntryConfiguration
|
||||||
|
{
|
||||||
|
Label = "Expiry date"
|
||||||
|
},
|
||||||
|
new MaskedTextEntryConfiguration
|
||||||
|
{
|
||||||
|
Label = "Card verification code"
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace Bitvault;
|
||||||
|
|
||||||
|
[JsonDerivedType(typeof(DropdownEntryConfiguration), typeDiscriminator: "Dropdown")]
|
||||||
|
[JsonDerivedType(typeof(MaskedTextEntryConfiguration), typeDiscriminator: "MaskedText")]
|
||||||
|
[JsonDerivedType(typeof(NoteEntryConfiguration), typeDiscriminator: "Note")]
|
||||||
|
[JsonDerivedType(typeof(NumberEntryConfiguration), typeDiscriminator: "Number")]
|
||||||
|
[JsonDerivedType(typeof(PasswordEntryConfiguration), typeDiscriminator: "Password")]
|
||||||
|
[JsonDerivedType(typeof(TextEntryConfiguration), typeDiscriminator: "Text")]
|
||||||
|
public record ItemEntryConfiguration
|
||||||
|
{
|
||||||
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||||
|
public string? Label { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||||
|
public object? Value { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public record ItemSectionConfiguration
|
||||||
|
{
|
||||||
|
public IList<ItemEntryConfiguration> Entries { get; set; } = new List<ItemEntryConfiguration>();
|
||||||
|
}
|
||||||
@@ -52,7 +52,7 @@ public partial class ItemViewModel :
|
|||||||
|
|
||||||
public Task Handle(UpdateEventArgs<Item> args)
|
public Task Handle(UpdateEventArgs<Item> args)
|
||||||
{
|
{
|
||||||
Publisher.Publish(Notify.As(Factory.Create<CommandCollection>(new List<IDisposable>
|
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||||
{
|
{
|
||||||
Factory.Create<ConfirmItemActionViewModel>(),
|
Factory.Create<ConfirmItemActionViewModel>(),
|
||||||
Factory.Create<DismissItemActionViewModel>(),
|
Factory.Create<DismissItemActionViewModel>(),
|
||||||
@@ -63,7 +63,7 @@ public partial class ItemViewModel :
|
|||||||
|
|
||||||
public Task Handle(CancelEventArgs<Item> args)
|
public Task Handle(CancelEventArgs<Item> args)
|
||||||
{
|
{
|
||||||
Publisher.Publish(Notify.As(Factory.Create<CommandCollection>(new List<IDisposable>
|
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||||
{
|
{
|
||||||
Factory.Create<EditItemActionViewModel>(),
|
Factory.Create<EditItemActionViewModel>(),
|
||||||
Factory.Create<ArchiveItemActionViewModel>(),
|
Factory.Create<ArchiveItemActionViewModel>(),
|
||||||
@@ -74,7 +74,7 @@ public partial class ItemViewModel :
|
|||||||
|
|
||||||
public Task Handle(ConfirmEventArgs<Item> args)
|
public Task Handle(ConfirmEventArgs<Item> args)
|
||||||
{
|
{
|
||||||
Publisher.Publish(Notify.As(Factory.Create<CommandCollection>(new List<IDisposable>
|
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||||
{
|
{
|
||||||
Factory.Create<FavouriteItemActionViewModel>(Favourite),
|
Factory.Create<FavouriteItemActionViewModel>(Favourite),
|
||||||
Factory.Create<EditItemActionViewModel>(),
|
Factory.Create<EditItemActionViewModel>(),
|
||||||
@@ -88,7 +88,7 @@ public partial class ItemViewModel :
|
|||||||
{
|
{
|
||||||
if (!Immutable)
|
if (!Immutable)
|
||||||
{
|
{
|
||||||
Publisher.Publish(Notify.As(Factory.Create<CommandCollection>(new List<IDisposable>
|
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||||
{
|
{
|
||||||
Factory.Create<ConfirmItemActionViewModel>(),
|
Factory.Create<ConfirmItemActionViewModel>(),
|
||||||
Factory.Create<DismissItemActionViewModel>(),
|
Factory.Create<DismissItemActionViewModel>(),
|
||||||
@@ -96,14 +96,14 @@ public partial class ItemViewModel :
|
|||||||
}
|
}
|
||||||
else if (Archived)
|
else if (Archived)
|
||||||
{
|
{
|
||||||
Publisher.Publish(Notify.As(Factory.Create<CommandCollection>(new List<IDisposable>
|
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||||
{
|
{
|
||||||
Factory.Create<UnarchiveItemActionViewModel>(),
|
Factory.Create<UnarchiveItemActionViewModel>(),
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Publisher.Publish(Notify.As(Factory.Create<CommandCollection>(new List<IDisposable>
|
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||||
{
|
{
|
||||||
Factory.Create<FavouriteItemActionViewModel>(Favourite),
|
Factory.Create<FavouriteItemActionViewModel>(Favourite),
|
||||||
Factory.Create<EditItemActionViewModel>(),
|
Factory.Create<EditItemActionViewModel>(),
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public record Container
|
public record Locker
|
||||||
{
|
{
|
||||||
public Container(string name, string password)
|
public Locker(string name, string password)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
Password = password;
|
Password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Container(string password)
|
public Locker(string password)
|
||||||
{
|
{
|
||||||
Password = password;
|
Password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Container()
|
public Locker()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Toolkit.Foundation;
|
||||||
|
|
||||||
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public class LockerActivatedHandler(ILockerHostCollection lockers,
|
||||||
|
IPublisher publisher) :
|
||||||
|
INotificationHandler<ActivatedEventArgs<IComponentHost>>
|
||||||
|
{
|
||||||
|
public Task Handle(ActivatedEventArgs<IComponentHost> args)
|
||||||
|
{
|
||||||
|
if (args.Value is IComponentHost locker)
|
||||||
|
{
|
||||||
|
List<IComponentHost> sortedLockers = [.. lockers, locker];
|
||||||
|
sortedLockers = [.. sortedLockers.OrderBy(x => x.GetConfiguration<LockerConfiguration>() is LockerConfiguration configuration ? configuration.Name : null)];
|
||||||
|
|
||||||
|
int index = sortedLockers.IndexOf(locker);
|
||||||
|
|
||||||
|
if (locker.Services.GetRequiredService<LockerConfiguration>() is LockerConfiguration configuration)
|
||||||
|
{
|
||||||
|
if (locker.Services.GetRequiredService<IServiceFactory>() is IServiceFactory serviceFactory)
|
||||||
|
{
|
||||||
|
if (serviceFactory.Create<LockerNavigationViewModel>(configuration.Name) is LockerNavigationViewModel viewModel)
|
||||||
|
{
|
||||||
|
publisher.Publish(new InsertEventArgs<IMainNavigationViewModel>(index, viewModel),
|
||||||
|
nameof(MainViewModel));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public class LockerCommandHeaderCollection(IList<IDisposable> list) :
|
||||||
|
ReadOnlyCollection<IDisposable>(list);
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
using Toolkit.Foundation;
|
||||||
|
|
||||||
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public class LockerComponent(IComponentBuilder builder) : Component(builder),
|
||||||
|
ILockerComponent;
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public record ContainerConfiguration :
|
public record LockerConfiguration :
|
||||||
ComponentConfiguration
|
ComponentConfiguration
|
||||||
{
|
{
|
||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public class ContainerConnection(string connection)
|
public class LockerConnection(string connection)
|
||||||
{
|
{
|
||||||
private readonly string connection = connection;
|
private readonly string connection = connection;
|
||||||
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using Toolkit.Foundation;
|
||||||
|
|
||||||
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public class LockerFactory(IComponentFactory componentFactory) :
|
||||||
|
ILockerFactory
|
||||||
|
{
|
||||||
|
public IComponentHost? Create(string name)
|
||||||
|
{
|
||||||
|
if (componentFactory.Create<ILockerComponent, LockerConfiguration>($"Locker:{name}",
|
||||||
|
new LockerConfiguration { Name = name }) is IComponentHost host)
|
||||||
|
{
|
||||||
|
return host;
|
||||||
|
}
|
||||||
|
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
using Toolkit.Foundation;
|
||||||
|
|
||||||
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public partial class LockerHeaderViewModel(IServiceProvider provider,
|
||||||
|
IServiceFactory factory,
|
||||||
|
IMediator mediator,
|
||||||
|
IPublisher publisher,
|
||||||
|
ISubscription subscriber,
|
||||||
|
IDisposer disposer,
|
||||||
|
IContentTemplate template) :
|
||||||
|
ObservableCollection(provider, factory, mediator, publisher, subscriber, disposer),
|
||||||
|
INotificationHandler<NotifyEventArgs<LockerCommandHeaderCollection>>
|
||||||
|
{
|
||||||
|
public IContentTemplate Template { get; set; } = template;
|
||||||
|
|
||||||
|
public Task Handle(NotifyEventArgs<LockerCommandHeaderCollection> args)
|
||||||
|
{
|
||||||
|
Clear();
|
||||||
|
|
||||||
|
if (args.Value is LockerCommandHeaderCollection commandCollection)
|
||||||
|
{
|
||||||
|
foreach (IDisposable command in commandCollection)
|
||||||
|
{
|
||||||
|
Add(command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,8 +3,8 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public class ContainerHostCollection :
|
public class LockerHostCollection :
|
||||||
IContainerHostCollection
|
ILockerHostCollection
|
||||||
|
|
||||||
{
|
{
|
||||||
private readonly List<IComponentHost> hosts = [];
|
private readonly List<IComponentHost> hosts = [];
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using Toolkit.Foundation;
|
||||||
|
|
||||||
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public class LockerInitializer(IEnumerable<IConfigurationDescriptor<LockerConfiguration>> configurations,
|
||||||
|
IComponentFactory componentFactory,
|
||||||
|
ILockerHostCollection lockers) : IInitializer
|
||||||
|
{
|
||||||
|
public async Task Initialize()
|
||||||
|
{
|
||||||
|
foreach (IConfigurationDescriptor<LockerConfiguration> configuration in configurations)
|
||||||
|
{
|
||||||
|
if (componentFactory.Create<ILockerComponent,
|
||||||
|
LockerConfiguration>(configuration.Section, configuration.Value)
|
||||||
|
is IComponentHost host)
|
||||||
|
{
|
||||||
|
lockers.Add(host);
|
||||||
|
await host.StartAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,13 +3,13 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public partial class ContainerNavigationViewModel :
|
public partial class LockerNavigationViewModel :
|
||||||
ObservableCollection<IContainerNavigationViewModel>,
|
ObservableCollection<ILockerNavigationViewModel>,
|
||||||
IMainNavigationViewModel,
|
IMainNavigationViewModel,
|
||||||
INotificationHandler<OpenedEventArgs<Container>>,
|
INotificationHandler<OpenedEventArgs<Locker>>,
|
||||||
INotificationHandler<ClosedEventArgs<Container>>,
|
INotificationHandler<ClosedEventArgs<Locker>>,
|
||||||
INotificationHandler<ActivatedEventArgs<Container>>,
|
INotificationHandler<ActivatedEventArgs<Locker>>,
|
||||||
INotificationHandler<DeactivatedEventArgs<Container>>
|
INotificationHandler<DeactivatedEventArgs<Locker>>
|
||||||
{
|
{
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool activated;
|
private bool activated;
|
||||||
@@ -26,7 +26,7 @@ public partial class ContainerNavigationViewModel :
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool selected;
|
private bool selected;
|
||||||
|
|
||||||
public ContainerNavigationViewModel(IServiceProvider provider,
|
public LockerNavigationViewModel(IServiceProvider provider,
|
||||||
IServiceFactory factory,
|
IServiceFactory factory,
|
||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
@@ -41,7 +41,7 @@ public partial class ContainerNavigationViewModel :
|
|||||||
|
|
||||||
public IContentTemplate Template { get; set; }
|
public IContentTemplate Template { get; set; }
|
||||||
|
|
||||||
public Task Handle(OpenedEventArgs<Container> args)
|
public Task Handle(OpenedEventArgs<Locker> args)
|
||||||
{
|
{
|
||||||
Add<AllNavigationViewModel>("All");
|
Add<AllNavigationViewModel>("All");
|
||||||
Add<StarredNavigationViewModel>("Starred");
|
Add<StarredNavigationViewModel>("Starred");
|
||||||
@@ -52,7 +52,7 @@ public partial class ContainerNavigationViewModel :
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task Handle(ClosedEventArgs<Container> args)
|
public Task Handle(ClosedEventArgs<Locker> args)
|
||||||
{
|
{
|
||||||
Opened = true;
|
Opened = true;
|
||||||
Clear();
|
Clear();
|
||||||
@@ -60,9 +60,9 @@ public partial class ContainerNavigationViewModel :
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task Handle(DeactivatedEventArgs<Container> args) =>
|
public Task Handle(DeactivatedEventArgs<Locker> args) =>
|
||||||
Task.FromResult(Activated = false);
|
Task.FromResult(Activated = false);
|
||||||
|
|
||||||
public Task Handle(ActivatedEventArgs<Container> args) =>
|
public Task Handle(ActivatedEventArgs<Locker> args) =>
|
||||||
Task.FromResult(Activated = true);
|
Task.FromResult(Activated = true);
|
||||||
}
|
}
|
||||||
@@ -6,19 +6,19 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public class ContainerStorageFactory(IValueStore<ContainerConnection> connection,
|
public class LockerStorageFactory(IValueStore<LockerConnection> connection,
|
||||||
IHostEnvironment environment,
|
IHostEnvironment environment,
|
||||||
IServiceProvider provider) :
|
IServiceProvider provider) :
|
||||||
IContainerStorageFactory
|
ILockerStorageFactory
|
||||||
{
|
{
|
||||||
public async Task<bool> Create(string name,
|
public async Task<bool> Create(string name,
|
||||||
SecurityKey key)
|
SecurityKey key)
|
||||||
{
|
{
|
||||||
connection.Set(new ContainerConnection($"Data Source={Path.Combine(environment.ContentRootPath, name)}" +
|
connection.Set(new LockerConnection($"Data Source={Path.Combine(environment.ContentRootPath, name)}" +
|
||||||
$".vault;Mode=ReadWriteCreate;Pooling=false;Password={Convert.ToBase64String(key.DecryptedKey)}"));
|
$".vault;Mode=ReadWriteCreate;Pooling=false;Password={Convert.ToBase64String(key.DecryptedKey)}"));
|
||||||
|
|
||||||
IDbContextFactory<ContainerDbContext> dbContextFactory = provider.GetRequiredService<IDbContextFactory<ContainerDbContext>>();
|
IDbContextFactory<LockerContext> dbContextFactory = provider.GetRequiredService<IDbContextFactory<LockerContext>>();
|
||||||
using ContainerDbContext context = await dbContextFactory.CreateDbContextAsync();
|
using LockerContext context = await dbContextFactory.CreateDbContextAsync();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -3,7 +3,7 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public partial class ContainerViewModel :
|
public partial class LockerViewModel :
|
||||||
Observable
|
Observable
|
||||||
{
|
{
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
@@ -11,7 +11,7 @@ public partial class ContainerViewModel :
|
|||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string filter;
|
private string filter;
|
||||||
public ContainerViewModel(IServiceProvider provider,
|
public LockerViewModel(IServiceProvider provider,
|
||||||
IServiceFactory factory,
|
IServiceFactory factory,
|
||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
@@ -26,13 +26,13 @@ public partial class ContainerViewModel :
|
|||||||
|
|
||||||
public override async Task OnActivated()
|
public override async Task OnActivated()
|
||||||
{
|
{
|
||||||
Publisher.Publish(Activated.As<Container>());
|
Publisher.Publish(Activated.As<Locker>());
|
||||||
await base.OnActivated();
|
await base.OnActivated();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task OnDeactivated()
|
public override async Task OnDeactivated()
|
||||||
{
|
{
|
||||||
Publisher.Publish(Deactivated.As<Container>());
|
Publisher.Publish(Deactivated.As<Locker>());
|
||||||
await base.OnDeactivated();
|
await base.OnDeactivated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public record ContainerViewModelConfiguration
|
public record LockerViewModelConfiguration
|
||||||
{
|
{
|
||||||
public string? Filter { get; set; } = "All";
|
public string? Filter { get; set; } = "All";
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ public partial class ManageViewModel :
|
|||||||
{
|
{
|
||||||
Template = template;
|
Template = template;
|
||||||
|
|
||||||
Add<CreateContainerNavigationViewModel>();
|
Add<CreateLockerNavigationViewModel>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IContentTemplate Template { get; set; }
|
public IContentTemplate Template { get; set; }
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public record MaskedTextEntryConfiguration :
|
||||||
|
ItemEntryConfiguration
|
||||||
|
{
|
||||||
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||||
|
public string? Pattern { get; set; }
|
||||||
|
}
|
||||||
@@ -28,7 +28,7 @@ public class ModifiedItemHandler(IServiceProvider serviceProvider,
|
|||||||
int newIndex = cache.IndexOf(newItem);
|
int newIndex = cache.IndexOf(newItem);
|
||||||
valueStore.Set(newItem);
|
valueStore.Set(newItem);
|
||||||
|
|
||||||
publisher.Publish(MoveTo.As<ItemNavigationViewModel>(oldIndex, newIndex), nameof(ContainerViewModel));
|
publisher.Publish(MoveTo.As<ItemNavigationViewModel>(oldIndex, newIndex), nameof(LockerViewModel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public record NoteEntryConfiguration :
|
||||||
|
ItemEntryConfiguration
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public record NumberEntryConfiguration :
|
||||||
|
ItemEntryConfiguration
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
using System.Text;
|
|
||||||
using Toolkit.Foundation;
|
|
||||||
|
|
||||||
namespace Bitvault;
|
|
||||||
|
|
||||||
public class OpenContainerHandler(ContainerConfiguration configuration,
|
|
||||||
ISecurityKeyFactory keyVaultFactory,
|
|
||||||
IContainerStorageFactory vaultStorage) :
|
|
||||||
IHandler<ActivateEventArgs<Container>, bool>
|
|
||||||
{
|
|
||||||
public async Task<bool> Handle(ActivateEventArgs<Container> args,
|
|
||||||
CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
if (args.Value is Container container && configuration.Name is { Length: > 0 } name && container.Password is { Length: > 0 } password)
|
|
||||||
{
|
|
||||||
if (configuration.Key?.Split(':') is { Length: >= 2 } keyPart)
|
|
||||||
{
|
|
||||||
byte[]? salt = Convert.FromBase64String(keyPart[0]);
|
|
||||||
byte[]? encryptedKey = Convert.FromBase64String(keyPart[1]);
|
|
||||||
|
|
||||||
if (keyVaultFactory.Create(Encoding.UTF8.GetBytes(password), encryptedKey, salt) is SecurityKey key)
|
|
||||||
{
|
|
||||||
if (await vaultStorage.Create(name, key))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
using System.Text;
|
||||||
|
using Toolkit.Foundation;
|
||||||
|
|
||||||
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public class OpenLockerHandler(LockerConfiguration configuration,
|
||||||
|
ISecurityKeyFactory securityKeyFactory,
|
||||||
|
ILockerStorageFactory lockerStorageFactory) :
|
||||||
|
IHandler<ActivateEventArgs<Locker>, bool>
|
||||||
|
{
|
||||||
|
public async Task<bool> Handle(ActivateEventArgs<Locker> args,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (args.Value is Locker locker && configuration.Name is { Length: > 0 } name && locker.Password is { Length: > 0 } password)
|
||||||
|
{
|
||||||
|
if (configuration.Key?.Split(':') is { Length: >= 2 } keyPart)
|
||||||
|
{
|
||||||
|
byte[]? salt = Convert.FromBase64String(keyPart[0]);
|
||||||
|
byte[]? encryptedKey = Convert.FromBase64String(keyPart[1]);
|
||||||
|
|
||||||
|
if (securityKeyFactory.Create(Encoding.UTF8.GetBytes(password), encryptedKey, salt) is SecurityKey key)
|
||||||
|
{
|
||||||
|
if (await lockerStorageFactory.Create(name, key))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public partial class OpenContainerViewModel(IServiceProvider provider,
|
public partial class OpenLockerViewModel(IServiceProvider provider,
|
||||||
IServiceFactory factory,
|
IServiceFactory factory,
|
||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
@@ -20,9 +20,9 @@ public partial class OpenContainerViewModel(IServiceProvider provider,
|
|||||||
{
|
{
|
||||||
if (Password is { Length: > 0 })
|
if (Password is { Length: > 0 })
|
||||||
{
|
{
|
||||||
if (await Mediator.Handle<ActivateEventArgs<Container>, bool>(Activate.As(new Container(Password))))
|
if (await Mediator.Handle<ActivateEventArgs<Locker>, bool>(Activate.As(new Locker(Password))))
|
||||||
{
|
{
|
||||||
Publisher.Publish(Opened.As<Container>());
|
Publisher.Publish(Opened.As<Locker>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public record PasswordEntryConfiguration :
|
||||||
|
ItemEntryConfiguration
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public record QueryContainerConfiguration
|
public record QueryLockerConfiguration
|
||||||
{
|
{
|
||||||
public string? Filter { get; set; }
|
public string? Filter { get; set; }
|
||||||
|
|
||||||
@@ -5,15 +5,15 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public class QueryContainerHandler(IDbContextFactory<ContainerDbContext> dbContextFactory) :
|
public class QueryLockerHandler(IDbContextFactory<LockerContext> dbContextFactory) :
|
||||||
IHandler<RequestEventArgs<QueryContainerConfiguration>, IReadOnlyCollection<(Guid Id, string? Name, bool Favourite, bool Archived)>>
|
IHandler<RequestEventArgs<QueryLockerConfiguration>, IReadOnlyCollection<(Guid Id, string? Name, bool Favourite, bool Archived)>>
|
||||||
{
|
{
|
||||||
public async Task<IReadOnlyCollection<(Guid Id, string? Name, bool Favourite, bool Archived)>> Handle(RequestEventArgs<QueryContainerConfiguration> args,
|
public async Task<IReadOnlyCollection<(Guid Id, string? Name, bool Favourite, bool Archived)>> Handle(RequestEventArgs<QueryLockerConfiguration> args,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
List<(Guid Id, string? Name, bool Favourite, bool Archived)> items = [];
|
List<(Guid Id, string? Name, bool Favourite, bool Archived)> items = [];
|
||||||
|
|
||||||
if (args.Value is QueryContainerConfiguration queryConfiguration)
|
if (args.Value is QueryLockerConfiguration queryConfiguration)
|
||||||
{
|
{
|
||||||
ExpressionStarter<ItemEntry> predicate =
|
ExpressionStarter<ItemEntry> predicate =
|
||||||
PredicateBuilder.New<ItemEntry>(true);
|
PredicateBuilder.New<ItemEntry>(true);
|
||||||
@@ -40,7 +40,7 @@ public class QueryContainerHandler(IDbContextFactory<ContainerDbContext> dbConte
|
|||||||
|
|
||||||
var results = await Task.Run(async () =>
|
var results = await Task.Run(async () =>
|
||||||
{
|
{
|
||||||
using ContainerDbContext context = dbContextFactory.CreateDbContext();
|
using LockerContext context = dbContextFactory.CreateDbContext();
|
||||||
return await context.Set<ItemEntry>()
|
return await context.Set<ItemEntry>()
|
||||||
.Where(predicate)
|
.Where(predicate)
|
||||||
.Select(x => new
|
.Select(x => new
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
|
||||||
using CommunityToolkit.Mvvm.Input;
|
|
||||||
using Toolkit.Foundation;
|
|
||||||
|
|
||||||
namespace Bitvault;
|
|
||||||
|
|
||||||
public partial class SearchContainerActionViewModel(IServiceProvider provider,
|
|
||||||
IServiceFactory factory,
|
|
||||||
IMediator mediator,
|
|
||||||
IPublisher publisher,
|
|
||||||
ISubscription subscriber,
|
|
||||||
IDisposer disposer,
|
|
||||||
int index) : Observable<string>(provider, factory, mediator, publisher, subscriber, disposer)
|
|
||||||
{
|
|
||||||
[ObservableProperty]
|
|
||||||
private int index = index;
|
|
||||||
|
|
||||||
[RelayCommand]
|
|
||||||
public void Invoke() => Publisher.Publish(Notify.As(new Search(Value)),
|
|
||||||
nameof(ItemCollectionViewModel));
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using Toolkit.Foundation;
|
||||||
|
|
||||||
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public partial class SearchLockerActionViewModel(IServiceProvider provider,
|
||||||
|
IServiceFactory factory,
|
||||||
|
IMediator mediator,
|
||||||
|
IPublisher publisher,
|
||||||
|
ISubscription subscriber,
|
||||||
|
IDisposer disposer) : Observable<string>(provider, factory, mediator, publisher, subscriber, disposer)
|
||||||
|
{
|
||||||
|
[ObservableProperty]
|
||||||
|
private int index = 2;
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
public void Invoke() => Publisher.Publish(Notify.As(new Search(Value)),
|
||||||
|
nameof(ItemCollectionViewModel));
|
||||||
|
}
|
||||||
|
|
||||||
|
public partial class BackContainerActionViewModel(IServiceProvider provider,
|
||||||
|
IServiceFactory factory,
|
||||||
|
IMediator mediator,
|
||||||
|
IPublisher publisher,
|
||||||
|
ISubscription subscriber,
|
||||||
|
IDisposer disposer) : Observable<string>(provider, factory, mediator, publisher, subscriber, disposer)
|
||||||
|
{
|
||||||
|
[ObservableProperty]
|
||||||
|
private int index = 2;
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
public void Invoke() => Publisher.Publish(Notify.As(new Search(Value)),
|
||||||
|
nameof(ItemCollectionViewModel));
|
||||||
|
}
|
||||||
@@ -8,4 +8,4 @@ public partial class StarredNavigationViewModel(IServiceProvider provider,
|
|||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
string name) : FilterContainerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
string name) : FilterLockerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public record TextEntryConfiguration :
|
||||||
|
ItemEntryConfiguration
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ using Toolkit.Foundation;
|
|||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public class UnarchiveItemHandler(IValueStore<Item> valueStore,
|
public class UnarchiveItemHandler(IValueStore<Item> valueStore,
|
||||||
IDbContextFactory<ContainerDbContext> dbContextFactory) :
|
IDbContextFactory<LockerContext> dbContextFactory) :
|
||||||
INotificationHandler<UnarchiveEventArgs<Item>>
|
INotificationHandler<UnarchiveEventArgs<Item>>
|
||||||
{
|
{
|
||||||
public async Task Handle(UnarchiveEventArgs<Item> args)
|
public async Task Handle(UnarchiveEventArgs<Item> args)
|
||||||
@@ -16,7 +16,7 @@ public class UnarchiveItemHandler(IValueStore<Item> valueStore,
|
|||||||
{
|
{
|
||||||
await Task.Run(async () =>
|
await Task.Run(async () =>
|
||||||
{
|
{
|
||||||
using ContainerDbContext context = await dbContextFactory.CreateDbContextAsync();
|
using LockerContext context = await dbContextFactory.CreateDbContextAsync();
|
||||||
|
|
||||||
if (await context.FindAsync<ItemEntry>(item.Id) is ItemEntry result)
|
if (await context.FindAsync<ItemEntry>(item.Id) is ItemEntry result)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public class UpdateItemHander(IDbContextFactory<ContainerDbContext> dbContextFactory) :
|
public class UpdateItemHander(IDbContextFactory<LockerContext> dbContextFactory) :
|
||||||
IHandler<UpdateEventArgs<(Guid, ItemConfiguration)>, bool>
|
IHandler<UpdateEventArgs<(Guid, ItemConfiguration)>, bool>
|
||||||
{
|
{
|
||||||
public async Task<bool> Handle(UpdateEventArgs<(Guid, ItemConfiguration)> args,
|
public async Task<bool> Handle(UpdateEventArgs<(Guid, ItemConfiguration)> args,
|
||||||
@@ -15,7 +15,7 @@ public class UpdateItemHander(IDbContextFactory<ContainerDbContext> dbContextFac
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
string? name = configuration.Name;
|
string? name = configuration.Name;
|
||||||
using ContainerDbContext context = dbContextFactory.CreateDbContext();
|
using LockerContext context = dbContextFactory.CreateDbContext();
|
||||||
ItemEntry? result = null;
|
ItemEntry? result = null;
|
||||||
|
|
||||||
await Task.Run(async () =>
|
await Task.Run(async () =>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public class UpdateItemStateHandler(IDbContextFactory<ContainerDbContext> dbContextFactory) :
|
public class UpdateItemStateHandler(IDbContextFactory<LockerContext> dbContextFactory) :
|
||||||
IHandler<UpdateEventArgs<(Guid, int)>, bool>
|
IHandler<UpdateEventArgs<(Guid, int)>, bool>
|
||||||
{
|
{
|
||||||
public async Task<bool> Handle(UpdateEventArgs<(Guid, int)> args,
|
public async Task<bool> Handle(UpdateEventArgs<(Guid, int)> args,
|
||||||
@@ -14,7 +14,7 @@ public class UpdateItemStateHandler(IDbContextFactory<ContainerDbContext> dbCont
|
|||||||
{
|
{
|
||||||
await Task.Run(async () =>
|
await Task.Run(async () =>
|
||||||
{
|
{
|
||||||
using ContainerDbContext context = await dbContextFactory.CreateDbContextAsync();
|
using LockerContext context = await dbContextFactory.CreateDbContextAsync();
|
||||||
if (await context.FindAsync<ItemEntry>(id) is ItemEntry result)
|
if (await context.FindAsync<ItemEntry>(id) is ItemEntry result)
|
||||||
{
|
{
|
||||||
result.State = state;
|
result.State = state;
|
||||||
|
|||||||
Reference in New Issue
Block a user