Pageing on CDN Assets Page, and Player management
This commit is contained in:
@@ -169,6 +169,27 @@ MINIO_USE_SSL=true</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Browse Pagination -->
|
||||
@if (Model.BrowseTotalPages > 1)
|
||||
{
|
||||
<div class="p-4 border-t border-gray-700 flex items-center justify-between">
|
||||
<p class="text-sm text-gray-400">
|
||||
Showing @((Model.BrowsePage - 1) * Model.BrowsePageSize + 1)-@Math.Min(Model.BrowsePage * Model.BrowsePageSize, Model.AllFiles.Count) of @Model.AllFiles.Count files
|
||||
</p>
|
||||
<div class="flex items-center gap-2">
|
||||
@if (Model.BrowsePage > 1)
|
||||
{
|
||||
<a href="@Model.GetBrowsePageUrl(Model.BrowsePage - 1)" class="btn btn-secondary">← Prev</a>
|
||||
}
|
||||
<span class="text-gray-400 px-2">@Model.BrowsePage / @Model.BrowseTotalPages</span>
|
||||
@if (Model.BrowsePage < Model.BrowseTotalPages)
|
||||
{
|
||||
<a href="@Model.GetBrowsePageUrl(Model.BrowsePage + 1)" class="btn btn-secondary">Next →</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
else if (!Model.Subfolders.Any())
|
||||
{
|
||||
|
||||
@@ -27,7 +27,16 @@ public class IndexModel : AdminPageModel
|
||||
public string? Prefix { get; set; }
|
||||
|
||||
public bool CdnConfigured => _cdnService.IsConfigured;
|
||||
public List<CdnFile> Files { get; set; } = new();
|
||||
// Browse tab pagination
|
||||
[FromQuery(Name = "bpage")]
|
||||
public int BrowsePage { get; set; } = 1;
|
||||
public int BrowsePageSize { get; set; } = 100;
|
||||
public int BrowseTotalPages => (int)Math.Ceiling(AllFiles.Count / (double)BrowsePageSize);
|
||||
public List<CdnFile> AllFiles { get; set; } = new();
|
||||
public List<CdnFile> Files => AllFiles
|
||||
.Skip((BrowsePage - 1) * BrowsePageSize)
|
||||
.Take(BrowsePageSize)
|
||||
.ToList();
|
||||
public List<string> Subfolders { get; set; } = new();
|
||||
public List<string> AvailableFolders { get; set; } = new()
|
||||
{
|
||||
@@ -67,6 +76,13 @@ public class IndexModel : AdminPageModel
|
||||
public string? Message { get; set; }
|
||||
public bool IsError { get; set; }
|
||||
|
||||
public string GetBrowsePageUrl(int page)
|
||||
{
|
||||
var parts = new List<string> { $"tab=browse", $"bpage={page}" };
|
||||
if (!string.IsNullOrEmpty(Prefix)) parts.Add($"prefix={Uri.EscapeDataString(Prefix)}");
|
||||
return "/admin/assets?" + string.Join("&", parts);
|
||||
}
|
||||
|
||||
public string GetTrackedPageUrl(int page)
|
||||
{
|
||||
var parts = new List<string> { $"tab=tracked", $"tpage={page}" };
|
||||
@@ -91,13 +107,15 @@ public class IndexModel : AdminPageModel
|
||||
|
||||
if (Tab == "browse" && CdnConfigured)
|
||||
{
|
||||
if (BrowsePage < 1) BrowsePage = 1;
|
||||
|
||||
// Normalize prefix
|
||||
Prefix = Prefix?.TrimEnd('/');
|
||||
if (!string.IsNullOrEmpty(Prefix))
|
||||
Prefix += "/";
|
||||
|
||||
// List files from MinIO
|
||||
var allItems = await _cdnService.ListFilesAsync(Prefix ?? "", 200);
|
||||
// List files from MinIO (increased limit)
|
||||
var allItems = await _cdnService.ListFilesAsync(Prefix ?? "", 100000);
|
||||
|
||||
// Separate files and folders
|
||||
Subfolders = allItems
|
||||
@@ -106,7 +124,7 @@ public class IndexModel : AdminPageModel
|
||||
.OrderBy(f => f)
|
||||
.ToList();
|
||||
|
||||
Files = allItems
|
||||
AllFiles = allItems
|
||||
.Where(f => !f.IsDirectory)
|
||||
.OrderBy(f => f.Name)
|
||||
.ToList();
|
||||
|
||||
Reference in New Issue
Block a user