-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pagination and make replay cards look more funky
- Loading branch information
Showing
10 changed files
with
125 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
namespace Server.Helpers; | ||
|
||
/// <summary> | ||
/// A class that helps with pagination. | ||
/// </summary> | ||
public class Paginator | ||
{ | ||
/// <summary> | ||
/// Returns the number of pages needed to display all items. | ||
/// </summary> | ||
public static int GetPageCount(int totalItems, int itemsPerPage) | ||
{ | ||
return (int) Math.Ceiling((double) totalItems / itemsPerPage); | ||
} | ||
|
||
/// <summary> | ||
/// Returns the offset for a given page. | ||
/// </summary> | ||
public static int GetOffset(int page, int itemsPerPage) | ||
{ | ||
return page * itemsPerPage; | ||
} | ||
|
||
/// <summary> | ||
/// Returns the page for a given offset. | ||
/// </summary> | ||
public static int GetPage(int offset, int itemsPerPage) | ||
{ | ||
return offset / itemsPerPage; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
public class Constants | ||
{ | ||
public const int SearchLimit = int.MaxValue; | ||
public const int ReplaysPerPage = 32; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Shared.Models; | ||
|
||
namespace Shared; | ||
|
||
public class SearchResult | ||
{ | ||
public int PageCount { get; set; } | ||
public int CurrentPage { get; set; } | ||
public List<Replay> Replays { get; set; } | ||
public int TotalReplays { get; set; } | ||
} |