Skip to content
This repository has been archived by the owner on Apr 8, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminsampica committed May 18, 2022
2 parents a7a4152 + afaeeb0 commit 8c2b7a2
Show file tree
Hide file tree
Showing 44 changed files with 1,431 additions and 381 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,15 @@ By default, a test account is created with administrator permissions with the fo
Username `[email protected]`

Password `hunter2`

# Contributing

Please make sure all tests pass before submitting a new pull request.

## Adding a Migration

New migrations can be added to the database by:

1. Installing the dotnet ef tools via `dotnet tool install --global dotnet-ef`
2. Running the following command with a command line while inside the `/src/Server` folder
`dotnet ef migrations add {YourMigrationName} -o ./Infrastructure/Migrations --context ApplicationDbContext --project DynamoLeagueBlazor.Server.csproj
11 changes: 10 additions & 1 deletion src/Client/Features/Admin/StartSeason.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@
</Title>

<MudAlert Severity=Severity.Warning Class="mb-2">
Clicking the below button will begin a new season - all players who are eligble to be free agents will be set to a free agent status. Proceed with caution.
Clicking the below button will begin a new season. Beginning a new season includes
<br/><br/>
<ul>
<li>
- All players who are eligble to be free agents will be set to a free agent status.
</li>
<li>
- All fines for the previous year will be removed.
</li>
</ul>
</MudAlert>
<LoadingButton @bind-IsLoading="_isDisabled" Icon=@Icons.Outlined.SportsFootball Color=Color.Primary OnClick=StartSeasonAsync>
<IsLoadingContent>
Expand Down
4 changes: 3 additions & 1 deletion src/Client/Features/Dashboard/Dashboard.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@page "/"
@using DynamoLeagueBlazor.Client.Features.Dashboard.TopOffenders

<Title>
@_title
Expand All @@ -9,4 +8,7 @@
<MudItem xs=12>
<TopOffenders />
</MudItem>
<MudItem xs=12>
<TopTeamFines />
</MudItem>
</MudGrid>
20 changes: 20 additions & 0 deletions src/Client/Features/Dashboard/Shared/RankedCard.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<MudCard Style=@BackgroundColor Class="ma-1">
<MudCardHeader>
<CardHeaderAvatar>
<MudAvatar Image=@RankedItem.ImageUrl></MudAvatar>
</CardHeaderAvatar>
<CardHeaderContent>
<MudText Typo="NameTypo">@RankedItem.Name</MudText>
</CardHeaderContent>
<CardHeaderActions>
<MudText Typo="AmountTypo" Color=Color.Success>@RankedItem.Amount</MudText>
</CardHeaderActions>
</MudCardHeader>
</MudCard>

@code {
[Parameter, EditorRequired] public IRankedItem RankedItem { get; set; } = null!;
[Parameter, EditorRequired] public Typo NameTypo { get; set; }
[Parameter, EditorRequired] public Typo AmountTypo { get; set; }
[Parameter] public string? BackgroundColor { get; set; }
}
30 changes: 30 additions & 0 deletions src/Client/Features/Dashboard/Shared/RankedList.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@if(RankedItems.Count() > 2)
{
<MudItem xs=12>
@{
var first =RankedItems.First();
var second = RankedItems.Skip(1).First();
var third = RankedItems.Skip(2).First();
}
<RankedCard BackgroundColor="background: rgba(167, 149, 70, 1);" RankedItem="@first" NameTypo=Typo.h4 AmountTypo=Typo.h4/>
<RankedCard BackgroundColor="background: rgba(147, 147, 147, 1);" RankedItem="@second" NameTypo=Typo.h5 AmountTypo=Typo.h5/>
<RankedCard BackgroundColor="background: rgba(135, 106, 63, 1);" RankedItem="@third" NameTypo=Typo.h5 AmountTypo=Typo.h5/>
</MudItem>
@foreach(var rankedItem in RankedItems.Skip(3))
{
<MudItem xs=12 sm=4 Class="mx-auto">
<RankedCard RankedItem="@rankedItem" NameTypo=Typo.body1 AmountTypo=Typo.h6 />
</MudItem>
}
}
else
{
<MudAlert Severity=Severity.Normal>
@NotEnoughItemsContent
</MudAlert>
}

@code {
[Parameter] public IEnumerable<IRankedItem> RankedItems { get; set; } = Array.Empty<IRankedItem>();
[Parameter, EditorRequired] public RenderFragment NotEnoughItemsContent { get; set; } = null!;
}
38 changes: 38 additions & 0 deletions src/Client/Features/Dashboard/TopOffenders.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@if(_result is null)
{
<MudSkeleton SkeletonType="SkeletonType.Text" Width="100%" Height="50px"/>
@for(int i = 0; i < 3; i++)
{
<MudItem xs=12>
<MudCard Class="ma-1">
<MudCardHeader>
<CardHeaderAvatar>
<MudSkeleton SkeletonType=SkeletonType.Circle Width="50px" Height="50px"></MudSkeleton>
</CardHeaderAvatar>
<CardHeaderContent>
<MudSkeleton SkeletonType=SkeletonType.Text Width="200px" Height="40px"></MudSkeleton>
</CardHeaderContent>
<CardHeaderActions>
<MudSkeleton SkeletonType=SkeletonType.Text Width="40px" Height="40px"></MudSkeleton>
</CardHeaderActions>
</MudCardHeader>
</MudCard>
</MudItem>
}
}
else
{
<MudGrid>
<MudItem xs=12>
<PageHeader>
Top Offenders
</PageHeader>
</MudItem>

<RankedList RankedItems="_result.Players">
<NotEnoughItemsContent>
There aren't enough players with fines quite yet. Check back later!
</NotEnoughItemsContent>
</RankedList>
</MudGrid>
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
using System.Net.Http.Json;

namespace DynamoLeagueBlazor.Client.Features.Dashboard.TopOffenders;
namespace DynamoLeagueBlazor.Client.Features.Dashboard;

public sealed partial class TopOffenders : IDisposable
{
Expand Down
22 changes: 0 additions & 22 deletions src/Client/Features/Dashboard/TopOffenders/PlayerCard.razor

This file was deleted.

58 changes: 0 additions & 58 deletions src/Client/Features/Dashboard/TopOffenders/TopOffenders.razor

This file was deleted.

38 changes: 38 additions & 0 deletions src/Client/Features/Dashboard/TopTeamFines.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@if(_result is null)
{
<MudSkeleton SkeletonType="SkeletonType.Text" Width="100%" Height="50px"/>
@for(int i = 0; i < 3; i++)
{
<MudItem xs=12>
<MudCard Class="ma-1">
<MudCardHeader>
<CardHeaderAvatar>
<MudSkeleton SkeletonType=SkeletonType.Circle Width="50px" Height="50px"></MudSkeleton>
</CardHeaderAvatar>
<CardHeaderContent>
<MudSkeleton SkeletonType=SkeletonType.Text Width="200px" Height="40px"></MudSkeleton>
</CardHeaderContent>
<CardHeaderActions>
<MudSkeleton SkeletonType=SkeletonType.Text Width="40px" Height="40px"></MudSkeleton>
</CardHeaderActions>
</MudCardHeader>
</MudCard>
</MudItem>
}
}
else
{
<MudGrid>
<MudItem xs=12>
<PageHeader>
Top Team Fines
</PageHeader>
</MudItem>

<RankedList RankedItems="_result.Teams">
<NotEnoughItemsContent>
There aren't enough teams with fines quite yet. Check back later!
</NotEnoughItemsContent>
</RankedList>
</MudGrid>
}
32 changes: 32 additions & 0 deletions src/Client/Features/Dashboard/TopTeamFines.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using DynamoLeagueBlazor.Shared.Features.Dashboard;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
using System.Net.Http.Json;

namespace DynamoLeagueBlazor.Client.Features.Dashboard;

public sealed partial class TopTeamFines : IDisposable
{
[Inject] private HttpClient HttpClient { get; set; } = null!;

private TopTeamFinesResult? _result;
private readonly CancellationTokenSource _cts = new();

protected override async Task OnInitializedAsync()
{
try
{
_result = await HttpClient.GetFromJsonAsync<TopTeamFinesResult>(TopTeamFinesRouteFactory.Uri, _cts.Token);
}
catch (AccessTokenNotAvailableException exception)
{
exception.Redirect();
}
}

public void Dispose()
{
_cts.Cancel();
_cts.Dispose();
}
}
2 changes: 2 additions & 0 deletions src/Client/Features/Dashboard/_Imports.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@using DynamoLeagueBlazor.Client.Features.Dashboard.Shared
@using DynamoLeagueBlazor.Shared.Features.Dashboard.Shared
6 changes: 5 additions & 1 deletion src/Client/Features/Fines/List.razor
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
</Authorized>
</AuthorizeView>
<MudTh><MudTableSortLabel SortBy="new Func<FineItem,object>(x=> x.PlayerName)">Name</MudTableSortLabel></MudTh>
<MudTh><MudTableSortLabel SortBy="new Func<FineItem,object>(x=> x.TeamName)">Team</MudTableSortLabel></MudTh>
<MudTh>Reason</MudTh>
<MudTh><MudTableSortLabel SortBy="new Func<FineItem,object>(x=> x.Amount)">Amount</MudTableSortLabel></MudTh>
<MudTh><MudTableSortLabel SortBy="new Func<FineItem,object>(x=> x.Status)">Status</MudTableSortLabel></MudTh>
Expand All @@ -34,7 +35,10 @@
</Authorized>
</AuthorizeView>
<MudTd DataLabel=Name>
<PlayerNameWithHeadShot Name="@fineItem.PlayerName" HeadShotUrl="@fineItem.PlayerHeadShotUrl" />
<NameWithImage Name="@fineItem.PlayerName" ImageUrl="@fineItem.PlayerHeadShotUrl" />
</MudTd>
<MudTd DataLabel=Team>
<NameWithImage Name="@fineItem.TeamName" ImageUrl="@fineItem.TeamLogoUrl" />
</MudTd>
<MudTd DataLabel=Reason>@fineItem.Reason</MudTd>
<MudTd DataLabel=Amount>@fineItem.Amount</MudTd>
Expand Down
6 changes: 5 additions & 1 deletion src/Client/Features/Fines/List.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ private async void OpenManageFineDialog(int fineId)

var result = await dialog.Result;

if (!result.Cancelled) await LoadDataAsync();
if (!result.Cancelled)
{
await LoadDataAsync();
StateHasChanged();
}
}

public void Dispose()
Expand Down
2 changes: 1 addition & 1 deletion src/Client/Features/FreeAgents/List.razor
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<MudIconButton Icon="@Icons.Material.Filled.AttachMoney" Color="Color.Primary" Variant="Variant.Outlined" Size="Size.Small" Class="ma-2" Link="@href"/>
</MudTd>
<MudTd DataLabel="Player Name">
<PlayerNameWithHeadShot Name="@context.Name" HeadShotUrl="@context.HeadShotUrl" />
<NameWithImage Name="@context.Name" ImageUrl="@context.HeadShotUrl" />
</MudTd>
<MudTd DataLabel="Player Position">@context.Position</MudTd>
<MudTd DataLabel="Player Team">@context.Team</MudTd>
Expand Down
2 changes: 1 addition & 1 deletion src/Client/Features/OfferMatching/List.razor
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<MudIconButton Icon="@Icons.Filled.Handshake" Color="Color.Primary" Variant="Variant.Outlined" Size="Size.Small" Class="ma-2" />
</MudTd>
<MudTd DataLabel="Player Name">
<PlayerNameWithHeadShot Name="@context.Name" HeadShotUrl="@context.HeadShotUrl" />
<NameWithImage Name="@context.Name" ImageUrl="@context.HeadShotUrl" />
</MudTd>
<MudTd DataLabel="Player Position">@context.Position</MudTd>
<MudTd DataLabel="Offering Team">@context.OfferingTeam</MudTd>
Expand Down
2 changes: 1 addition & 1 deletion src/Client/Features/Players/List.razor
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<MudIconButton Icon="@Icons.Material.Filled.MoneyOff" Color="Color.Error" Variant="Variant.Outlined" Size="Size.Small" Class="ma-2" OnClick="(e) => OpenAddFineDialog(context.Id)" />
</MudTd>
<MudTd DataLabel=@nameof(PlayerItem.Name)>
<PlayerNameWithHeadShot Name="@context.Name" HeadShotUrl="@context.HeadShotUrl" />
<NameWithImage Name="@context.Name" ImageUrl="@context.HeadShotUrl" />
</MudTd>
<MudTd DataLabel=@nameof(PlayerItem.Position)>@context.Position</MudTd>
<MudTd DataLabel=@nameof(PlayerItem.Team)>@context.Team</MudTd>
Expand Down
2 changes: 1 addition & 1 deletion src/Client/Features/Teams/List.razor
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ else
@foreach(var team in _result.Teams)
{
var detailHref = $"/teams/{team.Id}";
<MudItem lg=4 xs=12 Class=grow>
<MudItem lg=4 xs=12 Class="grow mx-auto">
<a href=@detailHref>
<MudCard>
<MudCardHeader Class="mud-card-header-override">
Expand Down
9 changes: 9 additions & 0 deletions src/Client/Shared/Components/NameWithImage.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="d-flex align-center">
<MudAvatar Image=@ImageUrl Class="mr-1"></MudAvatar>
@Name
</div>

@code {
[Parameter, EditorRequired] public string Name { get; set; } = string.Empty;
[Parameter, EditorRequired] public string ImageUrl { get; set; } = string.Empty;
}
9 changes: 0 additions & 9 deletions src/Client/Shared/Components/PlayerNameWithHeadShot.razor

This file was deleted.

Loading

0 comments on commit 8c2b7a2

Please sign in to comment.