2022-08-19 20:46:45 -05:00
|
|
|
using Microsoft.JSInterop;
|
|
|
|
using Microsoft.AspNetCore.Components;
|
2022-08-26 13:13:40 -05:00
|
|
|
using NftFaucetRadzen.Components;
|
2022-08-19 20:46:45 -05:00
|
|
|
using NftFaucetRadzen.Models;
|
2022-08-27 12:37:49 -05:00
|
|
|
using NftFaucetRadzen.Plugins.NetworkPlugins;
|
2022-08-19 20:46:45 -05:00
|
|
|
using Radzen;
|
|
|
|
|
2022-08-26 13:13:40 -05:00
|
|
|
namespace NftFaucetRadzen.Pages;
|
|
|
|
|
2022-08-26 17:39:23 -05:00
|
|
|
public partial class NetworkPage : BasicComponent
|
2022-08-19 20:46:45 -05:00
|
|
|
{
|
2022-08-26 13:13:40 -05:00
|
|
|
[Inject]
|
|
|
|
protected IJSRuntime JSRuntime { get; set; }
|
2022-08-19 20:46:45 -05:00
|
|
|
|
2022-08-26 13:13:40 -05:00
|
|
|
[Inject]
|
|
|
|
protected DialogService DialogService { get; set; }
|
2022-08-19 20:46:45 -05:00
|
|
|
|
2022-08-26 13:13:40 -05:00
|
|
|
[Inject]
|
|
|
|
protected TooltipService TooltipService { get; set; }
|
2022-08-19 20:46:45 -05:00
|
|
|
|
2022-08-26 13:13:40 -05:00
|
|
|
[Inject]
|
|
|
|
protected ContextMenuService ContextMenuService { get; set; }
|
2022-08-19 20:46:45 -05:00
|
|
|
|
2022-08-26 13:13:40 -05:00
|
|
|
[Inject]
|
|
|
|
protected NotificationService NotificationService { get; set; }
|
2022-08-19 20:46:45 -05:00
|
|
|
|
2022-08-26 13:13:40 -05:00
|
|
|
protected override void OnInitialized()
|
|
|
|
{
|
2022-08-27 17:22:50 -05:00
|
|
|
Networks = AppState.Storage.Networks
|
2022-08-27 18:05:07 -05:00
|
|
|
.GroupBy(x => x.SubType)
|
2022-08-27 17:22:50 -05:00
|
|
|
.ToDictionary(x => x.Key, x => x.OrderBy(v => v.Order ?? int.MaxValue).Select(MapCardListItem).ToArray());
|
2022-08-26 13:13:40 -05:00
|
|
|
}
|
2022-08-19 20:46:45 -05:00
|
|
|
|
2022-08-27 18:05:07 -05:00
|
|
|
private Dictionary<NetworkSubtype, CardListItem[]> Networks { get; set; }
|
2022-08-20 21:10:54 -05:00
|
|
|
|
2022-08-27 12:37:49 -05:00
|
|
|
private static CardListItem MapCardListItem(INetwork model)
|
2022-08-26 13:13:40 -05:00
|
|
|
=> new CardListItem
|
2022-08-20 21:10:54 -05:00
|
|
|
{
|
2022-08-26 17:48:40 -05:00
|
|
|
Id = model.Id,
|
2022-08-26 13:13:40 -05:00
|
|
|
ImageName = model.ImageName,
|
|
|
|
Header = model.Name,
|
|
|
|
IsDisabled = !model.IsSupported,
|
|
|
|
Properties = new[]
|
2022-08-25 20:28:24 -05:00
|
|
|
{
|
2022-08-26 13:13:40 -05:00
|
|
|
new CardListItemProperty { Name = "ChainID", Value = model.ChainId?.ToString() },
|
|
|
|
new CardListItemProperty { Name = "Currency", Value = model.Currency },
|
|
|
|
},
|
|
|
|
Badges = new[]
|
|
|
|
{
|
|
|
|
!model.IsSupported ? new CardListItemBadge { Style = BadgeStyle.Light, Text = "Not Supported" } : null,
|
|
|
|
!model.IsTestnet ? new CardListItemBadge { Style = BadgeStyle.Danger, Text = "Mainnet" } : null,
|
|
|
|
model.IsDeprecated ? new CardListItemBadge { Style = BadgeStyle.Warning, Text = "Deprecated" } : null,
|
|
|
|
}.Where(x => x != null).ToArray(),
|
|
|
|
};
|
2022-08-19 20:46:45 -05:00
|
|
|
}
|