@page @model PlanTempusAdmin.Pages.Forgejo.RepositoriesModel @{ ViewData["Title"] = "Forgejo Repositories"; } @section Styles { } @if (!Model.IsConnected) {

Kan ikke forbinde til Forgejo database

} else { var backedUp = Model.Repositories.Count(r => Model.BackupStatus.ContainsKey(r.FullName.ToLower())); var notBackedUp = Model.Repositories.Count - backedUp;
Total Repos
@Model.Repositories.Count
Med Backup
@backedUp
Mangler Backup
@notBackedUp
Total Størrelse
@FormatSize(Model.Repositories.Sum(r => r.Size) * 1024)
@foreach (var repo in Model.Repositories) { var hasBackup = Model.BackupStatus.TryGetValue(repo.FullName.ToLower(), out var backupInfo); var rowClass = hasBackup ? "backed-up" : "not-backed-up"; if (repo.IsPrivate) { rowClass += " private"; } }
Repository Type Størrelse Issues PRs Opdateret Backup Status
@repo.FullName @if (repo.Description != null) {
@TruncateText(repo.Description, 60)
}
@if (repo.IsPrivate) { privat } @if (repo.IsFork) { fork } @if (repo.IsMirror) { mirror } @if (repo.IsArchived) { arkiveret } @if (!repo.IsPrivate && !repo.IsFork && !repo.IsMirror && !repo.IsArchived) { public } @repo.SizeFormatted @if (repo.OpenIssues > 0) { @repo.OpenIssues } else { 0 } @if (repo.OpenPulls > 0) { @repo.OpenPulls } else { 0 } @FormatTimeAgo(repo.UpdatedAt) @if (hasBackup) { OK @FormatTimeAgo(backupInfo.LastBackup) · @FormatSize(backupInfo.LastSize) } else { MANGLER }
@if (notBackedUp > 0) {
Repositories uden backup

Følgende repositories har ingen backup registreret:

@foreach (var repo in Model.Repositories.Where(r => !Model.BackupStatus.ContainsKey(r.FullName))) { @repo.FullName }
} } @functions { string FormatSize(long bytes) { if (bytes == 0) return "0 B"; var sizes = new[] { "B", "KB", "MB", "GB", "TB" }; var i = (int)Math.Floor(Math.Log(bytes) / Math.Log(1024)); return $"{Math.Round(bytes / Math.Pow(1024, i), 1)} {sizes[i]}"; } string FormatTimeAgo(DateTime? time) { if (!time.HasValue) return "-"; var diff = DateTime.Now - time.Value; if (diff.TotalMinutes < 1) return "lige nu"; if (diff.TotalMinutes < 60) return $"{(int)diff.TotalMinutes}m siden"; if (diff.TotalHours < 24) return $"{(int)diff.TotalHours}t siden"; if (diff.TotalDays < 7) return $"{(int)diff.TotalDays}d siden"; return time.Value.ToString("dd/MM"); } string FormatTimeAgo(DateTime time) => FormatTimeAgo((DateTime?)time); string TruncateText(string text, int maxLength) { if (string.IsNullOrEmpty(text)) return ""; return text.Length <= maxLength ? text : text.Substring(0, maxLength) + "..."; } }