Codemaid
This commit is contained in:
@@ -1,16 +1,16 @@
|
|||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
using Bitvault.Data;
|
||||||
|
using HotAvalonia;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using Toolkit.Avalonia;
|
using Toolkit.Avalonia;
|
||||||
using Toolkit.Foundation;
|
using Toolkit.Foundation;
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
||||||
using HotAvalonia;
|
|
||||||
using Bitvault.Data;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Bitvault.Avalonia;
|
namespace Bitvault.Avalonia;
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ public partial class App : Application
|
|||||||
|
|
||||||
services.AddHandler<ContainerActivatedHandler>();
|
services.AddHandler<ContainerActivatedHandler>();
|
||||||
|
|
||||||
services.AddTransient<IContainerComponent> (provider => Component.Create<ContainerComponent>(provider, args =>
|
services.AddTransient<IContainerComponent>(provider => Component.Create<ContainerComponent>(provider, args =>
|
||||||
{
|
{
|
||||||
args.AddServices(services =>
|
args.AddServices(services =>
|
||||||
{
|
{
|
||||||
@@ -62,12 +62,12 @@ public partial class App : Application
|
|||||||
|
|
||||||
services.AddDbContextFactory<ContainerDbContext>((provider, args) =>
|
services.AddDbContextFactory<ContainerDbContext>((provider, args) =>
|
||||||
{
|
{
|
||||||
if (provider.GetRequiredService<IValueStore<ContainerConnection>>()
|
if (provider.GetRequiredService<IValueStore<ContainerConnection>>()
|
||||||
is IValueStore<ContainerConnection> connection)
|
is IValueStore<ContainerConnection> connection)
|
||||||
{
|
{
|
||||||
args.UseSqlite($"{connection.Value}");
|
args.UseSqlite($"{connection.Value}");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
services.AddHandler<QueryContainerHandler>();
|
services.AddHandler<QueryContainerHandler>();
|
||||||
services.AddHandler<CreateItemHandler>();
|
services.AddHandler<CreateItemHandler>();
|
||||||
@@ -121,7 +121,7 @@ public partial class App : Application
|
|||||||
});
|
});
|
||||||
})!);
|
})!);
|
||||||
|
|
||||||
services.AddTransient<IContainerFactory, ContainerFactory>();
|
services.AddTransient<IContainerFactory, ContainerFactory>();
|
||||||
services.AddHandler<CreateContainerHandler>();
|
services.AddHandler<CreateContainerHandler>();
|
||||||
|
|
||||||
services.AddSingleton<IContainerHostCollection, ContainerHostCollection>();
|
services.AddSingleton<IContainerHostCollection, ContainerHostCollection>();
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ namespace Bitvault.Avalonia;
|
|||||||
public partial class ArchiveItemActionView : UserControl
|
public partial class ArchiveItemActionView : UserControl
|
||||||
{
|
{
|
||||||
public ArchiveItemActionView() => InitializeComponent();
|
public ArchiveItemActionView() => InitializeComponent();
|
||||||
}
|
}
|
||||||
@@ -21,11 +21,11 @@
|
|||||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.999-cibuild0048140-alpha" />
|
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.999-cibuild0048140-alpha" />
|
||||||
<PackageReference Include="Avalonia.Labs.Controls" Version="11.0.10.1" />
|
<PackageReference Include="Avalonia.Labs.Controls" Version="11.0.10.1" />
|
||||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
||||||
<PackageReference Include="FluentAvaloniaUI" Version="2.1.0-preview1" />
|
<PackageReference Include="FluentAvaloniaUI" Version="2.1.0-preview5" />
|
||||||
<PackageReference Include="System.Reactive" Version="6.0.1-preview.1" />
|
<PackageReference Include="System.Reactive" Version="6.0.1" />
|
||||||
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.1.0-beta2.1" />
|
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.1.0-beta2.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0-preview.3.24172.9" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0-preview.4.24266.19" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0-preview.3.24172.4">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0-preview.4.24267.1">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ namespace Bitvault.Avalonia;
|
|||||||
public partial class ConfirmItemActionView : UserControl
|
public partial class ConfirmItemActionView : UserControl
|
||||||
{
|
{
|
||||||
public ConfirmItemActionView() => InitializeComponent();
|
public ConfirmItemActionView() => InitializeComponent();
|
||||||
}
|
}
|
||||||
@@ -5,4 +5,4 @@ namespace Bitvault.Avalonia;
|
|||||||
public partial class ContainerHeaderView : UserControl
|
public partial class ContainerHeaderView : UserControl
|
||||||
{
|
{
|
||||||
public ContainerHeaderView() => InitializeComponent();
|
public ContainerHeaderView() => InitializeComponent();
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
AutoScrollToSelectedItem="True"
|
AutoScrollToSelectedItem="True"
|
||||||
ItemTemplate="{ReflectionBinding Template}"
|
ItemTemplate="{ReflectionBinding Template}"
|
||||||
ItemsSource="{Binding}"
|
ItemsSource="{Binding}"
|
||||||
SelectedItem="{Binding SelectedItem}"
|
SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
|
||||||
SelectionMode="Single">
|
SelectionMode="Single">
|
||||||
<ListBox.Styles>
|
<ListBox.Styles>
|
||||||
<Style Selector="ListBoxItem">
|
<Style Selector="ListBoxItem">
|
||||||
@@ -52,7 +52,10 @@
|
|||||||
BorderThickness="1,1,0,0"
|
BorderThickness="1,1,0,0"
|
||||||
CornerRadius="8 0 0 0">
|
CornerRadius="8 0 0 0">
|
||||||
<Grid RowDefinitions="Auto, *">
|
<Grid RowDefinitions="Auto, *">
|
||||||
<Border Grid.Row="0" Padding="4" Height="44">
|
<Border
|
||||||
|
Grid.Row="0"
|
||||||
|
Height="44"
|
||||||
|
Padding="4">
|
||||||
<ContentControl>
|
<ContentControl>
|
||||||
<Interaction.Behaviors>
|
<Interaction.Behaviors>
|
||||||
<AttachedBehaviour>
|
<AttachedBehaviour>
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ namespace Bitvault.Avalonia;
|
|||||||
public partial class CreateItemActionView : UserControl
|
public partial class CreateItemActionView : UserControl
|
||||||
{
|
{
|
||||||
public CreateItemActionView() => InitializeComponent();
|
public CreateItemActionView() => InitializeComponent();
|
||||||
}
|
}
|
||||||
@@ -9,4 +9,4 @@ namespace Bitvault.Avalonia
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,4 +5,4 @@ namespace Bitvault.Avalonia;
|
|||||||
public partial class DismissItemActionView : UserControl
|
public partial class DismissItemActionView : UserControl
|
||||||
{
|
{
|
||||||
public DismissItemActionView() => InitializeComponent();
|
public DismissItemActionView() => InitializeComponent();
|
||||||
}
|
}
|
||||||
@@ -5,4 +5,4 @@ namespace Bitvault.Avalonia;
|
|||||||
public partial class EditItemActionView : UserControl
|
public partial class EditItemActionView : UserControl
|
||||||
{
|
{
|
||||||
public EditItemActionView() => InitializeComponent();
|
public EditItemActionView() => InitializeComponent();
|
||||||
}
|
}
|
||||||
@@ -5,4 +5,4 @@ namespace Bitvault.Avalonia;
|
|||||||
public partial class FavouriteItemActionView : UserControl
|
public partial class FavouriteItemActionView : UserControl
|
||||||
{
|
{
|
||||||
public FavouriteItemActionView() => InitializeComponent();
|
public FavouriteItemActionView() => InitializeComponent();
|
||||||
}
|
}
|
||||||
@@ -5,4 +5,4 @@ namespace Bitvault.Avalonia;
|
|||||||
public partial class ItemCommandHeaderView : UserControl
|
public partial class ItemCommandHeaderView : UserControl
|
||||||
{
|
{
|
||||||
public ItemCommandHeaderView() => InitializeComponent();
|
public ItemCommandHeaderView() => InitializeComponent();
|
||||||
}
|
}
|
||||||
@@ -5,4 +5,4 @@ namespace Bitvault.Avalonia;
|
|||||||
public partial class ItemHeaderView : UserControl
|
public partial class ItemHeaderView : UserControl
|
||||||
{
|
{
|
||||||
public ItemHeaderView() => InitializeComponent();
|
public ItemHeaderView() => InitializeComponent();
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
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:ItemNavigationViewModel"
|
x:DataType="vm:ItemNavigationViewModel"
|
||||||
IsSelected="{Binding Selected}">
|
IsSelected="{Binding Selected, Mode=TwoWay}">
|
||||||
<ListBoxItem.Resources>
|
<ListBoxItem.Resources>
|
||||||
<SolidColorBrush x:Key="StarredIconForegroundBrush" Color="#FFEDB120" />
|
<SolidColorBrush x:Key="StarredIconForegroundBrush" Color="#FFEDB120" />
|
||||||
</ListBoxItem.Resources>
|
</ListBoxItem.Resources>
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ namespace Bitvault.Avalonia;
|
|||||||
public partial class ItemNavigationView : ListBoxItem
|
public partial class ItemNavigationView : ListBoxItem
|
||||||
{
|
{
|
||||||
public ItemNavigationView() => InitializeComponent();
|
public ItemNavigationView() => InitializeComponent();
|
||||||
}
|
}
|
||||||
@@ -5,4 +5,4 @@ namespace Bitvault.Avalonia;
|
|||||||
public partial class ItemView : UserControl
|
public partial class ItemView : UserControl
|
||||||
{
|
{
|
||||||
public ItemView() => InitializeComponent();
|
public ItemView() => InitializeComponent();
|
||||||
}
|
}
|
||||||
@@ -5,4 +5,4 @@ namespace Bitvault.Avalonia;
|
|||||||
public partial class SearchContainerActionView : UserControl
|
public partial class SearchContainerActionView : UserControl
|
||||||
{
|
{
|
||||||
public SearchContainerActionView() => InitializeComponent();
|
public SearchContainerActionView() => InitializeComponent();
|
||||||
}
|
}
|
||||||
@@ -5,4 +5,4 @@ namespace Bitvault.Avalonia;
|
|||||||
public partial class UnarchiveItemActionView : UserControl
|
public partial class UnarchiveItemActionView : UserControl
|
||||||
{
|
{
|
||||||
public UnarchiveItemActionView() => InitializeComponent();
|
public UnarchiveItemActionView() => InitializeComponent();
|
||||||
}
|
}
|
||||||
@@ -5,13 +5,13 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0-preview.3.24172.4" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0-preview.4.24267.1" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0-preview.3.24172.4">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0-preview.4.24267.1">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="9.0.0-preview.3.24172.4" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="9.0.0-preview.4.24267.1" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0-preview.3.24172.4">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0-preview.4.24267.1">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Bitvault.Data;
|
namespace Bitvault.Data;
|
||||||
|
|
||||||
public class ContainerDbContext(DbContextOptions<ContainerDbContext> options) :
|
public class ContainerDbContext(DbContextOptions<ContainerDbContext> options) :
|
||||||
DbContext(options)
|
DbContext(options)
|
||||||
{
|
{
|
||||||
public DbSet<BlobEntry> Blobs { get; set; }
|
public DbSet<BlobEntry> Blobs { get; set; }
|
||||||
@@ -21,4 +21,4 @@ public class ContainerDbContext(DbContextOptions<ContainerDbContext> options) :
|
|||||||
.HasMany(x => x.Blobs)
|
.HasMany(x => x.Blobs)
|
||||||
.WithOne();
|
.WithOne();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,4 +10,4 @@ public class TagEntry
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@ public class AggerateContainerViewModelHandler(IMediator mediator,
|
|||||||
IPublisher publisher) :
|
IPublisher publisher) :
|
||||||
INotificationHandler<AggerateEventArgs<ItemNavigationViewModel, ContainerViewModelConfiguration>>
|
INotificationHandler<AggerateEventArgs<ItemNavigationViewModel, ContainerViewModelConfiguration>>
|
||||||
{
|
{
|
||||||
public async Task Handle(AggerateEventArgs<ItemNavigationViewModel,
|
public async Task Handle(AggerateEventArgs<ItemNavigationViewModel,
|
||||||
ContainerViewModelConfiguration> args)
|
ContainerViewModelConfiguration> args)
|
||||||
{
|
{
|
||||||
if (args.Options is ContainerViewModelConfiguration configuration)
|
if (args.Options is ContainerViewModelConfiguration configuration)
|
||||||
@@ -18,10 +18,10 @@ public class AggerateContainerViewModelHandler(IMediator mediator,
|
|||||||
bool selected = true;
|
bool selected = true;
|
||||||
|
|
||||||
if (await mediator.Handle<RequestEventArgs<QueryContainerConfiguration>,
|
if (await mediator.Handle<RequestEventArgs<QueryContainerConfiguration>,
|
||||||
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 QueryContainerConfiguration
|
||||||
{
|
{
|
||||||
Filter = configuration.Filter,
|
Filter = configuration.Filter,
|
||||||
Query = configuration.Query
|
Query = configuration.Query
|
||||||
})) is IReadOnlyCollection<(Guid Id, string Name, bool Favourite, bool Archived)> results)
|
})) is IReadOnlyCollection<(Guid Id, string Name, bool Favourite, bool Archived)> results)
|
||||||
{
|
{
|
||||||
foreach ((Guid Id, string Name, bool Favourite, bool Archived) in results)
|
foreach ((Guid Id, string Name, bool Favourite, bool Archived) in results)
|
||||||
@@ -44,4 +44,4 @@ public class AggerateContainerViewModelHandler(IMediator mediator,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,4 +16,4 @@ public class AggerateItemViewModelHandler(IMediator mediator,
|
|||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@ public class AggerateMainViewModelHandler(IPublisher publisher,
|
|||||||
{
|
{
|
||||||
public Task Handle(AggerateEventArgs<IMainNavigationViewModel> args)
|
public Task Handle(AggerateEventArgs<IMainNavigationViewModel> args)
|
||||||
{
|
{
|
||||||
foreach (IComponentHost container in containers.OrderBy(x => x.GetConfiguration<ContainerConfiguration>()
|
foreach (IComponentHost container in containers.OrderBy(x => x.GetConfiguration<ContainerConfiguration>()
|
||||||
is ContainerConfiguration configuration ? configuration.Name : null))
|
is ContainerConfiguration configuration ? configuration.Name : null))
|
||||||
{
|
{
|
||||||
if (container.Services.GetRequiredService<ContainerConfiguration>() is ContainerConfiguration configuration)
|
if (container.Services.GetRequiredService<ContainerConfiguration>() is ContainerConfiguration configuration)
|
||||||
|
|||||||
@@ -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) : FilterContainerNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, filter);
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public record ArchiveEventArgs<TValue>(TValue Value);
|
public record ArchiveEventArgs<TValue>(TValue Value);
|
||||||
@@ -28,7 +28,6 @@ public class ArchiveItemHandler(IValueStore<Item> valueStore,
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
||||||
<PackageReference Include="LinqKit.Microsoft.EntityFrameworkCore" Version="8.1.5" />
|
<PackageReference Include="LinqKit.Microsoft.EntityFrameworkCore" Version="8.1.5" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0-preview.3.24172.4" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0-preview.4.24267.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Bitvault.Data\Bitvault.Data.csproj" />
|
<ProjectReference Include="..\Bitvault.Data\Bitvault.Data.csproj" />
|
||||||
|
|||||||
+1
-1
@@ -7,4 +7,4 @@ public record Closed
|
|||||||
public static ChangedEventArgs<TValue> As<TValue>(TValue value) => new(value);
|
public static ChangedEventArgs<TValue> As<TValue>(TValue value) => new(value);
|
||||||
|
|
||||||
public static ChangedEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
|
public static ChangedEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public record ClosedEventArgs<TValue>(TValue? Value = default);
|
public record ClosedEventArgs<TValue>(TValue? Value = default);
|
||||||
@@ -7,6 +7,5 @@ public class CommandCollection :
|
|||||||
{
|
{
|
||||||
public CommandCollection(IList<IDisposable> list) : base(list)
|
public CommandCollection(IList<IDisposable> list) : base(list)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,6 @@ public partial class ConfirmItemActionViewModel(IServiceProvider provider,
|
|||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer) : Observable(provider, factory, mediator, publisher, subscriber, disposer)
|
IDisposer disposer) : Observable(provider, factory, mediator, publisher, subscriber, disposer)
|
||||||
{
|
{
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
public void Invoke() => Publisher.Publish(Confirm.As<Item>());
|
public void Invoke() => Publisher.Publish(Confirm.As<Item>());
|
||||||
}
|
}
|
||||||
@@ -25,8 +25,8 @@ public class ConfirmItemHandler(IValueStore<Item> valueStore,
|
|||||||
publisher.Publish(Modified.As(item, newItem));
|
publisher.Publish(Modified.As(item, newItem));
|
||||||
|
|
||||||
valueStore.Set(newItem);
|
valueStore.Set(newItem);
|
||||||
|
|
||||||
await mediator.Handle<EditEventArgs<(Guid, ItemConfiguration)>, bool>(new EditEventArgs<(Guid,
|
await mediator.Handle<EditEventArgs<(Guid, ItemConfiguration)>, bool>(new EditEventArgs<(Guid,
|
||||||
ItemConfiguration)>((item.Id, new ItemConfiguration { Name = name })));
|
ItemConfiguration)>((item.Id, new ItemConfiguration { Name = name })));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -34,7 +34,7 @@ public class ConfirmItemHandler(IValueStore<Item> valueStore,
|
|||||||
Guid id = Guid.NewGuid();
|
Guid id = Guid.NewGuid();
|
||||||
string? name = configuration.Name;
|
string? name = configuration.Name;
|
||||||
|
|
||||||
bool Success = await mediator.Handle<CreateEventArgs<(Guid,
|
bool Success = await mediator.Handle<CreateEventArgs<(Guid,
|
||||||
ItemConfiguration)>, bool>(new CreateEventArgs<(Guid, ItemConfiguration)>((id, new ItemConfiguration { Name = name })));
|
ItemConfiguration)>, bool>(new CreateEventArgs<(Guid, ItemConfiguration)>((id, new ItemConfiguration { Name = name })));
|
||||||
|
|
||||||
if (Success)
|
if (Success)
|
||||||
@@ -44,4 +44,4 @@ public class ConfirmItemHandler(IValueStore<Item> valueStore,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
|
|||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public class ContainerActivatedHandler(IContainerHostCollection containers,
|
public class ContainerActivatedHandler(IContainerHostCollection containers,
|
||||||
IPublisher publisher) :
|
IPublisher publisher) :
|
||||||
INotificationHandler<ActivatedEventArgs<IComponentHost>>
|
INotificationHandler<ActivatedEventArgs<IComponentHost>>
|
||||||
{
|
{
|
||||||
public Task Handle(ActivatedEventArgs<IComponentHost> args)
|
public Task Handle(ActivatedEventArgs<IComponentHost> args)
|
||||||
@@ -12,7 +12,7 @@ public class ContainerActivatedHandler(IContainerHostCollection containers,
|
|||||||
if (args.Value is IComponentHost container)
|
if (args.Value is IComponentHost container)
|
||||||
{
|
{
|
||||||
List<IComponentHost> sortedContainers = [.. containers, container];
|
List<IComponentHost> sortedContainers = [.. containers, container];
|
||||||
sortedContainers = [.. sortedContainers.OrderBy(x => x.GetConfiguration< ContainerConfiguration>() is ContainerConfiguration configuration ? configuration.Name : null)];
|
sortedContainers = [.. sortedContainers.OrderBy(x => x.GetConfiguration<ContainerConfiguration>() is ContainerConfiguration configuration ? configuration.Name : null)];
|
||||||
|
|
||||||
int index = sortedContainers.IndexOf(container);
|
int index = sortedContainers.IndexOf(container);
|
||||||
|
|
||||||
|
|||||||
@@ -8,4 +8,4 @@ public record ContainerConfiguration :
|
|||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
|
|
||||||
public string? Key { get; set; }
|
public string? Key { get; set; }
|
||||||
}
|
}
|
||||||
@@ -5,4 +5,4 @@ public class ContainerConnection(string connection)
|
|||||||
private readonly string connection = connection;
|
private readonly string connection = connection;
|
||||||
|
|
||||||
public override string ToString() => connection;
|
public override string ToString() => connection;
|
||||||
}
|
}
|
||||||
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public class ContainerFactory(IComponentFactory componentFactory) :
|
public class ContainerFactory(IComponentFactory componentFactory) :
|
||||||
IContainerFactory
|
IContainerFactory
|
||||||
{
|
{
|
||||||
public IComponentHost? Create(string name)
|
public IComponentHost? Create(string name)
|
||||||
{
|
{
|
||||||
if (componentFactory.Create<IContainerComponent, ContainerConfiguration>($"Vault:{name}",
|
if (componentFactory.Create<IContainerComponent, ContainerConfiguration>($"Vault:{name}",
|
||||||
new ContainerConfiguration { Name = name }) is IComponentHost host)
|
new ContainerConfiguration { Name = name }) is IComponentHost host)
|
||||||
{
|
{
|
||||||
return host;
|
return host;
|
||||||
@@ -15,4 +15,4 @@ public class ContainerFactory(IComponentFactory componentFactory) :
|
|||||||
|
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public partial class ContainerHeaderViewModel :
|
public partial class ContainerHeaderViewModel :
|
||||||
ObservableCollection
|
ObservableCollection
|
||||||
{
|
{
|
||||||
public ContainerHeaderViewModel(IServiceProvider provider,
|
public ContainerHeaderViewModel(IServiceProvider provider,
|
||||||
IServiceFactory factory,
|
IServiceFactory factory,
|
||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
@@ -20,4 +20,4 @@ public partial class ContainerHeaderViewModel :
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IContentTemplate Template { get; set; }
|
public IContentTemplate Template { get; set; }
|
||||||
}
|
}
|
||||||
@@ -3,15 +3,15 @@
|
|||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public class ContainerInitializer(IEnumerable<IConfigurationDescriptor<ContainerConfiguration>> configurations,
|
public class ContainerInitializer(IEnumerable<IConfigurationDescriptor<ContainerConfiguration>> configurations,
|
||||||
IComponentFactory componentFactory,
|
IComponentFactory componentFactory,
|
||||||
IContainerHostCollection vaults) : IInitializer
|
IContainerHostCollection vaults) : IInitializer
|
||||||
{
|
{
|
||||||
public async Task Initialize()
|
public async Task Initialize()
|
||||||
{
|
{
|
||||||
foreach (IConfigurationDescriptor<ContainerConfiguration> configuration in configurations)
|
foreach (IConfigurationDescriptor<ContainerConfiguration> configuration in configurations)
|
||||||
{
|
{
|
||||||
if (componentFactory.Create<IContainerComponent,
|
if (componentFactory.Create<IContainerComponent,
|
||||||
ContainerConfiguration>(configuration.Section, configuration.Value)
|
ContainerConfiguration>(configuration.Section, configuration.Value)
|
||||||
is IComponentHost host)
|
is IComponentHost host)
|
||||||
{
|
{
|
||||||
vaults.Add(host);
|
vaults.Add(host);
|
||||||
@@ -19,4 +19,4 @@ public class ContainerInitializer(IEnumerable<IConfigurationDescriptor<Container
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ public class ContainerStorageFactory(IValueStore<ContainerConnection> connection
|
|||||||
IServiceProvider provider) :
|
IServiceProvider provider) :
|
||||||
IContainerStorageFactory
|
IContainerStorageFactory
|
||||||
{
|
{
|
||||||
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 ContainerConnection($"Data Source={Path.Combine(environment.ContentRootPath, name)}" +
|
||||||
@@ -28,7 +28,6 @@ public class ContainerStorageFactory(IValueStore<ContainerConnection> connection
|
|||||||
await context.Database.CloseConnectionAsync().ConfigureAwait(false);
|
await context.Database.CloseConnectionAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
context.Database.SetConnectionString(null);
|
context.Database.SetConnectionString(null);
|
||||||
|
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
@@ -38,4 +37,4 @@ public class ContainerStorageFactory(IValueStore<ContainerConnection> connection
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,11 +15,9 @@ public record ContainerToken
|
|||||||
|
|
||||||
public ContainerToken()
|
public ContainerToken()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public string Name { get; } = "";
|
public string Name { get; } = "";
|
||||||
|
|
||||||
public string? Password { get; } = "";
|
public string? Password { get; } = "";
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,6 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
|
|
||||||
[Aggerate(nameof(ContainerViewModel))]
|
[Aggerate(nameof(ContainerViewModel))]
|
||||||
public partial class ContainerViewModel(IServiceProvider provider,
|
public partial class ContainerViewModel(IServiceProvider provider,
|
||||||
IServiceFactory factory,
|
IServiceFactory factory,
|
||||||
@@ -44,6 +43,7 @@ public partial class ContainerViewModel(IServiceProvider provider,
|
|||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task Handle(NotifyEventArgs<Search> args)
|
public Task Handle(NotifyEventArgs<Search> args)
|
||||||
{
|
{
|
||||||
if (args.Value is Search search)
|
if (args.Value is Search search)
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ public record ContainerViewModelConfiguration
|
|||||||
public string? Filter { get; set; } = "All";
|
public string? Filter { get; set; } = "All";
|
||||||
|
|
||||||
public string? Query { get; set; }
|
public string? Query { get; set; }
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@ public class CreateContainerHandler(IContainerFactory componentFactory,
|
|||||||
IPublisher publisher) :
|
IPublisher publisher) :
|
||||||
IHandler<CreateEventArgs<ContainerToken>, bool>
|
IHandler<CreateEventArgs<ContainerToken>, bool>
|
||||||
{
|
{
|
||||||
public async Task<bool> Handle(CreateEventArgs<ContainerToken> args,
|
public async Task<bool> Handle(CreateEventArgs<ContainerToken> args,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (args.Value is ContainerToken container && container.Name is { Length: > 0 } name &&
|
if (args.Value is ContainerToken container && container.Name is { Length: > 0 } name &&
|
||||||
|
|||||||
@@ -21,6 +21,6 @@ public partial class CreateContainerViewModel(IServiceProvider provider,
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string password;
|
private string password;
|
||||||
|
|
||||||
public async Task<bool> Confirm() =>
|
public async Task<bool> Confirm() =>
|
||||||
await Mediator.Handle<CreateEventArgs<ContainerToken>, bool>(Create.As(new ContainerToken(Name, Password)));
|
await Mediator.Handle<CreateEventArgs<ContainerToken>, bool>(Create.As(new ContainerToken(Name, Password)));
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public class CreateItemHandler(IDbContextFactory<ContainerDbContext> dbContextFactory) :
|
public class CreateItemHandler(IDbContextFactory<ContainerDbContext> 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,
|
||||||
@@ -24,7 +24,6 @@ public class CreateItemHandler(IDbContextFactory<ContainerDbContext> dbContextFa
|
|||||||
{
|
{
|
||||||
result = await context.AddAsync(new ItemEntry { Id = id, Name = name }, cancellationToken);
|
result = await context.AddAsync(new ItemEntry { Id = id, Name = name }, cancellationToken);
|
||||||
await context.SaveChangesAsync(cancellationToken);
|
await context.SaveChangesAsync(cancellationToken);
|
||||||
|
|
||||||
}, cancellationToken);
|
}, cancellationToken);
|
||||||
|
|
||||||
if (result is not null)
|
if (result is not null)
|
||||||
@@ -34,10 +33,9 @@ public class CreateItemHandler(IDbContextFactory<ContainerDbContext> dbContextFa
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
using FluentAvalonia.Core;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Toolkit.Foundation;
|
using Toolkit.Foundation;
|
||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public class CreatedItemHandler(IServiceProvider serviceProvider,
|
public class CreatedItemHandler(IServiceProvider serviceProvider,
|
||||||
ICache< Item> cache,
|
ICache<Item> cache,
|
||||||
IPublisher publisher) :
|
IPublisher publisher) :
|
||||||
INotificationHandler<CreatedEventArgs<Item>>
|
INotificationHandler<CreatedEventArgs<Item>>
|
||||||
{
|
{
|
||||||
@@ -17,7 +16,7 @@ public class CreatedItemHandler(IServiceProvider serviceProvider,
|
|||||||
IServiceFactory serviceFactory = serviceScope.ServiceProvider.GetRequiredService<IServiceFactory>();
|
IServiceFactory serviceFactory = serviceScope.ServiceProvider.GetRequiredService<IServiceFactory>();
|
||||||
IValueStore<Item> valueStore = serviceScope.ServiceProvider.GetRequiredService<IValueStore<Item>>();
|
IValueStore<Item> valueStore = serviceScope.ServiceProvider.GetRequiredService<IValueStore<Item>>();
|
||||||
|
|
||||||
if (serviceFactory.Create<ItemNavigationViewModel>(item.Id, item.Name, "Description", true)
|
if (serviceFactory.Create<ItemNavigationViewModel>(item.Id, item.Name, "Description", true)
|
||||||
is ItemNavigationViewModel viewModel)
|
is ItemNavigationViewModel viewModel)
|
||||||
{
|
{
|
||||||
cache.Add(item);
|
cache.Add(item);
|
||||||
@@ -31,4 +30,4 @@ public class CreatedItemHandler(IServiceProvider serviceProvider,
|
|||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,4 +12,4 @@ public partial class DeleteItemActionViewModel(IServiceProvider provider,
|
|||||||
{
|
{
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
public void Invoke() => Publisher.Publish(Delete.As<Item>());
|
public void Invoke() => Publisher.Publish(Delete.As<Item>());
|
||||||
}
|
}
|
||||||
@@ -27,8 +27,7 @@ public class EditItemHander(IDbContextFactory<ContainerDbContext> dbContextFacto
|
|||||||
{
|
{
|
||||||
result.Name = name;
|
result.Name = name;
|
||||||
await context.SaveChangesAsync(cancellationToken);
|
await context.SaveChangesAsync(cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, cancellationToken);
|
}, cancellationToken);
|
||||||
|
|
||||||
if (result is not null)
|
if (result is not null)
|
||||||
@@ -38,10 +37,9 @@ public class EditItemHander(IDbContextFactory<ContainerDbContext> dbContextFacto
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,4 +7,4 @@ public record Favourite
|
|||||||
|
|
||||||
public static FavouriteEventArgs<TValue> As<TValue>() where TValue : new() =>
|
public static FavouriteEventArgs<TValue> As<TValue>() where TValue : new() =>
|
||||||
new(new TValue());
|
new(new TValue());
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public record FavouriteEventArgs<TValue>(TValue Value);
|
public record FavouriteEventArgs<TValue>(TValue Value);
|
||||||
@@ -26,5 +26,4 @@ public partial class FavouriteItemActionViewModel(IServiceProvider provider,
|
|||||||
Publisher.Publish(Unfavourite.As<Item>());
|
Publisher.Publish(Unfavourite.As<Item>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,7 +28,6 @@ public class FavouriteItemHandler(IValueStore<Item> valueStore,
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public record Filter(string? Value);
|
public record Filter(string? Value);
|
||||||
@@ -36,6 +36,6 @@ public partial class FilterContainerNavigationViewModel : Observable,
|
|||||||
Task.FromResult(Activated = true);
|
Task.FromResult(Activated = true);
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
public void Invoke() => Publisher.Publish(Notify.As(new Filter(Filter)),
|
public void Invoke() => Publisher.Publish(Notify.As(new Filter(Filter)),
|
||||||
nameof(ContainerViewModel));
|
nameof(ContainerViewModel));
|
||||||
}
|
}
|
||||||
@@ -14,4 +14,4 @@ public partial class FooterViewModel :
|
|||||||
{
|
{
|
||||||
Add<ManageNavigationViewModel>();
|
Add<ManageNavigationViewModel>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
public record Form
|
public record Form
|
||||||
{
|
{
|
||||||
public ICollection<FormEntry>? Entries { get; set;}
|
public ICollection<FormEntry>? Entries { get; set; }
|
||||||
}
|
}
|
||||||
@@ -13,4 +13,4 @@ public enum FormFieldType
|
|||||||
Text,
|
Text,
|
||||||
Time,
|
Time,
|
||||||
Url
|
Url
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public interface IContainerNavigationViewModel :
|
public interface IContainerNavigationViewModel :
|
||||||
ISelectable,
|
ISelectable,
|
||||||
IDisposable;
|
IDisposable;
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public interface IItemEntryViewModel :
|
public interface IItemEntryViewModel :
|
||||||
IDisposable
|
IDisposable
|
||||||
{
|
{
|
||||||
|
}
|
||||||
}
|
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public interface IMainNavigationViewModel : IDisposable;
|
public interface IMainNavigationViewModel : IDisposable;
|
||||||
@@ -5,4 +5,4 @@ public interface ISecurityKeyFactory
|
|||||||
SecurityKey? Create(byte[] phrase,
|
SecurityKey? Create(byte[] phrase,
|
||||||
byte[]? encryptedKey = null,
|
byte[]? encryptedKey = null,
|
||||||
byte[]? salt = null);
|
byte[]? salt = null);
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,5 @@ public partial class IconViewModel : Observable
|
|||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
IDisposer disposer) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-2
@@ -5,5 +5,4 @@ public record Item
|
|||||||
public Guid Id { get; init; }
|
public Guid Id { get; init; }
|
||||||
|
|
||||||
public string? Name { get; init; } = "";
|
public string? Name { get; init; } = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@ public partial class ItemCommandHeaderViewModel(IServiceProvider provider,
|
|||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
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<CommandCollection>>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
public record ItemConfiguration
|
public record ItemConfiguration
|
||||||
{
|
{
|
||||||
public string? Name { get; set; } = "";
|
public string? Name { get; set; } = "";
|
||||||
}
|
}
|
||||||
@@ -3,4 +3,4 @@
|
|||||||
public record ItemHeaderConfiguration
|
public record ItemHeaderConfiguration
|
||||||
{
|
{
|
||||||
public string? Name { get; init; } = "";
|
public string? Name { get; init; } = "";
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using System.Xml.Linq;
|
|
||||||
using Toolkit.Foundation;
|
using Toolkit.Foundation;
|
||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
@@ -30,7 +29,7 @@ public partial class ItemHeaderViewModel : Observable<string, string>,
|
|||||||
Track(nameof(Value), () => Value, newValue => Value = newValue);
|
Track(nameof(Value), () => Value, newValue => Value = newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<bool> Handle(ValidationEventArgs<Item> args,
|
public Task<bool> Handle(ValidationEventArgs<Item> args,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
return Task.FromResult(true);
|
return Task.FromResult(true);
|
||||||
@@ -39,7 +38,7 @@ public partial class ItemHeaderViewModel : Observable<string, string>,
|
|||||||
public Task<ItemHeaderConfiguration> Handle(ConfirmEventArgs<Item> args,
|
public Task<ItemHeaderConfiguration> Handle(ConfirmEventArgs<Item> args,
|
||||||
CancellationToken cancellationToken) => Task.FromResult(new ItemHeaderConfiguration { Name = Value });
|
CancellationToken cancellationToken) => Task.FromResult(new ItemHeaderConfiguration { Name = Value });
|
||||||
|
|
||||||
public Task Handle(EditEventArgs<Item> args) =>
|
public Task Handle(EditEventArgs<Item> args) =>
|
||||||
Task.FromResult(Immutable = false);
|
Task.FromResult(Immutable = false);
|
||||||
|
|
||||||
public Task Handle(CancelEventArgs<Item> args)
|
public Task Handle(CancelEventArgs<Item> args)
|
||||||
@@ -57,4 +56,4 @@ public partial class ItemHeaderViewModel : Observable<string, string>,
|
|||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,17 +49,18 @@ public partial class ItemNavigationViewModel(IServiceProvider provider,
|
|||||||
|
|
||||||
public IContentTemplate Template { get; set; } = template;
|
public IContentTemplate Template { get; set; } = template;
|
||||||
|
|
||||||
public Task Handle(ArchiveEventArgs<Item> args) =>
|
public Task Handle(ArchiveEventArgs<Item> args) =>
|
||||||
Task.Run(Dispose);
|
Task.Run(Dispose);
|
||||||
|
|
||||||
public Task Handle(UnarchiveEventArgs<Item> args) =>
|
public Task Handle(UnarchiveEventArgs<Item> args) =>
|
||||||
Task.Run(Dispose);
|
Task.Run(Dispose);
|
||||||
|
|
||||||
public Task Handle(FavouriteEventArgs<Item> args) =>
|
public Task Handle(FavouriteEventArgs<Item> args) =>
|
||||||
Task.FromResult(Favourite = true);
|
Task.FromResult(Favourite = true);
|
||||||
|
|
||||||
public Task Handle(UnfavouriteEventArgs<Item> args) =>
|
public Task Handle(UnfavouriteEventArgs<Item> args) =>
|
||||||
Task.FromResult(Favourite = false);
|
Task.FromResult(Favourite = false);
|
||||||
|
|
||||||
public Task Handle(NotifyEventArgs<ItemHeaderConfiguration> args)
|
public Task Handle(NotifyEventArgs<ItemHeaderConfiguration> args)
|
||||||
{
|
{
|
||||||
if (args.Value is ItemHeaderConfiguration configuration)
|
if (args.Value is ItemHeaderConfiguration configuration)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public partial class ItemViewModel :
|
public partial class ItemViewModel :
|
||||||
ObservableCollection<IItemEntryViewModel>,
|
ObservableCollection<IItemEntryViewModel>,
|
||||||
INotificationHandler<EditEventArgs<Item>>,
|
INotificationHandler<EditEventArgs<Item>>,
|
||||||
INotificationHandler<ConfirmEventArgs<Item>>,
|
INotificationHandler<ConfirmEventArgs<Item>>,
|
||||||
@@ -25,10 +25,10 @@ public partial class ItemViewModel :
|
|||||||
private string name;
|
private string name;
|
||||||
|
|
||||||
public ItemViewModel(IServiceProvider provider,
|
public ItemViewModel(IServiceProvider provider,
|
||||||
IServiceFactory factory,
|
IServiceFactory factory,
|
||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
IContentTemplate template,
|
IContentTemplate template,
|
||||||
NamedComponent named,
|
NamedComponent named,
|
||||||
@@ -37,7 +37,7 @@ public partial class ItemViewModel :
|
|||||||
bool favourite = false,
|
bool favourite = false,
|
||||||
bool archived = false) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
bool archived = false) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||||
{
|
{
|
||||||
Named = $"{named}";
|
Named = $"{named}";
|
||||||
Template = template;
|
Template = template;
|
||||||
Immutable = immutable;
|
Immutable = immutable;
|
||||||
Favourite = favourite;
|
Favourite = favourite;
|
||||||
@@ -112,4 +112,4 @@ public partial class ItemViewModel :
|
|||||||
|
|
||||||
return base.OnActivated();
|
return base.OnActivated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,4 +34,4 @@ public class ModifiedItemHandler(IServiceProvider serviceProvider,
|
|||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,5 @@ public partial class NoteViewModel : Observable
|
|||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
IDisposer disposer) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@ public class OpenContainerHandler(ContainerConfiguration configuration,
|
|||||||
byte[]? salt = Convert.FromBase64String(keyPart[0]);
|
byte[]? salt = Convert.FromBase64String(keyPart[0]);
|
||||||
byte[]? encryptedKey = Convert.FromBase64String(keyPart[1]);
|
byte[]? encryptedKey = Convert.FromBase64String(keyPart[1]);
|
||||||
|
|
||||||
if ( keyVaultFactory.Create(Encoding.UTF8.GetBytes(password), encryptedKey, salt) is SecurityKey key)
|
if (keyVaultFactory.Create(Encoding.UTF8.GetBytes(password), encryptedKey, salt) is SecurityKey key)
|
||||||
{
|
{
|
||||||
if (await vaultStorage.Create(name, key))
|
if (await vaultStorage.Create(name, key))
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -5,4 +5,4 @@ public record Opened
|
|||||||
public static OpenedEventArgs<TValue> As<TValue>(TValue value) => new(value);
|
public static OpenedEventArgs<TValue> As<TValue>(TValue value) => new(value);
|
||||||
|
|
||||||
public static OpenedEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
|
public static OpenedEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public record OpenedEventArgs<TValue>(TValue? Value = default);
|
public record OpenedEventArgs<TValue>(TValue? Value = default);
|
||||||
@@ -11,6 +11,5 @@ public partial class PasswordViewModel : Observable
|
|||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
IDisposer disposer) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,14 +8,14 @@ namespace Bitvault;
|
|||||||
public class QueryContainerHandler(IDbContextFactory<ContainerDbContext> dbContextFactory) :
|
public class QueryContainerHandler(IDbContextFactory<ContainerDbContext> dbContextFactory) :
|
||||||
IHandler<RequestEventArgs<QueryContainerConfiguration>, IReadOnlyCollection<(Guid Id, string? Name, bool Favourite, bool Archived)>>
|
IHandler<RequestEventArgs<QueryContainerConfiguration>, 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<QueryContainerConfiguration> 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 QueryContainerConfiguration queryConfiguration)
|
||||||
{
|
{
|
||||||
ExpressionStarter<ItemEntry> predicate =
|
ExpressionStarter<ItemEntry> predicate =
|
||||||
PredicateBuilder.New<ItemEntry>(true);
|
PredicateBuilder.New<ItemEntry>(true);
|
||||||
|
|
||||||
if (queryConfiguration.Filter == "All")
|
if (queryConfiguration.Filter == "All")
|
||||||
@@ -33,7 +33,7 @@ public class QueryContainerHandler(IDbContextFactory<ContainerDbContext> dbConte
|
|||||||
predicate = predicate.And(x => x.State == 2);
|
predicate = predicate.And(x => x.State == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (queryConfiguration.Query is { Length: > 0} query)
|
if (queryConfiguration.Query is { Length: > 0 } query)
|
||||||
{
|
{
|
||||||
predicate = predicate.And(x => EF.Functions.Like(x.Name, $"%{query}%"));
|
predicate = predicate.And(x => EF.Functions.Like(x.Name, $"%{query}%"));
|
||||||
}
|
}
|
||||||
@@ -60,4 +60,4 @@ public class QueryContainerHandler(IDbContextFactory<ContainerDbContext> dbConte
|
|||||||
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,4 +3,4 @@
|
|||||||
public record QueryItemConfiguration
|
public record QueryItemConfiguration
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
@@ -18,5 +18,4 @@ public partial class SearchContainerActionViewModel(IServiceProvider provider,
|
|||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
public void Invoke() => Publisher.Publish(Notify.As(new Search(Value)),
|
public void Invoke() => Publisher.Publish(Notify.As(new Search(Value)),
|
||||||
nameof(ContainerViewModel));
|
nameof(ContainerViewModel));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5,7 +5,7 @@ namespace Bitvault;
|
|||||||
public class SecurityKeyFactory(IKeyGenerator generator,
|
public class SecurityKeyFactory(IKeyGenerator generator,
|
||||||
IKeyDeriver deriver,
|
IKeyDeriver deriver,
|
||||||
IEncryptor encryptor,
|
IEncryptor encryptor,
|
||||||
IDecryptor decryptor) :
|
IDecryptor decryptor) :
|
||||||
ISecurityKeyFactory
|
ISecurityKeyFactory
|
||||||
{
|
{
|
||||||
public SecurityKey? Create(byte[] phrase,
|
public SecurityKey? Create(byte[] phrase,
|
||||||
@@ -30,5 +30,4 @@ public class SecurityKeyFactory(IKeyGenerator generator,
|
|||||||
|
|
||||||
return new SecurityKey(salt, encryptedKey, decryptedKey);
|
return new SecurityKey(salt, encryptedKey, decryptedKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -11,6 +11,5 @@ public partial class TextViewModel : Observable
|
|||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
IDisposer disposer) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,4 +7,4 @@ public record Unarchive
|
|||||||
|
|
||||||
public static UnarchiveEventArgs<TValue> As<TValue>() where TValue : new() =>
|
public static UnarchiveEventArgs<TValue> As<TValue>() where TValue : new() =>
|
||||||
new(new TValue());
|
new(new TValue());
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public record UnarchiveEventArgs<TValue>(TValue Value);
|
public record UnarchiveEventArgs<TValue>(TValue Value);
|
||||||
@@ -13,5 +13,4 @@ public partial class UnarchiveItemActionViewModel(IServiceProvider provider,
|
|||||||
{
|
{
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
public void Invoke() => Publisher.Publish(Unarchive.As<Item>());
|
public void Invoke() => Publisher.Publish(Unarchive.As<Item>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,7 +28,6 @@ public class UnarchiveItemHandler(IValueStore<Item> valueStore,
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,4 +7,4 @@ public record Unfavourite
|
|||||||
|
|
||||||
public static UnfavouriteEventArgs<TValue> As<TValue>() where TValue : new() =>
|
public static UnfavouriteEventArgs<TValue> As<TValue>() where TValue : new() =>
|
||||||
new(new TValue());
|
new(new TValue());
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public record UnfavouriteEventArgs<TValue>(TValue Value);
|
public record UnfavouriteEventArgs<TValue>(TValue Value);
|
||||||
@@ -13,5 +13,4 @@ public partial class UnfavouriteItemActionViewModel(IServiceProvider provider,
|
|||||||
{
|
{
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
public void Invoke() => Publisher.Publish(Unfavourite.As<Item>());
|
public void Invoke() => Publisher.Publish(Unfavourite.As<Item>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,7 +28,6 @@ public class UnfavouriteItemHandler(IValueStore<Item> valueStore,
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
Submodule Toolkit updated: 246dab4297...40a150fe80
Reference in New Issue
Block a user