Pageing on CDN Assets Page, and Player management
This commit is contained in:
@@ -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