-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add modal component service & create add node modal (#152)
* Add modal component service & creat add node modal * Add error message * move the code for blazor modal to its own feature * Fix modal * Add refresh button * Lay foundations for tx details * Add wallet selection dropdown * Additional navigation * Move some components to node host * Fix wallet sync calculation Co-authored-by: dangershony <dan.gershony@gmail.com>
- Loading branch information
1 parent
75fa06c
commit 48b2bd9
Showing
27 changed files
with
599 additions
and
166 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,29 @@ | ||
using Microsoft.AspNetCore.Components; | ||
using System; | ||
|
||
namespace BlazorModal.Services | ||
{ | ||
public class ModalService | ||
{ | ||
public event Action<string, RenderFragment> OnShow; | ||
|
||
public event Action OnClose; | ||
|
||
public void Show(string title, Type contentType) | ||
{ | ||
if (contentType.BaseType != typeof(ComponentBase)) | ||
{ | ||
throw new ArgumentException($"{contentType.FullName} must be a Blazor Component"); | ||
} | ||
|
||
var content = new RenderFragment(x => { x.OpenComponent(1, contentType); x.CloseComponent(); }); | ||
|
||
OnShow?.Invoke(title, content); | ||
} | ||
|
||
public void Close() | ||
{ | ||
OnClose?.Invoke(); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/Features/Blockcore.Features.ColdStaking/UI/Dropdown.razor
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,33 @@ | ||
@typeparam TItem | ||
<div class="dropdown"> | ||
<button class="btn btn-primary btn-sm dropdown-toggle mr-1" data-toggle="dropdown" type="button" @onclick="e => this.show=!this.show " | ||
aria-haspopup="true" aria-expanded="false"> | ||
@Tip | ||
</button> | ||
<CascadingValue name="Dropdown" Value="@this"> | ||
<div class="dropdown-menu @(show? "show":"")" > | ||
@ChildContent | ||
</div> | ||
</CascadingValue> | ||
</div> | ||
|
||
@code { | ||
[Parameter] | ||
public RenderFragment InitialTip{get;set;} | ||
[Parameter] | ||
public RenderFragment ChildContent{get;set;} | ||
[Parameter] | ||
public EventCallback<TItem> OnSelected {get;set;} | ||
|
||
private bool show = false; | ||
private RenderFragment Tip ; | ||
|
||
protected override void OnInitialized(){ this.Tip = InitialTip; } | ||
public async Task HandleSelect(TItem item, RenderFragment<TItem> contentFragment) | ||
{ | ||
this.Tip= contentFragment.Invoke(item); | ||
this.show=false; | ||
StateHasChanged(); | ||
await this.OnSelected.InvokeAsync(item); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/Features/Blockcore.Features.ColdStaking/UI/DropdownListItem.razor
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,12 @@ | ||
@typeparam TItem | ||
<a class="dropdown-item" Item="@Item" @onclick="e=> Dropdown.HandleSelect(Item, ChildContent)" >@ChildContent(Item)</a> | ||
|
||
@code { | ||
[CascadingParameter(Name="Dropdown")] | ||
public Dropdown<TItem> Dropdown {get;set;} | ||
|
||
[Parameter] | ||
public TItem Item{get;set;} | ||
[Parameter] | ||
public RenderFragment<TItem> ChildContent {get;set;} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
src/Features/Blockcore.Features.ColdStaking/UI/Pages/ViewTransaction.razor
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,13 @@ | ||
@if (ShowForm) | ||
{ | ||
|
||
} | ||
|
||
@code | ||
{ | ||
bool ShowForm { get; set; } = true; | ||
private void SubmitForm() | ||
{ | ||
ShowForm = false; | ||
} | ||
} |
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
@using Microsoft.AspNetCore.Components.Web | ||
@using Microsoft.AspNetCore.Components.Web | ||
@using BlazorModal | ||
@using BlazorModal.Services |
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
38 changes: 38 additions & 0 deletions
38
src/Features/Blockcore.Features.NodeHost/UI/Pages/AddNode.razor
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,38 @@ | ||
@using Blockcore.Utilities.Extensions | ||
|
||
@inject Blockcore.Connection.IConnectionManager ConnectionManager | ||
|
||
@if (ShowForm) | ||
{ | ||
|
||
<div class="input-group"> | ||
<input @bind="NodeIp" type="text" class="form-control" placeholder="Node IP Address" /> | ||
<div class="input-group-append"> | ||
<button class="btn btn-primary" @onclick="Addnode"> | ||
<span class="oi oi-plus" aria-hidden="true"></span> Add Node</button> | ||
</div> | ||
<div class="input-group mt-2"> | ||
<div class="alert-warning"> | ||
@Alert | ||
</div> | ||
</div> | ||
</div> | ||
} | ||
|
||
@code | ||
{ | ||
bool ShowForm { get; set; } = true; | ||
private string NodeIp { get; set; } | ||
string Alert { get; set; } | ||
private void Addnode() | ||
{ | ||
|
||
if (string.IsNullOrEmpty(this.NodeIp)) { this.Alert = "Please enter an IP address"; return; } | ||
this.Alert = string.Empty; | ||
var endpoint = this.NodeIp.ToIPEndPoint(this.ConnectionManager.Network.DefaultPort); | ||
this.ConnectionManager.AddNodeAddress(endpoint); | ||
this.Alert = $"Added Node: {endpoint}"; | ||
} | ||
|
||
|
||
} |
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
Oops, something went wrong.