mirror of
https://github.com/aljazceru/BTCPayServerPlugins.git
synced 2025-12-17 15:44:26 +01:00
many fixes to prism ui
This commit is contained in:
@@ -29,8 +29,12 @@
|
|||||||
<span class="form-text">When a payout is being generated, how much of its amount in percentage should be excluded to cover the fee? Once the payment is settled, if the lightning node provides the exact fee, the balance is adjusted accordingly. Leave blank to use default setting.</span>
|
<span class="form-text">When a payout is being generated, how much of its amount in percentage should be excluded to cover the fee? Once the payment is settled, if the lightning node provides the exact fee, the balance is adjusted accordingly. Leave blank to use default setting.</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button type="button" class="btn btn-primary" @onclick="Update">Update</button>
|
<button type="button" class="btn btn-primary" @onclick="Update">@(string.IsNullOrEmpty(OriginalWorkingId)? "Create": "Update")</button>
|
||||||
|
<button type="button" class="btn btn-secondary" @onclick="Cancel">Cancel</button>
|
||||||
|
@if (!string.IsNullOrEmpty(OriginalWorkingId))
|
||||||
|
{
|
||||||
<button type="button" class="btn btn-outline-danger" @onclick="() => SettingsChanged.InvokeAsync(null)">Remove</button>
|
<button type="button" class="btn btn-outline-danger" @onclick="() => SettingsChanged.InvokeAsync(null)">Remove</button>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -42,7 +46,8 @@
|
|||||||
private string WorkingId { get; set; }
|
private string WorkingId { get; set; }
|
||||||
private string OriginalWorkingId { get; set; }
|
private string OriginalWorkingId { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public EventCallback OnCancel { get; set; }
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public Func<string, bool> ValidateDestination { get; set; }
|
public Func<string, bool> ValidateDestination { get; set; }
|
||||||
|
|
||||||
@@ -66,8 +71,9 @@
|
|||||||
get => WorkingId;
|
get => WorkingId;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (OriginalWorkingId != value)
|
if (OriginalWorkingId != value )
|
||||||
{
|
{
|
||||||
|
|
||||||
WorkingId = value;
|
WorkingId = value;
|
||||||
OriginalWorkingId = value;
|
OriginalWorkingId = value;
|
||||||
InvalidId = false;
|
InvalidId = false;
|
||||||
@@ -87,8 +93,7 @@
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await SettingsChanged.InvokeAsync(WorkingCopy);
|
await IdChanged.InvokeAsync(WorkingId).ContinueWith(task => SettingsChanged.InvokeAsync(WorkingCopy));
|
||||||
await IdChanged.InvokeAsync(WorkingId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
@@ -98,4 +103,9 @@
|
|||||||
public EventCallback<string> IdChanged { get; set; }
|
public EventCallback<string> IdChanged { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
private Task Cancel()
|
||||||
|
{
|
||||||
|
return OnCancel.InvokeAsync(null);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
@* @using NBitcoin *@
|
|
||||||
@* @if (Destinations.Any()) *@
|
|
||||||
@* { *@
|
|
||||||
@* <div class="form-group"> *@
|
|
||||||
@* <select class="form-select" @bind="SelectedDestinationId"> *@
|
|
||||||
@* *@
|
|
||||||
@* <option value="null">Select destination to configure</option> *@
|
|
||||||
@* @foreach (var destination in Destinations) *@
|
|
||||||
@* { *@
|
|
||||||
@* <option value="@destination.Key">@destination.Key</option> *@
|
|
||||||
@* } *@
|
|
||||||
@* </select> *@
|
|
||||||
@* </div> *@
|
|
||||||
@* *@
|
|
||||||
@* @if (SelectedDestinationId is not null && SelectedDestinationId != "null") *@
|
|
||||||
@* { *@
|
|
||||||
@* <PrismDestinationEditor ValidateId="ValidateId" Id="@SelectedDestinationId" IdChanged="OnIdRenamed" ValidateDestination="s => ValidateDestination(s, false)" @bind-Settings="SelectedDestination"></PrismDestinationEditor> *@
|
|
||||||
@* } *@
|
|
||||||
@* } *@
|
|
||||||
@* *@
|
|
||||||
@* @code { *@
|
|
||||||
@* *@
|
|
||||||
@* [Parameter] *@
|
|
||||||
@* public Dictionary<string, PrismDestination> Destinations { get; set; } *@
|
|
||||||
@* *@
|
|
||||||
@* *@
|
|
||||||
@* public string? SelectedDestinationId { get; set; } *@
|
|
||||||
@* *@
|
|
||||||
@* public PrismDestination? SelectedDestination *@
|
|
||||||
@* { *@
|
|
||||||
@* get *@
|
|
||||||
@* { *@
|
|
||||||
@* if (SelectedDestinationId is null or "null") *@
|
|
||||||
@* return null; *@
|
|
||||||
@* Destinations.TryGetValue(SelectedDestinationId, out var res); *@
|
|
||||||
@* return res; *@
|
|
||||||
@* } *@
|
|
||||||
@* set *@
|
|
||||||
@* { *@
|
|
||||||
@* if (SelectedDestinationId is null) *@
|
|
||||||
@* return; *@
|
|
||||||
@* if (value is null) *@
|
|
||||||
@* { *@
|
|
||||||
@* Destinations.Remove(SelectedDestinationId); *@
|
|
||||||
@* SelectedDestinationId = null; *@
|
|
||||||
@* } *@
|
|
||||||
@* else *@
|
|
||||||
@* { *@
|
|
||||||
@* Destinations.AddOrReplace(SelectedDestinationId, value); *@
|
|
||||||
@* } *@
|
|
||||||
@* } *@
|
|
||||||
@* } *@
|
|
||||||
@* *@
|
|
||||||
@* } *@
|
|
||||||
@@ -66,7 +66,15 @@ else
|
|||||||
|
|
||||||
<EditForm EditContext="EditContext" OnValidSubmit="Save">
|
<EditForm EditContext="EditContext" OnValidSubmit="Save">
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
|
|
||||||
|
<div class="row" id="prism-holder">
|
||||||
|
|
||||||
|
<div class="prism col-sm-12 border border-light p-2">
|
||||||
|
@if (SelectedDestinationId is null or "null")
|
||||||
|
{
|
||||||
|
<h2>Global Prism Settings</h2>
|
||||||
|
<div class="row mb-4">
|
||||||
<div class="col-xl-10 col-xxl-constrain">
|
<div class="col-xl-10 col-xxl-constrain">
|
||||||
|
|
||||||
<div class="form-group form-check">
|
<div class="form-group form-check">
|
||||||
@@ -91,31 +99,38 @@ else
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row" id="prism-holder">
|
@if(Settings.Splits.Any())
|
||||||
|
{
|
||||||
<div class="prism col-sm-12 col-md-8 border border-light p-2">
|
<h2>Your Prisms</h2>
|
||||||
@foreach (var item in Settings.Splits)
|
@foreach (var item in Settings.Splits)
|
||||||
{
|
{
|
||||||
<PrismSplit Split="@item" OnRequestRemove="@RemovePrism"/>
|
<PrismSplit Split="@item" OnRequestRemove="@RemovePrism"/>
|
||||||
}
|
}
|
||||||
</div>
|
|
||||||
<div class="prism col-sm-12 col-md-4 border border-light p-2">
|
|
||||||
@if (Destinations.Any())
|
|
||||||
{
|
|
||||||
<div class="form-group">
|
|
||||||
<select class="form-select" @bind="SelectedDestinationId">
|
|
||||||
|
|
||||||
<option value="null">Select destination to configure</option>
|
|
||||||
@foreach (var destination in Destinations)
|
|
||||||
{
|
|
||||||
<option value="@destination">@destination</option>
|
|
||||||
}
|
}
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
@if (SelectedDestinationId is not null && SelectedDestinationId != "null")
|
@if (SelectedDestinationId is not null && SelectedDestinationId != "null")
|
||||||
{
|
{
|
||||||
<PrismDestinationEditor ValidateId="ValidateId" Id="@SelectedDestinationId" IdChanged="OnIdRenamed" ValidateDestination="s => ValidateDestination(s, false)" @bind-Settings="SelectedDestination"></PrismDestinationEditor>
|
switch (SelectedDestinationId)
|
||||||
|
{
|
||||||
|
case "":
|
||||||
|
<h2>Create new Destination</h2>
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
<h2>Editing @SelectedDestinationId Destination</h2>
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
<PrismDestinationEditor
|
||||||
|
ValidateId="ValidateId"
|
||||||
|
ValidateDestination="s => ValidateDestination(s, false)"
|
||||||
|
Id="@SelectedDestinationId"
|
||||||
|
IdChanged="OnIdRenamed"
|
||||||
|
@bind-Settings="SelectedDestination"
|
||||||
|
OnCancel="o => SelectedDestinationId = null">
|
||||||
|
</PrismDestinationEditor>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -130,12 +145,25 @@ else
|
|||||||
}
|
}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
|
@if (SelectedDestinationId is null or "null")
|
||||||
|
{
|
||||||
|
|
||||||
<button type="button" class="btn btn-primary mx-2" id="add-prism" @onclick="CreateNewPrism">Add Prism</button>
|
<button type="button" class="btn btn-primary mx-2" id="add-prism" @onclick="CreateNewPrism">Add Prism</button>
|
||||||
<button type="button" class="btn btn-primary mx-2" id="add-destination" @onclick="AddDestination">Add Destination</button>
|
|
||||||
<button type="submit" class="btn btn-primary mx-2">Save</button>
|
<button type="submit" class="btn btn-primary mx-2">Save</button>
|
||||||
|
<select class="form-select mx-2" style="max-width: fit-content" @bind="SelectedDestinationId" disabled="@(SelectedDestinationId is not null && SelectedDestinationId != "null")">
|
||||||
|
|
||||||
|
<option value="null">Select destination to configure</option>
|
||||||
|
@foreach (var destination in Destinations)
|
||||||
|
{
|
||||||
|
<option value="@destination">@destination</option>
|
||||||
|
}
|
||||||
|
<option value="">Create new destination</option>
|
||||||
|
</select>
|
||||||
|
}
|
||||||
|
|
||||||
@if (PrismEditButtonsFilter is not null)
|
@if (PrismEditButtonsFilter is not null)
|
||||||
{
|
{
|
||||||
@((MarkupString)PrismEditButtonsFilter)
|
@((MarkupString) PrismEditButtonsFilter)
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -151,7 +179,7 @@ else
|
|||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string? SelectedDestinationId { get; set; }
|
public string? SelectedDestinationId { get; set; } = "null";
|
||||||
|
|
||||||
public PrismDestination? SelectedDestination
|
public PrismDestination? SelectedDestination
|
||||||
{
|
{
|
||||||
@@ -169,12 +197,23 @@ else
|
|||||||
if (value is null)
|
if (value is null)
|
||||||
{
|
{
|
||||||
Settings.Destinations.Remove(SelectedDestinationId);
|
Settings.Destinations.Remove(SelectedDestinationId);
|
||||||
|
|
||||||
|
foreach (var settingsSplit in Settings.Splits)
|
||||||
|
{
|
||||||
|
settingsSplit.Destinations.RemoveAll(split => split.Destination == SelectedDestinationId);
|
||||||
|
}
|
||||||
|
|
||||||
SelectedDestinationId = null;
|
SelectedDestinationId = null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Settings.Destinations.AddOrReplace(SelectedDestinationId, value);
|
Settings.Destinations.AddOrReplace(SelectedDestinationId, value);
|
||||||
|
|
||||||
|
SelectedDestinationId = "null";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_ = SaveDestinations();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,6 +225,7 @@ else
|
|||||||
public bool NoPayoutProcessors { get; set; }
|
public bool NoPayoutProcessors { get; set; }
|
||||||
|
|
||||||
private string PrismEditButtonsFilter { get; set; }
|
private string PrismEditButtonsFilter { get; set; }
|
||||||
|
|
||||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
{
|
{
|
||||||
if (firstRender)
|
if (firstRender)
|
||||||
@@ -347,6 +387,13 @@ else
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task SaveDestinations()
|
||||||
|
{
|
||||||
|
var settz = await SatBreaker.Get(StoreId);
|
||||||
|
settz.Destinations = Settings.Destinations;
|
||||||
|
await UpdateAndShowResult(settz);
|
||||||
|
}
|
||||||
|
|
||||||
private async Task Save()
|
private async Task Save()
|
||||||
{
|
{
|
||||||
var settz = await SatBreaker.Get(StoreId);
|
var settz = await SatBreaker.Get(StoreId);
|
||||||
@@ -356,6 +403,11 @@ else
|
|||||||
settz.SatThreshold = Settings.SatThreshold;
|
settz.SatThreshold = Settings.SatThreshold;
|
||||||
settz.Reserve = Settings.Reserve;
|
settz.Reserve = Settings.Reserve;
|
||||||
Settings = settz;
|
Settings = settz;
|
||||||
|
await UpdateAndShowResult(settz);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task UpdateAndShowResult(PrismSettings settz)
|
||||||
|
{
|
||||||
var updateResult = await SatBreaker.UpdatePrismSettingsForStore(StoreId, settz);
|
var updateResult = await SatBreaker.UpdatePrismSettingsForStore(StoreId, settz);
|
||||||
|
|
||||||
if (!updateResult)
|
if (!updateResult)
|
||||||
@@ -404,8 +456,13 @@ else
|
|||||||
|
|
||||||
private async Task OnIdRenamed(string s)
|
private async Task OnIdRenamed(string s)
|
||||||
{
|
{
|
||||||
if(SelectedDestinationId == s)
|
if (SelectedDestinationId == s)
|
||||||
return;
|
return;
|
||||||
|
if (string.IsNullOrEmpty(SelectedDestinationId))
|
||||||
|
{
|
||||||
|
SelectedDestinationId = s;
|
||||||
|
return;
|
||||||
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await SatBreaker._updateLock.WaitAsync();
|
await SatBreaker._updateLock.WaitAsync();
|
||||||
@@ -423,7 +480,7 @@ else
|
|||||||
{
|
{
|
||||||
Settings.DestinationBalance.Add(s, db);
|
Settings.DestinationBalance.Add(s, db);
|
||||||
}
|
}
|
||||||
if(Settings.Destinations.Remove(SelectedDestinationId, out var dest))
|
if (Settings.Destinations.Remove(SelectedDestinationId, out var dest))
|
||||||
{
|
{
|
||||||
Settings.Destinations.Add(s, dest);
|
Settings.Destinations.Add(s, dest);
|
||||||
}
|
}
|
||||||
@@ -451,11 +508,11 @@ else
|
|||||||
Settings.DestinationBalance.AddOrReplace(obj.destination, obj.newBalance);
|
Settings.DestinationBalance.AddOrReplace(obj.destination, obj.newBalance);
|
||||||
}
|
}
|
||||||
await SatBreaker.UpdatePrismSettingsForStore(StoreId, Settings, true);
|
await SatBreaker.UpdatePrismSettingsForStore(StoreId, Settings, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
SatBreaker._updateLock.Release();
|
SatBreaker._updateLock.Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -313,7 +313,7 @@ namespace BTCPayServer.Plugins.Prism
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var onChainCatchAllIdentifier = "*"+ PaymentTypes.BTCLike.ToStringNormalized();
|
var onChainCatchAllIdentifier = "*"+ PaymentTypes.BTCLike.ToStringNormalized();
|
||||||
var catchAllPrism = prismSettings.Splits.FirstOrDefault(split => split.Source == "*" || split.Source ==onChainCatchAllIdentifier);
|
var catchAllPrism = prismSettings.Splits.FirstOrDefault(split => split.Source == "*" || split.Source ==onChainCatchAllIdentifier);
|
||||||
Split prism = null;
|
Split prism = null;
|
||||||
LightningAddressData address = null;
|
LightningAddressData address = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user