Initial commit
This commit is contained in:
commit
77d35ff965
51 changed files with 5591 additions and 0 deletions
40
Pages/Forgejo/Repositories.cshtml.cs
Normal file
40
Pages/Forgejo/Repositories.cshtml.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue