mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-21 10:27:18 +02:00
chore: infrastructure code
This commit is contained in:
1 parent
44c89f2e5d
commit
14aae034af
7 files changed
+63
-3
No files matched your search
@@ -0,0 +1,12 @@
|
||||
using System.Text.Json;
|
||||
|
||||
namespace WotBlitzStatisticsPro.Blazor.Helpers
|
||||
{
|
||||
public static class Formatter
|
||||
{
|
||||
public static string Json<T>(this T data)
|
||||
{
|
||||
return JsonSerializer.Serialize(data, new JsonSerializerOptions { WriteIndented = true });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,13 @@
|
||||
@page "/player/{AccountId:long}"
|
||||
@using WotBlitzStatisticsPro.Blazor.Helpers
|
||||
@inherits PlayerInfoLayoutBase
|
||||
<h3>PlayerInfoLayout</h3>
|
||||
AccountId: @AccountId
|
||||
|
||||
@if (AccountInfo != null)
|
||||
{
|
||||
<p>
|
||||
Player:
|
||||
@AccountInfo.Json()
|
||||
</p>
|
||||
}
|
||||
@@ -1,11 +1,34 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using WotBlitzStatisticsPro.Blazor.GraphQl;
|
||||
using WotBlitzStatisticsPro.Blazor.Services;
|
||||
|
||||
namespace WotBlitzStatisticsPro.Blazor.Pages
|
||||
{
|
||||
public class PlayerInfoLayoutBase: ComponentBase
|
||||
{
|
||||
[Inject]
|
||||
public IGraphQlBackendService GraphQlBackendService { get; set; }
|
||||
|
||||
[Inject]
|
||||
public ILocalStorageService LocalStorageService { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public long AccountId { get; set; }
|
||||
|
||||
public RealmType CurrentRealmType { get; set; } = RealmType.Eu;
|
||||
|
||||
public IPlayer_AccountInfo AccountInfo { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var settings = await LocalStorageService.ReadSettings();
|
||||
CurrentRealmType = settings.RealmType;
|
||||
|
||||
AccountInfo = await GraphQlBackendService.GetPlayerInfo(AccountId, CurrentRealmType);
|
||||
|
||||
await base.OnInitializedAsync();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,11 +42,11 @@ namespace WotBlitzStatisticsPro.Blazor
|
||||
//var useMock = Environment.GetEnvironmentVariable("USE_GRAPH_QL_MOCK");
|
||||
//if (useMock != null && useMock == "true")
|
||||
//{
|
||||
builder.Services.AddTransient<IGraphQlBackendService, GraphQlBackendMockService>();
|
||||
//builder.Services.AddTransient<IGraphQlBackendService, GraphQlBackendMockService>();
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
//builder.Services.AddTransient<IGraphQlBackendService, GraphQlBackendService>();
|
||||
builder.Services.AddTransient<IGraphQlBackendService, GraphQlBackendService>();
|
||||
//}
|
||||
|
||||
var host = builder.Build();
|
||||
|
||||
@@ -74,6 +74,11 @@ namespace WotBlitzStatisticsPro.Blazor.Services
|
||||
return result;
|
||||
}
|
||||
|
||||
public Task<IPlayer_AccountInfo> GetPlayerInfo(long accountId, RealmType realmType)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private string FakerLanguage(RequestLanguage language)
|
||||
{
|
||||
switch (language)
|
||||
|
||||
@@ -38,6 +38,14 @@ namespace WotBlitzStatisticsPro.Blazor.Services
|
||||
return clans.Data?.Clans;
|
||||
}
|
||||
|
||||
public async Task<IPlayer_AccountInfo> GetPlayerInfo(long accountId, RealmType realmType)
|
||||
{
|
||||
var playerInfo = await _client.Player.ExecuteAsync(accountId, realmType, GetLanguage());
|
||||
CheckErrors(playerInfo.Errors);
|
||||
|
||||
return playerInfo.Data?.AccountInfo;
|
||||
}
|
||||
|
||||
private RequestLanguage GetLanguage()
|
||||
{
|
||||
var culture = CultureInfo.CurrentCulture;
|
||||
|
||||
@@ -13,5 +13,9 @@ namespace WotBlitzStatisticsPro.Blazor.Services
|
||||
Task<IReadOnlyList<IFindClans_Clans>?> FindClans(
|
||||
string clanNameOrTag,
|
||||
RealmType realmType);
|
||||
|
||||
Task<IPlayer_AccountInfo> GetPlayerInfo(
|
||||
long accountId,
|
||||
RealmType realmType);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user