Skip to content

Commit

Permalink
Merge pull request #523 from ipax77/dev
Browse files Browse the repository at this point in the history
ReplayComponent leaver duration indicator
  • Loading branch information
ipax77 authored Nov 9, 2024
2 parents 6830879 + 4d32203 commit 7db67c9
Show file tree
Hide file tree
Showing 17 changed files with 399 additions and 26 deletions.
1 change: 1 addition & 0 deletions src/dsstats.db8services/Builds/BuildService.Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public async Task<BuildMapResponse> GetReplayBuildMap(BuildRequest request, Canc
.OrderByDescending(o => o.GameTime)
.Where(x => skipMinDuration || x.Duration >= minDuration)
.ProjectTo<ReplayDto>(mapper.ConfigurationProvider)
.AsSplitQuery()
.FirstOrDefaultAsync();

if (replay is null)
Expand Down
1 change: 1 addition & 0 deletions src/dsstats.db8services/IReplayRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Task SaveReplay(ReplayDto replayDto,
Task<ReplayDto?> GetLatestReplay();
Task<ReplayDto?> GetPreviousReplay(DateTime gameTime);
Task<ReplayDto?> GetNextReplay(DateTime gameTime);
Task<ReplayDto?> GetReplay(string replayHash);
Task SetReplayViews();
Task SetReplayDownloads();
Task FixDsstatsPlayerNames();
Expand Down
11 changes: 11 additions & 0 deletions src/dsstats.db8services/ReplayRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Diagnostics;

namespace dsstats.db8services;
Expand Down Expand Up @@ -192,6 +193,16 @@ private async Task<ICollection<PlayerUpgrade>> GetMapedPlayerUpgrades(ReplayPlay
.FirstOrDefaultAsync();
}

public async Task<ReplayDto?> GetReplay(string replayHash)
{
return await context.Replays
.AsNoTracking()
.AsSplitQuery()
.Where(x => x.ReplayHash == replayHash)
.ProjectTo<ReplayDto>(mapper.ConfigurationProvider)
.FirstOrDefaultAsync();
}

public async Task SetReplayViews()
{
var viewedHashes = await context.ReplayViewCounts
Expand Down
4 changes: 2 additions & 2 deletions src/dsstats.maui/dsstats.maui8/Components/Pages/Home.razor
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<button type="button" class="btn btn-outline-success" @onclick="e => dsstatsService.ScanForNewReplays()">@Loc["Scan"]</button>
<button type="button" class="btn btn-outline-info" @onclick="Upload">@Loc["Upload"]</button>
</div>
<div class="row">
<div class="row justify-content-between">
<div class="col-auto">
@if (currentReplay is not null)
{
Expand Down Expand Up @@ -67,7 +67,7 @@
<div class="collapse show" id="SessionComponent">
@if (showSessionProgress)
{
<SessionComponent @ref="sessionComponent" />
<SessionComponent @ref="sessionComponent" RequestReplay="e => LoadSessionReplay(e)" />
}
</div>
</div>
Expand Down
11 changes: 11 additions & 0 deletions src/dsstats.maui/dsstats.maui8/Components/Pages/Home.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,17 @@ private async Task LoadNextReplay(bool next)
await InvokeAsync(() => StateHasChanged());
}

private async Task LoadSessionReplay(string replayHash)
{
var sessionReplay = await replayRepository.GetReplay(replayHash);
if (sessionReplay is null)
{
return;
}
currentReplay = sessionReplay;
await InvokeAsync(() => StateHasChanged());
}

private void Upload()
{
if (!configService.AppOptions.UploadCredential)
Expand Down
21 changes: 20 additions & 1 deletion src/dsstats.maui/dsstats.maui8/Components/SessionComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
</label>
</div>
</div>
@if (remote)
{
<div class="ms-auto">
<div>
<span class="bi bi-arrow-clockwise text-light pointer" @onclick="e => Reload()"></span>
</div>
</div>
}
</div>
<div class="mt-1">
@if (infos.Count > 0)
Expand All @@ -53,7 +61,7 @@
<tbody>
@foreach (var info in infos.OrderByDescending(o => o.GameTime))
{
<tr>
<tr class="pointer" @onclick="e => RequestReplay.InvokeAsync(info.ReplayHash)">
<td>
@if (remote)
{
Expand Down Expand Up @@ -90,6 +98,9 @@


@code {
[Parameter]
public EventCallback<string> RequestReplay { get; set; }

List<SessionReplayInfo> infos = [];
bool remote;
bool isLoading;
Expand All @@ -113,4 +124,12 @@
isLoading = false;
await InvokeAsync(() => StateHasChanged());
}

private async Task Reload()
{
isLoading = true;
await InvokeAsync(() => StateHasChanged());
await dsstatsService.ReloadSessionReplayInfos(remote);
await LoadData();
}
}
4 changes: 2 additions & 2 deletions src/dsstats.maui/dsstats.maui8/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ public static MauiApp CreateMauiApp()
builder.Services.AddAutoMapper(typeof(AutoMapperProfile));
builder.Services.AddChartJs(options =>
{
options.ChartJsLocation = "/_content/dsstats.razorlib/js/chart.js";
options.ChartJsLocation = "/_content/dsstats.razorlib/js/chart.umd.js";
options.ChartJsPluginDatalabelsLocation = "/_content/dsstats.razorlib/js/chartjs-plugin-datalabels.js";
});
builder.Services.AddBlazoredToast();
builder.Services.AddLocalization();
builder.Services.AddSingleton<IFolderPicker>(FolderPicker.Default);
builder.Services.AddSingleton<IFilePicker>(FilePicker.Default);

builder.Services.AddSingleton<IRemoteToggleService, RemoteToggleService>();
builder.Services.AddSingleton<IRemoteToggleService, maui8.Services.RemoteToggleService>();
builder.Services.AddSingleton<ConfigService>();
builder.Services.AddSingleton<DsstatsService>();
builder.Services.AddSingleton<ImportService>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,16 @@ public partial class DsstatsService
private readonly ConcurrentDictionary<string, ReplayRatingDto?> remoteRatings = [];

private readonly DateTime sessionStart = DateTime.UtcNow;
// private readonly DateTime sessionStart = new DateTime(2023, 11, 20);
// private readonly DateTime sessionStart = new DateTime(2024, 11, 08);

public async Task ReloadSessionReplayInfos(bool remote)
{
if (remote)
{
remoteRatings.Clear();
}
await GetSessionReplayInfos(remote);
}

public async Task<List<SessionReplayInfo>> GetSessionReplayInfos(bool remote)
{
Expand Down
5 changes: 5 additions & 0 deletions src/dsstats.maui/dsstats.maui8/Services/RatingsSaveService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -429,4 +429,9 @@ public Task SaveContinueComboRatings(Dictionary<int, Dictionary<PlayerId, CalcRa
{
throw new NotImplementedException();
}

public Task SaveContinueArcadeRatings(Dictionary<int, Dictionary<PlayerId, CalcRating>> mmrIdRatings, List<shared.Calc.ReplayRatingDto> replayRatings)
{
throw new NotImplementedException();
}
}
12 changes: 6 additions & 6 deletions src/dsstats.maui/dsstats.maui8/dsstats.maui8.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Localization" Version="8.0.7" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.70" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.70" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="8.0.70" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="8.0.10" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.93" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.93" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="8.0.93" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.1" />
<PackageReference Include="IronPython.StdLib" Version="2.7.12" />
<PackageReference Include="Blazored.Toast" Version="4.2.1" />
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.2" />
<PackageReference Include="CommunityToolkit.Maui" Version="9.1.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/*!
* Bootstrap Icons v1.10.5 (https://icons.getbootstrap.com/)
* Bootstrap Icons v1.11.1 (https://icons.getbootstrap.com/)
* Copyright 2019-2023 The Bootstrap Authors
* Licensed under MIT (https://github.com/twbs/icons/blob/main/LICENSE)
*/

@font-face {
font-display: block;
font-family: "bootstrap-icons";
src: url("./fonts/bootstrap-icons.woff2?1fa40e8900654d2863d011707b9fb6f2") format("woff2"),
url("./fonts/bootstrap-icons.woff?1fa40e8900654d2863d011707b9fb6f2") format("woff");
src: url("./fonts/bootstrap-icons.woff2?2820a3852bdb9a5832199cc61cec4e65") format("woff2"),
url("./fonts/bootstrap-icons.woff?2820a3852bdb9a5832199cc61cec4e65") format("woff");
}

.bi::before,
Expand Down Expand Up @@ -1979,3 +1979,100 @@ url("./fonts/bootstrap-icons.woff?1fa40e8900654d2863d011707b9fb6f2") format("wof
.bi-sina-weibo::before { content: "\f8ca"; }
.bi-tencent-qq::before { content: "\f8cb"; }
.bi-wikipedia::before { content: "\f8cc"; }
.bi-alphabet-uppercase::before { content: "\f2a5"; }
.bi-alphabet::before { content: "\f68a"; }
.bi-amazon::before { content: "\f68d"; }
.bi-arrows-collapse-vertical::before { content: "\f690"; }
.bi-arrows-expand-vertical::before { content: "\f695"; }
.bi-arrows-vertical::before { content: "\f698"; }
.bi-arrows::before { content: "\f6a2"; }
.bi-ban-fill::before { content: "\f6a3"; }
.bi-ban::before { content: "\f6b6"; }
.bi-bing::before { content: "\f6c2"; }
.bi-cake::before { content: "\f6e0"; }
.bi-cake2::before { content: "\f6ed"; }
.bi-cookie::before { content: "\f6ee"; }
.bi-copy::before { content: "\f759"; }
.bi-crosshair::before { content: "\f769"; }
.bi-crosshair2::before { content: "\f794"; }
.bi-emoji-astonished-fill::before { content: "\f795"; }
.bi-emoji-astonished::before { content: "\f79a"; }
.bi-emoji-grimace-fill::before { content: "\f79b"; }
.bi-emoji-grimace::before { content: "\f7a0"; }
.bi-emoji-grin-fill::before { content: "\f7a1"; }
.bi-emoji-grin::before { content: "\f7a6"; }
.bi-emoji-surprise-fill::before { content: "\f7a7"; }
.bi-emoji-surprise::before { content: "\f7ac"; }
.bi-emoji-tear-fill::before { content: "\f7ad"; }
.bi-emoji-tear::before { content: "\f7b2"; }
.bi-envelope-arrow-down-fill::before { content: "\f7b3"; }
.bi-envelope-arrow-down::before { content: "\f7b8"; }
.bi-envelope-arrow-up-fill::before { content: "\f7b9"; }
.bi-envelope-arrow-up::before { content: "\f7be"; }
.bi-feather::before { content: "\f7bf"; }
.bi-feather2::before { content: "\f7c4"; }
.bi-floppy-fill::before { content: "\f7c5"; }
.bi-floppy::before { content: "\f7d8"; }
.bi-floppy2-fill::before { content: "\f7d9"; }
.bi-floppy2::before { content: "\f7e4"; }
.bi-gitlab::before { content: "\f7e5"; }
.bi-highlighter::before { content: "\f7f8"; }
.bi-marker-tip::before { content: "\f802"; }
.bi-nvme-fill::before { content: "\f803"; }
.bi-nvme::before { content: "\f80c"; }
.bi-opencollective::before { content: "\f80d"; }
.bi-pci-card-network::before { content: "\f8cd"; }
.bi-pci-card-sound::before { content: "\f8ce"; }
.bi-radar::before { content: "\f8cf"; }
.bi-send-arrow-down-fill::before { content: "\f8d0"; }
.bi-send-arrow-down::before { content: "\f8d1"; }
.bi-send-arrow-up-fill::before { content: "\f8d2"; }
.bi-send-arrow-up::before { content: "\f8d3"; }
.bi-sim-slash-fill::before { content: "\f8d4"; }
.bi-sim-slash::before { content: "\f8d5"; }
.bi-sourceforge::before { content: "\f8d6"; }
.bi-substack::before { content: "\f8d7"; }
.bi-threads-fill::before { content: "\f8d8"; }
.bi-threads::before { content: "\f8d9"; }
.bi-transparency::before { content: "\f8da"; }
.bi-twitter-x::before { content: "\f8db"; }
.bi-type-h4::before { content: "\f8dc"; }
.bi-type-h5::before { content: "\f8dd"; }
.bi-type-h6::before { content: "\f8de"; }
.bi-backpack-fill::before { content: "\f8df"; }
.bi-backpack::before { content: "\f8e0"; }
.bi-backpack2-fill::before { content: "\f8e1"; }
.bi-backpack2::before { content: "\f8e2"; }
.bi-backpack3-fill::before { content: "\f8e3"; }
.bi-backpack3::before { content: "\f8e4"; }
.bi-backpack4-fill::before { content: "\f8e5"; }
.bi-backpack4::before { content: "\f8e6"; }
.bi-brilliance::before { content: "\f8e7"; }
.bi-cake-fill::before { content: "\f8e8"; }
.bi-cake2-fill::before { content: "\f8e9"; }
.bi-duffle-fill::before { content: "\f8ea"; }
.bi-duffle::before { content: "\f8eb"; }
.bi-exposure::before { content: "\f8ec"; }
.bi-gender-neuter::before { content: "\f8ed"; }
.bi-highlights::before { content: "\f8ee"; }
.bi-luggage-fill::before { content: "\f8ef"; }
.bi-luggage::before { content: "\f8f0"; }
.bi-mailbox-flag::before { content: "\f8f1"; }
.bi-mailbox2-flag::before { content: "\f8f2"; }
.bi-noise-reduction::before { content: "\f8f3"; }
.bi-passport-fill::before { content: "\f8f4"; }
.bi-passport::before { content: "\f8f5"; }
.bi-person-arms-up::before { content: "\f8f6"; }
.bi-person-raised-hand::before { content: "\f8f7"; }
.bi-person-standing-dress::before { content: "\f8f8"; }
.bi-person-standing::before { content: "\f8f9"; }
.bi-person-walking::before { content: "\f8fa"; }
.bi-person-wheelchair::before { content: "\f8fb"; }
.bi-shadows::before { content: "\f8fc"; }
.bi-suitcase-fill::before { content: "\f8fd"; }
.bi-suitcase-lg-fill::before { content: "\f8fe"; }
.bi-suitcase-lg::before { content: "\f8ff"; }
.bi-suitcase::before { content: "\f900"; }
.bi-suitcase2-fill::before { content: "\f901"; }
.bi-suitcase2::before { content: "\f902"; }
.bi-vignette::before { content: "\f903"; }
Loading

0 comments on commit 7db67c9

Please sign in to comment.