-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from michielpost/feature/addressbook
Feature/addressbook
- Loading branch information
Showing
13 changed files
with
286 additions
and
112 deletions.
There are no files selected for viewing
This file contains 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,132 @@ | ||
@page "/address-book" | ||
@using aoWebWallet.Models | ||
@inherits MvvmComponentBase<MainViewModel> | ||
@inject IDialogService DialogService | ||
@inject ISnackbar Snackbar | ||
@inject ClipboardService ClipboardService | ||
|
||
<PageTitle>Address Book - @Program.PageTitlePostFix</PageTitle> | ||
|
||
|
||
<MudContainer Class="mt-16 px-8" MaxWidth="MaxWidth.False"> | ||
|
||
|
||
<MudText Typo="Typo.h5">Address Book</MudText> | ||
|
||
<MudContainer Width="100%" Class="d-flex justify-end mb-4 pr-3 d-max-w-100"> | ||
@if (BindingContext.WalletList.Data != null && BindingContext.WalletList.Data.Any()) | ||
{ | ||
<MudTooltip Text="Add contact" Arrow="true" Placement="Placement.Left"> | ||
<MudIconButton Icon="@Icons.Material.Filled.AddCircle" aria-label="add contact" Size="Size.Large" OnClick="OpenDialog"></MudIconButton> | ||
</MudTooltip> | ||
} | ||
</MudContainer> | ||
|
||
<MudStack> | ||
@if (BindingContext.WalletList.Data != null) | ||
{ | ||
if(BindingContext.WalletList.Data.Where(x => x.IsReadOnly).Any()) | ||
{ | ||
int logoCount = 1; | ||
foreach (var wallet in BindingContext.WalletList.Data.Where(x => x.IsReadOnly)) | ||
{ | ||
string logoUrl = $"images/account--{logoCount}.svg"; | ||
string detailUrl = $"wallet/{wallet.Address}"; | ||
<MudPaper Class="pa-4"> | ||
<MudStack Row="true"> | ||
<MudAvatar Image="@logoUrl" Size="Size.Large" Class="rounded-full" /> | ||
|
||
<MudStack Class="d-overflow-hidden" Justify="Justify.Center" Spacing="0"> | ||
<div Class="d-custom-2"> | ||
<MudLink Class="KodeMono tx-wrap" Href="@detailUrl" Typo="Typo.h6"> | ||
@wallet.Address | ||
</MudLink> | ||
<MudIconButton Class="copy-clipboard" Icon="@Icons.Material.Filled.ContentCopy" Color="Color.Default" OnClick="async () => { await ClipboardService.CopyToClipboard(wallet.Address); }" /> | ||
</div> | ||
<div Class="d-flex flex-row"> | ||
<MudText Typo="Typo.body2">@wallet.Name</MudText> | ||
</div> | ||
</MudStack> | ||
<MudSpacer /> | ||
@if(BindingContext.ProcessesDataList?.Data?.Where(x => x.Data?.Address == wallet.Address && (x.Data?.Processes?.Any() ?? false)).Any() ?? false) | ||
{ | ||
<MudChip>AOS</MudChip> | ||
} | ||
|
||
<MudIconButton Class="delete-address" Icon="@Icons.Material.Filled.Edit" aria-label="edit" OnClick="() => { EditWallet(wallet); }"></MudIconButton> | ||
<MudIconButton Class="delete-address" Icon="@Icons.Material.Filled.Delete" aria-label="delete" OnClick="() => { DeleteWallet(wallet); }"></MudIconButton> | ||
</MudStack> | ||
</MudPaper> | ||
|
||
logoCount++; | ||
if (logoCount > 5) | ||
logoCount = 1; | ||
} | ||
} | ||
else | ||
{ | ||
<MudGrid Row="true" Justify="Justify.Center" Class="p-2"> | ||
<MudItem sm="12" xs="12"> | ||
<AddWalletComponent IsExpanded="true"></AddWalletComponent> | ||
Check warning on line 70 in src/aoWebWallet/Pages/AddressBook.razor GitHub Actions / build
Check warning on line 70 in src/aoWebWallet/Pages/AddressBook.razor GitHub Actions / build
|
||
</MudItem> | ||
</MudGrid> | ||
|
||
} | ||
} | ||
else | ||
{ | ||
<MudText Typo="Typo.h6">Loading address book...</MudText> | ||
|
||
<DataLoaderProgress DataLoader="BindingContext.WalletList.DataLoader" Title="wallets" /> | ||
} | ||
|
||
</MudStack> | ||
</MudContainer> | ||
|
||
|
||
@code | ||
{ | ||
private void OpenDialog() | ||
{ | ||
var tempWallet = new Wallet() | ||
{ | ||
Address = string.Empty, | ||
IsReadOnly = true, | ||
AddedDate = DateTimeOffset.UtcNow, | ||
Source = WalletTypes.Manual | ||
}; | ||
|
||
var parameters = new DialogParameters<EditWalletComponent> { { x => x.Wallet, tempWallet } }; | ||
|
||
var options = new DialogOptions { CloseOnEscapeKey = true, MaxWidth = MaxWidth.Small, FullWidth = true }; | ||
DialogService.Show<EditWalletComponent>("Add Contact", parameters, options); | ||
} | ||
|
||
private async void EditWallet(Wallet wallet) | ||
{ | ||
var parameters = new DialogParameters<EditWalletComponent> { { x => x.Wallet, wallet } }; | ||
|
||
var options = new DialogOptions { CloseOnEscapeKey = true, MaxWidth = MaxWidth.Small, FullWidth = true }; | ||
DialogService.Show<EditWalletComponent>("Edit Contact", parameters, options); | ||
|
||
StateHasChanged(); | ||
} | ||
|
||
private async void DeleteWallet(Wallet wallet) | ||
{ | ||
bool? result = await DialogService.ShowMessageBox( | ||
"Warning", | ||
$"Are you sure you want to delete this contact? {wallet.Address}?", | ||
yesText: "Delete!", cancelText: "Cancel"); | ||
|
||
if (result != null) | ||
{ | ||
await BindingContext.DeleteWallet(wallet); | ||
|
||
Snackbar.Add($"Contact deleted ({wallet.Address})", Severity.Info); | ||
} | ||
StateHasChanged(); | ||
} | ||
|
||
|
||
} |
This file contains 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,27 @@ | ||
using aoWebWallet.ViewModels; | ||
|
||
namespace aoWebWallet.Pages | ||
{ | ||
public partial class AddressBook : MvvmComponentBase<MainViewModel> | ||
{ | ||
protected override void OnInitialized() | ||
{ | ||
//WatchDataLoaderVM(BindingContext.TokenList); | ||
WatchDataLoaderVM(BindingContext.WalletList); | ||
WatchDataLoaderVM(BindingContext.ProcessesDataList); | ||
|
||
base.OnInitialized(); | ||
} | ||
|
||
protected override async Task OnAfterRenderAsync(bool firstRender) | ||
{ | ||
if (firstRender) | ||
{ | ||
await BindingContext.LoadWalletList(); | ||
} | ||
|
||
await base.OnAfterRenderAsync(firstRender); | ||
} | ||
|
||
} | ||
} |
This file contains 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 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 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 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 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 was deleted.
Oops, something went wrong.
This file contains 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
Oops, something went wrong.