-
Notifications
You must be signed in to change notification settings - Fork 33
Add Founder projects to Avalonia app #366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
cd8a559
Add test for pending investments
SuperJMN 533dccc
Add testing integration in the UI
SuperJMN 99ba5cd
Improve names
SuperJMN fca3933
Improve readability
SuperJMN ffbafdd
Improve readability
SuperJMN 494182d
Add `TryGet` method to ProjectRepository and refactor usage
SuperJMN 16612ac
Refactor `Get` method to use `TryGet` and remove `FindById`
SuperJMN e559575
Refactor `GetFounderProjects` and integrate project data.
SuperJMN 9a4ded6
Add detailed project and investment views for founders
SuperJMN a8cd19a
Improve readability
SuperJMN 5b85201
Improve command design
SuperJMN 7f5186b
Clean up namespaces
SuperJMN File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/Angor/Avalonia/Angor.Contexts.Funding/Founder/Operations/GetFounderProjects.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Angor.Contests.CrossCutting; | ||
using Angor.Contexts.Funding.Projects.Application.Dtos; | ||
using Angor.Contexts.Funding.Projects.Domain; | ||
using Angor.Contexts.Funding.Projects.Infrastructure.Impl; | ||
using Angor.Contexts.Funding.Shared; | ||
using Angor.Shared; | ||
using CSharpFunctionalExtensions; | ||
using MediatR; | ||
using Zafiro.CSharpFunctionalExtensions; | ||
|
||
namespace Angor.Contexts.Funding.Founder.Operations; | ||
|
||
public static class GetFounderProjects | ||
{ | ||
public class GetFounderProjectsHandler( | ||
IProjectRepository projectRepository, | ||
ISeedwordsProvider seedwordsProvider, | ||
IDerivationOperations derivationOperations, | ||
INetworkConfiguration networkConfiguration) : IRequestHandler<GetFounderProjectsRequest, Result<IEnumerable<ProjectDto>>> | ||
{ | ||
public Task<Result<IEnumerable<ProjectDto>>> Handle(GetFounderProjectsRequest request, CancellationToken cancellationToken) | ||
{ | ||
return GetProjectIds(request) | ||
.Traverse(projectRepository.TryGet) | ||
.Map(projectMaybes => projectMaybes.Values()) | ||
.MapEach(project => project.ToDto()); | ||
} | ||
|
||
private Task<Result<IEnumerable<ProjectId>>> GetProjectIds(GetFounderProjectsRequest request) | ||
{ | ||
return seedwordsProvider.GetSensitiveData(request.WalletId) | ||
.Map(p => p.ToWalletWords()) | ||
.Map(words => derivationOperations.DeriveProjectKeys(words, networkConfiguration.GetAngorKey())) | ||
.Map(collection => collection.Keys.AsEnumerable()) | ||
.MapEach(keys => keys.ProjectIdentifier) | ||
.MapEach(fk => new ProjectId(fk)); | ||
} | ||
} | ||
|
||
public record GetFounderProjectsRequest(Guid WalletId) : IRequest<Result<IEnumerable<ProjectDto>>>; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
src/Angor/Avalonia/AngorApp/Sections/Browse/BrowseSectionViewModel.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/Angor/Avalonia/AngorApp/Sections/Founder/Details/FounderProjectDetailsView.axaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<UserControl xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:c="clr-namespace:Zafiro.Avalonia.Controls;assembly=Zafiro.Avalonia" | ||
xmlns:sdg="clr-namespace:Zafiro.Avalonia.Controls.SlimDataGrid;assembly=Zafiro.Avalonia" | ||
xmlns:angorApp="clr-namespace:AngorApp" | ||
xmlns:asyncImageLoader="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia" | ||
xmlns:controls="clr-namespace:AngorApp.UI.Controls" | ||
xmlns:pt="https://github.com/projektanker/icons.avalonia" | ||
xmlns:details="clr-namespace:AngorApp.Sections.Founder.Details" | ||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" | ||
x:Class="AngorApp.Sections.Founder.Details.FounderProjectDetailsView" x:DataType="details:IFounderProjectDetailsViewModel"> | ||
|
||
<Design.DataContext> | ||
<details:FounderProjectDetailsViewModelDesign BannerUrl="https://images-assets.nasa.gov/image/PIA05062/PIA05062~thumb.jpg" /> | ||
</Design.DataContext> | ||
|
||
<Interaction.Behaviors> | ||
<DataContextChangedTrigger> | ||
<InvokeCommandAction Command="{Binding LoadPendingInvestments}" /> | ||
</DataContextChangedTrigger> | ||
</Interaction.Behaviors> | ||
|
||
<StackPanel Spacing="10"> | ||
<controls:Pane Padding="0" CornerRadius="20"> | ||
<StackPanel> | ||
<asyncImageLoader:AdvancedImage CornerRadius="20 20 0 0" Height="200" Stretch="UniformToFill" Source="{Binding BannerUrl}" /> | ||
<StackPanel Margin="20" Spacing="10"> | ||
<TextBlock Classes="SizeBig" Text="{Binding Name}" /> | ||
<TextBlock TextWrapping="Wrap" Text="{Binding ShortDescription}" /> | ||
</StackPanel> | ||
</StackPanel> | ||
</controls:Pane> | ||
<controls:Pane Title="Investments pending approval" IsTitleVisible="True"> | ||
<controls:Pane.TitleRightContent> | ||
<Button pt:Attached.Icon="fa-rotate-right" Command="{Binding LoadPendingInvestments}" /> | ||
</controls:Pane.TitleRightContent> | ||
<c:Loading IsLoading="{Binding LoadPendingInvestments.IsExecuting^}"> | ||
<sdg:SlimDataGrid Margin="0 10" ItemsSource="{Binding PendingInvestments}"> | ||
<sdg:SlimDataGrid.Columns> | ||
<sdg:Column Header="Amount" Binding="{Binding Amount}" /> | ||
<sdg:Column Header="NPub" Binding="{Binding InvestorNostrPubKey}" /> | ||
<sdg:Column Header="Date" Binding="{Binding Created}" /> | ||
</sdg:SlimDataGrid.Columns> | ||
</sdg:SlimDataGrid> | ||
</c:Loading> | ||
</controls:Pane> | ||
</StackPanel> | ||
</UserControl> |
9 changes: 9 additions & 0 deletions
9
src/Angor/Avalonia/AngorApp/Sections/Founder/Details/FounderProjectDetailsView.axaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<
3D11
a href="{{ revealButtonHref }}" data-view-component="true" class="btn-sm btn"> Show hidden characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace AngorApp.Sections.Founder.Details; | ||
|
||
public partial class FounderProjectDetailsView : UserControl | ||
{ | ||
public FounderProjectDetailsView() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/Angor/Avalonia/AngorApp/Sections/Founder/Details/FounderProjectDetailsViewModel.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Angor.Contexts.Funding.Founder.Operations; | ||
using Angor.Contexts.Funding.Investor; | ||
using Angor.Contexts.Funding.Projects.Application.Dtos; | ||
using AngorApp.UI.Services; | ||
using DynamicData; | ||
using Zafiro.CSharpFunctionalExtensions; | ||
using Zafiro.UI; | ||
|
||
namespace AngorApp.Sections.Founder.Details; | ||
|
||
public class FounderProjectDetailsViewModel : IFounderProjectDetailsViewModel | ||
{ | ||
private readonly ProjectDto projectDto; | ||
|
||
public FounderProjectDetailsViewModel(ProjectDto projectDto, IInvestmentAppService investmentAppService, UIServices uiServices) | ||
{ | ||
this.projectDto = projectDto; | ||
LoadPendingInvestments = ReactiveCommand.CreateFromTask(token => | ||
{ | ||
return uiServices.WalletRoot.GetDefaultWalletAndActivate() | ||
.Bind(maybe => maybe.ToResult("You need to create a wallet first")) | ||
.Bind(wallet => investmentAppService.GetPendingInvestments(wallet.Id.Value, projectDto.Id)); | ||
}); | ||
|
||
LoadPendingInvestments.HandleErrorsWith(uiServices.NotificationService, "Failed to get pending investments"); | ||
|
||
LoadPendingInvestments.Successes() | ||
.EditDiff(dto => dto) | ||
.Bind(out var pendingInvestments) | ||
.Subscribe(); | ||
|
||
PendingInvestments = pendingInvestments; | ||
} | ||
|
||
public IEnumerable<GetPendingInvestments.PendingInvestmentDto> PendingInvestments { get; } | ||
|
||
public ReactiveCommand<Unit, Result<IEnumerable<GetPendingInvestments.PendingInvestmentDto>>> LoadPendingInvestments { get; } | ||
public Uri? BannerUrl => projectDto.Banner; | ||
public string ShortDescription => projectDto.ShortDescription; | ||
public string Name => projectDto.Name; | ||
} |
19 changes: 19 additions & 0 deletions
19
src/Angor/Avalonia/AngorApp/Sections/Founder/Details/FounderProjectDetailsViewModelDesign.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Angor.Contexts.Funding.Founder.Operations; | ||
|
||
namespace AngorApp.Sections.Founder.Details; | ||
|
||
public class FounderProjectDetailsViewModelDesign : IFounderProjectDetailsViewModel | ||
{ | ||
public string Name { get; } = "Test"; | ||
|
||
public IEnumerable<GetPendingInvestments.PendingInvestmentDto> PendingInvestments { get; } = new List<GetPendingInvestments.PendingInvestmentDto>() | ||
{ | ||
new(DateTime.Now, 1234, "nostr pub key"), | ||
new(DateTime.Now.AddHours(-2), 1233, "nostr pub key"), | ||
new(DateTime.Now.AddHours(-4), 1235, "nostr pub key"), | ||
}; | ||
|
||
public ReactiveCommand<Unit, Result<IEnumerable<GetPendingInvestments.PendingInvestmentDto>>> LoadPendingInvestments { get; } | ||
public Uri? BannerUrl { get; set; } | ||
public string ShortDescription { get; } = "Short description, Bitcoin ONLY."; | ||
} |
12 changes: 12 additions & 0 deletions
12
src/Angor/Avalonia/AngorApp/Sections/Founder/Details/IFounderProjectDetailsViewModel.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Angor.Contexts.Funding.Founder.Operations; | ||
5B27 |
|
|
namespace AngorApp.Sections.Founder.Details; | ||
|
||
public interface IFounderProjectDetailsViewModel | ||
{ | ||
public string Name { get; } | ||
public IEnumerable<GetPendingInvestments.PendingInvestmentDto> PendingInvestments { get; } | ||
ReactiveCommand<Unit, Result<IEnumerable<GetPendingInvestments.PendingInvestmentDto>>> LoadPendingInvestments { get; } | ||
public Uri? BannerUrl { get; } | ||
public string ShortDescription { get; } | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.