Added EonaCat.LogStack.Status

Updated EonaCat.LogStack.LogClient to support EonaCat.LogStack.Status
This commit is contained in:
2026-03-12 21:15:33 +01:00
parent 776cc624bd
commit 977374ce02
41 changed files with 3412 additions and 180 deletions

View File

@@ -0,0 +1,37 @@
using Microsoft.EntityFrameworkCore;
using EonaCat.LogStack.Status.Models;
using Monitor = EonaCat.LogStack.Status.Models.Monitor;
namespace EonaCat.LogStack.Status.Data;
// This file is part of the EonaCat project(s) which is released under the Apache License.
// See the LICENSE file or go to https://EonaCat.com/License for full license details.
public class DatabaseContext : DbContext
{
public DatabaseContext(DbContextOptions<DatabaseContext> options) : base(options) { }
public DbSet<Monitor> Monitors => Set<Monitor>();
public DbSet<MonitorCheck> MonitorChecks => Set<MonitorCheck>();
public DbSet<CertificateEntry> Certificates => Set<CertificateEntry>();
public DbSet<LogEntry> Logs => Set<LogEntry>();
public DbSet<AppSettings> Settings => Set<AppSettings>();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<MonitorCheck>().HasIndex(c => new { c.MonitorId, c.CheckedAt });
modelBuilder.Entity<LogEntry>().HasIndex(l => l.Timestamp);
modelBuilder.Entity<LogEntry>().HasIndex(l => new { l.Level, l.Source });
modelBuilder.Entity<AppSettings>().HasIndex(s => s.Key).IsUnique();
// Seed default settings
modelBuilder.Entity<AppSettings>().HasData(
new AppSettings { Id = 1, Key = "AdminPasswordHash", Value = BCrypt.Net.BCrypt.EnhancedHashPassword("adminEonaCat") },
new AppSettings { Id = 2, Key = "SiteName", Value = "Status" },
new AppSettings { Id = 3, Key = "ShowLogsPublicly", Value = "false" },
new AppSettings { Id = 4, Key = "ShowUptimePublicly", Value = "true" },
new AppSettings { Id = 5, Key = "MaxLogRetentionDays", Value = "30" },
new AppSettings { Id = 6, Key = "AlertEmail", Value = "" }
);
}
}