@page "/changelog" @implements IDisposable; @inject IGitService GitService; @layout PageLayout @if (GitService.IsLoaded()) { Change Log @foreach (var patch in Patches.OrderBy(x => x.Date).Reverse()) { @if (!patch.Important.Equals("True") && isViewImportant) { continue; } var daysAgo = Math.Floor(DateTime.Now.Subtract(patch.Date).TotalDays);
@patch.Name
@if (daysAgo == 0) { Today } else if (daysAgo < 8) { @daysAgo days ago } else { @patch.Date.ToString("dd/MM/yyyy") }
@foreach (var change in Changes.FindAll(e => e.PatchModelId == patch.Id)) { @if (!change.Important.Equals("True") && isViewImportant) { continue; }
- @change.Name @if (change.Commit != CommitType.None) { (@change.Commit) } : @((MarkupString)change.Description)
}
}
} else { } @code { #if NO_SQL public List Patches => GitService.PatchModels; public List Changes => GitService.ChangeModels; #else [Inject] DatabaseContext Database { get; set; } [Parameter] public DbSet Patches { get; set; } [Parameter] public DbSet Changes { get; set; } #endif private bool isViewImportant = true; protected override void OnInitialized() { GitService.Subscribe(HasChanged); } void IDisposable.Dispose() { GitService.Unsubscribe(HasChanged); } void OnChangeClicked(ChangeEventArgs changeEventArgs) { isViewImportant = (bool)changeEventArgs.Value; } void HasChanged() { StateHasChanged(); } protected override async Task OnInitializedAsync() { #if NO_SQL GitService.Load(); #else GitService.Load(Database); #endif } }