Track Gallery front end

- For now uses a table but will replace with graphical media cards
This commit is contained in:
2025-09-01 16:50:08 -04:00
parent 3d79df725c
commit f0d60190cc
9 changed files with 176 additions and 60 deletions
+46
View File
@@ -0,0 +1,46 @@
using DeepDrftModels.Entities;
using DeepDrftModels.Models;
using NetBlocks.Models;
using System.Text.Json;
using System.Web;
namespace DeepDrftWeb.Client.Clients;
public class TrackClient : ApiClient<ClientConfig>
{
public TrackClient(ClientConfig config) : base(config) { }
public async Task<ApiResult<PagedResult<TrackEntity>>> GetPage(
int pageNumber,
int pageSize,
string? sortColumn = null,
bool sortDescending = false)
{
var uriBuilder = new UriBuilder(http.BaseAddress!)
{
Path = "api/track/page"
};
var query = HttpUtility.ParseQueryString(string.Empty);
query["pageNumber"] = pageNumber.ToString();
query["pageSize"] = pageSize.ToString();
if (!string.IsNullOrEmpty(sortColumn))
query["sortColumn"] = sortColumn;
if (sortDescending)
query["sortDescending"] = "true";
uriBuilder.Query = query.ToString();
var response = await http.GetAsync(uriBuilder.Uri);
var json = await response.Content.ReadAsStringAsync();
var dto = JsonSerializer.Deserialize<ApiResultDto<PagedResult<TrackEntity>>>(json, new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
});
return dto?.From() ?? ApiResult<PagedResult<TrackEntity>>.CreateFailResult("Failed to deserialize response");
}
}