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