40 lines
1.4 KiB
C#
40 lines
1.4 KiB
C#
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
using PlanTempusAdmin.Models;
|
|
using PlanTempusAdmin.Services;
|
|
|
|
namespace PlanTempusAdmin.Pages.Forgejo;
|
|
|
|
public class RepositoriesModel : PageModel
|
|
{
|
|
private readonly ForgejoService _forgejoService;
|
|
private readonly BackupService _backupService;
|
|
|
|
public bool IsConnected { get; set; }
|
|
public List<ForgejoRepository> Repositories { get; set; } = new();
|
|
public Dictionary<string, (DateTime? LastBackup, long LastSize)> BackupStatus { get; set; } = new();
|
|
|
|
public RepositoriesModel(ForgejoService forgejoService, BackupService backupService)
|
|
{
|
|
_forgejoService = forgejoService;
|
|
_backupService = backupService;
|
|
}
|
|
|
|
public async Task OnGetAsync()
|
|
{
|
|
IsConnected = await _forgejoService.TestConnectionAsync();
|
|
if (IsConnected)
|
|
{
|
|
Repositories = await _forgejoService.GetAllRepositoriesAsync();
|
|
|
|
// Get backup status for comparison
|
|
if (await _backupService.TestConnectionAsync())
|
|
{
|
|
var repoSummaries = await _backupService.GetRepositorySummariesAsync();
|
|
foreach (var summary in repoSummaries.Where(s => s.BackupType == "forgejo_repos"))
|
|
{
|
|
BackupStatus[summary.SourceName.ToLower()] = (summary.LastSuccessfulBackup, summary.LastBackupSizeBytes ?? 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|