Skip to content

Commit

Permalink
Fixed wallet UI (#63)
Browse files Browse the repository at this point in the history
* Remove extra js codes

* Fix wallet UI except modals

* Fixed create and recover modal UI

* Fixed wallet words modad UI

* Fixed tables UI

* Fixed checkbox UI
  • Loading branch information
miladsoft authored Apr 3, 2024
1 parent 9b77f2d commit 9360a03
Show file tree
Hide file tree
Showing 13 changed files with 913 additions and 1,407 deletions.
20 changes: 10 additions & 10 deletions src/Angor/Client/Pages/Founder.razor
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@inject NavigationManager NavigationManager
@inject IWalletStorage _walletStorage;
@inject IClientStorage storage;
@inject IRelayService RelayService;
@inject IRelayService RelayService;
@inject IIndexerService _IndexerService

@if (!hasWallet)
Expand All @@ -22,8 +22,8 @@

<div class="container my-4">
<h1>Founder Page</h1>
<NotificationComponent @ref="notificationComponent"/>

<NotificationComponent @ref="notificationComponent" />

<div class="row">
<div class="col">
Expand All @@ -48,7 +48,7 @@
else
{
<button class="btn btn-primary mb-4" @onclick="LookupProjectKeysOnIndexerAsync">Scan for founder projects</button>
<br/>
<br />
}
</div>
</div>
Expand All @@ -74,7 +74,7 @@
</div>


@code {
@code {
private string founderKey;
private string projectId;
private List<FounderProject> founderProjects = new();
Expand All @@ -84,7 +84,7 @@
private NotificationComponent notificationComponent;




protected override async Task OnInitializedAsync()
{
Expand All @@ -99,7 +99,7 @@
private async Task LookupProjectKeysOnIndexerAsync()
{
scanningForProjects = true;

var keys = _walletStorage.GetFounderKeys();

var founderProjectsToLookup = new List<string>();
Expand Down Expand Up @@ -128,11 +128,11 @@
if (founderProject != null && founderProject.Metadata is null)
founderProject.Metadata = nostrMetadata;
// else
// notificationComponent.ShowNotificationMessage($"Couldn't find the project details for the project {nostrMetadata.Name} try adding the missing relay."); //TODO
// notificationComponent.ShowNotificationMessage($"Couldn't find the project details for the project {nostrMetadata.Name} try adding the missing relay."); //TODO
break;
case { Kind: NostrKind.ApplicationSpecificData }:
var projectInfo = JsonSerializer.Deserialize<ProjectInfo>(e.Content, Angor.Shared.Services.RelayService.settings);
if(founderProjects.All(_ => _.ProjectInfo.NostrPubKey != e.Pubkey)) //Getting events from multiple relays
if (founderProjects.All(_ => _.ProjectInfo.NostrPubKey != e.Pubkey)) //Getting events from multiple relays
founderProjects.Add(new FounderProject { ProjectInfo = projectInfo });
break;
}
Expand All @@ -147,7 +147,7 @@
else
scanningForProjects = false;
}

private void NavigateToCreateProject()
{
NavigationManager.NavigateTo("/create");
Expand Down
137 changes: 75 additions & 62 deletions src/Angor/Client/Pages/Investor.razor
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
<div class="d-flex justify-content-between align-items-center">
<h1 class="mb-4">Invested Portfolio</h1>
<button class="btn btn-secondary" @onclick="NavigateToPenalties">View Penalties</button>
</div>
<NotificationComponent @ref="notificationComponent"/>
</div>
<NotificationComponent @ref="notificationComponent" />

<!-- Summary Statistics -->
<div class="row row-cols-1 row-cols-md-4 g-4 mb-4">
<div class="col">
Expand Down Expand Up @@ -63,65 +63,78 @@
</div>

<!-- List of Projects -->
<h2 class="mb-4">Your Projects</h2>
<div class="row">
<div class="col">
<table class="table table-bordered">
<thead>
<tr >
<th></th>
<th></th>
<th>Funding Target (@network.CoinTicker)</th>
<th>Raised (@network.CoinTicker)</th>
<th>Raised (% Target)</th>
<th>Project Status</th>
<th>My Investment (@network.CoinTicker)</th>
<th>Spent by Founder</th>
<th>Available to Founder</th>
<th>In Recovery</th>
</tr>
</thead>
<tbody>
@foreach(var project in projects)
{
Stats.TryGetValue(project.ProjectInfo.ProjectIdentifier, out var stats);

<tr>
<td>
<a href=@($"/view/{project.ProjectInfo.ProjectIdentifier}") class="btn btn-link"> @TrimString(@project.ProjectInfo.ProjectIdentifier)</a>
</td>
<td> @project.Metadata?.Name</td>
<td>@project.ProjectInfo.TargetAmount @network.CoinTicker</td>
<td>@Money.Satoshis(stats?.AmountInvested ?? 0).ToUnit(MoneyUnit.BTC) @network.CoinTicker </td>
<td>@((stats?.AmountInvested ?? 0) * 100 / Money.Coins(project.ProjectInfo.TargetAmount).Satoshi) %</td>
<td>
@if (project.ProjectInfo.StartDate < DateTime.UtcNow)
{
<p class="text-info">Funding</p>
}
else
{
<p class="text-success">Live</p>
}
</td>
<td>@Money.Satoshis(project.AmountInvested ?? 0).ToUnit(MoneyUnit.BTC) @network.CoinTicker
@if (!project.SignaturesInfo?.Signatures.Any() ?? false)
{
<a href=@($"/invest/{project.ProjectInfo.ProjectIdentifier}") class="btn btn-link" data-toggle="tooltip" title="Pending"> <i class="oi oi-clock"></i></a>
}
</td>
<td>-</td>
<td>-</td>
<td>@Money.Satoshis(project.AmountInRecovery ?? 0).ToUnit(MoneyUnit.BTC) @network.CoinTicker</td>
</tr>
}
</tbody>
</table>
<div class="col-md-12">
<div class="card">
<div class="card-header pb-0 p-3">
<div class="row">
<div class="col-6 d-flex align-items-center">
<h6 class="mb-0">Your Projects</h6>
</div>
</div>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table align-items-center mb-0">
<thead>
<tr>
<th class="text-uppercase text-xxs font-weight-bolder opacity-7"></th>
<th class="text-uppercase text-xxs font-weight-bolder opacity-7">Name</th>
<th class="text-uppercase text-xxs font-weight-bolder opacity-7">Funding Target (@network.CoinTicker)</th>
<th class="text-uppercase text-xxs font-weight-bolder opacity-7">Raised (@network.CoinTicker)</th>
<th class="text-uppercase text-xxs font-weight-bolder opacity-7">Raised (% Target)</th>
<th class="text-uppercase text-xxs font-weight-bolder opacity-7">Project Status</th>
<th class="text-uppercase text-xxs font-weight-bolder opacity-7">My Investment (@network.CoinTicker)</th>
<th class="text-uppercase text-xxs font-weight-bolder opacity-7">Spent by Founder</th>
<th class="text-uppercase text-xxs font-weight-bolder opacity-7">Available to Founder</th>
<th class="text-uppercase text-xxs font-weight-bolder opacity-7">In Recovery</th>
</tr>
</thead>
<tbody>

@foreach (var project in projects)
{
Stats.TryGetValue(project.ProjectInfo.ProjectIdentifier, out var stats);

<tr>
<td>
<a href=@($"/view/{project.ProjectInfo.ProjectIdentifier}")>@project.Metadata?.Name</a>
</td>
<td>@project.ProjectInfo.TargetAmount @network.CoinTicker</td>
<td>@Money.Satoshis(stats?.AmountInvested ?? 0).ToUnit(MoneyUnit.BTC) @network.CoinTicker </td>
<td>@((stats?.AmountInvested ?? 0) * 100 / Money.Coins(project.ProjectInfo.TargetAmount).Satoshi) %</td>
<td>
@if (project.ProjectInfo.StartDate < DateTime.UtcNow)
{
<p class="text-info">Funding</p>
}
else
{
<p class="text-success">Live</p>
}
</td>
<td>
@Money.Satoshis(project.AmountInvested ?? 0).ToUnit(MoneyUnit.BTC) @network.CoinTicker
@if (!project.SignaturesInfo?.Signatures.Any() ?? false)
{
<a href=@($"/invest/{project.ProjectInfo.ProjectIdentifier}") class="btn btn-link" data-toggle="tooltip" title="Pending"> <i class="oi oi-clock"></i></a>
}
</td>
<td>-</td>
<td>-</td>
<td>@Money.Satoshis(project.AmountInRecovery ?? 0).ToUnit(MoneyUnit.BTC) @network.CoinTicker</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
</div>

</div>

</div>

@code {

private List<InvestorProject> projects = new();
Expand All @@ -131,8 +144,8 @@
int TotalFundedProjects = 0;
long TotalInRecovery = 0;

public Dictionary<string,ProjectStats> Stats = new();
public Dictionary<string, ProjectStats> Stats = new();

protected override async Task OnInitializedAsync()
{
hasWallet = _walletStorage.HasWallet();
Expand All @@ -148,7 +161,7 @@
abi.UpdateAccountBalanceInfo(accountInfo, unconfirmedInfo);

TotalFundedProjects = projects.Count;
TotalInvested = projects.Sum(s => s.AmountInvested ?? 0);
TotalInvested = projects.Sum(s => s.AmountInvested ?? 0);
TotalWallet = abi.TotalBalance;
TotalInRecovery = projects.Sum(s => s.AmountInRecovery ?? 0);

Expand All @@ -161,7 +174,7 @@
try
{
Stats.Clear();

foreach (var project in projects)
{
var projectStats = await _IndexerService.GetProjectStatsAsync(project.ProjectInfo.ProjectIdentifier);
Expand All @@ -188,4 +201,4 @@
{
NavigationManager.NavigateTo("/penalties");
}
}
}
99 changes: 57 additions & 42 deletions src/Angor/Client/Pages/Penalties.razor
Original file line number Diff line number Diff line change
Expand Up @@ -30,44 +30,59 @@
{
<!-- Penalties Details Section -->
<div class="row mt-4">
<div class="col">
<h4>Penalties Details</h4>
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>Project ID</th>
<th>Amount in Penalty</th>
<th>Days Left</th>
</tr>
</thead>
<tbody>
@foreach (var penalty in penaltyProjects)
{
<tr>
<td>@penalty.ProjectIdentifier</td>
<td>@penalty.Amount @network.CoinTicker</td>
<td>
@if (penalty.IsExpired)
{
if (penalty.IsReleased)
{
<button disabled class="btn btn-secondary">Penalty Released</button>
}
else
{
<button class="btn btn-info" @onclick="() => ClaimPenalty(penalty.ProjectIdentifier)">Claim Penalty</button>
}
}
else

<div class="col-md-12">
<div class="card">
<div class="card-header pb-0 p-3">
<div class="row">
<div class="col-6 d-flex align-items-center">
<h6 class="mb-0">Penalties Details</h6>
</div>
</div>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table align-items-center mb-0">
<thead>
<tr>
<th class="text-uppercase text-xxs font-weight-bolder opacity-7">Project ID</th>
<th class="text-uppercase text-xxs font-weight-bolder opacity-7">Amount in Penalty</th>
<th class="text-uppercase text-xxs font-weight-bolder opacity-7">Days Left</th>
</tr>
</thead>
<tbody>
@foreach (var penalty in penaltyProjects)
{
<button disabled class="btn btn-warning">Penalty Release in @penalty.DaysLeftForPenalty days</button>
<tr>
<td>@penalty.ProjectIdentifier</td>
<td>@penalty.Amount @network.CoinTicker</td>
<td>
@if (penalty.IsExpired)
{
if (penalty.IsReleased)
{
<button disabled class="btn btn-secondary">Penalty Released</button>
}
else
{
<button class="btn btn-info" @onclick="() => ClaimPenalty(penalty.ProjectIdentifier)">Claim Penalty</button>
}
}
else
{
<button disabled class="btn btn-warning">Penalty Release in @penalty.DaysLeftForPenalty days</button>
}
</td>
</tr>
}
</td>
</tr>
}
</tbody>
</table>
</tbody>
</table>
</div>
</div>
</div>
</div>


</div>
}
</div>
Expand All @@ -86,7 +101,7 @@
public int DaysLeftForPenalty;
}


protected override async Task OnInitializedAsync()
{
if (hasWallet)
Expand All @@ -98,11 +113,11 @@
if (!string.IsNullOrEmpty(project.RecoveryTransactionId))
{
penaltyProjects.Add(new PenaltiesData
{
ProjectIdentifier = project.ProjectInfo.ProjectIdentifier,
RecoveryTransactionId = project.RecoveryTransactionId,
IsReleased = !string.IsNullOrEmpty(project.RecoveryReleaseTransactionId),
});
{
ProjectIdentifier = project.ProjectInfo.ProjectIdentifier,
RecoveryTransactionId = project.RecoveryTransactionId,
IsReleased = !string.IsNullOrEmpty(project.RecoveryReleaseTransactionId),
});
}
}
}
Expand All @@ -121,7 +136,7 @@
foreach (var penaltyProject in penaltyProjects)
{
var recoveryTansaction = await _IndexerService.GetTransactionInfoByIdAsync(penaltyProject.RecoveryTransactionId);

var totalsats = recoveryTansaction.Outputs.Where(s => Script.FromHex(s.ScriptPubKey).IsScriptType(ScriptType.P2WSH)).Sum(s => s.Balance);
penaltyProject.Amount = Money.Satoshis(totalsats).ToUnit(MoneyUnit.BTC);

Expand Down
Loading

0 comments on commit 9360a03

Please sign in to comment.