Compare commits
1 Commits
pluginify-
...
fix-array-
Author | SHA1 | Date | |
---|---|---|---|
|
8290a1606f |
@@ -1301,11 +1301,21 @@ namespace BTCPayServer.Controllers
|
|||||||
{
|
{
|
||||||
case JTokenType.Array:
|
case JTokenType.Array:
|
||||||
var items = item.Value.AsEnumerable().ToList();
|
var items = item.Value.AsEnumerable().ToList();
|
||||||
|
var arrayResult = new List<object>();
|
||||||
for (var i = 0; i < items.Count; i++)
|
for (var i = 0; i < items.Count; i++)
|
||||||
{
|
{
|
||||||
result.TryAdd($"{item.Key}[{i}]", ParsePosData(items[i]));
|
if (items[i] is JObject)
|
||||||
|
{
|
||||||
|
arrayResult.Add( ParsePosData(items[i]));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
arrayResult.Add( items[i].ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result.TryAdd(item.Key, arrayResult);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case JTokenType.Object:
|
case JTokenType.Object:
|
||||||
result.TryAdd(item.Key, ParsePosData(item.Value));
|
result.TryAdd(item.Key, ParsePosData(item.Value));
|
||||||
|
@@ -1,47 +1,77 @@
|
|||||||
@model (Dictionary<string, object> Items, int Level)
|
@model (Dictionary<string, object> Items, int Level)
|
||||||
|
|
||||||
@functions {
|
@functions {
|
||||||
|
|
||||||
private bool IsValidURL(string source)
|
private bool IsValidURL(string source)
|
||||||
{
|
{
|
||||||
return Uri.TryCreate(source, UriKind.Absolute, out var uriResult) &&
|
return Uri.TryCreate(source, UriKind.Absolute, out var uriResult) &&
|
||||||
(uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);
|
(uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (Model.Items.Count > 0)
|
@if (Model.Items.Count > 0)
|
||||||
{
|
{
|
||||||
<table class="table my-0" v-pre>
|
<table class="table my-0" v-pre>
|
||||||
@foreach (var (key, value) in Model.Items)
|
@foreach (var (key, value) in Model.Items)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
@if (value is string str)
|
@if (value is string str)
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(key))
|
|
||||||
{
|
{
|
||||||
<th class="w-150px">@key</th>
|
if (!string.IsNullOrEmpty(key))
|
||||||
|
{
|
||||||
|
<th class="w-150px">@key</th>
|
||||||
|
}
|
||||||
|
<td>
|
||||||
|
@if (IsValidURL(str))
|
||||||
|
{
|
||||||
|
<a href="@str" target="_blank" rel="noreferrer noopener">@str</a>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@value?.ToString()
|
||||||
|
}
|
||||||
|
</td>
|
||||||
}
|
}
|
||||||
<td>
|
else if (value is Dictionary<string, object> {Count: > 0 } subItems)
|
||||||
@if (IsValidURL(str))
|
{
|
||||||
{
|
<td colspan="2">
|
||||||
<a href="@str" target="_blank" rel="noreferrer noopener">@str</a>
|
@{
|
||||||
}
|
@if (!string.IsNullOrEmpty(key))
|
||||||
else
|
{
|
||||||
{
|
Write(Html.Raw($"<h{Model.Level + 3} class=\"mt-4 mb-3\">"));
|
||||||
@value?.ToString()
|
Write(key);
|
||||||
}
|
Write(Html.Raw($"</h{Model.Level + 3}>"));
|
||||||
</td>
|
}
|
||||||
}
|
}
|
||||||
else if (value is Dictionary<string, object> {Count: > 0 } subItems)
|
<partial name="PosData" model="@((subItems, Model.Level + 1))" />
|
||||||
{
|
</td>
|
||||||
<td colspan="2" >
|
}
|
||||||
@{
|
else if (value is IEnumerable<object> valueArray)
|
||||||
Write(Html.Raw($"<h{Model.Level + 3} class=\"mt-4 mb-3\">"));
|
{
|
||||||
Write(key);
|
<td colspan="2">
|
||||||
Write(Html.Raw($"</h{Model.Level + 3}>"));
|
@{
|
||||||
}
|
@if (!string.IsNullOrEmpty(key))
|
||||||
<partial name="PosData" model="@((subItems, Model.Level + 1))"/>
|
{
|
||||||
</td>
|
Write(Html.Raw($"<h{Model.Level + 3} class=\"mt-4 mb-3\">"));
|
||||||
}
|
Write(key);
|
||||||
</tr>
|
Write(Html.Raw($"</h{Model.Level + 3}>"));
|
||||||
}
|
}
|
||||||
</table>
|
}
|
||||||
|
@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>
|
||||||
|
}
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</table>
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user