/
EditLightningAddress.cshtml
161 lines (150 loc) · 8.04 KB
/
EditLightningAddress.cshtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
@using BTCPayServer.Views.Stores
@using BTCPayServer.Abstractions.Extensions
@using BTCPayServer.Abstractions.Models
@model UILNURLController.EditLightningAddressVM
@{
ViewData.SetActivePage("LightningAddress", nameof(StoreNavPages), "Lightning Address", Context.GetStoreData().Id);
}
@section PageHeadContent {
<style>
.settings-holder span:not(:last-child):after{
content: " / ";
}
</style>
}
@section PageFootContent {
<script>
delegate('click', '.remove', event => {
event.preventDefault()
const { name, value } = event.target
const confirmButton = document.getElementById('ConfirmContinue')
confirmButton.setAttribute('name', name)
confirmButton.setAttribute('value', value)
})
</script>
}
<partial name="_StatusMessage" />
@if (Context.Request.PathBase.ToString() != string.Empty)
{
<div class="alert alert-warning" role="alert">
Your BTCPay Server installation is using the root path <span class="fw-bold">@Context.Request.PathBase</span>.<br /><br />
This is incompatible with wallets attempting to resolve <span class="fw-bold">@Context.Request.GetAbsoluteUriNoPathBase(new Uri("/.well-known/lnurlp/{username}", UriKind.Relative))</span> rather than <span class="fw-bold">@Context.Request.GetAbsoluteUri("/.well-known/lnurlp/{username}")</span>.<br /><br />
If the LN Address doesn't work, ask your integrator to redirect queries from <span class="fw-bold">@Context.Request.GetAbsoluteUriNoPathBase(new Uri("/.well-known/lnurlp/{username}", UriKind.Relative))</span> to <span class="fw-bold">@Context.Request.GetAbsoluteUri("/.well-known/lnurlp/{username}")</span>.
</div>
}
<div class="d-flex align-items-center justify-content-between mb-2">
<h2 class="mb-0">@ViewData["Title"]</h2>
<a data-bs-toggle="collapse" data-bs-target="#AddAddress" class="btn btn-primary" role="button">
<span class="fa fa-plus"></span>
Add Address
</a>
</div>
<form asp-action="EditLightningAddress" method="post">
@{
var showAddForm = !ViewContext.ViewData.ModelState.IsValid || !string.IsNullOrEmpty(Model.Add?.Username) || Model.Add?.Max != null || Model.Add?.Min != null || !string.IsNullOrEmpty(Model.Add?.CurrencyCode);
var showAdvancedOptions = !string.IsNullOrEmpty(Model.Add?.CurrencyCode) || Model.Add?.Min != null || Model.Add?.Max != null;
}
<div class="collapse @(showAddForm ? "show": "")" id="AddAddress">
<div class="form-group pt-2">
<label asp-for="Add.Username" class="form-label"></label>
<div class="input-group">
<input asp-for="Add.Username" class="form-control"/>
<span class="input-group-text">@@@Context.Request.Host.ToUriComponent()@Context.Request.PathBase</span>
</div>
<span asp-validation-for="Add.Username" class="text-danger"></span>
</div>
<button class="d-inline-flex align-items-center btn btn-link text-primary fw-semibold p-0 mb-3" type="button" id="AdvancedSettingsButton" data-bs-toggle="collapse" data-bs-target="#AdvancedSettings" aria-expanded="false" aria-controls="AdvancedSettings">
<vc:icon symbol="caret-down"/>
<span class="ms-1">Advanced settings</span>
</button>
<div id="AdvancedSettings" class="collapse @(showAdvancedOptions ? "show" : "")">
<div class="row">
<div class="col-12 col-sm-auto">
<div class="form-group">
<label asp-for="Add.CurrencyCode" class="form-label"></label>
<input asp-for="Add.CurrencyCode" class="form-control w-auto" currency-selection style="max-width:16ch;"/>
<span asp-validation-for="Add.CurrencyCode" class="text-danger"></span>
</div>
</div>
<div class="col-12 col-sm-auto">
<div class="form-group">
<label asp-for="Add.Min" class="form-label"></label>
<input asp-for="Add.Min" class="form-control" type="number" inputmode="numeric" min="1" style="max-width:16ch;"/>
<span asp-validation-for="Add.Min" class="text-danger"></span>
</div>
</div>
<div class="col-12 col-sm-auto">
<div class="form-group">
<label asp-for="Add.Max" class="form-label"></label>
<input asp-for="Add.Max" class="form-control" type="number" inputmode="numeric" min="1" max="@int.MaxValue" style="max-width:16ch;"/>
<span asp-validation-for="Add.Max" class="text-danger"></span>
</div>
</div>
</div>
</div>
<div class="form-group">
<button type="submit" name="command" value="add" class="btn btn-primary">Save</button>
</div>
</div>
@if (Model.Items.Any())
{
<div class="row">
<div class="col">
<table class="table table-hover">
<thead>
<tr>
<th>Address</th>
<th>Settings</th>
<th class="text-end">Actions</th>
</tr>
</thead>
<tbody>
@for (var index = 0; index < Model.Items.Count; index++)
{
<input asp-for="Items[index].CurrencyCode" type="hidden"/>
<input asp-for="Items[index].Min" type="hidden"/>
<input asp-for="Items[index].Max" type="hidden"/>
<input asp-for="Items[index].Username" type="hidden"/>
var address = $"{Model.Items[index].Username}@{Context.Request.Host.ToUriComponent()}";
<tr>
<td>
<div class="input-group" data-clipboard="@address">
<input type="text" class="form-control copy-cursor lightning-address-value" readonly="readonly" value="@address"/>
<button type="button" class="btn btn-outline-secondary" data-clipboard-confirm>Copy</button>
</div>
</td>
<td class="settings-holder align-middle">
@if (Model.Items[index].Min.HasValue)
{
<span>@Model.Items[index].Min min sats</span>
}
@if (Model.Items[index].Max.HasValue)
{
<span>@Model.Items[index].Max max sats</span>
}
@if (!string.IsNullOrEmpty(Model.Items[index].CurrencyCode))
{
<span>tracked in @Model.Items[index].CurrencyCode</span>
}
</td>
<td class="text-end">
<button type="submit" title="Remove" name="command" value="@($"remove:{Model.Items[index].Username}")"
class="btn btn-link px-0 remove" data-bs-toggle="modal" data-bs-target="#ConfirmModal" data-description="The Lightning Address <strong>@Html.Encode(address)</strong> will be removed." data-confirm-input="REMOVE">
Remove
</button>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
}
else
{
<p class="text-secondary mt-3">
There are no Lightning Addresses yet.
</p>
}
</form>
<partial name="_Confirm" model="@(new ConfirmModel("Remove Lightning Address", "This Lightning Address will be removed.", "Remove"))" />