feat: realm added. Plus clans bug fixed

This commit is contained in:
Mikhail Shabanov committed 2021-05-15 22:23:49 +02:00
1 parent 68faee2d23
commit 3c67595d94
6 files changed
+49 -9

No files matched your search

@@ -0,0 +1,7 @@
using WotBlitzStatisticsPro.Blazor.GraphQl;
namespace WotBlitzStatisticsPro.Blazor.Model
{
public record RealmSelector(RealmType RealmType, string RealmImage);
}
@@ -1,12 +1,24 @@
@using WotBlitzStatisticsPro.Blazor.Model @using WotBlitzStatisticsPro.Blazor.Model
@inherits SearchDialogTypeBase @inherits SearchDialogTypeBase
<!--Realm type selection--> <div class="row">
<RadzenTextBox Placeholder=@($"{Localizer["Search"]}...") Change=@OnSearchTextChange Disabled="@ComponentBusy" Style="width: 100%;" /> <div class="col-md-4">
<RadzenDropDown @bind-Value=@CurrentRealmType
Data=@Realms
ValueProperty="RealmType"
Style="width: 87px">
<Template>
<img src="@(((RealmSelector) context).RealmImage)" style="height: 27px"/>
</Template>
</RadzenDropDown>
</div>
<div class="col-md-8">
<RadzenTextBox Placeholder=@($"{Localizer["Search"]}...") Change=@OnSearchTextChange Disabled="@ComponentBusy" Style="width: 150px;"/>
</div>
</div>
<RadzenProgressBar Value="100" ShowValue="false" Mode="ProgressBarMode.Indeterminate" <RadzenProgressBar Value="100" ShowValue="false" Mode="ProgressBarMode.Indeterminate"
Visible="@ComponentBusy" Visible="@ComponentBusy"
Style="width: 100%; margin-top: 10px;" /> Style="width: 100%; margin-top: 10px;" />
<RadzenListBox <RadzenListBox @bind-Value=@CurrentValue
@bind-Value=@CurrentValue
Data=@FilteredList Data=@FilteredList
ValueProperty="ItemId" ValueProperty="ItemId"
Style="height:335px; width: 100%; margin-top: 10px;" Style="height:335px; width: 100%; margin-top: 10px;"
@@ -16,8 +28,7 @@
@(((SearchItem) context).ItemName) | accountId: @(((SearchItem) context).ItemId) @(((SearchItem) context).ItemName) | accountId: @(((SearchItem) context).ItemId)
</Template> </Template>
</RadzenListBox> </RadzenListBox>
<RadzenButton <RadzenButton Click=@(args => OnOkButtonClick())
Click=@(args => OnOkButtonClick())
Text="Ok" Text="Ok"
Visible="@(!ComponentBusy)" Visible="@(!ComponentBusy)"
Style="margin: 10px auto 10px auto; display: block; width: 150px; " /> Style="margin: 10px auto 10px auto; display: block; width: 150px; " />
@@ -32,12 +32,26 @@ namespace WotBlitzStatisticsPro.Blazor.Pages
public List<SearchItem> FilteredList { get; set; } = new(); public List<SearchItem> FilteredList { get; set; } = new();
public List<RealmSelector> Realms { get; set; }
public RealmType CurrentRealmType { get; set; } = RealmType.Eu; public RealmType CurrentRealmType { get; set; } = RealmType.Eu;
public long CurrentValue { get; set; } public long CurrentValue { get; set; }
public bool ComponentBusy { get; set; } = false; public bool ComponentBusy { get; set; } = false;
public SearchDialogTypeBase()
{
Realms = new List<RealmSelector>()
{
new(RealmType.Eu, "/realm/region.eu.scale-200.png"),
new(RealmType.Ru, "/realm/region.ru.scale-200.png"),
new(RealmType.Na, "/realm/region.na.scale-200.png"),
new(RealmType.Asia, "/realm/region.asia.scale-200.png"),
};
}
public async Task OnSearchTextChange(string value) public async Task OnSearchTextChange(string value)
{ {
if (DialogType == DialogType.FindPlayer && value.Length < 3) if (DialogType == DialogType.FindPlayer && value.Length < 3)
@@ -21,8 +21,8 @@ namespace WotBlitzStatisticsPro.Blazor.Services
{ {
result.Add(new FindPlayers_Players_AccountsSearchResponseItem( result.Add(new FindPlayers_Players_AccountsSearchResponseItem(
faker.Random.Long(100000, 999999), faker.Random.Long(100000, 999999),
faker.Name.LastName(), faker.Internet.UserName(),
faker.Lorem.Word().OrNull(faker, 0.8f), faker.Hacker.Abbreviation().OrNull(faker, 0.6f),
faker.Date.Past(), faker.Date.Past(),
faker.Random.Number(10, 20000), faker.Random.Number(10, 20000),
faker.Random.Number(30, 90))); faker.Random.Number(30, 90)));
@@ -30,7 +30,7 @@ namespace WotBlitzStatisticsPro.GraphQl.Query
/// <param name="realmType">Wargaming Realm.</param> /// <param name="realmType">Wargaming Realm.</param>
/// <param name="language">Language for the output data.</param> /// <param name="language">Language for the output data.</param>
/// <returns></returns> /// <returns></returns>
public Task<ICollection<AccountsSearchResponseItem>> Players( public Task<ICollection<AccountsSearchResponseItem>?> Players(
string accountNick, string accountNick,
RealmType? realmType, RealmType? realmType,
RequestLanguage? language) RequestLanguage? language)
@@ -163,6 +163,10 @@ namespace WotBlitzStatisticsPro.WgApiClient
public async Task<List<ClanAccountInfo>?> GetBulkPlayerClans(long[] accountIds, RealmType realmType = RealmType.Ru, public async Task<List<ClanAccountInfo>?> GetBulkPlayerClans(long[] accountIds, RealmType realmType = RealmType.Ru,
RequestLanguage language = RequestLanguage.En) RequestLanguage language = RequestLanguage.En)
{ {
if (accountIds.Length == 0)
{
return null;
}
var clanInfo = await GetFromBlitzApi<Dictionary<string, ClanAccountInfo>>( var clanInfo = await GetFromBlitzApi<Dictionary<string, ClanAccountInfo>>(
realmType, realmType,
language, language,
@@ -174,6 +178,10 @@ namespace WotBlitzStatisticsPro.WgApiClient
public async Task<List<ClanInfo>?> GetShortClansInfo(long[] clanIds, RealmType realmType = RealmType.Ru, public async Task<List<ClanInfo>?> GetShortClansInfo(long[] clanIds, RealmType realmType = RealmType.Ru,
RequestLanguage language = RequestLanguage.En) RequestLanguage language = RequestLanguage.En)
{ {
if (clanIds.Length == 0)
{
return null;
}
var clanInfo = await GetFromBlitzApi<Dictionary<string, ClanInfo>>( var clanInfo = await GetFromBlitzApi<Dictionary<string, ClanInfo>>(
realmType, realmType,
language, language,