mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 01:43:50 +01:00
Fx pos data additional info (#6172)
* Resolve Additional Information from posData * code formatting * Minor adjustments * Update ChromeDriver * Revert and improve PosData partial --------- Co-authored-by: Dennis Reimann <mail@dennisreimann.de> Co-authored-by: Nicolas Dorier <nicolas.dorier@gmail.com>
This commit is contained in:
parent
a60c55c6df
commit
f59751853a
@ -1,14 +1,6 @@
|
||||
@using Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@model (Dictionary<string, object> Items, int Level)
|
||||
|
||||
@functions {
|
||||
private bool IsValidURL(string source)
|
||||
{
|
||||
return Uri.TryCreate(source, UriKind.Absolute, out var uriResult) &&
|
||||
(uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);
|
||||
}
|
||||
}
|
||||
|
||||
@if (Model.Items.Any())
|
||||
{
|
||||
@* Use titlecase and lowercase versions for backwards-compatibility *@
|
||||
@ -27,8 +19,7 @@
|
||||
@foreach (var (key, value) in cartDict)
|
||||
{
|
||||
<tr>
|
||||
<th>@key</th>
|
||||
<td class="text-end">@value</td>
|
||||
<partial name="PosDataEntry" model="(key, value, Model.Level)"/>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
@ -39,7 +30,7 @@
|
||||
@foreach (var value in cartCollection)
|
||||
{
|
||||
<tr>
|
||||
<td>@value</td>
|
||||
<partial name="PosDataEntry" model="(string.Empty, value, Model.Level)"/>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
@ -80,52 +71,7 @@
|
||||
foreach (var (key, value) in Model.Items)
|
||||
{
|
||||
<tr>
|
||||
@if (value is string str)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(key))
|
||||
{
|
||||
<th>@key</th>
|
||||
}
|
||||
<td style="white-space:pre-wrap">@* Explicitely remove whitespace at front here *@@if (IsValidURL(str)){<a href="@str" target="_blank" rel="noreferrer noopener">@str</a>}else {@str.Trim()}</td>
|
||||
}
|
||||
else if (value is Dictionary<string, object> { Count: > 0 } subItems)
|
||||
{
|
||||
<td colspan="2">
|
||||
@{
|
||||
@if (!string.IsNullOrEmpty(key))
|
||||
{
|
||||
Write(Html.Raw($"<h{Model.Level + 3} class=\"mb-3 fw-semibold\">"));
|
||||
Write(key);
|
||||
Write(Html.Raw($"</h{Model.Level + 3}>"));
|
||||
}
|
||||
}
|
||||
<partial name="PosData" model="@((subItems, Model.Level + 1))" />
|
||||
</td>
|
||||
}
|
||||
else if (value is IEnumerable<object> valueArray)
|
||||
{
|
||||
<td colspan="2">
|
||||
@{
|
||||
@if (!string.IsNullOrEmpty(key))
|
||||
{
|
||||
Write(Html.Raw($"<h{Model.Level + 3} class=\"mb-3 fw-semibold\">"));
|
||||
Write(key);
|
||||
Write(Html.Raw($"</h{Model.Level + 3}>"));
|
||||
}
|
||||
}
|
||||
@foreach (var item in valueArray)
|
||||
{
|
||||
@if (item is Dictionary<string, object> { Count: > 0 } subItems2)
|
||||
{
|
||||
<partial name="PosData" model="@((subItems2, Model.Level + 1))" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<partial name="PosData" model="@((new Dictionary<string, object> { { "", item } }, Model.Level + 1))" />
|
||||
}
|
||||
}
|
||||
</td>
|
||||
}
|
||||
<partial name="PosDataEntry" model="(key, value, Model.Level)"/>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
|
56
BTCPayServer/Views/Shared/PosDataEntry.cshtml
Normal file
56
BTCPayServer/Views/Shared/PosDataEntry.cshtml
Normal file
@ -0,0 +1,56 @@
|
||||
@model (string Key, object Value, int Level)
|
||||
|
||||
@functions {
|
||||
private bool IsValidURL(string source)
|
||||
{
|
||||
return Uri.TryCreate(source, UriKind.Absolute, out var uriResult) &&
|
||||
(uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);
|
||||
}
|
||||
}
|
||||
|
||||
@if (Model.Value is string str)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Model.Key))
|
||||
{
|
||||
<th>@Model.Key</th>
|
||||
}
|
||||
<td style="white-space:pre-wrap" class="@(string.IsNullOrEmpty(Model.Key) ? null : "text-end")">@* Explicitely remove whitespace at front here *@@if (IsValidURL(str)){<a href="@str" target="_blank" rel="noreferrer noopener">@str</a>}else {@str.Trim()}</td>
|
||||
}
|
||||
else if (Model.Value is Dictionary<string, object> { Count: > 0 } subItems)
|
||||
{
|
||||
<td colspan="2">
|
||||
@{
|
||||
@if (!string.IsNullOrEmpty(Model.Key))
|
||||
{
|
||||
Write(Html.Raw($"<h{Model.Level + 3} class=\"mb-3 fw-semibold\">"));
|
||||
Write(Model.Key);
|
||||
Write(Html.Raw($"</h{Model.Level + 3}>"));
|
||||
}
|
||||
}
|
||||
<partial name="PosData" model="@((subItems, Model.Level + 1))" />
|
||||
</td>
|
||||
}
|
||||
else if (Model.Value is IEnumerable<object> valueArray)
|
||||
{
|
||||
<td colspan="2">
|
||||
@{
|
||||
@if (!string.IsNullOrEmpty(Model.Key))
|
||||
{
|
||||
Write(Html.Raw($"<h{Model.Level + 3} class=\"mb-3 fw-semibold\">"));
|
||||
Write(Model.Key);
|
||||
Write(Html.Raw($"</h{Model.Level + 3}>"));
|
||||
}
|
||||
}
|
||||
@foreach (var item in valueArray)
|
||||
{
|
||||
@if (item is Dictionary<string, object> { Count: > 0 } subItems2)
|
||||
{
|
||||
<partial name="PosData" model="@((subItems2, Model.Level + 1))" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<partial name="PosData" model="@((new Dictionary<string, object> { { "", item } }, Model.Level + 1))" />
|
||||
}
|
||||
}
|
||||
</td>
|
||||
}
|
Loading…
Reference in New Issue
Block a user