Skip to content

Commit

Permalink
Merge pull request #155 from SSchulze1989/develop
Browse files Browse the repository at this point in the history
v 0.12.1
  • Loading branch information
SSchulze1989 authored Jul 12, 2024
2 parents 3e300bb + b046e49 commit 86d345c
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@namespace iRLeagueManager.Web.Components
@using iRLeagueApiCore.Common.Models.Standings
@using iRLeagueApiCore.Common.Models

<div @attributes=AdditionalAttributes>
@{
Expand All @@ -15,7 +16,7 @@

@if (showRaceByRace)
{
<RaceByRacePoints StandingRows="Standing.StandingRows" />
<RaceByRacePoints StandingRows="Standing.StandingRows" Events="raceEvents"/>
}
else
{
Expand Down Expand Up @@ -67,12 +68,22 @@
</div>

@code {
[CascadingParameter]
private EventListViewModel EventList { get; set; } = default!;
[Parameter(CaptureUnmatchedValues = true)]
public IDictionary<string, object>? AdditionalAttributes { get; set; }
[Parameter, EditorRequired]
public StandingsModel Standing { get; set; } = default!;

private bool showRaceByRace = false;
private IEnumerable<EventModel> raceEvents = [];

protected override void OnParametersSet()
{
base.OnParametersSet();
BlazorParameterNullException.ThrowIfNull(this, EventList, cascading: true);
raceEvents = GetStandingEvents();
}

private bool HasDriver(IEnumerable<StandingRowModel> rows)
{
Expand All @@ -83,4 +94,19 @@
{
return rows.Any(x => x.TeamId != null);
}

private IEnumerable<EventModel> GetStandingEvents()
{
var eventIds = Standing.StandingRows
.SelectMany(x => x.ResultRows)
.NotNull()
.Select(x => x.EventId)
.Distinct();
var events = eventIds
.Select(eventId => EventList.EventList.FirstOrDefault(e => e.EventId == eventId))
.NotNull()
.Select(x => x.GetModel())
.ToList();
return events;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,80 @@
<MudSimpleTable Elevation=5 Dense="true" Bordered="true">
@{
var columnsCount = RaceColumns ?? StandingRows.Select(x => x.ResultRows.Count()).Max();
int raceColumnWidthPct = 90 / (columnsCount == 0 ? 1 : columnsCount);
}
<thead>
<tr>
<td rowspan="2" class="py-2">
Pos.
</td>
<td rowspan="2" class="py-2">
<td rowspan="2" class="py-2" width="15%">
Name
</td>
@for (int i = 1; i <= columnsCount; i++)
@for (int i = 0; i < columnsCount; i++)
{
<th colspan="3" style="text-align: center">
var @event = Events.ElementAtOrDefault(i);
<th colspan="3" class="px-0 py-0" style="text-align: center">
R@(i.ToString())
@if (@event is not null)
{
<MudText Typo="Typo.subtitle2">
@(@event.Date.GetValueOrDefault().ToString("dd.MM.yy"))
</MudText>
}
</th>
}
</tr>
<tr>
@for (int i = 0; i < columnsCount; i++)
{
var @event = Events.ElementAtOrDefault(i);
<td colspan="3" class="px-0 py-0" style="@($"width: {raceColumnWidthPct}%; text-align: center")">
@if (@event is not null)
{
<MudText Typo="Typo.caption">
@(@event.TrackName)
</MudText>
}
</td>
}
</tr>
</thead>

<tbody>
<tr>
<td rowspan="2" class="py-0">
</td>
<td rowspan="2" class="py-0">
</td>
@for (int i = 0; i < columnsCount; i++)
{
<td colspan="3" class="px-0 py-0" style="text-align: center">
Total
</td>
}
</tr>
<tr>
@for (int i = 0; i < columnsCount; i++)
{
<td class="px-0 py-0" style="text-align: center">
<MudTooltip Text="Race points">
R
</MudTooltip>
</td>
<td class="px-0 py-0" style="text-align: center">
<MudTooltip Text="Bonus points">
B
</MudTooltip>
</td>
<td class="px-0 py-0" style="text-align: center">
<MudTooltip Text="Penalty points">
P
</MudTooltip>
</td>
}
</tr>
</tbody>
@foreach (var row in StandingRows)
{
var columns = row.ResultRows.ToList();
Expand All @@ -47,14 +104,14 @@
<tr>
@foreach (var race in columns)
{
<td class="@($"col-1 py-0 {(race?.IsScored == false ? "dropped" : "")}")">
<td class="@($"col-1 px-2 py-0 {(race?.IsScored == false ? "dropped" : "")}")" style="text-align: center">
@race?.RacePoints
</td>
<td class="@($"col-1 py-0 {(race?.IsScored == false ? "dropped" : "")}")">
@race?.BonusPoints
<td class="@($"col-1 px-2 py-0 {(race?.IsScored == false ? "dropped" : "")}")" style="text-align: center">
@(race?.BonusPoints is > 0 ? $"+{race.BonusPoints}" : race is not null ? "-" : "")
</td>
<td class="@($"col-1 py-0 {(race?.IsScored == false ? "dropped" : "")}")" style="@(race?.PenaltyPoints != 0 ? "color:red" : "")">
@(race?.PenaltyPoints is < 0 or > 0 ? "-" : "")@race?.PenaltyPoints
<td class="@($"col-1 px-2 py-0 {(race?.IsScored == false ? "dropped" : "")}")" style="@(race?.PenaltyPoints != 0 ? "color:red" : "" + "text-align: center")">
@(race?.PenaltyPoints is < 0 or > 0 ? $"-{@race?.PenaltyPoints}" : race is not null ? "-" : "")
</td>
}
</tr>
Expand All @@ -63,12 +120,14 @@
</MudSimpleTable>

@code {
[Parameter] public IEnumerable<EventModel> Events { get; set; } = default!;
[Parameter] public IEnumerable<StandingRowModel> StandingRows { get; set; } = default!;
[Parameter] public int? RaceColumns { get; set; }

protected override void OnParametersSet()
{
base.OnParametersSet();
BlazorParameterNullException.ThrowIfNull(this, Events);
BlazorParameterNullException.ThrowIfNull(this, StandingRows);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
.mud-simple-table .mud-table-container table tbody tr:last-child {
.mud-simple-table .mud-table-container table tbody tr:last-child td,
.mud-simple-table .mud-table-container table thead tr:last-child th{
border-bottom: 1px solid var(--mud-palette-table-lines);
}

.mud-simple-table .mud-table-container table thead tr:not(:last-child) th {
border-bottom: none;
}

.mud-simple-table .mud-table-container table tbody:hover {
background-color: var(--mud-palette-table-hover) !important;
}
Expand All @@ -19,5 +24,5 @@
}

.mud-simple-table .mud-table-container table tbody tr td.dropped {
color: var(--mud-palette-text-disabled);
color: #3074ff90;
}
4 changes: 2 additions & 2 deletions src/iRLeagueManager.Web/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
}
},
"AllowedHosts": "*",
"APIServer": "http://localhost:5000",
//"APIServer": "https://irleaguemanager.net/api/",
//"APIServer": "http://localhost:5000",
"APIServer": "https://irleaguemanager.net/api/",
"DefaultUser": "testuser",
"DefaultPassword": "TestPass123!"
}
2 changes: 1 addition & 1 deletion src/iRLeagueManager.Web/iRLeagueManager.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Version>0.12.0</Version>
<Version>0.12.1</Version>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-iRLeagueManager.Web-2B05F9DC-55A3-49D1-BD64-31507000EDF3</UserSecretsId>
Expand Down

0 comments on commit 86d345c

Please sign in to comment.