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
7 files changed
+66 -26

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,23 +1,34 @@
@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">
<RadzenProgressBar Value="100" ShowValue="false" Mode="ProgressBarMode.Indeterminate" <RadzenDropDown @bind-Value=@CurrentRealmType
Visible="@ComponentBusy" Data=@Realms
Style="width: 100%; margin-top: 10px;" /> ValueProperty="RealmType"
<RadzenListBox Style="width: 87px">
@bind-Value=@CurrentValue <Template>
Data=@FilteredList <img src="@(((RealmSelector) context).RealmImage)" style="height: 27px"/>
ValueProperty="ItemId" </Template>
Style="height:335px; width: 100%; margin-top: 10px;" </RadzenDropDown>
Visible="@(!ComponentBusy)"> </div>
<Template> <div class="col-md-8">
<!--ToDo: Create new component that will show nick[clan] {WinRate with color}, {battles count with translatable word "battles"}. And another component for Clans--> <RadzenTextBox Placeholder=@($"{Localizer["Search"]}...") Change=@OnSearchTextChange Disabled="@ComponentBusy" Style="width: 150px;"/>
@(((SearchItem) context).ItemName) | accountId: @(((SearchItem) context).ItemId) </div>
</Template> </div>
</RadzenListBox> <RadzenProgressBar Value="100" ShowValue="false" Mode="ProgressBarMode.Indeterminate"
<RadzenButton Visible="@ComponentBusy"
Click=@(args => OnOkButtonClick()) Style="width: 100%; margin-top: 10px;" />
Text="Ok" <RadzenListBox @bind-Value=@CurrentValue
Visible="@(!ComponentBusy)" Data=@FilteredList
Style="margin: 10px auto 10px auto; display: block; width: 150px; " /> ValueProperty="ItemId"
Style="height:335px; width: 100%; margin-top: 10px;"
Visible="@(!ComponentBusy)">
<Template>
<!--ToDo: Create new component that will show nick[clan] {WinRate with color}, {battles count with translatable word "battles"}. And another component for Clans-->
@(((SearchItem) context).ItemName) | accountId: @(((SearchItem) context).ItemId)
</Template>
</RadzenListBox>
<RadzenButton Click=@(args => OnOkButtonClick())
Text="Ok"
Visible="@(!ComponentBusy)"
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)
+2 -2
View File
@@ -40,11 +40,11 @@ namespace WotBlitzStatisticsPro.Blazor
//var useMock = Environment.GetEnvironmentVariable("USE_GRAPH_QL_MOCK"); //var useMock = Environment.GetEnvironmentVariable("USE_GRAPH_QL_MOCK");
//if (useMock != null && useMock == "true") //if (useMock != null && useMock == "true")
//{ //{
builder.Services.AddTransient<IGraphQlBackendService, GraphQlBackendMockService>(); builder.Services.AddTransient<IGraphQlBackendService, GraphQlBackendMockService>();
//} //}
//else //else
//{ //{
// builder.Services.AddTransient<IGraphQlBackendService, GraphQlBackendService>(); //builder.Services.AddTransient<IGraphQlBackendService, GraphQlBackendService>();
//} //}
var host = builder.Build(); var host = builder.Build();
@@ -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,