- Implemented pagination for all tables to improve usability and navigation.

- Expanded the zombie siege table to display all waves survived by the entire alliance
This commit is contained in:
Tomasi - Developing 2025-01-28 12:05:50 +01:00
parent bb2dee0cf8
commit 19182e7b36
47 changed files with 494 additions and 159 deletions

View File

@ -34,17 +34,16 @@ namespace Api.Controllers.v1
}
[HttpGet("Alliance/{allianceId:guid}")]
public async Task<ActionResult<List<CustomEventDto>>> GetAllianceCustomEvents(Guid allianceId,
[FromQuery] int take, CancellationToken cancellationToken)
public async Task<ActionResult<List<CustomEventDto>>> GetAllianceCustomEvents(Guid allianceId, CancellationToken cancellationToken, [FromQuery] int pageNumber = 1, [FromQuery] int pageSize = 10)
{
try
{
var allianceCustomEventsResult =
await customEventRepository.GetAllianceCustomEventsAsync(allianceId, take, cancellationToken);
await customEventRepository.GetAllianceCustomEventsAsync(allianceId, pageNumber, pageSize, cancellationToken);
if (allianceCustomEventsResult.IsFailure) return BadRequest(allianceCustomEventsResult.Error);
return allianceCustomEventsResult.Value.Count > 0
return allianceCustomEventsResult.Value.Data.Count > 0
? Ok(allianceCustomEventsResult.Value)
: NoContent();
}

View File

@ -34,17 +34,16 @@ namespace Api.Controllers.v1
}
[HttpGet("Alliance/{allianceId:guid}")]
public async Task<ActionResult<List<DesertStormDto>>> GetAllianceDesertStorms(Guid allianceId,
[FromQuery] int take, CancellationToken cancellationToken)
public async Task<ActionResult<List<DesertStormDto>>> GetAllianceDesertStorms(Guid allianceId, CancellationToken cancellationToken, [FromQuery] int pageNumber = 1, [FromQuery] int pageSize = 10)
{
try
{
var allianceDesertStormsResult =
await desertStormRepository.GetAllianceDesertStormsAsync(allianceId, take, cancellationToken);
await desertStormRepository.GetAllianceDesertStormsAsync(allianceId, pageNumber, pageSize, cancellationToken);
if (allianceDesertStormsResult.IsFailure) return BadRequest(allianceDesertStormsResult.Error);
return allianceDesertStormsResult.Value.Count > 0
return allianceDesertStormsResult.Value.Data.Count > 0
? Ok(allianceDesertStormsResult.Value)
: NoContent();
}

View File

@ -34,17 +34,16 @@ namespace Api.Controllers.v1
}
[HttpGet("Alliance/{allianceId:guid}")]
public async Task<ActionResult<List<MarshalGuardDto>>> GetAllianceMarshalGuards(Guid allianceId, [FromQuery] int take,
CancellationToken cancellationToken)
public async Task<ActionResult<List<MarshalGuardDto>>> GetAllianceMarshalGuards(Guid allianceId, CancellationToken cancellationToken, [FromQuery] int pageNumber = 1, [FromQuery] int pageSize = 10)
{
try
{
var allianceMarshalGuardsResult =
await marshalGuardRepository.GetAllianceMarshalGuardsAsync(allianceId, take, cancellationToken);
await marshalGuardRepository.GetAllianceMarshalGuardsAsync(allianceId, pageNumber, pageSize, cancellationToken);
if (allianceMarshalGuardsResult.IsFailure) return BadRequest(allianceMarshalGuardsResult.Error);
return allianceMarshalGuardsResult.Value.Count > 0
return allianceMarshalGuardsResult.Value.Data.Count > 0
? Ok(allianceMarshalGuardsResult.Value)
: NoContent();
}

View File

@ -1,4 +1,5 @@
using Application.DataTransferObjects.ExcelImport;
using Application.DataTransferObjects;
using Application.DataTransferObjects.ExcelImport;
using Application.DataTransferObjects.Player;
using Application.Errors;
using Application.Interfaces;
@ -55,16 +56,16 @@ namespace Api.Controllers.v1
}
[HttpGet("Alliance/dismiss/{allianceId:guid}")]
public async Task<ActionResult<List<PlayerDto>>> GetAllianceDismissPlayers(Guid allianceId, CancellationToken cancellationToken)
public async Task<ActionResult<PagedResponseDto<PlayerDto>>> GetAllianceDismissPlayers(Guid allianceId, CancellationToken cancellationToken, [FromQuery] int pageNumber = 1, [FromQuery] int pageSize = 10)
{
try
{
var allianceDismissPlayersResult =
await playerRepository.GetAllianceDismissPlayersAsync(allianceId, cancellationToken);
await playerRepository.GetAllianceDismissPlayersAsync(allianceId, pageNumber, pageSize, cancellationToken);
if (allianceDismissPlayersResult.IsFailure) return BadRequest(allianceDismissPlayersResult.Error);
return allianceDismissPlayersResult.Value.Count > 0
return allianceDismissPlayersResult.Value.Data.Count > 0
? Ok(allianceDismissPlayersResult.Value)
: NoContent();
}

View File

@ -1,4 +1,5 @@
using Application.DataTransferObjects.VsDuel;
using Application.DataTransferObjects;
using Application.DataTransferObjects.VsDuel;
using Application.Errors;
using Application.Interfaces;
using Asp.Versioning;
@ -32,17 +33,16 @@ namespace Api.Controllers.v1
}
[HttpGet("Alliance/{allianceId:guid}")]
public async Task<ActionResult<List<VsDuelDto>>> GetAllianceVsDuels(Guid allianceId, [FromQuery] int take,
CancellationToken cancellationToken)
public async Task<ActionResult<PagedResponseDto<VsDuelDto>>> GetAllianceVsDuels(Guid allianceId, CancellationToken cancellationToken, [FromQuery] int pageNumber = 1, [FromQuery] int pageSize = 10)
{
try
{
var allianceVsDuelsResult =
await vsDuelRepository.GetAllianceVsDuelsAsync(allianceId, take, cancellationToken);
await vsDuelRepository.GetAllianceVsDuelsAsync(allianceId, pageNumber, pageSize, cancellationToken);
if (allianceVsDuelsResult.IsFailure) return BadRequest(allianceVsDuelsResult.Error);
return allianceVsDuelsResult.Value.Count > 0
return allianceVsDuelsResult.Value.Data.Count > 0
? Ok(allianceVsDuelsResult.Value)
: NoContent();
}

View File

@ -1,4 +1,5 @@
using Application.DataTransferObjects.ZombieSiege;
using Application.DataTransferObjects;
using Application.DataTransferObjects.ZombieSiege;
using Application.Errors;
using Application.Interfaces;
using Asp.Versioning;
@ -34,17 +35,17 @@ namespace Api.Controllers.v1
}
[HttpGet("Alliance/{allianceId:guid}")]
public async Task<ActionResult<List<ZombieSiegeDto>>> GetAllianceZombieSieges(Guid allianceId, [FromQuery] int take,
CancellationToken cancellationToken)
public async Task<ActionResult<PagedResponseDto<ZombieSiegeDto>>> GetAllianceZombieSieges(Guid allianceId, CancellationToken cancellationToken, [FromQuery] int pageNumber = 1, [FromQuery] int pageSize = 10)
{
try
{
var allianceZombieSiegesResult =
await zombieSiegeRepository.GetAllianceZombieSiegesAsync(allianceId, take, cancellationToken);
await zombieSiegeRepository.GetAllianceZombieSiegesAsync(allianceId, pageNumber, pageSize,
cancellationToken);
if (allianceZombieSiegesResult.IsFailure) return BadRequest(allianceZombieSiegesResult.Error);
return allianceZombieSiegesResult.Value.Count > 0
return allianceZombieSiegesResult.Value.TotalRecords > 0
? Ok(allianceZombieSiegesResult.Value)
: NoContent();
}

View File

@ -0,0 +1,12 @@
namespace Application.DataTransferObjects;
public class PagedResponseDto<T>
{
public int TotalRecords { get; set; }
public int PageSize { get; set; }
public int PageNumber { get; set; }
public List<T> Data { get; set; } = [];
}

View File

@ -8,6 +8,8 @@ public class ZombieSiegeDto
public int TotalLevel20Players { get; set; }
public int TotalWavesSurvived { get; set; }
public Guid AllianceId { get; set; }
public DateTime EventDate { get; set; }

View File

@ -1,4 +1,5 @@
using Application.Classes;
using Application.DataTransferObjects;
using Application.DataTransferObjects.CustomEvent;
namespace Application.Interfaces;
@ -9,7 +10,7 @@ public interface ICustomEventRepository
Task<Result<CustomEventDetailDto>> GetCustomEventDetailAsync(Guid customEventId, CancellationToken cancellationToken);
Task<Result<List<CustomEventDto>>> GetAllianceCustomEventsAsync(Guid allianceId, int take, CancellationToken cancellationToken);
Task<Result<PagedResponseDto<CustomEventDto>>> GetAllianceCustomEventsAsync(Guid allianceId, int pageNumber, int pageSize, CancellationToken cancellationToken);
Task<Result<CustomEventDto>> CreateCustomEventAsync(CreateCustomEventDto createCustomEventDto, string createdBy,
CancellationToken cancellationToken);

View File

@ -1,4 +1,5 @@
using Application.Classes;
using Application.DataTransferObjects;
using Application.DataTransferObjects.DesertStorm;
namespace Application.Interfaces;
@ -7,7 +8,7 @@ public interface IDesertStormRepository
{
Task<Result<DesertStormDto>> GetDesertStormAsync(Guid desertStormId, CancellationToken cancellationToken);
Task<Result<List<DesertStormDto>>> GetAllianceDesertStormsAsync(Guid allianceId, int take, CancellationToken cancellationToken);
Task<Result<PagedResponseDto<DesertStormDto>>> GetAllianceDesertStormsAsync(Guid allianceId, int pageNumber, int pageSize, CancellationToken cancellationToken);
Task<Result<DesertStormDetailDto>> GetDesertStormDetailAsync(Guid desertStormId, CancellationToken cancellationToken);

View File

@ -1,4 +1,5 @@
using Application.Classes;
using Application.DataTransferObjects;
using Application.DataTransferObjects.MarshalGuard;
namespace Application.Interfaces;
@ -9,7 +10,7 @@ public interface IMarshalGuardRepository
Task<Result<MarshalGuardDetailDto>> GetMarshalGuardDetailAsync(Guid marshalGuardId, CancellationToken cancellationToken);
Task<Result<List<MarshalGuardDto>>> GetAllianceMarshalGuardsAsync(Guid allianceId, int take, CancellationToken cancellationToken);
Task<Result<PagedResponseDto<MarshalGuardDto>>> GetAllianceMarshalGuardsAsync(Guid allianceId, int pageNumber, int pageSize, CancellationToken cancellationToken);
Task<Result<MarshalGuardDto>> CreateMarshalGuardsAsync(CreateMarshalGuardDto createMarshalGuardDto, string createdBy, CancellationToken cancellationToken);

View File

@ -1,4 +1,5 @@
using Application.Classes;
using Application.DataTransferObjects;
using Application.DataTransferObjects.Player;
namespace Application.Interfaces;
@ -9,7 +10,7 @@ public interface IPlayerRepository
Task<Result<List<PlayerDto>>> GetAlliancePlayersAsync(Guid allianceId, CancellationToken cancellationToken);
Task<Result<List<PlayerDto>>> GetAllianceDismissPlayersAsync(Guid allianceId, CancellationToken cancellationToken);
Task<Result<PagedResponseDto<PlayerDto>>> GetAllianceDismissPlayersAsync(Guid allianceId, int pageNumber, int pageSize, CancellationToken cancellationToken);
Task<Result<List<PlayerMvpDto>>> GetAlliancePlayersMvp(Guid allianceId, CancellationToken cancellationToken);

View File

@ -1,4 +1,5 @@
using Application.Classes;
using Application.DataTransferObjects;
using Application.DataTransferObjects.VsDuel;
namespace Application.Interfaces;
@ -9,7 +10,7 @@ public interface IVsDuelRepository
Task<Result<VsDuelDetailDto>> GetVsDuelDetailAsync(Guid vsDuelId, CancellationToken cancellationToken);
Task<Result<List<VsDuelDto>>> GetAllianceVsDuelsAsync(Guid allianceId, int take, CancellationToken cancellationToken);
Task<Result<PagedResponseDto<VsDuelDto>>> GetAllianceVsDuelsAsync(Guid allianceId, int pageNumber, int pageSize, CancellationToken cancellationToken);
Task<Result<VsDuelDto>> CreateVsDuelAsync(CreateVsDuelDto createVsDuelDto, string createdBy, CancellationToken cancellationToken);

View File

@ -1,4 +1,5 @@
using Application.Classes;
using Application.DataTransferObjects;
using Application.DataTransferObjects.ZombieSiege;
namespace Application.Interfaces;
@ -9,7 +10,7 @@ public interface IZombieSiegeRepository
Task<Result<ZombieSiegeDetailDto>> GetZombieSiegeDetailAsync(Guid zombieSiegeId, CancellationToken cancellationToken);
Task<Result<List<ZombieSiegeDto>>> GetAllianceZombieSiegesAsync(Guid allianceId, int take, CancellationToken cancellationToken);
Task<Result<PagedResponseDto<ZombieSiegeDto>>> GetAllianceZombieSiegesAsync(Guid allianceId, int pageNumber, int pageSize, CancellationToken cancellationToken);
Task<Result<ZombieSiegeDto>> CreateZombieSiegeAsync(CreateZombieSiegeDto createZombieSiegeDto, string createdBy, CancellationToken cancellationToken);

View File

@ -9,10 +9,14 @@ public class ZombieSiegeProfile : Profile
public ZombieSiegeProfile()
{
CreateMap<ZombieSiege, ZombieSiegeDto>()
.ForMember(des => des.TotalWavesSurvived,
opt => opt.MapFrom(scr => scr.ZombieSiegeParticipants.Sum(p => p.SurvivedWaves)))
.ForMember(des => des.TotalLevel20Players,
opt => opt.MapFrom(src => src.ZombieSiegeParticipants.Count(p => p.SurvivedWaves == 20)));
CreateMap<ZombieSiege, ZombieSiegeDetailDto>()
.ForMember(des => des.TotalWavesSurvived,
opt => opt.MapFrom(scr => scr.ZombieSiegeParticipants.Sum(p => p.SurvivedWaves)))
.ForMember(des => des.TotalLevel20Players,
opt => opt.MapFrom(src => src.ZombieSiegeParticipants.Count(p => p.SurvivedWaves == 20)));

View File

@ -1,4 +1,5 @@
using Application.Classes;
using Application.DataTransferObjects;
using Application.DataTransferObjects.CustomEvent;
using Application.Errors;
using Application.Interfaces;
@ -37,17 +38,28 @@ public class CustomEventRepository(ApplicationContext context, IMapper mapper, I
: Result.Success(customEventDetail);
}
public async Task<Result<List<CustomEventDto>>> GetAllianceCustomEventsAsync(Guid allianceId, int take, CancellationToken cancellationToken)
public async Task<Result<PagedResponseDto<CustomEventDto>>> GetAllianceCustomEventsAsync(Guid allianceId, int pageNumber, int pageSize, CancellationToken cancellationToken)
{
var allianceCustomEvents = await context.CustomEvents
var query = context.CustomEvents
.Where(customEvent => customEvent.AllianceId == allianceId)
.ProjectTo<CustomEventDto>(mapper.ConfigurationProvider)
.AsNoTracking()
.OrderByDescending(customEvent => customEvent.EventDate)
.Take(take)
.AsNoTracking();
var totalRecord = await query.CountAsync(cancellationToken);
var pagedCustomEvents = await query
.Skip((pageNumber - 1) * pageSize)
.Take(pageSize)
.ProjectTo<CustomEventDto>(mapper.ConfigurationProvider)
.ToListAsync(cancellationToken);
return Result.Success(allianceCustomEvents);
return Result.Success(new PagedResponseDto<CustomEventDto>
{
Data = pagedCustomEvents,
TotalRecords = totalRecord,
PageSize = pageSize,
PageNumber = pageNumber
});
}
public async Task<Result<CustomEventDto>> CreateCustomEventAsync(CreateCustomEventDto createCustomEventDto, string createdBy,

View File

@ -1,4 +1,5 @@
using Application.Classes;
using Application.DataTransferObjects;
using Application.DataTransferObjects.DesertStorm;
using Application.Errors;
using Application.Interfaces;
@ -25,17 +26,28 @@ public class DesertStormRepository(ApplicationContext context, IMapper mapper, I
: Result.Success(desertStormById);
}
public async Task<Result<List<DesertStormDto>>> GetAllianceDesertStormsAsync(Guid allianceId, int take, CancellationToken cancellationToken)
public async Task<Result<PagedResponseDto<DesertStormDto>>> GetAllianceDesertStormsAsync(Guid allianceId, int pageNumber, int pageSize, CancellationToken cancellationToken)
{
var allianceDesertStorms = await context.DesertStorms
var query = context.DesertStorms
.Where(desertStorm => desertStorm.AllianceId == allianceId)
.ProjectTo<DesertStormDto>(mapper.ConfigurationProvider)
.AsNoTracking()
.OrderByDescending(desertStorm => desertStorm.EventDate)
.Take(take)
.AsNoTracking();
var totalRecord = await query.CountAsync(cancellationToken);
var pagedDesertStorms = await query
.Skip((pageNumber - 1) * pageSize)
.Take(pageSize)
.ProjectTo<DesertStormDto>(mapper.ConfigurationProvider)
.ToListAsync(cancellationToken);
return Result.Success(allianceDesertStorms);
return Result.Success(new PagedResponseDto<DesertStormDto>
{
Data = pagedDesertStorms,
TotalRecords = totalRecord,
PageSize = pageSize,
PageNumber = pageNumber
});
}
public async Task<Result<DesertStormDetailDto>> GetDesertStormDetailAsync(Guid desertStormId, CancellationToken cancellationToken)

View File

@ -1,4 +1,5 @@
using Application.Classes;
using Application.DataTransferObjects;
using Application.DataTransferObjects.MarshalGuard;
using Application.Errors;
using Application.Interfaces;
@ -37,17 +38,28 @@ public class MarshalGuardRepository(ApplicationContext context, IMapper mapper,
: Result.Success(detailMarshalGuard);
}
public async Task<Result<List<MarshalGuardDto>>> GetAllianceMarshalGuardsAsync(Guid allianceId, int take, CancellationToken cancellationToken)
public async Task<Result<PagedResponseDto<MarshalGuardDto>>> GetAllianceMarshalGuardsAsync(Guid allianceId, int pageNumber, int pageSize, CancellationToken cancellationToken)
{
var allianceMarshalGuards = await context.MarshalGuards
var query = context.MarshalGuards
.Where(marshalGuard => marshalGuard.AllianceId == allianceId)
.OrderByDescending(marshalGuard => marshalGuard.EventDate)
.AsNoTracking();
var totalRecord = await query.CountAsync(cancellationToken);
var pagedMarshalGuards = await query
.Skip((pageNumber - 1) * pageSize)
.Take(pageSize)
.ProjectTo<MarshalGuardDto>(mapper.ConfigurationProvider)
.AsNoTracking()
.Take(take)
.ToListAsync(cancellationToken);
return Result.Success(allianceMarshalGuards);
return Result.Success(new PagedResponseDto<MarshalGuardDto>
{
Data = pagedMarshalGuards,
TotalRecords = totalRecord,
PageSize = pageSize,
PageNumber = pageNumber
});
}

View File

@ -1,4 +1,5 @@
using Application.Classes;
using Application.DataTransferObjects;
using Application.DataTransferObjects.Player;
using Application.Errors;
using Application.Interfaces;
@ -36,16 +37,30 @@ public class PlayerRepository(ApplicationContext context, IMapper mapper, ILogge
return Result.Success(alliancePlayers);
}
public async Task<Result<List<PlayerDto>>> GetAllianceDismissPlayersAsync(Guid allianceId, CancellationToken cancellationToken)
public async Task<Result<PagedResponseDto<PlayerDto>>> GetAllianceDismissPlayersAsync(Guid allianceId, int pageNumber, int pageSize, CancellationToken cancellationToken)
{
var dismissAlliancePlayers = await context.Players
var query = context.Players
.IgnoreQueryFilters()
.ProjectTo<PlayerDto>(mapper.ConfigurationProvider)
.AsNoTracking()
.Where(player => player.AllianceId == allianceId && player.IsDismissed)
.OrderByDescending(player => player.DismissedAt)
.AsNoTracking();
var totalRecord = await query.CountAsync(cancellationToken);
var pagedDismissPlayers = await query
.Skip((pageNumber - 1) * pageSize)
.Take(pageSize)
.ProjectTo<PlayerDto>(mapper.ConfigurationProvider)
.ToListAsync(cancellationToken);
return Result.Success(dismissAlliancePlayers);
return Result.Success(new PagedResponseDto<PlayerDto>
{
Data = pagedDismissPlayers,
TotalRecords = totalRecord,
PageSize = pageSize,
PageNumber = pageNumber
});
}
public async Task<Result<List<PlayerMvpDto>>> GetAlliancePlayersMvp(Guid allianceId, CancellationToken cancellationToken)

View File

@ -1,4 +1,5 @@
using Application.Classes;
using Application.DataTransferObjects;
using Application.DataTransferObjects.VsDuel;
using Application.Errors;
using Application.Interfaces;
@ -37,17 +38,28 @@ public class VsDuelRepository(ApplicationContext context, IMapper mapper, ILogge
: Result.Success(vsDuelDetail);
}
public async Task<Result<List<VsDuelDto>>> GetAllianceVsDuelsAsync(Guid allianceId, int take, CancellationToken cancellationToken)
public async Task<Result<PagedResponseDto<VsDuelDto>>> GetAllianceVsDuelsAsync(Guid allianceId, int pageNumber, int pageSize, CancellationToken cancellationToken)
{
var allianceVsDuels = await context.VsDuels
var query = context.VsDuels
.Where(vsDuel => vsDuel.AllianceId == allianceId)
.ProjectTo<VsDuelDto>(mapper.ConfigurationProvider)
.OrderByDescending(vsDuel => vsDuel.EventDate)
.Take(take)
.AsNoTracking()
.AsNoTracking();
var totalRecord = await query.CountAsync(cancellationToken);
var pagedVsDuels = await query
.Skip((pageNumber - 1) * pageSize)
.Take(pageSize)
.ProjectTo<VsDuelDto>(mapper.ConfigurationProvider)
.ToListAsync(cancellationToken);
return Result.Success(allianceVsDuels);
return Result.Success(new PagedResponseDto<VsDuelDto>
{
Data = pagedVsDuels,
TotalRecords = totalRecord,
PageSize = pageSize,
PageNumber = pageNumber
});
}
public async Task<Result<VsDuelDto>> CreateVsDuelAsync(CreateVsDuelDto createVsDuelDto, string createdBy, CancellationToken cancellationToken)

View File

@ -1,4 +1,5 @@
using Application.Classes;
using Application.DataTransferObjects;
using Application.DataTransferObjects.ZombieSiege;
using Application.Errors;
using Application.Interfaces;
@ -37,17 +38,28 @@ public class ZombieSiegeRepository(ApplicationContext context, IMapper mapper, I
: Result.Success(zombieSiegeDetail);
}
public async Task<Result<List<ZombieSiegeDto>>> GetAllianceZombieSiegesAsync(Guid allianceId, int take, CancellationToken cancellationToken)
public async Task<Result<PagedResponseDto<ZombieSiegeDto>>> GetAllianceZombieSiegesAsync(Guid allianceId, int pageNumber, int pageSize, CancellationToken cancellationToken)
{
var allianceZombieSieges = await context.ZombieSieges
var query = context.ZombieSieges
.Where(zombieSiege => zombieSiege.AllianceId == allianceId)
.OrderByDescending(zombieSiege => zombieSiege.EventDate)
.AsNoTracking();
var totalRecord = await query.CountAsync(cancellationToken);
var pagedZombieSieges = await query
.Skip((pageNumber - 1) * pageSize)
.Take(pageSize)
.ProjectTo<ZombieSiegeDto>(mapper.ConfigurationProvider)
.AsNoTracking()
.Take(take)
.ToListAsync(cancellationToken);
return Result.Success(allianceZombieSieges);
return Result.Success(new PagedResponseDto<ZombieSiegeDto>
{
Data = pagedZombieSieges,
TotalRecords = totalRecord,
PageSize = pageSize,
PageNumber = pageNumber
});
}
public async Task<Result<ZombieSiegeDto>> CreateZombieSiegeAsync(CreateZombieSiegeDto createZombieSiegeDto, string createdBy,

View File

@ -6,6 +6,14 @@ This project is currently in the **Beta Phase**.
---
### **[0.6.0-beta]** - *2025-01-28*
#### ✨ Added
- **Pagination**: Implemented and adjusted for all tables.
- **Zombie Siege**: Expanded the table to display all waves survived by the entire alliance.
#### 🛠️ Fixed
- *(N/A)*
### **[0.5.1-beta]** - *2025-01-27*
#### ✨ Added
- *(N/A)*

View File

@ -0,0 +1,6 @@
export interface PagedResponseModel<T> {
totalRecords: number;
pageNumber: number;
pageSize: number;
data: T[]
}

View File

@ -10,6 +10,7 @@ export interface ZombieSiegeModel {
allianceSize: number;
level: number;
totalLevel20Players: number;
totalWavesSurvived: number;
}
export interface ZombieSiegeDetailModel extends ZombieSiegeModel{

View File

@ -115,7 +115,7 @@
</tr>
</thead>
<tbody>
@for (customEvent of customEvents; track customEvent.id) {
@for (customEvent of customEvents | paginate: { id: 'customEventTable', itemsPerPage: pageSize, totalItems: totalRecord, currentPage: pageNumber}; track customEvent.id) {
<tr>
<td>{{customEvent.eventDate | date: 'dd.MM.yyyy'}}</td>
<td>{{customEvent.name}}</td>
@ -145,6 +145,20 @@
</tbody>
</table>
</div>
<!-- Pagination Controls -->
<div class="d-flex justify-content-between mt-3 flex-column flex-md-row">
<pagination-controls class="custom-pagination" [id]="'customEventTable'" [responsive]="true" [autoHide]=" true"
(pageChange)="pageChanged($event)"></pagination-controls>
<!-- Showing total results with improved styling -->
<div class="align-self-center text-muted mt-2 mt-md-0">
<small>
Showing
<strong>{{ (pageNumber - 1) * pageSize + 1 }} - {{ pageNumber * pageSize > totalRecord ? totalRecord : pageNumber * pageSize }}</strong>
of <strong>{{ totalRecord }}</strong> results
</small>
</div>
</div>
} @else {
<div class="alert alert-secondary text-center mt-5" role="alert">
No saved custom events

View File

@ -37,20 +37,25 @@ export class CustomEventComponent implements OnInit {
private readonly _toastr: ToastrService = inject(ToastrService);
private allianceId: string = this._tokenService.getAllianceId()!;
public totalRecord: number = 0;
public pageNumber: number = 1;
public pageSize: number = 10
get f() {
return this.customEventForm.controls;
}
ngOnInit() {
this.getCustomEvents(10);
this.getCustomEvents();
}
getCustomEvents(take: number) {
getCustomEvents() {
this.customEvents = [];
this._customEventService.getAllianceCustomEvents(this.allianceId, take).subscribe({
next: ((response: CustomEventModel[]) => {
this._customEventService.getAllianceCustomEvents(this.allianceId, this.pageNumber, this.pageSize).subscribe({
next: ((response) => {
if (response) {
this.customEvents = response;
this.customEvents = response.data;
this.totalRecord = response.totalRecords;
}
}),
error: (error) => {
@ -150,7 +155,7 @@ export class CustomEventComponent implements OnInit {
next: (() => {
this.playerParticipated = [];
this.onCancel();
this.getCustomEvents(10);
this.resetAndGetCustomEvents();
}),
error: (error) => {
console.log(error);
@ -194,7 +199,7 @@ export class CustomEventComponent implements OnInit {
title: "Deleted!",
text: "Custom event has been deleted",
icon: "success"
}).then(_ => this.getCustomEvents(10));
}).then(_ => this.resetAndGetCustomEvents());
}
}),
error: (error: Error) => {
@ -235,7 +240,7 @@ export class CustomEventComponent implements OnInit {
if (participantsToUpdate.length <= 0) {
this._toastr.success('Successfully updated!', 'Successfully');
this.onCancel();
this.getCustomEvents(10);
this.resetAndGetCustomEvents();
return;
}
@ -249,9 +254,19 @@ export class CustomEventComponent implements OnInit {
if (response) {
this._toastr.success('Successfully updated!', 'Successfully');
this.onCancel();
this.getCustomEvents(10);
this.resetAndGetCustomEvents();
}
})
})
}
pageChanged(event: number) {
this.pageNumber = event;
this.getCustomEvents();
}
resetAndGetCustomEvents() {
this.pageNumber = 1;
this.getCustomEvents();
}
}

View File

@ -127,7 +127,7 @@
</tr>
</thead>
<tbody>
@for (desertStorm of desertStorms; track desertStorm.id) {
@for (desertStorm of desertStorms | paginate: { id: 'desertStormTable', itemsPerPage: pageSize, totalItems: totalRecord, currentPage: pageNumber}; track desertStorm.id) {
<tr>
<td>{{desertStorm.eventDate | date: 'dd.MM.yyyy'}}</td>
<td>{{desertStorm.opponentName}}</td>
@ -153,6 +153,20 @@
</tbody>
</table>
</div>
<!-- Pagination Controls -->
<div class="d-flex justify-content-between mt-3 flex-column flex-md-row">
<pagination-controls class="custom-pagination" [id]="'desertStormTable'" [responsive]="true" [autoHide]=" true"
(pageChange)="pageChanged($event)"></pagination-controls>
<!-- Showing total results with improved styling -->
<div class="align-self-center text-muted mt-2 mt-md-0">
<small>
Showing
<strong>{{ (pageNumber - 1) * pageSize + 1 }} - {{ pageNumber * pageSize > totalRecord ? totalRecord : pageNumber * pageSize }}</strong>
of <strong>{{ totalRecord }}</strong> results
</small>
</div>
</div>
} @else {
<div class="alert alert-secondary text-center mt-5" role="alert">
No saved Desert storm events

View File

@ -33,6 +33,8 @@ export class DesertStormComponent implements OnInit {
private readonly _modalService: NgbModal = inject(NgbModal);
private readonly _toastr: ToastrService = inject(ToastrService);
private allianceId: string = this._tokenService.getAllianceId()!;
isCreateDessertStorm: boolean = false;
public desertStorms: DesertStormModel[] = [];
currentDate: Date = new Date();
@ -44,24 +46,29 @@ export class DesertStormComponent implements OnInit {
desertStormForm!: FormGroup;
isUpdate: boolean = false;
public totalRecord: number = 0;
public pageNumber: number = 1;
public pageSize: number = 10;
get f() {
return this.desertStormForm.controls;
}
ngOnInit() {
this.getDesertStorms(10);
this.getDesertStorms();
}
getDesertStorms(take: number) {
this._desertStormService.getAllianceDesertStorms(this._tokenService.getAllianceId()!, take).subscribe({
getDesertStorms() {
this._desertStormService.getAllianceDesertStorms(this.allianceId, this.pageNumber, this.pageSize).subscribe({
next: (response) => {
if (response) {
response.forEach((desertStorm: DesertStormModel) => {
response.data.forEach((desertStorm: DesertStormModel) => {
if (this._weekPipe.transform(desertStorm.eventDate) === this._weekPipe.transform(new Date())) {
this.currentWeekDuelExists = true;
}
})
this.desertStorms = response;
this.desertStorms = response.data;
this.totalRecord = response.totalRecords;
} else {
this.desertStorms = [];
this.currentWeekDuelExists = false;
@ -130,7 +137,7 @@ export class DesertStormComponent implements OnInit {
title: "Deleted!",
text: "Desert storm has been deleted",
icon: "success"
}).then(_ => this.getDesertStorms(10));
}).then(_ => this.resetAndGetDesertStorms());
}
}),
error: (error: Error) => {
@ -188,7 +195,7 @@ export class DesertStormComponent implements OnInit {
next: (() => {
this._toastr.success('Successfully created!', 'Successfully');
this.onCancel();
this.getDesertStorms(10);
this.resetAndGetDesertStorms();
})
})
}
@ -234,7 +241,7 @@ export class DesertStormComponent implements OnInit {
if (desertStormParticipants.length <= 0) {
this._toastr.success('Successfully updated!', 'Successfully');
this.onCancel();
this.getDesertStorms(10);
this.resetAndGetDesertStorms();
return;
}
const requests: Observable<DesertStormParticipantModel>[] = [];
@ -248,9 +255,19 @@ export class DesertStormComponent implements OnInit {
if (response) {
this._toastr.success('Successfully updated!', 'Successfully');
this.onCancel();
this.getDesertStorms(10);
this.resetAndGetDesertStorms();
}
})
})
}
pageChanged(event: number) {
this.pageNumber = event;
this.getDesertStorms();
}
resetAndGetDesertStorms() {
this.pageNumber = 1;
this.getDesertStorms();
}
}

View File

@ -14,7 +14,7 @@
</tr>
</thead>
<tbody>
@for (player of dismissedPlayers | paginate: { itemsPerPage: itemsPerPage, currentPage: page, id: 'dismissedTable'}; track player.id) {
@for (player of dismissedPlayers | paginate: { totalItems: totalRecord, itemsPerPage: pageSize, currentPage: pageNumber, id: 'dismissedTable'}; track player.id) {
<tr>
<td>{{player.playerName}}</td>
<td>{{player.dismissedAt | date: 'dd.MM.yyyy'}}</td>
@ -32,8 +32,20 @@
</tbody>
</table>
</div>
<!-- Pagination Controls -->
<div class="d-flex justify-content-between mt-3 flex-column flex-md-row">
<pagination-controls class="custom-pagination" [id]="'dismissedTable'" [responsive]="true" [autoHide]=" true"
(pageChange)="pageChanged($event)"></pagination-controls>
<pagination-controls class="custom-pagination" [responsive]="true" [id]="'dismissedTable'" (pageChange)="page = $event"></pagination-controls>
<!-- Showing total results with improved styling -->
<div class="align-self-center text-muted mt-2 mt-md-0">
<small>
Showing
<strong>{{ (pageNumber - 1) * pageSize + 1 }} - {{ pageNumber * pageSize > totalRecord ? totalRecord : pageNumber * pageSize }}</strong>
of <strong>{{ totalRecord }}</strong> results
</small>
</div>
</div>
} @else {
<div class="alert alert-secondary text-center mt-5" role="alert">
No dismissed players

View File

@ -26,8 +26,10 @@ export class DismissPlayerComponent implements OnInit {
private allianceId: string = this._tokenService.getAllianceId()!;
public dismissedPlayers: PlayerModel[] = [];
itemsPerPage: string | number = 10;
page: string | number = 1;
public totalRecord: number = 0;
public pageNumber: number = 1;
public pageSize: number = 10;
@ -36,10 +38,11 @@ export class DismissPlayerComponent implements OnInit {
}
getDismissedPlayers() {
this._playerService.getDismissedPlayers(this.allianceId).subscribe({
this._playerService.getDismissedPlayers(this.allianceId, this.pageNumber, this.pageSize).subscribe({
next: ((response) => {
if (response) {
this.dismissedPlayers = response;
this.dismissedPlayers = response.data;
this.totalRecord = response.totalRecords;
} else {
this.dismissedPlayers = [];
}
@ -114,4 +117,9 @@ export class DismissPlayerComponent implements OnInit {
{animation: true, backdrop: true, centered: true, size: 'lg', scrollable: true});
modalRef.componentInstance.playerId = player.id;
}
pageChanged(event: number) {
this.pageNumber = event;
this.getDismissedPlayers();
}
}

View File

@ -89,7 +89,7 @@
</tr>
</thead>
<tbody>
@for (marshalGuard of marshalGuards; track marshalGuard.id) {
@for (marshalGuard of marshalGuards | paginate: { id: 'marshalGuardTable', itemsPerPage: pageSize, totalItems: totalRecord, currentPage: pageNumber}; track marshalGuard.id) {
<tr>
<td>{{marshalGuard.eventDate | date: 'dd.MM.yyyy'}}</td>
<td>{{marshalGuard.level}}</td>
@ -120,6 +120,20 @@
</tbody>
</table>
</div>
<!-- Pagination Controls -->
<div class="d-flex justify-content-between mt-3 flex-column flex-md-row">
<pagination-controls class="custom-pagination" [id]="'marshalGuardTable'" [responsive]="true" [autoHide]=" true"
(pageChange)="pageChanged($event)"></pagination-controls>
<!-- Showing total results with improved styling -->
<div class="align-self-center text-muted mt-2 mt-md-0">
<small>
Showing
<strong>{{ (pageNumber - 1) * pageSize + 1 }} - {{ pageNumber * pageSize > totalRecord ? totalRecord : pageNumber * pageSize }}</strong>
of <strong>{{ totalRecord }}</strong> results
</small>
</div>
</div>
} @else {
<div class="alert alert-secondary text-center mt-5" role="alert">
No saved marshal guards

View File

@ -50,6 +50,10 @@ export class MarshalGuardComponent implements OnInit {
public playerSelected: boolean = false;
public marshalGuards: MarshalGuardModel[] = [];
public totalRecord: number = 0;
public pageNumber: number = 1;
public pageSize: number = 10;
private allianceId: string = this._tokenService.getAllianceId()!;
get f() {
@ -57,14 +61,15 @@ export class MarshalGuardComponent implements OnInit {
}
ngOnInit() {
this.getMarshalGuards(10);
this.getMarshalGuards();
}
public getMarshalGuards(take: number) {
this._marshalGuardService.getAllianceMarshalGuards(this.allianceId, take).subscribe({
public getMarshalGuards() {
this._marshalGuardService.getAllianceMarshalGuards(this.allianceId, this.pageNumber, this.pageSize).subscribe({
next: ((response) => {
if (response) {
this.marshalGuards = response;
this.marshalGuards = response.data;
this.totalRecord = response.totalRecords;
} else {
this.marshalGuards = [];
}
@ -185,7 +190,7 @@ export class MarshalGuardComponent implements OnInit {
this._marshalGuardParticipantService.insertMarshalGuardOParticipants(marshalGuardParticipants).subscribe({
next: (() => {
this.onCancel();
this.getMarshalGuards(10);
this.resetAndGetMarshalGuard();
this.playerParticipated = [];
})
})
@ -234,7 +239,7 @@ export class MarshalGuardComponent implements OnInit {
private updateMarshalGuardParticipants() {
if (this.participantToUpdate.length <= 0) {
this.onCancel();
this.getMarshalGuards(10);
this.resetAndGetMarshalGuard();
this.playerParticipated = [];
this.participantToUpdate = [];
this._toastr.success('Successfully updated marshalGuard', 'Update marshalGuard')
@ -250,7 +255,7 @@ export class MarshalGuardComponent implements OnInit {
next: ((response) => {
if (response) {
this.onCancel();
this.getMarshalGuards(10);
this.resetAndGetMarshalGuard();
this.playerParticipated = [];
this.participantToUpdate = [];
this._toastr.success('Successfully updated marshalGuard', 'Update marshalGuard');
@ -290,7 +295,7 @@ export class MarshalGuardComponent implements OnInit {
title: "Deleted!",
text: "Marshal guards has been deleted",
icon: "success"
}).then(_ => this.getMarshalGuards(10));
}).then(_ => this.resetAndGetMarshalGuard());
}
}),
error: (error: Error) => {
@ -304,4 +309,14 @@ export class MarshalGuardComponent implements OnInit {
onGoToMarshalGuardDetail(marshalGuard: MarshalGuardModel) {
this._router.navigate(['marshal-guard-detail', marshalGuard.id]).then();
}
resetAndGetMarshalGuard() {
this.pageNumber = 1;
this.getMarshalGuards();
}
pageChanged(event: number) {
this.pageNumber = event;
this.getMarshalGuards();
}
}

View File

@ -50,7 +50,7 @@
</tr>
</thead>
<tbody>
@for (player of filteredPlayers | paginate: { itemsPerPage: itemsPerPage, currentPage: page, id: 'playerTable'}; track player.id) {
@for (player of filteredPlayers | paginate: { itemsPerPage: pageSize, currentPage: pageNumber, id: 'playerTable'}; track player.id) {
<tr>
<td>
<div class="row">
@ -75,8 +75,20 @@
</tbody>
</table>
</div>
<!-- Pagination Controls -->
<div class="d-flex justify-content-between mt-3 flex-column flex-md-row">
<pagination-controls class="custom-pagination" [id]="'playerTable'" [responsive]="true" [autoHide]=" true"
(pageChange)="pageNumber = $event"></pagination-controls>
<pagination-controls class="custom-pagination" [responsive]="true" [id]="'playerTable'" (pageChange)="page = $event"></pagination-controls>
<!-- Showing total results with improved styling -->
<div class="align-self-center text-muted mt-2 mt-md-0">
<small>
Showing
<strong>{{ (pageNumber - 1) * pageSize + 1 }} - {{ pageNumber * pageSize > players.length ? players.length : pageNumber * pageSize }}</strong>
of <strong>{{ players.length }}</strong> results
</small>
</div>
</div>
} @else {
<div class="alert alert-secondary text-center mt-5" role="alert">
No registered players

View File

@ -39,8 +39,9 @@ export class PlayerComponent implements OnInit {
public r3Players: PlayerModel[] = [];
public r4Players: PlayerModel[] = [];
public filteredPlayers: PlayerModel[] = [];
public page: number = 1;
public itemsPerPage: number = 10;
public pageNumber: number = 1;
public pageSize: number = 10;
public filter = new FormControl('', { nonNullable: true });

View File

@ -36,7 +36,7 @@
</tr>
</thead>
<tbody>
@for (vsDuel of vsDuels | paginate: { itemsPerPage: 10, currentPage: page, id: 'vsDuelTable'}; track vsDuel.id) {
@for (vsDuel of vsDuels | paginate: { id: 'vsDuelTable', itemsPerPage: pageSize, totalItems: totalRecord, currentPage: pageNumber}; track vsDuel.id) {
<tr>
<td>{{vsDuel.eventDate | date: 'yyyy'}}</td>
<td>{{vsDuel.eventDate | week}}</td>
@ -73,7 +73,20 @@
}
</tbody>
</table>
<pagination-controls class="custom-pagination" [responsive]="true" [id]="'vsDuelTable'" (pageChange)="page = $event"></pagination-controls>
</div>
<!-- Pagination Controls -->
<div class="d-flex justify-content-between mt-3 flex-column flex-md-row">
<pagination-controls class="custom-pagination" [id]="'marshalGuardTable'" [responsive]="true" [autoHide]=" true"
(pageChange)="pageChanged($event)"></pagination-controls>
<!-- Showing total results with improved styling -->
<div class="align-self-center text-muted mt-2 mt-md-0">
<small>
Showing
<strong>{{ (pageNumber - 1) * pageSize + 1 }} - {{ pageNumber * pageSize > totalRecord ? totalRecord : pageNumber * pageSize }}</strong>
of <strong>{{ totalRecord }}</strong> results
</small>
</div>
</div>
}

View File

@ -20,22 +20,27 @@ export class VsDuelComponent implements OnInit {
private readonly _tokenService: JwtTokenService = inject(JwtTokenService);
private readonly _modalService : NgbModal = inject(NgbModal);
private readonly _vsDuelService: VsDuelService = inject(VsDuelService);
public readonly _router: Router = inject(Router);
private readonly _router: Router = inject(Router);
private allianceId = this._tokenService.getAllianceId()!;
public currentDate: Date = new Date();
public vsDuels: VsDuelModel[] = [];
public page: number = 1;
public currentWeekDuelExists: boolean = false;
public totalRecord: number = 0;
public pageNumber: number = 1;
public pageSize: number = 10
ngOnInit() {
this.getVsDuels(this._tokenService.getAllianceId()!, 10);
this.getVsDuels();
}
onCreateEvent() {
const vsDuel: VsDuelModel = {
eventDate: new Date(),
opponentName: '',
allianceId: this._tokenService.getAllianceId()!,
allianceId: this.allianceId,
id: '',
won: false,
opponentPower: 0,
@ -57,7 +62,7 @@ export class VsDuelComponent implements OnInit {
modalRef.closed.subscribe({
next: ((response: VsDuelModel) => {
if (response) {
this.getVsDuels(response.allianceId, 10);
this.resetAndGetVsDuels();
}
})
})
@ -89,7 +94,7 @@ export class VsDuelComponent implements OnInit {
title: "Deleted!",
text: "VS-Duel has been deleted",
icon: "success"
}).then(_ => this.getVsDuels(vsDuel.allianceId, 10));
}).then(_ => this.resetAndGetVsDuels());
}
}),
error: (error: Error) => {
@ -100,20 +105,31 @@ export class VsDuelComponent implements OnInit {
});
}
private getVsDuels(allianceId: string, take: number) {
private getVsDuels() {
this.vsDuels = []
this.currentWeekDuelExists = false;
this._vsDuelService.getAllianceVsDuels(allianceId, take).subscribe({
this._vsDuelService.getAllianceVsDuels(this.allianceId, this.pageNumber, this.pageSize).subscribe({
next: ((response) => {
if (response) {
response.forEach((vsDuel: VsDuelModel) => {
if (response.data) {
response.data.forEach((vsDuel: VsDuelModel) => {
if (this._weekPipe.transform(vsDuel.eventDate) === this._weekPipe.transform(new Date())) {
this.currentWeekDuelExists = true;
}
})
this.vsDuels = response;
this.vsDuels = response.data;
this.totalRecord = response.totalRecords;
}
})
});
}
pageChanged(event: number) {
this.pageNumber = event;
this.getVsDuels();
}
resetAndGetVsDuels() {
this.pageNumber = 1;
this.getVsDuels();
}
}

View File

@ -14,6 +14,7 @@
<h5 class="card-title">Level: <span class="text-primary">{{zombieSiegeDetail.level}}</span></h5>
<p class="card-text">Alliance size: <span class="text-primary">{{zombieSiegeDetail.allianceSize}}</span></p>
<p class="card-text">Wave 20 Survivor: <span class="text-primary">{{zombieSiegeDetail.totalLevel20Players}}</span></p>
<p class="card-text">Total Waves Survived: <span class="text-primary">{{zombieSiegeDetail.totalWavesSurvived}}</span> </p>
<hr>
<div>
<p class="card-text">Creator: <span class="text-primary">{{zombieSiegeDetail.createdBy}}</span></p>

View File

@ -38,7 +38,8 @@
}
</div>
<div class="form-floating mb-3 is-invalid">
<input type="number" class="form-control" id="allianceSize" placeholder="allianceSize" formControlName="allianceSize">
<input type="number" class="form-control" id="allianceSize" placeholder="allianceSize"
formControlName="allianceSize">
<label for="level">allianceSize</label>
</div>
@ -48,21 +49,25 @@
</div>
} @else {
<div class="d-flex justify-content-center">
<p><span class="fw-bold text-warning">{{playerParticipated.length}}</span> player(s) selected</p>
<p><span class="fw-bold text-warning">{{ playerParticipated.length }}</span> player(s) selected</p>
</div>
}
<div class="d-grid gap-2 col-6 mx-auto">
<button (click)="onAddParticipants()" class="btn btn-primary" type="button">{{isUpdate || playerParticipated.length > 0 ? 'Update Participants' : 'Add Participants'}}</button>
<button (click)="onAddParticipants()" class="btn btn-primary"
type="button">{{ isUpdate || playerParticipated.length > 0 ? 'Update Participants' : 'Add Participants' }}
</button>
</div>
<div class="d-flex justify-content-between">
<button (click)="onCancel()" type="button" class="btn btn-warning">Cancel</button>
<button [disabled]="zombieSiegeForm.invalid || playerParticipated.length <= 0" (click)="onSubmit()" type="submit" class="btn btn-success">{{isUpdate ? 'Update': 'Create'}}</button>
<button [disabled]="zombieSiegeForm.invalid || playerParticipated.length <= 0" (click)="onSubmit()"
type="submit" class="btn btn-success">{{ isUpdate ? 'Update' : 'Create' }}
</button>
</div>
</form>
}
@if(!isCreateZombieSiege) {
@if (!isCreateZombieSiege) {
@if (zombieSieges.length > 0) {
<div class="table-responsive mt-5">
<table class="table table-striped table-bordered">
@ -72,29 +77,39 @@
<th scope="col">Level</th>
<th scope="col">Alliance Size</th>
<th scope="col">Survived 20 waves</th>
<th scope="col">Total Waves Survived</th>
<th scope="col">Creator</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
@for (zombieSiege of zombieSieges; track zombieSiege.id) {
@for (zombieSiege of zombieSieges | paginate: {
id: 'zombieSiegeTable',
itemsPerPage: pageSize,
totalItems: totalRecord,
currentPage: pageNumber
}; track zombieSiege.id) {
<tr class="">
<td>{{zombieSiege.eventDate | date: 'dd.MM.yyyy'}}</td>
<td>{{zombieSiege.level}}</td>
<td>{{zombieSiege.allianceSize}}</td>
<td>{{zombieSiege.totalLevel20Players}}
<td>{{ zombieSiege.eventDate | date: 'dd.MM.yyyy' }}</td>
<td>{{ zombieSiege.level }}</td>
<td>{{ zombieSiege.allianceSize }}</td>
<td>{{ zombieSiege.totalLevel20Players }}
@if (zombieSiege.totalLevel20Players < 20) {
<i class="ps-3 bi bi-emoji-frown-fill text-danger"></i>
} @else {
<i class="ps-3 bi bi-emoji-smile-fill text-success"></i>
}
</td>
<td>{{zombieSiege.createdBy}}</td>
<td>{{ zombieSiege.totalWavesSurvived }}</td>
<td>{{ zombieSiege.createdBy }}</td>
<td>
<div class="d-flex gap-3 justify-content-around">
<i ngbTooltip="Show details" placement="auto" (click)="onGoToZombieSiegeDetail(zombieSiege)" class="bi custom-info-icon bi-info-circle-fill"></i>
<i ngbTooltip="Edit" placement="auto" (click)="onEditZombieSiege(zombieSiege)" class="bi custom-edit-icon bi-pencil-fill"></i>
<i ngbTooltip="Delete" placement="auto" (click)="onDeleteZombieSiege(zombieSiege)" class="bi custom-delete-icon bi-trash3"></i>
<i ngbTooltip="Show details" placement="auto" (click)="onGoToZombieSiegeDetail(zombieSiege)"
class="bi custom-info-icon bi-info-circle-fill"></i>
<i ngbTooltip="Edit" placement="auto" (click)="onEditZombieSiege(zombieSiege)"
class="bi custom-edit-icon bi-pencil-fill"></i>
<i ngbTooltip="Delete" placement="auto" (click)="onDeleteZombieSiege(zombieSiege)"
class="bi custom-delete-icon bi-trash3"></i>
</div>
</td>
</tr>
@ -102,6 +117,20 @@
</tbody>
</table>
</div>
<!-- Pagination Controls -->
<div class="d-flex justify-content-between mt-3 flex-column flex-md-row">
<pagination-controls class="custom-pagination" [id]="'zombieSiegeTable'" [responsive]="true" [autoHide]=" true"
(pageChange)="pageChanged($event)"></pagination-controls>
<!-- Showing total results with improved styling -->
<div class="align-self-center text-muted mt-2 mt-md-0">
<small>
Showing
<strong>{{ (pageNumber - 1) * pageSize + 1 }} - {{ pageNumber * pageSize > totalRecord ? totalRecord : pageNumber * pageSize }}</strong>
of <strong>{{ totalRecord }}</strong> results
</small>
</div>
</div>
} @else {
<div class="alert alert-secondary text-center mt-5" role="alert">
No saved zombie sieges

View File

@ -18,11 +18,12 @@ import {ZombieSiegeParticipantService} from "../../services/zombie-siege-partici
import Swal from "sweetalert2";
import {Router} from "@angular/router";
import {forkJoin, Observable} from "rxjs";
import {PagedResponseModel} from "../../models/pagedResponse.model";
@Component({
selector: 'app-zombie-siege',
templateUrl: './zombie-siege.component.html',
styleUrl: './zombie-siege.component.css'
styleUrl: './zombie-siege.component.css',
})
export class ZombieSiegeComponent implements OnInit {
@ -36,6 +37,10 @@ export class ZombieSiegeComponent implements OnInit {
private allianceId: string = this._tokenService.getAllianceId()!;
public totalRecord: number = 0;
public pageNumber: number = 1;
public pageSize: number = 10;
public isCreateZombieSiege: boolean = false;
public playerSelected: boolean = false;
public zombieSiegeForm!: FormGroup;
@ -51,14 +56,15 @@ export class ZombieSiegeComponent implements OnInit {
}
ngOnInit() {
this.getZombieSieges(10);
this.getZombieSieges();
}
getZombieSieges(limit: number) {
this._zombieSiegeService.getAllianceZombieSieges(this.allianceId, limit).subscribe({
next: ((response: any) => {
getZombieSieges() {
this._zombieSiegeService.getAllianceZombieSieges(this.allianceId, this.pageNumber, this.pageSize).subscribe({
next: ((response: PagedResponseModel<ZombieSiegeModel>) => {
if (response) {
this.zombieSieges = response;
this.zombieSieges = response.data;
this.totalRecord = response.totalRecords;
} else {
this.zombieSieges = [];
}
@ -162,7 +168,7 @@ export class ZombieSiegeComponent implements OnInit {
title: "Deleted!",
text: "Zombie Siege has been deleted",
icon: "success"
}).then(_ => this.getZombieSieges(10));
}).then(_ => this.resetAndGetZombieSieges());
}
}),
error: (error: Error) => {
@ -218,7 +224,7 @@ export class ZombieSiegeComponent implements OnInit {
this._zombieSiegeParticipantService.insertZombieSiegeParticipants(createZombieSiegeParticipants).subscribe({
next: (() => {
this.onCancel();
this.getZombieSieges(10);
this.resetAndGetZombieSieges()
this.playerParticipated = [];
})
});
@ -246,7 +252,7 @@ export class ZombieSiegeComponent implements OnInit {
if (zombieSiegeParticipants.length <= 0) {
this._toastr.success('Successfully updated!', 'Successfully');
this.onCancel();
this.getZombieSieges(10);
this.resetAndGetZombieSieges();
return;
}
const requests: Observable<ZombieSiegeParticipantModel>[] = [];
@ -260,9 +266,19 @@ export class ZombieSiegeComponent implements OnInit {
if (response) {
this._toastr.success('Successfully updated!', 'Successfully');
this.onCancel();
this.getZombieSieges(10);
this.resetAndGetZombieSieges();
}
})
})
}
pageChanged(event: number) {
this.pageNumber = event;
this.getZombieSieges()
}
resetAndGetZombieSieges() {
this.pageNumber = 1;
this.getZombieSieges();
}
}

View File

@ -3,6 +3,7 @@ import {environment} from "../../environments/environment";
import {HttpClient, HttpParams} from "@angular/common/http";
import {Observable} from "rxjs";
import {CreateCustomEventModel, CustomEventDetailModel, CustomEventModel} from "../models/customEvent.model";
import {PagedResponseModel} from "../models/pagedResponse.model";
@Injectable({
providedIn: 'root'
@ -13,10 +14,11 @@ export class CustomEventService {
private readonly _httpClient: HttpClient = inject(HttpClient);
getAllianceCustomEvents(allianceId: string, take: number): Observable<CustomEventModel[]> {
getAllianceCustomEvents(allianceId: string, pageNumber: number, pageSize: number): Observable<PagedResponseModel<CustomEventModel>> {
let params = new HttpParams();
params = params.append('take', take);
return this._httpClient.get<CustomEventModel[]>(this._serviceUrl + 'Alliance/' + allianceId, {params: params});
params = params.append('pageNumber', pageNumber);
params = params.append('pageSize', pageSize);
return this._httpClient.get<PagedResponseModel<CustomEventModel>>(this._serviceUrl + 'Alliance/' + allianceId, {params: params});
}
getCustomEventDetail(customEventId: string): Observable<CustomEventDetailModel> {

View File

@ -3,6 +3,7 @@ import {environment} from "../../environments/environment";
import {HttpClient, HttpParams} from "@angular/common/http";
import {CreateDesertStormModel, DesertStormDetailModel, DesertStormModel} from "../models/desertStorm.model";
import {Observable} from "rxjs";
import {PagedResponseModel} from "../models/pagedResponse.model";
@Injectable({
providedIn: 'root'
@ -16,10 +17,11 @@ export class DesertStormService {
return this._httpClient.post<DesertStormModel>(this._serviceUrl, createModel);
}
getAllianceDesertStorms(allianceId: string, take: number): Observable<DesertStormModel[]> {
getAllianceDesertStorms(allianceId: string, pageNumber: number, pageSize: number): Observable<PagedResponseModel<DesertStormModel>> {
let params = new HttpParams();
params = params.append('take', take);
return this._httpClient.get<DesertStormModel[]>(this._serviceUrl + 'Alliance/' + allianceId, {params: params});
params = params.append('pageNumber', pageNumber);
params = params.append('pageSize', pageSize);
return this._httpClient.get<PagedResponseModel<DesertStormModel>>(this._serviceUrl + 'Alliance/' + allianceId, {params: params});
}
getDesertStormDetail(desertStormId: string): Observable<DesertStormDetailModel> {

View File

@ -8,6 +8,7 @@ import {
UpdateMarshalGuardModel
} from "../models/marshalGuard.model";
import {Observable} from "rxjs";
import {PagedResponseModel} from "../models/pagedResponse.model";
@Injectable({
providedIn: 'root'
@ -26,10 +27,11 @@ export class MarshalGuardService {
return this._httpClient.get<MarshalGuardDetailModel>(this._serviceUrl + 'GetMarshalGuardDetail/' + marshalGuardId);
}
public getAllianceMarshalGuards(allianceId: string, take: number): Observable<MarshalGuardModel[]> {
public getAllianceMarshalGuards(allianceId: string, pageNumber: number, pageSize: number): Observable<PagedResponseModel<MarshalGuardModel>> {
let params = new HttpParams();
params = params.append('take', take);
return this._httpClient.get<MarshalGuardModel[]>(this._serviceUrl + 'Alliance/' + allianceId, {params: params});
params = params.append('pageNumber', pageNumber);
params = params.append('pageSize', pageSize);
return this._httpClient.get<PagedResponseModel<MarshalGuardModel>>(this._serviceUrl + 'Alliance/' + allianceId, {params: params});
}
public updateMarshalGuard(marshalGuardId: string, marshalGuard: UpdateMarshalGuardModel): Observable<MarshalGuardModel> {

View File

@ -1,6 +1,6 @@
import {inject, Injectable} from '@angular/core';
import {environment} from "../../environments/environment";
import {HttpClient} from "@angular/common/http";
import {HttpClient, HttpParams} from "@angular/common/http";
import {Observable} from "rxjs";
import {
CreatePlayerModel,
@ -9,6 +9,7 @@ import {
UpdatePlayerModel
} from "../models/player.model";
import {ExcelImportResponseModel} from "../models/excelImportResponse.model";
import {PagedResponseModel} from "../models/pagedResponse.model";
@Injectable({
providedIn: 'root'
@ -26,8 +27,11 @@ export class PlayerService {
return this._httpClient.get<PlayerModel[]>(this._serviceUrl + 'Alliance/' + allianceId);
}
public getDismissedPlayers(allianceId: string): Observable<PlayerModel[]> {
return this._httpClient.get<PlayerModel[]>(this._serviceUrl + 'Alliance/dismiss/' + allianceId);
public getDismissedPlayers(allianceId: string, pageNumber: number, pageSize: number): Observable<PagedResponseModel<PlayerModel>> {
let params = new HttpParams();
params = params.append('pageNumber', pageNumber);
params = params.append('pageSize', pageSize);
return this._httpClient.get<PagedResponseModel<PlayerModel>>(this._serviceUrl + 'Alliance/dismiss/' + allianceId, {params: params});
}
public getDismissPlayerInformation(playerId: string): Observable<DismissPlayerInformationModel> {

View File

@ -3,6 +3,7 @@ import {environment} from "../../environments/environment";
import {HttpClient, HttpParams} from "@angular/common/http";
import {Observable} from "rxjs";
import {VsDuelDetailModel, VsDuelModel} from "../models/vsDuel.model";
import {PagedResponseModel} from "../models/pagedResponse.model";
@Injectable({
providedIn: 'root'
@ -16,10 +17,11 @@ export class VsDuelService {
return this._httpClient.get<VsDuelModel>(this._serviceUrl + vsDuelId);
}
public getAllianceVsDuels(allianceId: string, take: number): Observable<VsDuelModel[]> {
public getAllianceVsDuels(allianceId: string, pageNumber: number, pageSize: number): Observable<PagedResponseModel<VsDuelModel>> {
let params = new HttpParams();
params = params.append('take', take);
return this._httpClient.get<VsDuelModel[]>(this._serviceUrl + 'Alliance/' + allianceId, {params: params});
params = params.append('pageNumber', pageNumber);
params = params.append('pageSize', pageSize);
return this._httpClient.get<PagedResponseModel<VsDuelModel>>(this._serviceUrl + 'Alliance/' + allianceId, {params: params});
}
public getVsDuelDetail(vsDuelId: string): Observable<VsDuelDetailModel> {

View File

@ -3,6 +3,7 @@ import {environment} from "../../environments/environment";
import {HttpClient, HttpParams} from "@angular/common/http";
import {Observable} from "rxjs";
import {CreateZombieSiegeModel, ZombieSiegeDetailModel, ZombieSiegeModel} from "../models/zombieSiege.model";
import {PagedResponseModel} from "../models/pagedResponse.model";
@Injectable({
providedIn: 'root'
@ -16,10 +17,11 @@ export class ZombieSiegeService {
return this._httpClient.get<ZombieSiegeDetailModel>(this._serviceUrl + 'GetZombieSiegeDetail/' + zombieSiegeId);
}
getAllianceZombieSieges(allianceId: string, take: number): Observable<ZombieSiegeModel[]> {
getAllianceZombieSieges(allianceId: string, pageNumber: number, pageSize: number): Observable<PagedResponseModel<ZombieSiegeModel>> {
let params = new HttpParams();
params = params.append('take', take);
return this._httpClient.get<ZombieSiegeModel[]>(this._serviceUrl + 'Alliance/' + allianceId, {params: params});
params = params.append('pageNumber', pageNumber);
params = params.append('pageSize', pageSize);
return this._httpClient.get<PagedResponseModel<ZombieSiegeModel>>(this._serviceUrl + 'Alliance/' + allianceId, {params: params});
}
createZombieSiege(createZombieSiege: CreateZombieSiegeModel): Observable<ZombieSiegeModel> {

View File

@ -22,6 +22,16 @@ html, body {
color: #2ea805;
}
.custom-pagination .ngx-pagination .current {
background: #6175d5;
}
.custom-pagination .ngx-pagination li {
color: white;
}
.custom-pagination .ngx-pagination li a{
color: white;
}