mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-23 19:30:06 +02:00
feat: tank info dialog mechanism
This commit is contained in:
1 parent
4c7e7b3ca2
commit
d5a139822d
9 files changed
+88
-7
No files matched your search
@@ -0,0 +1,15 @@
|
|||||||
|
using MediatR;
|
||||||
|
using WotBlitzStatisticsPro.Blazor.GraphQl;
|
||||||
|
|
||||||
|
namespace WotBlitzStatisticsPro.Blazor.Messages
|
||||||
|
{
|
||||||
|
public class OpenTankDialogMessage: INotification
|
||||||
|
{
|
||||||
|
public ITank Tank { get; }
|
||||||
|
|
||||||
|
public OpenTankDialogMessage(ITank tank)
|
||||||
|
{
|
||||||
|
Tank = tank;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
@using WotBlitzStatisticsPro.Blazor.Helpers
|
@using WotBlitzStatisticsPro.Blazor.Helpers
|
||||||
|
@using MediatR
|
||||||
|
@using WotBlitzStatisticsPro.Blazor.Messages
|
||||||
@inject IStringLocalizer<App> Localize;
|
@inject IStringLocalizer<App> Localize;
|
||||||
|
@inject IMediator Mediator
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<RadzenCard class="m-3" style="width: 350px;">
|
<RadzenCard class="m-3" style="width: 350px;">
|
||||||
@@ -51,7 +54,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col col-sm col-md col-lg col-xl">
|
<div class="col col-sm col-md col-lg col-xl">
|
||||||
</div>
|
</div>
|
||||||
<div class="col col-sm col-md col-lg col-xl">
|
<div class="col col-sm col-md col-lg col-xl" @onclick="@(async (e) => { await Mediator.Publish(new OpenTankDialogMessage(MostRelevantTank)); })">
|
||||||
@if (MostRelevantTank != null)
|
@if (MostRelevantTank != null)
|
||||||
{
|
{
|
||||||
<TankCard Tank=@MostRelevantTank></TankCard>
|
<TankCard Tank=@MostRelevantTank></TankCard>
|
||||||
@@ -67,7 +70,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col col-sm col-md col-lg col-xl">
|
<div class="col col-sm col-md col-lg col-xl">
|
||||||
</div>
|
</div>
|
||||||
<div class="col col-sm col-md col-lg col-xl">
|
<div class="col col-sm col-md col-lg col-xl" @onclick="@(async (e) => { await Mediator.Publish(new OpenTankDialogMessage(MaxXpTank)); })">
|
||||||
@if (MaxXpTank != null)
|
@if (MaxXpTank != null)
|
||||||
{
|
{
|
||||||
<TankCard Tank=@MaxXpTank></TankCard>
|
<TankCard Tank=@MaxXpTank></TankCard>
|
||||||
@@ -83,7 +86,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col col-sm col-md col-lg col-xl">
|
<div class="col col-sm col-md col-lg col-xl">
|
||||||
</div>
|
</div>
|
||||||
<div class="col col-sm col-md col-lg col-xl">
|
<div class="col col-sm col-md col-lg col-xl" @onclick="@(async (e) => { await Mediator.Publish(new OpenTankDialogMessage(MaxFragsTank)); })">
|
||||||
@if (MaxFragsTank != null)
|
@if (MaxFragsTank != null)
|
||||||
{
|
{
|
||||||
<TankCard Tank=@MaxFragsTank></TankCard>
|
<TankCard Tank=@MaxFragsTank></TankCard>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
@using WotBlitzStatisticsPro.Blazor.Helpers
|
@using WotBlitzStatisticsPro.Blazor.Helpers
|
||||||
|
@using WotBlitzStatisticsPro.Blazor.Messages
|
||||||
@inherits PlayerInfoTanksListBase;
|
@inherits PlayerInfoTanksListBase;
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -84,7 +85,8 @@
|
|||||||
<RadzenDataGridColumn TItem="ITank" Title="" Sortable="false" Filterable="false" Width="55px">
|
<RadzenDataGridColumn TItem="ITank" Title="" Sortable="false" Filterable="false" Width="55px">
|
||||||
<Template Context="data">
|
<Template Context="data">
|
||||||
<RadzenImage Path="@data.PreviewImage" style="width: 50px; height: 40px; border-radius: 8px;"
|
<RadzenImage Path="@data.PreviewImage" style="width: 50px; height: 40px; border-radius: 8px;"
|
||||||
MouseEnter="@(args => ShowTankTooltip(args, data.PreviewImage, data.TankNationId, new TooltipOptions(){ Style = "background-color:#2F3D43" }) )" />
|
MouseEnter="@(args => ShowTankTooltip(args, data.PreviewImage, data.TankNationId, new TooltipOptions(){ Style = "background-color:#2F3D43" }) )"
|
||||||
|
Click="@(async (args) => { await Mediator.Publish(new OpenTankDialogMessage(data)); })" />
|
||||||
</Template>
|
</Template>
|
||||||
</RadzenDataGridColumn>
|
</RadzenDataGridColumn>
|
||||||
<RadzenDataGridColumn TItem="ITank" Property="Name" Filterable="false" Sortable="true" Title="@Localize["Tank"]" Frozen="false" Width="100px" TextAlign="TextAlign.Left">
|
<RadzenDataGridColumn TItem="ITank" Property="Name" Filterable="false" Sortable="true" Title="@Localize["Tank"]" Frozen="false" Width="100px" TextAlign="TextAlign.Left">
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ using Radzen.Blazor;
|
|||||||
using WotBlitzStatisticsPro.Blazor.GraphQl;
|
using WotBlitzStatisticsPro.Blazor.GraphQl;
|
||||||
using WotBlitzStatisticsPro.Blazor.Helpers;
|
using WotBlitzStatisticsPro.Blazor.Helpers;
|
||||||
using WotBlitzStatisticsPro.Blazor.Model;
|
using WotBlitzStatisticsPro.Blazor.Model;
|
||||||
|
using MediatR;
|
||||||
|
using WotBlitzStatisticsPro.Blazor.Messages;
|
||||||
namespace WotBlitzStatisticsPro.Blazor.Pages
|
namespace WotBlitzStatisticsPro.Blazor.Pages
|
||||||
{
|
{
|
||||||
public class PlayerInfoTanksListBase: ComponentBase
|
public class PlayerInfoTanksListBase: ComponentBase
|
||||||
@@ -22,6 +23,9 @@ namespace WotBlitzStatisticsPro.Blazor.Pages
|
|||||||
[Inject]
|
[Inject]
|
||||||
public IStringLocalizer<App> Localize { get; set; }
|
public IStringLocalizer<App> Localize { get; set; }
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
public IMediator Mediator { get; set; }
|
||||||
|
|
||||||
public RadzenDataGrid<ITank> TanksGrid { get; set; }
|
public RadzenDataGrid<ITank> TanksGrid { get; set; }
|
||||||
|
|
||||||
public IEnumerable<ITank> FilteredTankList { get; set; }
|
public IEnumerable<ITank> FilteredTankList { get; set; }
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
@inherits PlayerInfoTanksListBase;
|
@using WotBlitzStatisticsPro.Blazor.Messages
|
||||||
|
@inherits PlayerInfoTanksListBase;
|
||||||
@if (TanksList != null && FilteredTankList.Count() > 0)
|
@if (TanksList != null && FilteredTankList.Count() > 0)
|
||||||
{
|
{
|
||||||
<div class="sorting">
|
<div class="sorting">
|
||||||
@@ -49,7 +50,9 @@
|
|||||||
<div class="tanks-list">
|
<div class="tanks-list">
|
||||||
@foreach (var tank in FilteredTankList)
|
@foreach (var tank in FilteredTankList)
|
||||||
{
|
{
|
||||||
<TankListItem Tank=@tank></TankListItem>
|
<div @onclick="@(async (e) => { await Mediator.Publish(new OpenTankDialogMessage(tank)); })">
|
||||||
|
<TankListItem Tank=@tank></TankListItem>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
@using WotBlitzStatisticsPro.Blazor.Model
|
||||||
|
|
||||||
|
<p>
|
||||||
|
@Tank.Name
|
||||||
|
</p>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public ITank Tank { get; set; }
|
||||||
|
}
|
||||||
@@ -31,6 +31,7 @@ namespace WotBlitzStatisticsPro.Blazor
|
|||||||
builder.Services.AddScoped<ISearchDialogService, SearchDialogService>();
|
builder.Services.AddScoped<ISearchDialogService, SearchDialogService>();
|
||||||
builder.Services.AddScoped<IChartsService, ChartService>();
|
builder.Services.AddScoped<IChartsService, ChartService>();
|
||||||
builder.Services.AddScoped<IMediaQueriesService, MediaQueriesService>();
|
builder.Services.AddScoped<IMediaQueriesService, MediaQueriesService>();
|
||||||
|
builder.Services.AddScoped<ITankStatisticDialogService, TankStatisticDialogService>();
|
||||||
|
|
||||||
builder.Services.AddMediatR(typeof(Program));
|
builder.Services.AddMediatR(typeof(Program));
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using System.Threading.Tasks;
|
||||||
|
using WotBlitzStatisticsPro.Blazor.GraphQl;
|
||||||
|
|
||||||
|
namespace WotBlitzStatisticsPro.Blazor.Services
|
||||||
|
{
|
||||||
|
public interface ITankStatisticDialogService
|
||||||
|
{
|
||||||
|
Task OpenTankStatistics(ITank tank);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using WotBlitzStatisticsPro.Blazor.GraphQl;
|
||||||
|
using MediatR;
|
||||||
|
using Radzen;
|
||||||
|
using WotBlitzStatisticsPro.Blazor.Messages;
|
||||||
|
using WotBlitzStatisticsPro.Blazor.Pages;
|
||||||
|
|
||||||
|
namespace WotBlitzStatisticsPro.Blazor.Services
|
||||||
|
{
|
||||||
|
public class TankStatisticDialogService: ITankStatisticDialogService, INotificationHandler<OpenTankDialogMessage>
|
||||||
|
{
|
||||||
|
private readonly DialogService _dialogService;
|
||||||
|
public TankStatisticDialogService(DialogService dialogService)
|
||||||
|
{
|
||||||
|
_dialogService = dialogService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task OpenTankStatistics(ITank tank)
|
||||||
|
{
|
||||||
|
await _dialogService.OpenAsync<TankInfoDialog>(tank.Name,
|
||||||
|
new Dictionary<string, object>() { { "Tank", tank } },
|
||||||
|
new DialogOptions() { Width = "300px", Height = "800px" });
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task Handle(OpenTankDialogMessage notification, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
return OpenTankStatistics(notification.Tank);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user