From cfb97536ca3051ffc0317f7bf9ce42942bb1b8ba Mon Sep 17 00:00:00 2001 From: triggermeelmo Date: Wed, 5 Nov 2025 21:15:10 +0100 Subject: [PATCH] KI shit haha --- .gitea/workflows/build.yml | 1 + Dockerfile | 7 + Watcher/.env.example | 25 +- Watcher/Controllers/AuthController.cs | 37 +- Watcher/Controllers/ContainerController.cs | 8 +- Watcher/Controllers/MonitoringController.cs | 1 - Watcher/Controllers/SystemController.cs | 31 +- Watcher/Controllers/UserController.cs | 2 - Watcher/Data/AppDbContext.cs | 23 +- ...0250617153602_InitialMigration.Designer.cs | 300 ------- .../20250617153602_InitialMigration.cs | 261 ------ ...0250617165126_ServerPrimaryKey.Designer.cs | 298 ------- .../20250617165126_ServerPrimaryKey.cs | 785 ------------------ ...250617174242_UserPasswordAdded.Designer.cs | 306 ------- .../20250617174242_UserPasswordAdded.cs | 40 - ...50621124832_DB-Update Issue#32.Designer.cs | 316 ------- .../20250621124832_DB-Update Issue#32.cs | 251 ------ ...te Issue#32 IsVerified-Servers.Designer.cs | 319 ------- ...7_DB-Update Issue#32 IsVerified-Servers.cs | 29 - ...0710090920_container-attribute.Designer.cs | 332 -------- .../20250710090920_container-attribute.cs | 119 --- ...3936_DiskSpace-ServerAttribute.Designer.cs | 335 -------- ...0250730113936_DiskSpace-ServerAttribute.cs | 28 - ...0730172010_MeasurementWarnings.Designer.cs | 377 --------- .../20250730172010_MeasurementWarnings.cs | 172 ---- .../20251003135555_ContainerUpdate.cs | 113 --- .../20251029105954_container-changed.cs | 22 - ...9125404_ContainerMetrics-Added.Designer.cs | 355 -------- .../20251029125404_ContainerMetrics-Added.cs | 22 - ...251105183329_InitialMigration.Designer.cs} | 53 +- .../20251105183329_InitialMigration.cs | 257 ++++++ ..._AddContainerServerNavigation.Designer.cs} | 63 +- ...1105201056_AddContainerServerNavigation.cs | 39 + .../Migrations/AppDbContextModelSnapshot.cs | 59 +- Watcher/Models/Container.cs | 4 + Watcher/Models/User.cs | 18 +- Watcher/Program.cs | 122 +-- Watcher/Services/IUpdateCheckStore.cs | 8 + Watcher/Services/IVersionService.cs | 6 + Watcher/Services/MetricCleanupService.cs | 127 +++ Watcher/Services/UpdateCheckService.cs | 159 ++++ Watcher/Services/UpdateCheckStore.cs | 8 + Watcher/Services/VersionService.cs | 19 + Watcher/Views/Container/Overview.cshtml | 5 +- Watcher/Views/Home/_DashboardStats.cshtml | 5 +- Watcher/Views/Shared/_Layout.cshtml | 18 +- Watcher/Views/System/Settings.cshtml | 8 +- Watcher/Watcher.csproj | 13 +- Watcher/appsettings.json | 16 +- docker-compose.yaml | 13 +- 50 files changed, 906 insertions(+), 5029 deletions(-) delete mode 100644 Watcher/Migrations/20250617153602_InitialMigration.Designer.cs delete mode 100644 Watcher/Migrations/20250617153602_InitialMigration.cs delete mode 100644 Watcher/Migrations/20250617165126_ServerPrimaryKey.Designer.cs delete mode 100644 Watcher/Migrations/20250617165126_ServerPrimaryKey.cs delete mode 100644 Watcher/Migrations/20250617174242_UserPasswordAdded.Designer.cs delete mode 100644 Watcher/Migrations/20250617174242_UserPasswordAdded.cs delete mode 100644 Watcher/Migrations/20250621124832_DB-Update Issue#32.Designer.cs delete mode 100644 Watcher/Migrations/20250621124832_DB-Update Issue#32.cs delete mode 100644 Watcher/Migrations/20250621125157_DB-Update Issue#32 IsVerified-Servers.Designer.cs delete mode 100644 Watcher/Migrations/20250621125157_DB-Update Issue#32 IsVerified-Servers.cs delete mode 100644 Watcher/Migrations/20250710090920_container-attribute.Designer.cs delete mode 100644 Watcher/Migrations/20250710090920_container-attribute.cs delete mode 100644 Watcher/Migrations/20250730113936_DiskSpace-ServerAttribute.Designer.cs delete mode 100644 Watcher/Migrations/20250730113936_DiskSpace-ServerAttribute.cs delete mode 100644 Watcher/Migrations/20250730172010_MeasurementWarnings.Designer.cs delete mode 100644 Watcher/Migrations/20250730172010_MeasurementWarnings.cs delete mode 100644 Watcher/Migrations/20251003135555_ContainerUpdate.cs delete mode 100644 Watcher/Migrations/20251029105954_container-changed.cs delete mode 100644 Watcher/Migrations/20251029125404_ContainerMetrics-Added.Designer.cs delete mode 100644 Watcher/Migrations/20251029125404_ContainerMetrics-Added.cs rename Watcher/Migrations/{20251003135555_ContainerUpdate.Designer.cs => 20251105183329_InitialMigration.Designer.cs} (88%) create mode 100644 Watcher/Migrations/20251105183329_InitialMigration.cs rename Watcher/Migrations/{20251029105954_container-changed.Designer.cs => 20251105201056_AddContainerServerNavigation.Designer.cs} (85%) create mode 100644 Watcher/Migrations/20251105201056_AddContainerServerNavigation.cs create mode 100644 Watcher/Services/IUpdateCheckStore.cs create mode 100644 Watcher/Services/IVersionService.cs create mode 100644 Watcher/Services/MetricCleanupService.cs create mode 100644 Watcher/Services/UpdateCheckService.cs create mode 100644 Watcher/Services/UpdateCheckStore.cs create mode 100644 Watcher/Services/VersionService.cs diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index ecd6e23..54ccced 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -117,6 +117,7 @@ jobs: run: | docker buildx build \ --platform ${{ env.DOCKER_PLATFORMS }} \ + --build-arg VERSION=${{ needs.set-tag.outputs.tag_name }} \ -t ${{ env.REGISTRY_URL }}/watcher/${{ env.DOCKER_IMAGE_NAME }}:${{ needs.set-tag.outputs.tag_name }} \ --push . diff --git a/Dockerfile b/Dockerfile index a7adde3..0ef5a36 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,10 @@ RUN dotnet publish -c Release -o /app/publish /p:UseAppHost=false # 2. Laufzeit-Phase: ASP.NET Core Runtime FROM mcr.microsoft.com/dotnet/aspnet:8.0 + +# Build-Argument für Version (wird zur Build-Zeit vom CI/CD gesetzt) +ARG VERSION=latest + WORKDIR /app COPY --from=build /app/publish . @@ -28,5 +32,8 @@ EXPOSE 5000 ENV ASPNETCORE_URLS=http://*:5000 ENV ASPNETCORE_ENVIRONMENT=Development +# Version als Environment Variable setzen +ENV WATCHER_VERSION=${VERSION} + # Anwendung starten ENTRYPOINT ["dotnet", "Watcher.dll"] diff --git a/Watcher/.env.example b/Watcher/.env.example index 032d787..87810d8 100644 --- a/Watcher/.env.example +++ b/Watcher/.env.example @@ -1,8 +1,19 @@ +# Application Version +# Bei lokalem Development wird "development" angezeigt, im Docker-Container die Image-Version +WATCHER_VERSION=development -# OIDC Einstellungen -AUTHENTICATION__USELOCAL=true -AUTHENTICATION__POCKETID__ENABLED=false -AUTHENTICATION__POCKETID__AUTHORITY=https://id.domain.app -AUTHENTICATION__POCKETID__CLIENTID= -AUTHENTICATION__POCKETID__CLIENTSECRET= -AUTHENTICATION__POCKETID__CALLBACKPATH=/signin-oidc +# Update Check +# Überprüft täglich, ob eine neue Version verfügbar ist +UPDATE_CHECK_ENABLED=true +UPDATE_CHECK_INTERVAL_HOURS=24 +UPDATE_CHECK_REPOSITORY_URL=https://git.triggermeelmo.com/api/v1/repos/Watcher/watcher/releases/latest + +# Data Retention Policy +# Wie lange sollen Metriken gespeichert werden (in Tagen)? +METRIC_RETENTION_DAYS=30 + +# Wie oft soll der Cleanup-Prozess laufen (in Stunden)? +METRIC_CLEANUP_INTERVAL_HOURS=24 + +# Soll der Cleanup-Service aktiviert sein? +METRIC_CLEANUP_ENABLED=true diff --git a/Watcher/Controllers/AuthController.cs b/Watcher/Controllers/AuthController.cs index b24110d..464a7c7 100644 --- a/Watcher/Controllers/AuthController.cs +++ b/Watcher/Controllers/AuthController.cs @@ -1,35 +1,20 @@ -using System.Net.Mail; using System.Security.Claims; -using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.Extensions.Options; using Watcher.Data; using Watcher.ViewModels; namespace Watcher.Controllers; -public class AppSettings -{ - public Boolean oidc { get; set; } -} - public class AuthController : Controller { private readonly AppDbContext _context; - private readonly AppSettings _settings; - - // Logging einbinden private readonly ILogger _logger; - - public AuthController(AppDbContext context, IOptions options, ILogger logger) + public AuthController(AppDbContext context, ILogger logger) { _context = context; - _settings = options.Value; _logger = logger; } @@ -43,7 +28,6 @@ public class AuthController : Controller ReturnUrl = returnUrl }; - ViewBag.oidc = _settings.oidc; return View(model); } @@ -88,32 +72,15 @@ public class AuthController : Controller } - // Login mit OIDC-Provider - public IActionResult SignIn() - { - return Challenge(new AuthenticationProperties - { - RedirectUri = "/Home/Index" - }, "oidc"); - } - - - // Logout [HttpPost] [ValidateAntiForgeryToken] public async Task Logout() { - var props = new AuthenticationProperties - { - RedirectUri = Url.Action("Login", "Auth") - }; - await HttpContext.SignOutAsync("Cookies"); - await HttpContext.SignOutAsync("oidc", props); _logger.LogInformation("User abgemeldet"); - return Redirect("/"); // nur als Fallback + return RedirectToAction("Login", "Auth"); } } diff --git a/Watcher/Controllers/ContainerController.cs b/Watcher/Controllers/ContainerController.cs index f3f5c63..5b3ee5b 100644 --- a/Watcher/Controllers/ContainerController.cs +++ b/Watcher/Controllers/ContainerController.cs @@ -19,7 +19,13 @@ public class ContainerController : Controller public async Task Overview() { - var containers = await _context.Containers.ToListAsync(); + // Container mit Server-Informationen laden und nach Server sortieren + var containers = await _context.Containers + .Include(c => c.Server) + .OrderBy(c => c.Server.Name) + .ThenBy(c => c.Name) + .ToListAsync(); + var servers = await _context.Servers.ToListAsync(); var viewModel = new ContainerOverviewViewModel diff --git a/Watcher/Controllers/MonitoringController.cs b/Watcher/Controllers/MonitoringController.cs index 59f4fb9..e7a2a22 100644 --- a/Watcher/Controllers/MonitoringController.cs +++ b/Watcher/Controllers/MonitoringController.cs @@ -9,7 +9,6 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; -using Microsoft.IdentityModel.Tokens; using Watcher.Data; using Watcher.Models; using Watcher.ViewModels; diff --git a/Watcher/Controllers/SystemController.cs b/Watcher/Controllers/SystemController.cs index e39ff2c..0190055 100644 --- a/Watcher/Controllers/SystemController.cs +++ b/Watcher/Controllers/SystemController.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Watcher.Data; +using Watcher.Services; using Watcher.ViewModels; namespace Watcher.Controllers; @@ -11,11 +12,13 @@ public class SystemController : Controller { private readonly AppDbContext _context; private readonly ILogger _logger; + private readonly IVersionService _versionService; - public SystemController(AppDbContext context, ILogger logger) + public SystemController(AppDbContext context, ILogger logger, IVersionService versionService) { _context = context; _logger = logger; + _versionService = versionService; } // Edit-Form anzeigen @@ -23,10 +26,32 @@ public class SystemController : Controller //public async Task Settings() public IActionResult Settings() { - ViewBag.DbProvider = "Microsoft.EntityFrameworkCore.Sqlite"; + ViewBag.DbProvider = "SQLite"; ViewBag.mail = "test@mail.com"; ViewBag.IdentityProvider = "Local"; - ViewBag.ServerVersion = "v0.1.0"; + ViewBag.ServerVersion = _versionService.GetVersion(); + + // Datenbankgröße ermitteln + try + { + var dbPath = "./persistence/watcher.db"; + if (System.IO.File.Exists(dbPath)) + { + var fileInfo = new System.IO.FileInfo(dbPath); + var sizeInMiB = fileInfo.Length / (1024.0 * 1024.0); + ViewBag.DatabaseSize = $"{sizeInMiB:F2} MiB"; + } + else + { + ViewBag.DatabaseSize = "Nicht gefunden"; + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Fehler beim Ermitteln der Datenbankgröße."); + ViewBag.DatabaseSize = "Fehler beim Laden"; + } + return View(); } diff --git a/Watcher/Controllers/UserController.cs b/Watcher/Controllers/UserController.cs index b227618..b4ef71e 100644 --- a/Watcher/Controllers/UserController.cs +++ b/Watcher/Controllers/UserController.cs @@ -33,14 +33,12 @@ public class UserController : Controller var username = user.Username; var mail = user.Email; var Id = user.Id; - var IdProvider = user.IdentityProvider; // Anzeigedaten an View übergeben ViewBag.Claims = claims; ViewBag.Name = username; ViewBag.Mail = mail; ViewBag.Id = Id; - ViewBag.IdProvider = IdProvider; return View(); diff --git a/Watcher/Data/AppDbContext.cs b/Watcher/Data/AppDbContext.cs index 1affd63..36030f1 100644 --- a/Watcher/Data/AppDbContext.cs +++ b/Watcher/Data/AppDbContext.cs @@ -34,24 +34,11 @@ public class AppDbContext : DbContext { if (!optionsBuilder.IsConfigured) { - var provider = _configuration["Database:Provider"]; - - if (provider == "MySql") - { - var connStr = _configuration.GetConnectionString("MySql") - ?? _configuration["Database:ConnectionStrings:MySql"]; - optionsBuilder.UseMySql(connStr, ServerVersion.AutoDetect(connStr)); - } - else if (provider == "Sqlite") - { - var connStr = _configuration.GetConnectionString("Sqlite") - ?? _configuration["Database:ConnectionStrings:Sqlite"]; - optionsBuilder.UseSqlite(connStr); - } - else - { - throw new Exception("Unsupported database provider configured."); - } + // Nur SQLite wird unterstützt + var connStr = _configuration.GetConnectionString("Sqlite") + ?? _configuration["Database:ConnectionStrings:Sqlite"] + ?? "Data Source=./persistence/watcher.db"; + optionsBuilder.UseSqlite(connStr); } } } diff --git a/Watcher/Migrations/20250617153602_InitialMigration.Designer.cs b/Watcher/Migrations/20250617153602_InitialMigration.Designer.cs deleted file mode 100644 index 5d549f0..0000000 --- a/Watcher/Migrations/20250617153602_InitialMigration.Designer.cs +++ /dev/null @@ -1,300 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Watcher.Data; - -#nullable disable - -namespace Watcher.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20250617153602_InitialMigration")] - partial class InitialMigration - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.6") - .HasAnnotation("Relational:MaxIdentifierLength", 64); - - modelBuilder.Entity("Watcher.Models.Container", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Hostname") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ImageId") - .HasColumnType("int"); - - b.Property("IsRunning") - .HasColumnType("tinyint(1)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Status") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("TagId") - .HasColumnType("int"); - - b.Property("Type") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.HasIndex("TagId"); - - b.ToTable("Containers"); - }); - - modelBuilder.Entity("Watcher.Models.Image", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Name") - .HasColumnType("longtext"); - - b.Property("Tag") - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Images"); - }); - - modelBuilder.Entity("Watcher.Models.LogEvent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ContainerId") - .HasColumnType("int"); - - b.Property("Level") - .HasColumnType("longtext"); - - b.Property("Message") - .HasColumnType("longtext"); - - b.Property("ServerId") - .HasColumnType("int"); - - b.Property("Timestamp") - .HasColumnType("datetime(6)"); - - b.HasKey("Id"); - - b.HasIndex("ContainerId"); - - b.HasIndex("ServerId"); - - b.ToTable("LogEvents"); - }); - - modelBuilder.Entity("Watcher.Models.Metric", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ContainerId") - .HasColumnType("int"); - - b.Property("ServerId") - .HasColumnType("int"); - - b.Property("Timestamp") - .HasColumnType("datetime(6)"); - - b.Property("Type") - .HasColumnType("longtext"); - - b.Property("Value") - .HasColumnType("double"); - - b.HasKey("Id"); - - b.HasIndex("ContainerId"); - - b.HasIndex("ServerId"); - - b.ToTable("Metrics"); - }); - - modelBuilder.Entity("Watcher.Models.Server", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CpuCores") - .HasColumnType("int"); - - b.Property("CpuType") - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Description") - .HasColumnType("longtext"); - - b.Property("GpuType") - .HasColumnType("longtext"); - - b.Property("IPAddress") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("IsOnline") - .HasColumnType("tinyint(1)"); - - b.Property("LastSeen") - .HasColumnType("datetime(6)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("RamSize") - .HasColumnType("double"); - - b.Property("TagId") - .HasColumnType("int"); - - b.Property("Type") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("TagId"); - - b.ToTable("Servers"); - }); - - modelBuilder.Entity("Watcher.Models.Tag", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Name") - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Tags"); - }); - - modelBuilder.Entity("Watcher.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Email") - .HasColumnType("longtext"); - - b.Property("LastLogin") - .HasColumnType("datetime(6)"); - - b.Property("PocketId") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("PreferredUsername") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Watcher.Models.Container", b => - { - b.HasOne("Watcher.Models.Image", "Image") - .WithMany("Containers") - .HasForeignKey("ImageId"); - - b.HasOne("Watcher.Models.Tag", null) - .WithMany("Containers") - .HasForeignKey("TagId"); - - b.Navigation("Image"); - }); - - modelBuilder.Entity("Watcher.Models.LogEvent", b => - { - b.HasOne("Watcher.Models.Container", "Container") - .WithMany() - .HasForeignKey("ContainerId"); - - b.HasOne("Watcher.Models.Server", "Server") - .WithMany() - .HasForeignKey("ServerId"); - - b.Navigation("Container"); - - b.Navigation("Server"); - }); - - modelBuilder.Entity("Watcher.Models.Metric", b => - { - b.HasOne("Watcher.Models.Container", "Container") - .WithMany() - .HasForeignKey("ContainerId"); - - b.HasOne("Watcher.Models.Server", "Server") - .WithMany() - .HasForeignKey("ServerId"); - - b.Navigation("Container"); - - b.Navigation("Server"); - }); - - modelBuilder.Entity("Watcher.Models.Server", b => - { - b.HasOne("Watcher.Models.Tag", null) - .WithMany("Servers") - .HasForeignKey("TagId"); - }); - - modelBuilder.Entity("Watcher.Models.Image", b => - { - b.Navigation("Containers"); - }); - - modelBuilder.Entity("Watcher.Models.Tag", b => - { - b.Navigation("Containers"); - - b.Navigation("Servers"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Watcher/Migrations/20250617153602_InitialMigration.cs b/Watcher/Migrations/20250617153602_InitialMigration.cs deleted file mode 100644 index e8bc8fd..0000000 --- a/Watcher/Migrations/20250617153602_InitialMigration.cs +++ /dev/null @@ -1,261 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Watcher.Migrations -{ - /// - public partial class InitialMigration : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterDatabase() - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "Images", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Tag = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_Images", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "Tags", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_Tags", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "Users", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - PocketId = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - PreferredUsername = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Email = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - LastLogin = table.Column(type: "datetime(6)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Users", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "Containers", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Status = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ImageId = table.Column(type: "int", nullable: true), - CreatedAt = table.Column(type: "datetime(6)", nullable: false), - Hostname = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Type = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - IsRunning = table.Column(type: "tinyint(1)", nullable: false), - TagId = table.Column(type: "int", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Containers", x => x.Id); - table.ForeignKey( - name: "FK_Containers_Images_ImageId", - column: x => x.ImageId, - principalTable: "Images", - principalColumn: "Id"); - table.ForeignKey( - name: "FK_Containers_Tags_TagId", - column: x => x.TagId, - principalTable: "Tags", - principalColumn: "Id"); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "Servers", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - IPAddress = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - CreatedAt = table.Column(type: "datetime(6)", nullable: false), - Type = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - IsOnline = table.Column(type: "tinyint(1)", nullable: false), - LastSeen = table.Column(type: "datetime(6)", nullable: false), - Description = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - CpuType = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - CpuCores = table.Column(type: "int", nullable: false), - GpuType = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - RamSize = table.Column(type: "double", nullable: false), - TagId = table.Column(type: "int", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Servers", x => x.Id); - table.ForeignKey( - name: "FK_Servers_Tags_TagId", - column: x => x.TagId, - principalTable: "Tags", - principalColumn: "Id"); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "LogEvents", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Timestamp = table.Column(type: "datetime(6)", nullable: false), - Message = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Level = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ServerId = table.Column(type: "int", nullable: true), - ContainerId = table.Column(type: "int", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_LogEvents", x => x.Id); - table.ForeignKey( - name: "FK_LogEvents_Containers_ContainerId", - column: x => x.ContainerId, - principalTable: "Containers", - principalColumn: "Id"); - table.ForeignKey( - name: "FK_LogEvents_Servers_ServerId", - column: x => x.ServerId, - principalTable: "Servers", - principalColumn: "Id"); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "Metrics", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Timestamp = table.Column(type: "datetime(6)", nullable: false), - Type = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Value = table.Column(type: "double", nullable: false), - ServerId = table.Column(type: "int", nullable: true), - ContainerId = table.Column(type: "int", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Metrics", x => x.Id); - table.ForeignKey( - name: "FK_Metrics_Containers_ContainerId", - column: x => x.ContainerId, - principalTable: "Containers", - principalColumn: "Id"); - table.ForeignKey( - name: "FK_Metrics_Servers_ServerId", - column: x => x.ServerId, - principalTable: "Servers", - principalColumn: "Id"); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_Containers_ImageId", - table: "Containers", - column: "ImageId"); - - migrationBuilder.CreateIndex( - name: "IX_Containers_TagId", - table: "Containers", - column: "TagId"); - - migrationBuilder.CreateIndex( - name: "IX_LogEvents_ContainerId", - table: "LogEvents", - column: "ContainerId"); - - migrationBuilder.CreateIndex( - name: "IX_LogEvents_ServerId", - table: "LogEvents", - column: "ServerId"); - - migrationBuilder.CreateIndex( - name: "IX_Metrics_ContainerId", - table: "Metrics", - column: "ContainerId"); - - migrationBuilder.CreateIndex( - name: "IX_Metrics_ServerId", - table: "Metrics", - column: "ServerId"); - - migrationBuilder.CreateIndex( - name: "IX_Servers_TagId", - table: "Servers", - column: "TagId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "LogEvents"); - - migrationBuilder.DropTable( - name: "Metrics"); - - migrationBuilder.DropTable( - name: "Users"); - - migrationBuilder.DropTable( - name: "Containers"); - - migrationBuilder.DropTable( - name: "Servers"); - - migrationBuilder.DropTable( - name: "Images"); - - migrationBuilder.DropTable( - name: "Tags"); - } - } -} diff --git a/Watcher/Migrations/20250617165126_ServerPrimaryKey.Designer.cs b/Watcher/Migrations/20250617165126_ServerPrimaryKey.Designer.cs deleted file mode 100644 index 14cf440..0000000 --- a/Watcher/Migrations/20250617165126_ServerPrimaryKey.Designer.cs +++ /dev/null @@ -1,298 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Watcher.Data; - -#nullable disable - -namespace Watcher.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20250617165126_ServerPrimaryKey")] - partial class ServerPrimaryKey - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "8.0.6"); - - modelBuilder.Entity("Watcher.Models.Container", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("Hostname") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("ImageId") - .HasColumnType("INTEGER"); - - b.Property("IsRunning") - .HasColumnType("INTEGER"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Status") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("TagId") - .HasColumnType("INTEGER"); - - b.Property("Type") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.HasIndex("TagId"); - - b.ToTable("Containers"); - }); - - modelBuilder.Entity("Watcher.Models.Image", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Tag") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Images"); - }); - - modelBuilder.Entity("Watcher.Models.LogEvent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("ContainerId") - .HasColumnType("INTEGER"); - - b.Property("Level") - .HasColumnType("TEXT"); - - b.Property("Message") - .HasColumnType("TEXT"); - - b.Property("ServerId") - .HasColumnType("INTEGER"); - - b.Property("Timestamp") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("ContainerId"); - - b.HasIndex("ServerId"); - - b.ToTable("LogEvents"); - }); - - modelBuilder.Entity("Watcher.Models.Metric", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("ContainerId") - .HasColumnType("INTEGER"); - - b.Property("ServerId") - .HasColumnType("INTEGER"); - - b.Property("Timestamp") - .HasColumnType("TEXT"); - - b.Property("Type") - .HasColumnType("TEXT"); - - b.Property("Value") - .HasColumnType("REAL"); - - b.HasKey("Id"); - - b.HasIndex("ContainerId"); - - b.HasIndex("ServerId"); - - b.ToTable("Metrics"); - }); - - modelBuilder.Entity("Watcher.Models.Server", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CpuCores") - .HasColumnType("INTEGER"); - - b.Property("CpuType") - .HasColumnType("TEXT"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("Description") - .HasColumnType("TEXT"); - - b.Property("GpuType") - .HasColumnType("TEXT"); - - b.Property("IPAddress") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("IsOnline") - .HasColumnType("INTEGER"); - - b.Property("LastSeen") - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("RamSize") - .HasColumnType("REAL"); - - b.Property("TagId") - .HasColumnType("INTEGER"); - - b.Property("Type") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("TagId"); - - b.ToTable("Servers"); - }); - - modelBuilder.Entity("Watcher.Models.Tag", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Tags"); - }); - - modelBuilder.Entity("Watcher.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Email") - .HasColumnType("TEXT"); - - b.Property("LastLogin") - .HasColumnType("TEXT"); - - b.Property("PocketId") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("PreferredUsername") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Watcher.Models.Container", b => - { - b.HasOne("Watcher.Models.Image", "Image") - .WithMany("Containers") - .HasForeignKey("ImageId"); - - b.HasOne("Watcher.Models.Tag", null) - .WithMany("Containers") - .HasForeignKey("TagId"); - - b.Navigation("Image"); - }); - - modelBuilder.Entity("Watcher.Models.LogEvent", b => - { - b.HasOne("Watcher.Models.Container", "Container") - .WithMany() - .HasForeignKey("ContainerId"); - - b.HasOne("Watcher.Models.Server", "Server") - .WithMany() - .HasForeignKey("ServerId"); - - b.Navigation("Container"); - - b.Navigation("Server"); - }); - - modelBuilder.Entity("Watcher.Models.Metric", b => - { - b.HasOne("Watcher.Models.Container", "Container") - .WithMany() - .HasForeignKey("ContainerId"); - - b.HasOne("Watcher.Models.Server", "Server") - .WithMany() - .HasForeignKey("ServerId"); - - b.Navigation("Container"); - - b.Navigation("Server"); - }); - - modelBuilder.Entity("Watcher.Models.Server", b => - { - b.HasOne("Watcher.Models.Tag", null) - .WithMany("Servers") - .HasForeignKey("TagId"); - }); - - modelBuilder.Entity("Watcher.Models.Image", b => - { - b.Navigation("Containers"); - }); - - modelBuilder.Entity("Watcher.Models.Tag", b => - { - b.Navigation("Containers"); - - b.Navigation("Servers"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Watcher/Migrations/20250617165126_ServerPrimaryKey.cs b/Watcher/Migrations/20250617165126_ServerPrimaryKey.cs deleted file mode 100644 index f258b61..0000000 --- a/Watcher/Migrations/20250617165126_ServerPrimaryKey.cs +++ /dev/null @@ -1,785 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Watcher.Migrations -{ - /// - public partial class ServerPrimaryKey : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "PreferredUsername", - table: "Users", - type: "TEXT", - nullable: false, - oldClrType: typeof(string), - oldType: "longtext"); - - migrationBuilder.AlterColumn( - name: "PocketId", - table: "Users", - type: "TEXT", - nullable: false, - oldClrType: typeof(string), - oldType: "longtext"); - - migrationBuilder.AlterColumn( - name: "LastLogin", - table: "Users", - type: "TEXT", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "datetime(6)"); - - migrationBuilder.AlterColumn( - name: "Email", - table: "Users", - type: "TEXT", - nullable: true, - oldClrType: typeof(string), - oldType: "longtext", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Id", - table: "Users", - type: "INTEGER", - nullable: false, - oldClrType: typeof(int), - oldType: "int") - .Annotation("Sqlite:Autoincrement", true) - .OldAnnotation("Sqlite:Autoincrement", true); - - migrationBuilder.AlterColumn( - name: "Name", - table: "Tags", - type: "TEXT", - nullable: true, - oldClrType: typeof(string), - oldType: "longtext", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Id", - table: "Tags", - type: "INTEGER", - nullable: false, - oldClrType: typeof(int), - oldType: "int") - .Annotation("Sqlite:Autoincrement", true) - .OldAnnotation("Sqlite:Autoincrement", true); - - migrationBuilder.AlterColumn( - name: "Type", - table: "Servers", - type: "TEXT", - nullable: false, - oldClrType: typeof(string), - oldType: "longtext"); - - migrationBuilder.AlterColumn( - name: "TagId", - table: "Servers", - type: "INTEGER", - nullable: true, - oldClrType: typeof(int), - oldType: "int", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "RamSize", - table: "Servers", - type: "REAL", - nullable: false, - oldClrType: typeof(double), - oldType: "double"); - - migrationBuilder.AlterColumn( - name: "Name", - table: "Servers", - type: "TEXT", - nullable: false, - oldClrType: typeof(string), - oldType: "longtext"); - - migrationBuilder.AlterColumn( - name: "LastSeen", - table: "Servers", - type: "TEXT", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "datetime(6)"); - - migrationBuilder.AlterColumn( - name: "IsOnline", - table: "Servers", - type: "INTEGER", - nullable: false, - oldClrType: typeof(bool), - oldType: "tinyint(1)"); - - migrationBuilder.AlterColumn( - name: "IPAddress", - table: "Servers", - type: "TEXT", - nullable: false, - oldClrType: typeof(string), - oldType: "longtext"); - - migrationBuilder.AlterColumn( - name: "GpuType", - table: "Servers", - type: "TEXT", - nullable: true, - oldClrType: typeof(string), - oldType: "longtext", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Description", - table: "Servers", - type: "TEXT", - nullable: true, - oldClrType: typeof(string), - oldType: "longtext", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "CreatedAt", - table: "Servers", - type: "TEXT", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "datetime(6)"); - - migrationBuilder.AlterColumn( - name: "CpuType", - table: "Servers", - type: "TEXT", - nullable: true, - oldClrType: typeof(string), - oldType: "longtext", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "CpuCores", - table: "Servers", - type: "INTEGER", - nullable: false, - oldClrType: typeof(int), - oldType: "int"); - - migrationBuilder.AlterColumn( - name: "Id", - table: "Servers", - type: "INTEGER", - nullable: false, - oldClrType: typeof(int), - oldType: "int") - .Annotation("Sqlite:Autoincrement", true) - .OldAnnotation("Sqlite:Autoincrement", true); - - migrationBuilder.AlterColumn( - name: "Value", - table: "Metrics", - type: "REAL", - nullable: false, - oldClrType: typeof(double), - oldType: "double"); - - migrationBuilder.AlterColumn( - name: "Type", - table: "Metrics", - type: "TEXT", - nullable: true, - oldClrType: typeof(string), - oldType: "longtext", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Timestamp", - table: "Metrics", - type: "TEXT", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "datetime(6)"); - - migrationBuilder.AlterColumn( - name: "ServerId", - table: "Metrics", - type: "INTEGER", - nullable: true, - oldClrType: typeof(int), - oldType: "int", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "ContainerId", - table: "Metrics", - type: "INTEGER", - nullable: true, - oldClrType: typeof(int), - oldType: "int", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Id", - table: "Metrics", - type: "INTEGER", - nullable: false, - oldClrType: typeof(int), - oldType: "int") - .Annotation("Sqlite:Autoincrement", true) - .OldAnnotation("Sqlite:Autoincrement", true); - - migrationBuilder.AlterColumn( - name: "Timestamp", - table: "LogEvents", - type: "TEXT", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "datetime(6)"); - - migrationBuilder.AlterColumn( - name: "ServerId", - table: "LogEvents", - type: "INTEGER", - nullable: true, - oldClrType: typeof(int), - oldType: "int", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Message", - table: "LogEvents", - type: "TEXT", - nullable: true, - oldClrType: typeof(string), - oldType: "longtext", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Level", - table: "LogEvents", - type: "TEXT", - nullable: true, - oldClrType: typeof(string), - oldType: "longtext", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "ContainerId", - table: "LogEvents", - type: "INTEGER", - nullable: true, - oldClrType: typeof(int), - oldType: "int", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Id", - table: "LogEvents", - type: "INTEGER", - nullable: false, - oldClrType: typeof(int), - oldType: "int") - .Annotation("Sqlite:Autoincrement", true) - .OldAnnotation("Sqlite:Autoincrement", true); - - migrationBuilder.AlterColumn( - name: "Tag", - table: "Images", - type: "TEXT", - nullable: true, - oldClrType: typeof(string), - oldType: "longtext", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Name", - table: "Images", - type: "TEXT", - nullable: true, - oldClrType: typeof(string), - oldType: "longtext", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Id", - table: "Images", - type: "INTEGER", - nullable: false, - oldClrType: typeof(int), - oldType: "int") - .Annotation("Sqlite:Autoincrement", true) - .OldAnnotation("Sqlite:Autoincrement", true); - - migrationBuilder.AlterColumn( - name: "Type", - table: "Containers", - type: "TEXT", - nullable: false, - oldClrType: typeof(string), - oldType: "longtext"); - - migrationBuilder.AlterColumn( - name: "TagId", - table: "Containers", - type: "INTEGER", - nullable: true, - oldClrType: typeof(int), - oldType: "int", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Status", - table: "Containers", - type: "TEXT", - nullable: false, - oldClrType: typeof(string), - oldType: "longtext"); - - migrationBuilder.AlterColumn( - name: "Name", - table: "Containers", - type: "TEXT", - nullable: false, - oldClrType: typeof(string), - oldType: "longtext"); - - migrationBuilder.AlterColumn( - name: "IsRunning", - table: "Containers", - type: "INTEGER", - nullable: false, - oldClrType: typeof(bool), - oldType: "tinyint(1)"); - - migrationBuilder.AlterColumn( - name: "ImageId", - table: "Containers", - type: "INTEGER", - nullable: true, - oldClrType: typeof(int), - oldType: "int", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Hostname", - table: "Containers", - type: "TEXT", - nullable: false, - oldClrType: typeof(string), - oldType: "longtext"); - - migrationBuilder.AlterColumn( - name: "CreatedAt", - table: "Containers", - type: "TEXT", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "datetime(6)"); - - migrationBuilder.AlterColumn( - name: "Id", - table: "Containers", - type: "INTEGER", - nullable: false, - oldClrType: typeof(int), - oldType: "int") - .Annotation("Sqlite:Autoincrement", true) - .OldAnnotation("Sqlite:Autoincrement", true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "PreferredUsername", - table: "Users", - type: "longtext", - nullable: false, - oldClrType: typeof(string), - oldType: "TEXT"); - - migrationBuilder.AlterColumn( - name: "PocketId", - table: "Users", - type: "longtext", - nullable: false, - oldClrType: typeof(string), - oldType: "TEXT"); - - migrationBuilder.AlterColumn( - name: "LastLogin", - table: "Users", - type: "datetime(6)", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "TEXT"); - - migrationBuilder.AlterColumn( - name: "Email", - table: "Users", - type: "longtext", - nullable: true, - oldClrType: typeof(string), - oldType: "TEXT", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Id", - table: "Users", - type: "int", - nullable: false, - oldClrType: typeof(int), - oldType: "INTEGER") - .Annotation("Sqlite:Autoincrement", true) - .OldAnnotation("Sqlite:Autoincrement", true); - - migrationBuilder.AlterColumn( - name: "Name", - table: "Tags", - type: "longtext", - nullable: true, - oldClrType: typeof(string), - oldType: "TEXT", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Id", - table: "Tags", - type: "int", - nullable: false, - oldClrType: typeof(int), - oldType: "INTEGER") - .Annotation("Sqlite:Autoincrement", true) - .OldAnnotation("Sqlite:Autoincrement", true); - - migrationBuilder.AlterColumn( - name: "Type", - table: "Servers", - type: "longtext", - nullable: false, - oldClrType: typeof(string), - oldType: "TEXT"); - - migrationBuilder.AlterColumn( - name: "TagId", - table: "Servers", - type: "int", - nullable: true, - oldClrType: typeof(int), - oldType: "INTEGER", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "RamSize", - table: "Servers", - type: "double", - nullable: false, - oldClrType: typeof(double), - oldType: "REAL"); - - migrationBuilder.AlterColumn( - name: "Name", - table: "Servers", - type: "longtext", - nullable: false, - oldClrType: typeof(string), - oldType: "TEXT"); - - migrationBuilder.AlterColumn( - name: "LastSeen", - table: "Servers", - type: "datetime(6)", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "TEXT"); - - migrationBuilder.AlterColumn( - name: "IsOnline", - table: "Servers", - type: "tinyint(1)", - nullable: false, - oldClrType: typeof(bool), - oldType: "INTEGER"); - - migrationBuilder.AlterColumn( - name: "IPAddress", - table: "Servers", - type: "longtext", - nullable: false, - oldClrType: typeof(string), - oldType: "TEXT"); - - migrationBuilder.AlterColumn( - name: "GpuType", - table: "Servers", - type: "longtext", - nullable: true, - oldClrType: typeof(string), - oldType: "TEXT", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Description", - table: "Servers", - type: "longtext", - nullable: true, - oldClrType: typeof(string), - oldType: "TEXT", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "CreatedAt", - table: "Servers", - type: "datetime(6)", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "TEXT"); - - migrationBuilder.AlterColumn( - name: "CpuType", - table: "Servers", - type: "longtext", - nullable: true, - oldClrType: typeof(string), - oldType: "TEXT", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "CpuCores", - table: "Servers", - type: "int", - nullable: false, - oldClrType: typeof(int), - oldType: "INTEGER"); - - migrationBuilder.AlterColumn( - name: "Id", - table: "Servers", - type: "int", - nullable: false, - oldClrType: typeof(int), - oldType: "INTEGER") - .Annotation("Sqlite:Autoincrement", true) - .OldAnnotation("Sqlite:Autoincrement", true); - - migrationBuilder.AlterColumn( - name: "Value", - table: "Metrics", - type: "double", - nullable: false, - oldClrType: typeof(double), - oldType: "REAL"); - - migrationBuilder.AlterColumn( - name: "Type", - table: "Metrics", - type: "longtext", - nullable: true, - oldClrType: typeof(string), - oldType: "TEXT", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Timestamp", - table: "Metrics", - type: "datetime(6)", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "TEXT"); - - migrationBuilder.AlterColumn( - name: "ServerId", - table: "Metrics", - type: "int", - nullable: true, - oldClrType: typeof(int), - oldType: "INTEGER", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "ContainerId", - table: "Metrics", - type: "int", - nullable: true, - oldClrType: typeof(int), - oldType: "INTEGER", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Id", - table: "Metrics", - type: "int", - nullable: false, - oldClrType: typeof(int), - oldType: "INTEGER") - .Annotation("Sqlite:Autoincrement", true) - .OldAnnotation("Sqlite:Autoincrement", true); - - migrationBuilder.AlterColumn( - name: "Timestamp", - table: "LogEvents", - type: "datetime(6)", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "TEXT"); - - migrationBuilder.AlterColumn( - name: "ServerId", - table: "LogEvents", - type: "int", - nullable: true, - oldClrType: typeof(int), - oldType: "INTEGER", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Message", - table: "LogEvents", - type: "longtext", - nullable: true, - oldClrType: typeof(string), - oldType: "TEXT", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Level", - table: "LogEvents", - type: "longtext", - nullable: true, - oldClrType: typeof(string), - oldType: "TEXT", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "ContainerId", - table: "LogEvents", - type: "int", - nullable: true, - oldClrType: typeof(int), - oldType: "INTEGER", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Id", - table: "LogEvents", - type: "int", - nullable: false, - oldClrType: typeof(int), - oldType: "INTEGER") - .Annotation("Sqlite:Autoincrement", true) - .OldAnnotation("Sqlite:Autoincrement", true); - - migrationBuilder.AlterColumn( - name: "Tag", - table: "Images", - type: "longtext", - nullable: true, - oldClrType: typeof(string), - oldType: "TEXT", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Name", - table: "Images", - type: "longtext", - nullable: true, - oldClrType: typeof(string), - oldType: "TEXT", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Id", - table: "Images", - type: "int", - nullable: false, - oldClrType: typeof(int), - oldType: "INTEGER") - .Annotation("Sqlite:Autoincrement", true) - .OldAnnotation("Sqlite:Autoincrement", true); - - migrationBuilder.AlterColumn( - name: "Type", - table: "Containers", - type: "longtext", - nullable: false, - oldClrType: typeof(string), - oldType: "TEXT"); - - migrationBuilder.AlterColumn( - name: "TagId", - table: "Containers", - type: "int", - nullable: true, - oldClrType: typeof(int), - oldType: "INTEGER", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Status", - table: "Containers", - type: "longtext", - nullable: false, - oldClrType: typeof(string), - oldType: "TEXT"); - - migrationBuilder.AlterColumn( - name: "Name", - table: "Containers", - type: "longtext", - nullable: false, - oldClrType: typeof(string), - oldType: "TEXT"); - - migrationBuilder.AlterColumn( - name: "IsRunning", - table: "Containers", - type: "tinyint(1)", - nullable: false, - oldClrType: typeof(bool), - oldType: "INTEGER"); - - migrationBuilder.AlterColumn( - name: "ImageId", - table: "Containers", - type: "int", - nullable: true, - oldClrType: typeof(int), - oldType: "INTEGER", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Hostname", - table: "Containers", - type: "longtext", - nullable: false, - oldClrType: typeof(string), - oldType: "TEXT"); - - migrationBuilder.AlterColumn( - name: "CreatedAt", - table: "Containers", - type: "datetime(6)", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "TEXT"); - - migrationBuilder.AlterColumn( - name: "Id", - table: "Containers", - type: "int", - nullable: false, - oldClrType: typeof(int), - oldType: "INTEGER") - .Annotation("Sqlite:Autoincrement", true) - .OldAnnotation("Sqlite:Autoincrement", true); - } - } -} diff --git a/Watcher/Migrations/20250617174242_UserPasswordAdded.Designer.cs b/Watcher/Migrations/20250617174242_UserPasswordAdded.Designer.cs deleted file mode 100644 index 123e1fa..0000000 --- a/Watcher/Migrations/20250617174242_UserPasswordAdded.Designer.cs +++ /dev/null @@ -1,306 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Watcher.Data; - -#nullable disable - -namespace Watcher.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20250617174242_UserPasswordAdded")] - partial class UserPasswordAdded - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "8.0.6"); - - modelBuilder.Entity("Watcher.Models.Container", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("Hostname") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("ImageId") - .HasColumnType("INTEGER"); - - b.Property("IsRunning") - .HasColumnType("INTEGER"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Status") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("TagId") - .HasColumnType("INTEGER"); - - b.Property("Type") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.HasIndex("TagId"); - - b.ToTable("Containers"); - }); - - modelBuilder.Entity("Watcher.Models.Image", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Tag") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Images"); - }); - - modelBuilder.Entity("Watcher.Models.LogEvent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("ContainerId") - .HasColumnType("INTEGER"); - - b.Property("Level") - .HasColumnType("TEXT"); - - b.Property("Message") - .HasColumnType("TEXT"); - - b.Property("ServerId") - .HasColumnType("INTEGER"); - - b.Property("Timestamp") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("ContainerId"); - - b.HasIndex("ServerId"); - - b.ToTable("LogEvents"); - }); - - modelBuilder.Entity("Watcher.Models.Metric", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("ContainerId") - .HasColumnType("INTEGER"); - - b.Property("ServerId") - .HasColumnType("INTEGER"); - - b.Property("Timestamp") - .HasColumnType("TEXT"); - - b.Property("Type") - .HasColumnType("TEXT"); - - b.Property("Value") - .HasColumnType("REAL"); - - b.HasKey("Id"); - - b.HasIndex("ContainerId"); - - b.HasIndex("ServerId"); - - b.ToTable("Metrics"); - }); - - modelBuilder.Entity("Watcher.Models.Server", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CpuCores") - .HasColumnType("INTEGER"); - - b.Property("CpuType") - .HasColumnType("TEXT"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("Description") - .HasColumnType("TEXT"); - - b.Property("GpuType") - .HasColumnType("TEXT"); - - b.Property("IPAddress") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("IsOnline") - .HasColumnType("INTEGER"); - - b.Property("LastSeen") - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("RamSize") - .HasColumnType("REAL"); - - b.Property("TagId") - .HasColumnType("INTEGER"); - - b.Property("Type") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("TagId"); - - b.ToTable("Servers"); - }); - - modelBuilder.Entity("Watcher.Models.Tag", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Tags"); - }); - - modelBuilder.Entity("Watcher.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Email") - .HasColumnType("TEXT"); - - b.Property("IdentityProvider") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("LastLogin") - .HasColumnType("TEXT"); - - b.Property("Password") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("PocketId") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("PreferredUsername") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Watcher.Models.Container", b => - { - b.HasOne("Watcher.Models.Image", "Image") - .WithMany("Containers") - .HasForeignKey("ImageId"); - - b.HasOne("Watcher.Models.Tag", null) - .WithMany("Containers") - .HasForeignKey("TagId"); - - b.Navigation("Image"); - }); - - modelBuilder.Entity("Watcher.Models.LogEvent", b => - { - b.HasOne("Watcher.Models.Container", "Container") - .WithMany() - .HasForeignKey("ContainerId"); - - b.HasOne("Watcher.Models.Server", "Server") - .WithMany() - .HasForeignKey("ServerId"); - - b.Navigation("Container"); - - b.Navigation("Server"); - }); - - modelBuilder.Entity("Watcher.Models.Metric", b => - { - b.HasOne("Watcher.Models.Container", "Container") - .WithMany() - .HasForeignKey("ContainerId"); - - b.HasOne("Watcher.Models.Server", "Server") - .WithMany() - .HasForeignKey("ServerId"); - - b.Navigation("Container"); - - b.Navigation("Server"); - }); - - modelBuilder.Entity("Watcher.Models.Server", b => - { - b.HasOne("Watcher.Models.Tag", null) - .WithMany("Servers") - .HasForeignKey("TagId"); - }); - - modelBuilder.Entity("Watcher.Models.Image", b => - { - b.Navigation("Containers"); - }); - - modelBuilder.Entity("Watcher.Models.Tag", b => - { - b.Navigation("Containers"); - - b.Navigation("Servers"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Watcher/Migrations/20250617174242_UserPasswordAdded.cs b/Watcher/Migrations/20250617174242_UserPasswordAdded.cs deleted file mode 100644 index 04ef332..0000000 --- a/Watcher/Migrations/20250617174242_UserPasswordAdded.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Watcher.Migrations -{ - /// - public partial class UserPasswordAdded : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "IdentityProvider", - table: "Users", - type: "TEXT", - nullable: false, - defaultValue: ""); - - migrationBuilder.AddColumn( - name: "Password", - table: "Users", - type: "TEXT", - nullable: false, - defaultValue: ""); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "IdentityProvider", - table: "Users"); - - migrationBuilder.DropColumn( - name: "Password", - table: "Users"); - } - } -} diff --git a/Watcher/Migrations/20250621124832_DB-Update Issue#32.Designer.cs b/Watcher/Migrations/20250621124832_DB-Update Issue#32.Designer.cs deleted file mode 100644 index e8cad36..0000000 --- a/Watcher/Migrations/20250621124832_DB-Update Issue#32.Designer.cs +++ /dev/null @@ -1,316 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Watcher.Data; - -#nullable disable - -namespace Watcher.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20250621124832_DB-Update Issue#32")] - partial class DBUpdateIssue32 - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "8.0.6"); - - modelBuilder.Entity("Watcher.Models.Container", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("Hostname") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("ImageId") - .HasColumnType("INTEGER"); - - b.Property("IsRunning") - .HasColumnType("INTEGER"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Status") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("TagId") - .HasColumnType("INTEGER"); - - b.Property("Type") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.HasIndex("TagId"); - - b.ToTable("Containers"); - }); - - modelBuilder.Entity("Watcher.Models.Image", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Tag") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Images"); - }); - - modelBuilder.Entity("Watcher.Models.LogEvent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("ContainerId") - .HasColumnType("INTEGER"); - - b.Property("Level") - .HasColumnType("TEXT"); - - b.Property("Message") - .HasColumnType("TEXT"); - - b.Property("ServerId") - .HasColumnType("INTEGER"); - - b.Property("Timestamp") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("ContainerId"); - - b.HasIndex("ServerId"); - - b.ToTable("LogEvents"); - }); - - modelBuilder.Entity("Watcher.Models.Metric", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CPU_Load") - .HasColumnType("REAL"); - - b.Property("CPU_Temp") - .HasColumnType("REAL"); - - b.Property("DISK_Size") - .HasColumnType("REAL"); - - b.Property("DISK_Temp") - .HasColumnType("REAL"); - - b.Property("DISK_Usage") - .HasColumnType("REAL"); - - b.Property("GPU_Load") - .HasColumnType("REAL"); - - b.Property("GPU_Temp") - .HasColumnType("REAL"); - - b.Property("GPU_Vram_Size") - .HasColumnType("REAL"); - - b.Property("GPU_Vram_Usage") - .HasColumnType("REAL"); - - b.Property("NET_In") - .HasColumnType("REAL"); - - b.Property("NET_Out") - .HasColumnType("REAL"); - - b.Property("RAM_Load") - .HasColumnType("REAL"); - - b.Property("RAM_Size") - .HasColumnType("REAL"); - - b.Property("ServerId") - .HasColumnType("INTEGER"); - - b.Property("Timestamp") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Metrics"); - }); - - modelBuilder.Entity("Watcher.Models.Server", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CpuCores") - .HasColumnType("INTEGER"); - - b.Property("CpuType") - .HasColumnType("TEXT"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("Description") - .HasColumnType("TEXT"); - - b.Property("GpuType") - .HasColumnType("TEXT"); - - b.Property("IPAddress") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("IsOnline") - .HasColumnType("INTEGER"); - - b.Property("LastSeen") - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("RamSize") - .HasColumnType("REAL"); - - b.Property("TagId") - .HasColumnType("INTEGER"); - - b.Property("Type") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("TagId"); - - b.ToTable("Servers"); - }); - - modelBuilder.Entity("Watcher.Models.Tag", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Tags"); - }); - - modelBuilder.Entity("Watcher.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Email") - .HasColumnType("TEXT"); - - b.Property("IdentityProvider") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("LastLogin") - .HasColumnType("TEXT"); - - b.Property("OIDC_Id") - .HasColumnType("TEXT"); - - b.Property("Password") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Username") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Watcher.Models.Container", b => - { - b.HasOne("Watcher.Models.Image", "Image") - .WithMany("Containers") - .HasForeignKey("ImageId"); - - b.HasOne("Watcher.Models.Tag", null) - .WithMany("Containers") - .HasForeignKey("TagId"); - - b.Navigation("Image"); - }); - - modelBuilder.Entity("Watcher.Models.LogEvent", b => - { - b.HasOne("Watcher.Models.Container", "Container") - .WithMany() - .HasForeignKey("ContainerId"); - - b.HasOne("Watcher.Models.Server", "Server") - .WithMany() - .HasForeignKey("ServerId"); - - b.Navigation("Container"); - - b.Navigation("Server"); - }); - - modelBuilder.Entity("Watcher.Models.Server", b => - { - b.HasOne("Watcher.Models.Tag", null) - .WithMany("Servers") - .HasForeignKey("TagId"); - }); - - modelBuilder.Entity("Watcher.Models.Image", b => - { - b.Navigation("Containers"); - }); - - modelBuilder.Entity("Watcher.Models.Tag", b => - { - b.Navigation("Containers"); - - b.Navigation("Servers"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Watcher/Migrations/20250621124832_DB-Update Issue#32.cs b/Watcher/Migrations/20250621124832_DB-Update Issue#32.cs deleted file mode 100644 index b7644a8..0000000 --- a/Watcher/Migrations/20250621124832_DB-Update Issue#32.cs +++ /dev/null @@ -1,251 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Watcher.Migrations -{ - /// - public partial class DBUpdateIssue32 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Metrics_Containers_ContainerId", - table: "Metrics"); - - migrationBuilder.DropForeignKey( - name: "FK_Metrics_Servers_ServerId", - table: "Metrics"); - - migrationBuilder.DropIndex( - name: "IX_Metrics_ContainerId", - table: "Metrics"); - - migrationBuilder.DropIndex( - name: "IX_Metrics_ServerId", - table: "Metrics"); - - migrationBuilder.DropColumn( - name: "PocketId", - table: "Users"); - - migrationBuilder.DropColumn( - name: "ContainerId", - table: "Metrics"); - - migrationBuilder.DropColumn( - name: "Type", - table: "Metrics"); - - migrationBuilder.RenameColumn( - name: "PreferredUsername", - table: "Users", - newName: "Username"); - - migrationBuilder.RenameColumn( - name: "Value", - table: "Metrics", - newName: "RAM_Size"); - - migrationBuilder.AddColumn( - name: "OIDC_Id", - table: "Users", - type: "TEXT", - nullable: true); - - migrationBuilder.AddColumn( - name: "CPU_Load", - table: "Metrics", - type: "REAL", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AddColumn( - name: "CPU_Temp", - table: "Metrics", - type: "REAL", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AddColumn( - name: "DISK_Size", - table: "Metrics", - type: "REAL", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AddColumn( - name: "DISK_Temp", - table: "Metrics", - type: "REAL", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AddColumn( - name: "DISK_Usage", - table: "Metrics", - type: "REAL", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AddColumn( - name: "GPU_Load", - table: "Metrics", - type: "REAL", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AddColumn( - name: "GPU_Temp", - table: "Metrics", - type: "REAL", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AddColumn( - name: "GPU_Vram_Size", - table: "Metrics", - type: "REAL", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AddColumn( - name: "GPU_Vram_Usage", - table: "Metrics", - type: "REAL", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AddColumn( - name: "NET_In", - table: "Metrics", - type: "REAL", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AddColumn( - name: "NET_Out", - table: "Metrics", - type: "REAL", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AddColumn( - name: "RAM_Load", - table: "Metrics", - type: "REAL", - nullable: false, - defaultValue: 0.0); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "OIDC_Id", - table: "Users"); - - migrationBuilder.DropColumn( - name: "CPU_Load", - table: "Metrics"); - - migrationBuilder.DropColumn( - name: "CPU_Temp", - table: "Metrics"); - - migrationBuilder.DropColumn( - name: "DISK_Size", - table: "Metrics"); - - migrationBuilder.DropColumn( - name: "DISK_Temp", - table: "Metrics"); - - migrationBuilder.DropColumn( - name: "DISK_Usage", - table: "Metrics"); - - migrationBuilder.DropColumn( - name: "GPU_Load", - table: "Metrics"); - - migrationBuilder.DropColumn( - name: "GPU_Temp", - table: "Metrics"); - - migrationBuilder.DropColumn( - name: "GPU_Vram_Size", - table: "Metrics"); - - migrationBuilder.DropColumn( - name: "GPU_Vram_Usage", - table: "Metrics"); - - migrationBuilder.DropColumn( - name: "NET_In", - table: "Metrics"); - - migrationBuilder.DropColumn( - name: "NET_Out", - table: "Metrics"); - - migrationBuilder.DropColumn( - name: "RAM_Load", - table: "Metrics"); - - migrationBuilder.RenameColumn( - name: "Username", - table: "Users", - newName: "PreferredUsername"); - - migrationBuilder.RenameColumn( - name: "RAM_Size", - table: "Metrics", - newName: "Value"); - - migrationBuilder.AddColumn( - name: "PocketId", - table: "Users", - type: "TEXT", - nullable: false, - defaultValue: ""); - - migrationBuilder.AddColumn( - name: "ContainerId", - table: "Metrics", - type: "INTEGER", - nullable: true); - - migrationBuilder.AddColumn( - name: "Type", - table: "Metrics", - type: "TEXT", - nullable: true); - - migrationBuilder.CreateIndex( - name: "IX_Metrics_ContainerId", - table: "Metrics", - column: "ContainerId"); - - migrationBuilder.CreateIndex( - name: "IX_Metrics_ServerId", - table: "Metrics", - column: "ServerId"); - - migrationBuilder.AddForeignKey( - name: "FK_Metrics_Containers_ContainerId", - table: "Metrics", - column: "ContainerId", - principalTable: "Containers", - principalColumn: "Id"); - - migrationBuilder.AddForeignKey( - name: "FK_Metrics_Servers_ServerId", - table: "Metrics", - column: "ServerId", - principalTable: "Servers", - principalColumn: "Id"); - } - } -} diff --git a/Watcher/Migrations/20250621125157_DB-Update Issue#32 IsVerified-Servers.Designer.cs b/Watcher/Migrations/20250621125157_DB-Update Issue#32 IsVerified-Servers.Designer.cs deleted file mode 100644 index feb5c2e..0000000 --- a/Watcher/Migrations/20250621125157_DB-Update Issue#32 IsVerified-Servers.Designer.cs +++ /dev/null @@ -1,319 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Watcher.Data; - -#nullable disable - -namespace Watcher.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20250621125157_DB-Update Issue#32 IsVerified-Servers")] - partial class DBUpdateIssue32IsVerifiedServers - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "8.0.6"); - - modelBuilder.Entity("Watcher.Models.Container", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("Hostname") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("ImageId") - .HasColumnType("INTEGER"); - - b.Property("IsRunning") - .HasColumnType("INTEGER"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Status") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("TagId") - .HasColumnType("INTEGER"); - - b.Property("Type") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.HasIndex("TagId"); - - b.ToTable("Containers"); - }); - - modelBuilder.Entity("Watcher.Models.Image", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Tag") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Images"); - }); - - modelBuilder.Entity("Watcher.Models.LogEvent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("ContainerId") - .HasColumnType("INTEGER"); - - b.Property("Level") - .HasColumnType("TEXT"); - - b.Property("Message") - .HasColumnType("TEXT"); - - b.Property("ServerId") - .HasColumnType("INTEGER"); - - b.Property("Timestamp") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("ContainerId"); - - b.HasIndex("ServerId"); - - b.ToTable("LogEvents"); - }); - - modelBuilder.Entity("Watcher.Models.Metric", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CPU_Load") - .HasColumnType("REAL"); - - b.Property("CPU_Temp") - .HasColumnType("REAL"); - - b.Property("DISK_Size") - .HasColumnType("REAL"); - - b.Property("DISK_Temp") - .HasColumnType("REAL"); - - b.Property("DISK_Usage") - .HasColumnType("REAL"); - - b.Property("GPU_Load") - .HasColumnType("REAL"); - - b.Property("GPU_Temp") - .HasColumnType("REAL"); - - b.Property("GPU_Vram_Size") - .HasColumnType("REAL"); - - b.Property("GPU_Vram_Usage") - .HasColumnType("REAL"); - - b.Property("NET_In") - .HasColumnType("REAL"); - - b.Property("NET_Out") - .HasColumnType("REAL"); - - b.Property("RAM_Load") - .HasColumnType("REAL"); - - b.Property("RAM_Size") - .HasColumnType("REAL"); - - b.Property("ServerId") - .HasColumnType("INTEGER"); - - b.Property("Timestamp") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Metrics"); - }); - - modelBuilder.Entity("Watcher.Models.Server", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CpuCores") - .HasColumnType("INTEGER"); - - b.Property("CpuType") - .HasColumnType("TEXT"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("Description") - .HasColumnType("TEXT"); - - b.Property("GpuType") - .HasColumnType("TEXT"); - - b.Property("IPAddress") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("IsOnline") - .HasColumnType("INTEGER"); - - b.Property("IsVerified") - .HasColumnType("INTEGER"); - - b.Property("LastSeen") - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("RamSize") - .HasColumnType("REAL"); - - b.Property("TagId") - .HasColumnType("INTEGER"); - - b.Property("Type") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("TagId"); - - b.ToTable("Servers"); - }); - - modelBuilder.Entity("Watcher.Models.Tag", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Tags"); - }); - - modelBuilder.Entity("Watcher.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Email") - .HasColumnType("TEXT"); - - b.Property("IdentityProvider") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("LastLogin") - .HasColumnType("TEXT"); - - b.Property("OIDC_Id") - .HasColumnType("TEXT"); - - b.Property("Password") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Username") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Watcher.Models.Container", b => - { - b.HasOne("Watcher.Models.Image", "Image") - .WithMany("Containers") - .HasForeignKey("ImageId"); - - b.HasOne("Watcher.Models.Tag", null) - .WithMany("Containers") - .HasForeignKey("TagId"); - - b.Navigation("Image"); - }); - - modelBuilder.Entity("Watcher.Models.LogEvent", b => - { - b.HasOne("Watcher.Models.Container", "Container") - .WithMany() - .HasForeignKey("ContainerId"); - - b.HasOne("Watcher.Models.Server", "Server") - .WithMany() - .HasForeignKey("ServerId"); - - b.Navigation("Container"); - - b.Navigation("Server"); - }); - - modelBuilder.Entity("Watcher.Models.Server", b => - { - b.HasOne("Watcher.Models.Tag", null) - .WithMany("Servers") - .HasForeignKey("TagId"); - }); - - modelBuilder.Entity("Watcher.Models.Image", b => - { - b.Navigation("Containers"); - }); - - modelBuilder.Entity("Watcher.Models.Tag", b => - { - b.Navigation("Containers"); - - b.Navigation("Servers"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Watcher/Migrations/20250621125157_DB-Update Issue#32 IsVerified-Servers.cs b/Watcher/Migrations/20250621125157_DB-Update Issue#32 IsVerified-Servers.cs deleted file mode 100644 index 974f389..0000000 --- a/Watcher/Migrations/20250621125157_DB-Update Issue#32 IsVerified-Servers.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Watcher.Migrations -{ - /// - public partial class DBUpdateIssue32IsVerifiedServers : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "IsVerified", - table: "Servers", - type: "INTEGER", - nullable: false, - defaultValue: false); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "IsVerified", - table: "Servers"); - } - } -} diff --git a/Watcher/Migrations/20250710090920_container-attribute.Designer.cs b/Watcher/Migrations/20250710090920_container-attribute.Designer.cs deleted file mode 100644 index deb4c2c..0000000 --- a/Watcher/Migrations/20250710090920_container-attribute.Designer.cs +++ /dev/null @@ -1,332 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Watcher.Data; - -#nullable disable - -namespace Watcher.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20250710090920_container-attribute")] - partial class containerattribute - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "8.0.6"); - - modelBuilder.Entity("Watcher.Models.Container", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("ExposedPort") - .HasColumnType("INTEGER"); - - b.Property("Health") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("HostServerId") - .HasColumnType("INTEGER"); - - b.Property("Image") - .HasColumnType("TEXT"); - - b.Property("ImageId") - .HasColumnType("INTEGER"); - - b.Property("InternalPort") - .HasColumnType("INTEGER"); - - b.Property("IsRunning") - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Status") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("TagId") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("HostServerId"); - - b.HasIndex("ImageId"); - - b.HasIndex("TagId"); - - b.ToTable("Containers"); - }); - - modelBuilder.Entity("Watcher.Models.Image", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Tag") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Images"); - }); - - modelBuilder.Entity("Watcher.Models.LogEvent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("ContainerId") - .HasColumnType("INTEGER"); - - b.Property("Level") - .HasColumnType("TEXT"); - - b.Property("Message") - .HasColumnType("TEXT"); - - b.Property("ServerId") - .HasColumnType("INTEGER"); - - b.Property("Timestamp") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("ContainerId"); - - b.HasIndex("ServerId"); - - b.ToTable("LogEvents"); - }); - - modelBuilder.Entity("Watcher.Models.Metric", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CPU_Load") - .HasColumnType("REAL"); - - b.Property("CPU_Temp") - .HasColumnType("REAL"); - - b.Property("DISK_Size") - .HasColumnType("REAL"); - - b.Property("DISK_Temp") - .HasColumnType("REAL"); - - b.Property("DISK_Usage") - .HasColumnType("REAL"); - - b.Property("GPU_Load") - .HasColumnType("REAL"); - - b.Property("GPU_Temp") - .HasColumnType("REAL"); - - b.Property("GPU_Vram_Size") - .HasColumnType("REAL"); - - b.Property("GPU_Vram_Usage") - .HasColumnType("REAL"); - - b.Property("NET_In") - .HasColumnType("REAL"); - - b.Property("NET_Out") - .HasColumnType("REAL"); - - b.Property("RAM_Load") - .HasColumnType("REAL"); - - b.Property("RAM_Size") - .HasColumnType("REAL"); - - b.Property("ServerId") - .HasColumnType("INTEGER"); - - b.Property("Timestamp") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Metrics"); - }); - - modelBuilder.Entity("Watcher.Models.Server", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CpuCores") - .HasColumnType("INTEGER"); - - b.Property("CpuType") - .HasColumnType("TEXT"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("Description") - .HasColumnType("TEXT"); - - b.Property("GpuType") - .HasColumnType("TEXT"); - - b.Property("IPAddress") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("IsOnline") - .HasColumnType("INTEGER"); - - b.Property("IsVerified") - .HasColumnType("INTEGER"); - - b.Property("LastSeen") - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("RamSize") - .HasColumnType("REAL"); - - b.Property("TagId") - .HasColumnType("INTEGER"); - - b.Property("Type") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("TagId"); - - b.ToTable("Servers"); - }); - - modelBuilder.Entity("Watcher.Models.Tag", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Tags"); - }); - - modelBuilder.Entity("Watcher.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Email") - .HasColumnType("TEXT"); - - b.Property("IdentityProvider") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("LastLogin") - .HasColumnType("TEXT"); - - b.Property("OIDC_Id") - .HasColumnType("TEXT"); - - b.Property("Password") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Username") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Watcher.Models.Container", b => - { - b.HasOne("Watcher.Models.Server", "HostServer") - .WithMany() - .HasForeignKey("HostServerId"); - - b.HasOne("Watcher.Models.Image", null) - .WithMany("Containers") - .HasForeignKey("ImageId"); - - b.HasOne("Watcher.Models.Tag", null) - .WithMany("Containers") - .HasForeignKey("TagId"); - - b.Navigation("HostServer"); - }); - - modelBuilder.Entity("Watcher.Models.LogEvent", b => - { - b.HasOne("Watcher.Models.Container", "Container") - .WithMany() - .HasForeignKey("ContainerId"); - - b.HasOne("Watcher.Models.Server", "Server") - .WithMany() - .HasForeignKey("ServerId"); - - b.Navigation("Container"); - - b.Navigation("Server"); - }); - - modelBuilder.Entity("Watcher.Models.Server", b => - { - b.HasOne("Watcher.Models.Tag", null) - .WithMany("Servers") - .HasForeignKey("TagId"); - }); - - modelBuilder.Entity("Watcher.Models.Image", b => - { - b.Navigation("Containers"); - }); - - modelBuilder.Entity("Watcher.Models.Tag", b => - { - b.Navigation("Containers"); - - b.Navigation("Servers"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Watcher/Migrations/20250710090920_container-attribute.cs b/Watcher/Migrations/20250710090920_container-attribute.cs deleted file mode 100644 index 7af4972..0000000 --- a/Watcher/Migrations/20250710090920_container-attribute.cs +++ /dev/null @@ -1,119 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Watcher.Migrations -{ - /// - public partial class containerattribute : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Hostname", - table: "Containers"); - - migrationBuilder.RenameColumn( - name: "Type", - table: "Containers", - newName: "Health"); - - migrationBuilder.AlterColumn( - name: "Name", - table: "Containers", - type: "TEXT", - nullable: true, - oldClrType: typeof(string), - oldType: "TEXT"); - - migrationBuilder.AddColumn( - name: "ExposedPort", - table: "Containers", - type: "INTEGER", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "HostServerId", - table: "Containers", - type: "INTEGER", - nullable: true); - - migrationBuilder.AddColumn( - name: "Image", - table: "Containers", - type: "TEXT", - nullable: true); - - migrationBuilder.AddColumn( - name: "InternalPort", - table: "Containers", - type: "INTEGER", - nullable: false, - defaultValue: 0); - - migrationBuilder.CreateIndex( - name: "IX_Containers_HostServerId", - table: "Containers", - column: "HostServerId"); - - migrationBuilder.AddForeignKey( - name: "FK_Containers_Servers_HostServerId", - table: "Containers", - column: "HostServerId", - principalTable: "Servers", - principalColumn: "Id"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Containers_Servers_HostServerId", - table: "Containers"); - - migrationBuilder.DropIndex( - name: "IX_Containers_HostServerId", - table: "Containers"); - - migrationBuilder.DropColumn( - name: "ExposedPort", - table: "Containers"); - - migrationBuilder.DropColumn( - name: "HostServerId", - table: "Containers"); - - migrationBuilder.DropColumn( - name: "Image", - table: "Containers"); - - migrationBuilder.DropColumn( - name: "InternalPort", - table: "Containers"); - - migrationBuilder.RenameColumn( - name: "Health", - table: "Containers", - newName: "Type"); - - migrationBuilder.AlterColumn( - name: "Name", - table: "Containers", - type: "TEXT", - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "TEXT", - oldNullable: true); - - migrationBuilder.AddColumn( - name: "Hostname", - table: "Containers", - type: "TEXT", - nullable: false, - defaultValue: ""); - } - } -} diff --git a/Watcher/Migrations/20250730113936_DiskSpace-ServerAttribute.Designer.cs b/Watcher/Migrations/20250730113936_DiskSpace-ServerAttribute.Designer.cs deleted file mode 100644 index d33eb83..0000000 --- a/Watcher/Migrations/20250730113936_DiskSpace-ServerAttribute.Designer.cs +++ /dev/null @@ -1,335 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Watcher.Data; - -#nullable disable - -namespace Watcher.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20250730113936_DiskSpace-ServerAttribute")] - partial class DiskSpaceServerAttribute - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "8.0.6"); - - modelBuilder.Entity("Watcher.Models.Container", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("ExposedPort") - .HasColumnType("INTEGER"); - - b.Property("Health") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("HostServerId") - .HasColumnType("INTEGER"); - - b.Property("Image") - .HasColumnType("TEXT"); - - b.Property("ImageId") - .HasColumnType("INTEGER"); - - b.Property("InternalPort") - .HasColumnType("INTEGER"); - - b.Property("IsRunning") - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Status") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("TagId") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("HostServerId"); - - b.HasIndex("ImageId"); - - b.HasIndex("TagId"); - - b.ToTable("Containers"); - }); - - modelBuilder.Entity("Watcher.Models.Image", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Tag") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Images"); - }); - - modelBuilder.Entity("Watcher.Models.LogEvent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("ContainerId") - .HasColumnType("INTEGER"); - - b.Property("Level") - .HasColumnType("TEXT"); - - b.Property("Message") - .HasColumnType("TEXT"); - - b.Property("ServerId") - .HasColumnType("INTEGER"); - - b.Property("Timestamp") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("ContainerId"); - - b.HasIndex("ServerId"); - - b.ToTable("LogEvents"); - }); - - modelBuilder.Entity("Watcher.Models.Metric", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CPU_Load") - .HasColumnType("REAL"); - - b.Property("CPU_Temp") - .HasColumnType("REAL"); - - b.Property("DISK_Size") - .HasColumnType("REAL"); - - b.Property("DISK_Temp") - .HasColumnType("REAL"); - - b.Property("DISK_Usage") - .HasColumnType("REAL"); - - b.Property("GPU_Load") - .HasColumnType("REAL"); - - b.Property("GPU_Temp") - .HasColumnType("REAL"); - - b.Property("GPU_Vram_Size") - .HasColumnType("REAL"); - - b.Property("GPU_Vram_Usage") - .HasColumnType("REAL"); - - b.Property("NET_In") - .HasColumnType("REAL"); - - b.Property("NET_Out") - .HasColumnType("REAL"); - - b.Property("RAM_Load") - .HasColumnType("REAL"); - - b.Property("RAM_Size") - .HasColumnType("REAL"); - - b.Property("ServerId") - .HasColumnType("INTEGER"); - - b.Property("Timestamp") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Metrics"); - }); - - modelBuilder.Entity("Watcher.Models.Server", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CpuCores") - .HasColumnType("INTEGER"); - - b.Property("CpuType") - .HasColumnType("TEXT"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("Description") - .HasColumnType("TEXT"); - - b.Property("DiskSpace") - .HasColumnType("TEXT"); - - b.Property("GpuType") - .HasColumnType("TEXT"); - - b.Property("IPAddress") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("IsOnline") - .HasColumnType("INTEGER"); - - b.Property("IsVerified") - .HasColumnType("INTEGER"); - - b.Property("LastSeen") - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("RamSize") - .HasColumnType("REAL"); - - b.Property("TagId") - .HasColumnType("INTEGER"); - - b.Property("Type") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("TagId"); - - b.ToTable("Servers"); - }); - - modelBuilder.Entity("Watcher.Models.Tag", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Tags"); - }); - - modelBuilder.Entity("Watcher.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Email") - .HasColumnType("TEXT"); - - b.Property("IdentityProvider") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("LastLogin") - .HasColumnType("TEXT"); - - b.Property("OIDC_Id") - .HasColumnType("TEXT"); - - b.Property("Password") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Username") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Watcher.Models.Container", b => - { - b.HasOne("Watcher.Models.Server", "HostServer") - .WithMany() - .HasForeignKey("HostServerId"); - - b.HasOne("Watcher.Models.Image", null) - .WithMany("Containers") - .HasForeignKey("ImageId"); - - b.HasOne("Watcher.Models.Tag", null) - .WithMany("Containers") - .HasForeignKey("TagId"); - - b.Navigation("HostServer"); - }); - - modelBuilder.Entity("Watcher.Models.LogEvent", b => - { - b.HasOne("Watcher.Models.Container", "Container") - .WithMany() - .HasForeignKey("ContainerId"); - - b.HasOne("Watcher.Models.Server", "Server") - .WithMany() - .HasForeignKey("ServerId"); - - b.Navigation("Container"); - - b.Navigation("Server"); - }); - - modelBuilder.Entity("Watcher.Models.Server", b => - { - b.HasOne("Watcher.Models.Tag", null) - .WithMany("Servers") - .HasForeignKey("TagId"); - }); - - modelBuilder.Entity("Watcher.Models.Image", b => - { - b.Navigation("Containers"); - }); - - modelBuilder.Entity("Watcher.Models.Tag", b => - { - b.Navigation("Containers"); - - b.Navigation("Servers"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Watcher/Migrations/20250730113936_DiskSpace-ServerAttribute.cs b/Watcher/Migrations/20250730113936_DiskSpace-ServerAttribute.cs deleted file mode 100644 index a8fbd9f..0000000 --- a/Watcher/Migrations/20250730113936_DiskSpace-ServerAttribute.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Watcher.Migrations -{ - /// - public partial class DiskSpaceServerAttribute : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "DiskSpace", - table: "Servers", - type: "TEXT", - nullable: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "DiskSpace", - table: "Servers"); - } - } -} diff --git a/Watcher/Migrations/20250730172010_MeasurementWarnings.Designer.cs b/Watcher/Migrations/20250730172010_MeasurementWarnings.Designer.cs deleted file mode 100644 index 25baf51..0000000 --- a/Watcher/Migrations/20250730172010_MeasurementWarnings.Designer.cs +++ /dev/null @@ -1,377 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Watcher.Data; - -#nullable disable - -namespace Watcher.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20250730172010_MeasurementWarnings")] - partial class MeasurementWarnings - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "8.0.6"); - - modelBuilder.Entity("Watcher.Models.Container", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("ExposedPort") - .HasColumnType("INTEGER"); - - b.Property("Health") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("HostServerId") - .HasColumnType("INTEGER"); - - b.Property("Image") - .HasColumnType("TEXT"); - - b.Property("ImageId") - .HasColumnType("INTEGER"); - - b.Property("InternalPort") - .HasColumnType("INTEGER"); - - b.Property("IsRunning") - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Status") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("TagId") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("HostServerId"); - - b.HasIndex("ImageId"); - - b.HasIndex("TagId"); - - b.ToTable("Containers"); - }); - - modelBuilder.Entity("Watcher.Models.Image", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Tag") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Images"); - }); - - modelBuilder.Entity("Watcher.Models.LogEvent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("ContainerId") - .HasColumnType("INTEGER"); - - b.Property("Level") - .HasColumnType("TEXT"); - - b.Property("Message") - .HasColumnType("TEXT"); - - b.Property("ServerId") - .HasColumnType("INTEGER"); - - b.Property("Timestamp") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("ContainerId"); - - b.HasIndex("ServerId"); - - b.ToTable("LogEvents"); - }); - - modelBuilder.Entity("Watcher.Models.Metric", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CPU_Load") - .HasColumnType("REAL"); - - b.Property("CPU_Temp") - .HasColumnType("REAL"); - - b.Property("DISK_Size") - .HasColumnType("REAL"); - - b.Property("DISK_Temp") - .HasColumnType("REAL"); - - b.Property("DISK_Usage") - .HasColumnType("REAL"); - - b.Property("GPU_Load") - .HasColumnType("REAL"); - - b.Property("GPU_Temp") - .HasColumnType("REAL"); - - b.Property("GPU_Vram_Size") - .HasColumnType("REAL"); - - b.Property("GPU_Vram_Usage") - .HasColumnType("REAL"); - - b.Property("NET_In") - .HasColumnType("REAL"); - - b.Property("NET_Out") - .HasColumnType("REAL"); - - b.Property("RAM_Load") - .HasColumnType("REAL"); - - b.Property("RAM_Size") - .HasColumnType("REAL"); - - b.Property("ServerId") - .HasColumnType("INTEGER"); - - b.Property("Timestamp") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Metrics"); - }); - - modelBuilder.Entity("Watcher.Models.Server", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CPU_Load_Critical") - .HasColumnType("REAL"); - - b.Property("CPU_Load_Warning") - .HasColumnType("REAL"); - - b.Property("CPU_Temp_Critical") - .HasColumnType("REAL"); - - b.Property("CPU_Temp_Warning") - .HasColumnType("REAL"); - - b.Property("CpuCores") - .HasColumnType("INTEGER"); - - b.Property("CpuType") - .HasColumnType("TEXT"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("DISK_Temp_Critical") - .HasColumnType("REAL"); - - b.Property("DISK_Temp_Warning") - .HasColumnType("REAL"); - - b.Property("Description") - .HasColumnType("TEXT"); - - b.Property("DiskSpace") - .HasColumnType("TEXT"); - - b.Property("Disk_Usage_Critical") - .HasColumnType("REAL"); - - b.Property("Disk_Usage_Warning") - .HasColumnType("REAL"); - - b.Property("GPU_Load_Critical") - .HasColumnType("REAL"); - - b.Property("GPU_Load_Warning") - .HasColumnType("REAL"); - - b.Property("GPU_Temp_Critical") - .HasColumnType("REAL"); - - b.Property("GPU_Temp_Warning") - .HasColumnType("REAL"); - - b.Property("GpuType") - .HasColumnType("TEXT"); - - b.Property("IPAddress") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("IsOnline") - .HasColumnType("INTEGER"); - - b.Property("IsVerified") - .HasColumnType("INTEGER"); - - b.Property("LastSeen") - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("RAM_Load_Critical") - .HasColumnType("REAL"); - - b.Property("RAM_Load_Warning") - .HasColumnType("REAL"); - - b.Property("RamSize") - .HasColumnType("REAL"); - - b.Property("TagId") - .HasColumnType("INTEGER"); - - b.Property("Type") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("TagId"); - - b.ToTable("Servers"); - }); - - modelBuilder.Entity("Watcher.Models.Tag", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Tags"); - }); - - modelBuilder.Entity("Watcher.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Email") - .HasColumnType("TEXT"); - - b.Property("IdentityProvider") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("LastLogin") - .HasColumnType("TEXT"); - - b.Property("OIDC_Id") - .HasColumnType("TEXT"); - - b.Property("Password") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Username") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Watcher.Models.Container", b => - { - b.HasOne("Watcher.Models.Server", "HostServer") - .WithMany() - .HasForeignKey("HostServerId"); - - b.HasOne("Watcher.Models.Image", null) - .WithMany("Containers") - .HasForeignKey("ImageId"); - - b.HasOne("Watcher.Models.Tag", null) - .WithMany("Containers") - .HasForeignKey("TagId"); - - b.Navigation("HostServer"); - }); - - modelBuilder.Entity("Watcher.Models.LogEvent", b => - { - b.HasOne("Watcher.Models.Container", "Container") - .WithMany() - .HasForeignKey("ContainerId"); - - b.HasOne("Watcher.Models.Server", "Server") - .WithMany() - .HasForeignKey("ServerId"); - - b.Navigation("Container"); - - b.Navigation("Server"); - }); - - modelBuilder.Entity("Watcher.Models.Server", b => - { - b.HasOne("Watcher.Models.Tag", null) - .WithMany("Servers") - .HasForeignKey("TagId"); - }); - - modelBuilder.Entity("Watcher.Models.Image", b => - { - b.Navigation("Containers"); - }); - - modelBuilder.Entity("Watcher.Models.Tag", b => - { - b.Navigation("Containers"); - - b.Navigation("Servers"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Watcher/Migrations/20250730172010_MeasurementWarnings.cs b/Watcher/Migrations/20250730172010_MeasurementWarnings.cs deleted file mode 100644 index f13e5c7..0000000 --- a/Watcher/Migrations/20250730172010_MeasurementWarnings.cs +++ /dev/null @@ -1,172 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Watcher.Migrations -{ - /// - public partial class MeasurementWarnings : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "CPU_Load_Critical", - table: "Servers", - type: "REAL", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AddColumn( - name: "CPU_Load_Warning", - table: "Servers", - type: "REAL", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AddColumn( - name: "CPU_Temp_Critical", - table: "Servers", - type: "REAL", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AddColumn( - name: "CPU_Temp_Warning", - table: "Servers", - type: "REAL", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AddColumn( - name: "DISK_Temp_Critical", - table: "Servers", - type: "REAL", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AddColumn( - name: "DISK_Temp_Warning", - table: "Servers", - type: "REAL", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AddColumn( - name: "Disk_Usage_Critical", - table: "Servers", - type: "REAL", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AddColumn( - name: "Disk_Usage_Warning", - table: "Servers", - type: "REAL", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AddColumn( - name: "GPU_Load_Critical", - table: "Servers", - type: "REAL", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AddColumn( - name: "GPU_Load_Warning", - table: "Servers", - type: "REAL", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AddColumn( - name: "GPU_Temp_Critical", - table: "Servers", - type: "REAL", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AddColumn( - name: "GPU_Temp_Warning", - table: "Servers", - type: "REAL", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AddColumn( - name: "RAM_Load_Critical", - table: "Servers", - type: "REAL", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AddColumn( - name: "RAM_Load_Warning", - table: "Servers", - type: "REAL", - nullable: false, - defaultValue: 0.0); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "CPU_Load_Critical", - table: "Servers"); - - migrationBuilder.DropColumn( - name: "CPU_Load_Warning", - table: "Servers"); - - migrationBuilder.DropColumn( - name: "CPU_Temp_Critical", - table: "Servers"); - - migrationBuilder.DropColumn( - name: "CPU_Temp_Warning", - table: "Servers"); - - migrationBuilder.DropColumn( - name: "DISK_Temp_Critical", - table: "Servers"); - - migrationBuilder.DropColumn( - name: "DISK_Temp_Warning", - table: "Servers"); - - migrationBuilder.DropColumn( - name: "Disk_Usage_Critical", - table: "Servers"); - - migrationBuilder.DropColumn( - name: "Disk_Usage_Warning", - table: "Servers"); - - migrationBuilder.DropColumn( - name: "GPU_Load_Critical", - table: "Servers"); - - migrationBuilder.DropColumn( - name: "GPU_Load_Warning", - table: "Servers"); - - migrationBuilder.DropColumn( - name: "GPU_Temp_Critical", - table: "Servers"); - - migrationBuilder.DropColumn( - name: "GPU_Temp_Warning", - table: "Servers"); - - migrationBuilder.DropColumn( - name: "RAM_Load_Critical", - table: "Servers"); - - migrationBuilder.DropColumn( - name: "RAM_Load_Warning", - table: "Servers"); - } - } -} diff --git a/Watcher/Migrations/20251003135555_ContainerUpdate.cs b/Watcher/Migrations/20251003135555_ContainerUpdate.cs deleted file mode 100644 index 8074ae7..0000000 --- a/Watcher/Migrations/20251003135555_ContainerUpdate.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Watcher.Migrations -{ - /// - public partial class ContainerUpdate : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Containers_Servers_HostServerId", - table: "Containers"); - - migrationBuilder.DropIndex( - name: "IX_Containers_HostServerId", - table: "Containers"); - - migrationBuilder.DropColumn( - name: "CreatedAt", - table: "Containers"); - - migrationBuilder.DropColumn( - name: "ExposedPort", - table: "Containers"); - - migrationBuilder.DropColumn( - name: "Health", - table: "Containers"); - - migrationBuilder.DropColumn( - name: "HostServerId", - table: "Containers"); - - migrationBuilder.DropColumn( - name: "Status", - table: "Containers"); - - migrationBuilder.RenameColumn( - name: "InternalPort", - table: "Containers", - newName: "ServerId"); - - migrationBuilder.AddColumn( - name: "ContainerId", - table: "Containers", - type: "TEXT", - nullable: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "ContainerId", - table: "Containers"); - - migrationBuilder.RenameColumn( - name: "ServerId", - table: "Containers", - newName: "InternalPort"); - - migrationBuilder.AddColumn( - name: "CreatedAt", - table: "Containers", - type: "TEXT", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - - migrationBuilder.AddColumn( - name: "ExposedPort", - table: "Containers", - type: "INTEGER", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "Health", - table: "Containers", - type: "TEXT", - nullable: false, - defaultValue: ""); - - migrationBuilder.AddColumn( - name: "HostServerId", - table: "Containers", - type: "INTEGER", - nullable: true); - - migrationBuilder.AddColumn( - name: "Status", - table: "Containers", - type: "TEXT", - nullable: false, - defaultValue: ""); - - migrationBuilder.CreateIndex( - name: "IX_Containers_HostServerId", - table: "Containers", - column: "HostServerId"); - - migrationBuilder.AddForeignKey( - name: "FK_Containers_Servers_HostServerId", - table: "Containers", - column: "HostServerId", - principalTable: "Servers", - principalColumn: "Id"); - } - } -} diff --git a/Watcher/Migrations/20251029105954_container-changed.cs b/Watcher/Migrations/20251029105954_container-changed.cs deleted file mode 100644 index 6f880a4..0000000 --- a/Watcher/Migrations/20251029105954_container-changed.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Watcher.Migrations -{ - /// - public partial class containerchanged : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/Watcher/Migrations/20251029125404_ContainerMetrics-Added.Designer.cs b/Watcher/Migrations/20251029125404_ContainerMetrics-Added.Designer.cs deleted file mode 100644 index 73b5076..0000000 --- a/Watcher/Migrations/20251029125404_ContainerMetrics-Added.Designer.cs +++ /dev/null @@ -1,355 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Watcher.Data; - -#nullable disable - -namespace Watcher.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20251029125404_ContainerMetrics-Added")] - partial class ContainerMetricsAdded - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "8.0.6"); - - modelBuilder.Entity("Watcher.Models.Container", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("ContainerId") - .HasColumnType("TEXT"); - - b.Property("Image") - .HasColumnType("TEXT"); - - b.Property("ImageId") - .HasColumnType("INTEGER"); - - b.Property("IsRunning") - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("ServerId") - .HasColumnType("INTEGER"); - - b.Property("TagId") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.HasIndex("TagId"); - - b.ToTable("Containers"); - }); - - modelBuilder.Entity("Watcher.Models.Image", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Tag") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Images"); - }); - - modelBuilder.Entity("Watcher.Models.LogEvent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("ContainerId") - .HasColumnType("INTEGER"); - - b.Property("Level") - .HasColumnType("TEXT"); - - b.Property("Message") - .HasColumnType("TEXT"); - - b.Property("ServerId") - .HasColumnType("INTEGER"); - - b.Property("Timestamp") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("ContainerId"); - - b.HasIndex("ServerId"); - - b.ToTable("LogEvents"); - }); - - modelBuilder.Entity("Watcher.Models.Metric", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CPU_Load") - .HasColumnType("REAL"); - - b.Property("CPU_Temp") - .HasColumnType("REAL"); - - b.Property("DISK_Size") - .HasColumnType("REAL"); - - b.Property("DISK_Temp") - .HasColumnType("REAL"); - - b.Property("DISK_Usage") - .HasColumnType("REAL"); - - b.Property("GPU_Load") - .HasColumnType("REAL"); - - b.Property("GPU_Temp") - .HasColumnType("REAL"); - - b.Property("GPU_Vram_Size") - .HasColumnType("REAL"); - - b.Property("GPU_Vram_Usage") - .HasColumnType("REAL"); - - b.Property("NET_In") - .HasColumnType("REAL"); - - b.Property("NET_Out") - .HasColumnType("REAL"); - - b.Property("RAM_Load") - .HasColumnType("REAL"); - - b.Property("RAM_Size") - .HasColumnType("REAL"); - - b.Property("ServerId") - .HasColumnType("INTEGER"); - - b.Property("Timestamp") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Metrics"); - }); - - modelBuilder.Entity("Watcher.Models.Server", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CPU_Load_Critical") - .HasColumnType("REAL"); - - b.Property("CPU_Load_Warning") - .HasColumnType("REAL"); - - b.Property("CPU_Temp_Critical") - .HasColumnType("REAL"); - - b.Property("CPU_Temp_Warning") - .HasColumnType("REAL"); - - b.Property("CpuCores") - .HasColumnType("INTEGER"); - - b.Property("CpuType") - .HasColumnType("TEXT"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("DISK_Temp_Critical") - .HasColumnType("REAL"); - - b.Property("DISK_Temp_Warning") - .HasColumnType("REAL"); - - b.Property("Description") - .HasColumnType("TEXT"); - - b.Property("DiskSpace") - .HasColumnType("TEXT"); - - b.Property("Disk_Usage_Critical") - .HasColumnType("REAL"); - - b.Property("Disk_Usage_Warning") - .HasColumnType("REAL"); - - b.Property("GPU_Load_Critical") - .HasColumnType("REAL"); - - b.Property("GPU_Load_Warning") - .HasColumnType("REAL"); - - b.Property("GPU_Temp_Critical") - .HasColumnType("REAL"); - - b.Property("GPU_Temp_Warning") - .HasColumnType("REAL"); - - b.Property("GpuType") - .HasColumnType("TEXT"); - - b.Property("IPAddress") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("IsOnline") - .HasColumnType("INTEGER"); - - b.Property("IsVerified") - .HasColumnType("INTEGER"); - - b.Property("LastSeen") - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("RAM_Load_Critical") - .HasColumnType("REAL"); - - b.Property("RAM_Load_Warning") - .HasColumnType("REAL"); - - b.Property("RamSize") - .HasColumnType("REAL"); - - b.Property("TagId") - .HasColumnType("INTEGER"); - - b.Property("Type") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("TagId"); - - b.ToTable("Servers"); - }); - - modelBuilder.Entity("Watcher.Models.Tag", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Tags"); - }); - - modelBuilder.Entity("Watcher.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Email") - .HasColumnType("TEXT"); - - b.Property("IdentityProvider") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("LastLogin") - .HasColumnType("TEXT"); - - b.Property("OIDC_Id") - .HasColumnType("TEXT"); - - b.Property("Password") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Username") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Watcher.Models.Container", b => - { - b.HasOne("Watcher.Models.Image", null) - .WithMany("Containers") - .HasForeignKey("ImageId"); - - b.HasOne("Watcher.Models.Tag", null) - .WithMany("Containers") - .HasForeignKey("TagId"); - }); - - modelBuilder.Entity("Watcher.Models.LogEvent", b => - { - b.HasOne("Watcher.Models.Container", "Container") - .WithMany() - .HasForeignKey("ContainerId"); - - b.HasOne("Watcher.Models.Server", "Server") - .WithMany() - .HasForeignKey("ServerId"); - - b.Navigation("Container"); - - b.Navigation("Server"); - }); - - modelBuilder.Entity("Watcher.Models.Server", b => - { - b.HasOne("Watcher.Models.Tag", null) - .WithMany("Servers") - .HasForeignKey("TagId"); - }); - - modelBuilder.Entity("Watcher.Models.Image", b => - { - b.Navigation("Containers"); - }); - - modelBuilder.Entity("Watcher.Models.Tag", b => - { - b.Navigation("Containers"); - - b.Navigation("Servers"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Watcher/Migrations/20251029125404_ContainerMetrics-Added.cs b/Watcher/Migrations/20251029125404_ContainerMetrics-Added.cs deleted file mode 100644 index c084fda..0000000 --- a/Watcher/Migrations/20251029125404_ContainerMetrics-Added.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Watcher.Migrations -{ - /// - public partial class ContainerMetricsAdded : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/Watcher/Migrations/20251003135555_ContainerUpdate.Designer.cs b/Watcher/Migrations/20251105183329_InitialMigration.Designer.cs similarity index 88% rename from Watcher/Migrations/20251003135555_ContainerUpdate.Designer.cs rename to Watcher/Migrations/20251105183329_InitialMigration.Designer.cs index 052eaa2..539298f 100644 --- a/Watcher/Migrations/20251003135555_ContainerUpdate.Designer.cs +++ b/Watcher/Migrations/20251105183329_InitialMigration.Designer.cs @@ -11,8 +11,8 @@ using Watcher.Data; namespace Watcher.Migrations { [DbContext(typeof(AppDbContext))] - [Migration("20251003135555_ContainerUpdate")] - partial class ContainerUpdate + [Migration("20251105183329_InitialMigration")] + partial class InitialMigration { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -27,10 +27,12 @@ namespace Watcher.Migrations .HasColumnType("INTEGER"); b.Property("ContainerId") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasAnnotation("Relational:JsonPropertyName", "id"); b.Property("Image") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasAnnotation("Relational:JsonPropertyName", "image"); b.Property("ImageId") .HasColumnType("INTEGER"); @@ -39,10 +41,12 @@ namespace Watcher.Migrations .HasColumnType("INTEGER"); b.Property("Name") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasAnnotation("Relational:JsonPropertyName", "name"); b.Property("ServerId") - .HasColumnType("INTEGER"); + .HasColumnType("INTEGER") + .HasAnnotation("Relational:JsonPropertyName", "Server_id"); b.Property("TagId") .HasColumnType("INTEGER"); @@ -56,6 +60,35 @@ namespace Watcher.Migrations b.ToTable("Containers"); }); + modelBuilder.Entity("Watcher.Models.ContainerMetric", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CPU_Load") + .HasColumnType("REAL"); + + b.Property("CPU_Temp") + .HasColumnType("REAL"); + + b.Property("ContainerId") + .HasColumnType("INTEGER"); + + b.Property("RAM_Load") + .HasColumnType("REAL"); + + b.Property("RAM_Size") + .HasColumnType("REAL"); + + b.Property("Timestamp") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("ContainerMetrics"); + }); + modelBuilder.Entity("Watcher.Models.Image", b => { b.Property("Id") @@ -282,22 +315,16 @@ namespace Watcher.Migrations b.Property("Email") .HasColumnType("TEXT"); - b.Property("IdentityProvider") - .IsRequired() - .HasColumnType("TEXT"); - b.Property("LastLogin") .HasColumnType("TEXT"); - b.Property("OIDC_Id") - .HasColumnType("TEXT"); - b.Property("Password") .IsRequired() .HasColumnType("TEXT"); b.Property("Username") .IsRequired() + .HasMaxLength(50) .HasColumnType("TEXT"); b.HasKey("Id"); diff --git a/Watcher/Migrations/20251105183329_InitialMigration.cs b/Watcher/Migrations/20251105183329_InitialMigration.cs new file mode 100644 index 0000000..253bf68 --- /dev/null +++ b/Watcher/Migrations/20251105183329_InitialMigration.cs @@ -0,0 +1,257 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Watcher.Migrations +{ + /// + public partial class InitialMigration : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "ContainerMetrics", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Timestamp = table.Column(type: "TEXT", nullable: false), + ContainerId = table.Column(type: "INTEGER", nullable: true), + CPU_Load = table.Column(type: "REAL", nullable: false), + CPU_Temp = table.Column(type: "REAL", nullable: false), + RAM_Size = table.Column(type: "REAL", nullable: false), + RAM_Load = table.Column(type: "REAL", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ContainerMetrics", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Images", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Name = table.Column(type: "TEXT", nullable: true), + Tag = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Images", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Metrics", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Timestamp = table.Column(type: "TEXT", nullable: false), + ServerId = table.Column(type: "INTEGER", nullable: true), + CPU_Load = table.Column(type: "REAL", nullable: false), + CPU_Temp = table.Column(type: "REAL", nullable: false), + GPU_Load = table.Column(type: "REAL", nullable: false), + GPU_Temp = table.Column(type: "REAL", nullable: false), + GPU_Vram_Size = table.Column(type: "REAL", nullable: false), + GPU_Vram_Usage = table.Column(type: "REAL", nullable: false), + RAM_Size = table.Column(type: "REAL", nullable: false), + RAM_Load = table.Column(type: "REAL", nullable: false), + DISK_Size = table.Column(type: "REAL", nullable: false), + DISK_Usage = table.Column(type: "REAL", nullable: false), + DISK_Temp = table.Column(type: "REAL", nullable: false), + NET_In = table.Column(type: "REAL", nullable: false), + NET_Out = table.Column(type: "REAL", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Metrics", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Tags", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Name = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Tags", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Users", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Username = table.Column(type: "TEXT", maxLength: 50, nullable: false), + Email = table.Column(type: "TEXT", nullable: true), + LastLogin = table.Column(type: "TEXT", nullable: false), + Password = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Users", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Containers", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + ServerId = table.Column(type: "INTEGER", nullable: false), + ContainerId = table.Column(type: "TEXT", nullable: true), + Image = table.Column(type: "TEXT", nullable: true), + Name = table.Column(type: "TEXT", nullable: true), + IsRunning = table.Column(type: "INTEGER", nullable: false), + ImageId = table.Column(type: "INTEGER", nullable: true), + TagId = table.Column(type: "INTEGER", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Containers", x => x.Id); + table.ForeignKey( + name: "FK_Containers_Images_ImageId", + column: x => x.ImageId, + principalTable: "Images", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Containers_Tags_TagId", + column: x => x.TagId, + principalTable: "Tags", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "Servers", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Name = table.Column(type: "TEXT", nullable: false), + IPAddress = table.Column(type: "TEXT", nullable: false), + Type = table.Column(type: "TEXT", nullable: false), + Description = table.Column(type: "TEXT", nullable: true), + CpuType = table.Column(type: "TEXT", nullable: true), + CpuCores = table.Column(type: "INTEGER", nullable: false), + GpuType = table.Column(type: "TEXT", nullable: true), + RamSize = table.Column(type: "REAL", nullable: false), + DiskSpace = table.Column(type: "TEXT", nullable: true), + CPU_Load_Warning = table.Column(type: "REAL", nullable: false), + CPU_Load_Critical = table.Column(type: "REAL", nullable: false), + CPU_Temp_Warning = table.Column(type: "REAL", nullable: false), + CPU_Temp_Critical = table.Column(type: "REAL", nullable: false), + RAM_Load_Warning = table.Column(type: "REAL", nullable: false), + RAM_Load_Critical = table.Column(type: "REAL", nullable: false), + GPU_Load_Warning = table.Column(type: "REAL", nullable: false), + GPU_Load_Critical = table.Column(type: "REAL", nullable: false), + GPU_Temp_Warning = table.Column(type: "REAL", nullable: false), + GPU_Temp_Critical = table.Column(type: "REAL", nullable: false), + Disk_Usage_Warning = table.Column(type: "REAL", nullable: false), + Disk_Usage_Critical = table.Column(type: "REAL", nullable: false), + DISK_Temp_Warning = table.Column(type: "REAL", nullable: false), + DISK_Temp_Critical = table.Column(type: "REAL", nullable: false), + CreatedAt = table.Column(type: "TEXT", nullable: false), + IsOnline = table.Column(type: "INTEGER", nullable: false), + LastSeen = table.Column(type: "TEXT", nullable: false), + IsVerified = table.Column(type: "INTEGER", nullable: false), + TagId = table.Column(type: "INTEGER", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Servers", x => x.Id); + table.ForeignKey( + name: "FK_Servers_Tags_TagId", + column: x => x.TagId, + principalTable: "Tags", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "LogEvents", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Timestamp = table.Column(type: "TEXT", nullable: false), + Message = table.Column(type: "TEXT", nullable: true), + Level = table.Column(type: "TEXT", nullable: true), + ServerId = table.Column(type: "INTEGER", nullable: true), + ContainerId = table.Column(type: "INTEGER", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_LogEvents", x => x.Id); + table.ForeignKey( + name: "FK_LogEvents_Containers_ContainerId", + column: x => x.ContainerId, + principalTable: "Containers", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_LogEvents_Servers_ServerId", + column: x => x.ServerId, + principalTable: "Servers", + principalColumn: "Id"); + }); + + migrationBuilder.CreateIndex( + name: "IX_Containers_ImageId", + table: "Containers", + column: "ImageId"); + + migrationBuilder.CreateIndex( + name: "IX_Containers_TagId", + table: "Containers", + column: "TagId"); + + migrationBuilder.CreateIndex( + name: "IX_LogEvents_ContainerId", + table: "LogEvents", + column: "ContainerId"); + + migrationBuilder.CreateIndex( + name: "IX_LogEvents_ServerId", + table: "LogEvents", + column: "ServerId"); + + migrationBuilder.CreateIndex( + name: "IX_Servers_TagId", + table: "Servers", + column: "TagId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ContainerMetrics"); + + migrationBuilder.DropTable( + name: "LogEvents"); + + migrationBuilder.DropTable( + name: "Metrics"); + + migrationBuilder.DropTable( + name: "Users"); + + migrationBuilder.DropTable( + name: "Containers"); + + migrationBuilder.DropTable( + name: "Servers"); + + migrationBuilder.DropTable( + name: "Images"); + + migrationBuilder.DropTable( + name: "Tags"); + } + } +} diff --git a/Watcher/Migrations/20251029105954_container-changed.Designer.cs b/Watcher/Migrations/20251105201056_AddContainerServerNavigation.Designer.cs similarity index 85% rename from Watcher/Migrations/20251029105954_container-changed.Designer.cs rename to Watcher/Migrations/20251105201056_AddContainerServerNavigation.Designer.cs index 4eda82f..bc2eae9 100644 --- a/Watcher/Migrations/20251029105954_container-changed.Designer.cs +++ b/Watcher/Migrations/20251105201056_AddContainerServerNavigation.Designer.cs @@ -11,8 +11,8 @@ using Watcher.Data; namespace Watcher.Migrations { [DbContext(typeof(AppDbContext))] - [Migration("20251029105954_container-changed")] - partial class containerchanged + [Migration("20251105201056_AddContainerServerNavigation")] + partial class AddContainerServerNavigation { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -27,10 +27,12 @@ namespace Watcher.Migrations .HasColumnType("INTEGER"); b.Property("ContainerId") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasAnnotation("Relational:JsonPropertyName", "id"); b.Property("Image") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasAnnotation("Relational:JsonPropertyName", "image"); b.Property("ImageId") .HasColumnType("INTEGER"); @@ -39,10 +41,12 @@ namespace Watcher.Migrations .HasColumnType("INTEGER"); b.Property("Name") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasAnnotation("Relational:JsonPropertyName", "name"); b.Property("ServerId") - .HasColumnType("INTEGER"); + .HasColumnType("INTEGER") + .HasAnnotation("Relational:JsonPropertyName", "Server_id"); b.Property("TagId") .HasColumnType("INTEGER"); @@ -51,11 +55,42 @@ namespace Watcher.Migrations b.HasIndex("ImageId"); + b.HasIndex("ServerId"); + b.HasIndex("TagId"); b.ToTable("Containers"); }); + modelBuilder.Entity("Watcher.Models.ContainerMetric", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CPU_Load") + .HasColumnType("REAL"); + + b.Property("CPU_Temp") + .HasColumnType("REAL"); + + b.Property("ContainerId") + .HasColumnType("INTEGER"); + + b.Property("RAM_Load") + .HasColumnType("REAL"); + + b.Property("RAM_Size") + .HasColumnType("REAL"); + + b.Property("Timestamp") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("ContainerMetrics"); + }); + modelBuilder.Entity("Watcher.Models.Image", b => { b.Property("Id") @@ -282,22 +317,16 @@ namespace Watcher.Migrations b.Property("Email") .HasColumnType("TEXT"); - b.Property("IdentityProvider") - .IsRequired() - .HasColumnType("TEXT"); - b.Property("LastLogin") .HasColumnType("TEXT"); - b.Property("OIDC_Id") - .HasColumnType("TEXT"); - b.Property("Password") .IsRequired() .HasColumnType("TEXT"); b.Property("Username") .IsRequired() + .HasMaxLength(50) .HasColumnType("TEXT"); b.HasKey("Id"); @@ -311,9 +340,17 @@ namespace Watcher.Migrations .WithMany("Containers") .HasForeignKey("ImageId"); + b.HasOne("Watcher.Models.Server", "Server") + .WithMany() + .HasForeignKey("ServerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + b.HasOne("Watcher.Models.Tag", null) .WithMany("Containers") .HasForeignKey("TagId"); + + b.Navigation("Server"); }); modelBuilder.Entity("Watcher.Models.LogEvent", b => diff --git a/Watcher/Migrations/20251105201056_AddContainerServerNavigation.cs b/Watcher/Migrations/20251105201056_AddContainerServerNavigation.cs new file mode 100644 index 0000000..b03c260 --- /dev/null +++ b/Watcher/Migrations/20251105201056_AddContainerServerNavigation.cs @@ -0,0 +1,39 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Watcher.Migrations +{ + /// + public partial class AddContainerServerNavigation : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateIndex( + name: "IX_Containers_ServerId", + table: "Containers", + column: "ServerId"); + + migrationBuilder.AddForeignKey( + name: "FK_Containers_Servers_ServerId", + table: "Containers", + column: "ServerId", + principalTable: "Servers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Containers_Servers_ServerId", + table: "Containers"); + + migrationBuilder.DropIndex( + name: "IX_Containers_ServerId", + table: "Containers"); + } + } +} diff --git a/Watcher/Migrations/AppDbContextModelSnapshot.cs b/Watcher/Migrations/AppDbContextModelSnapshot.cs index b642f34..99d7352 100644 --- a/Watcher/Migrations/AppDbContextModelSnapshot.cs +++ b/Watcher/Migrations/AppDbContextModelSnapshot.cs @@ -24,10 +24,12 @@ namespace Watcher.Migrations .HasColumnType("INTEGER"); b.Property("ContainerId") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasAnnotation("Relational:JsonPropertyName", "id"); b.Property("Image") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasAnnotation("Relational:JsonPropertyName", "image"); b.Property("ImageId") .HasColumnType("INTEGER"); @@ -36,10 +38,12 @@ namespace Watcher.Migrations .HasColumnType("INTEGER"); b.Property("Name") - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasAnnotation("Relational:JsonPropertyName", "name"); b.Property("ServerId") - .HasColumnType("INTEGER"); + .HasColumnType("INTEGER") + .HasAnnotation("Relational:JsonPropertyName", "Server_id"); b.Property("TagId") .HasColumnType("INTEGER"); @@ -48,11 +52,42 @@ namespace Watcher.Migrations b.HasIndex("ImageId"); + b.HasIndex("ServerId"); + b.HasIndex("TagId"); b.ToTable("Containers"); }); + modelBuilder.Entity("Watcher.Models.ContainerMetric", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CPU_Load") + .HasColumnType("REAL"); + + b.Property("CPU_Temp") + .HasColumnType("REAL"); + + b.Property("ContainerId") + .HasColumnType("INTEGER"); + + b.Property("RAM_Load") + .HasColumnType("REAL"); + + b.Property("RAM_Size") + .HasColumnType("REAL"); + + b.Property("Timestamp") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("ContainerMetrics"); + }); + modelBuilder.Entity("Watcher.Models.Image", b => { b.Property("Id") @@ -279,22 +314,16 @@ namespace Watcher.Migrations b.Property("Email") .HasColumnType("TEXT"); - b.Property("IdentityProvider") - .IsRequired() - .HasColumnType("TEXT"); - b.Property("LastLogin") .HasColumnType("TEXT"); - b.Property("OIDC_Id") - .HasColumnType("TEXT"); - b.Property("Password") .IsRequired() .HasColumnType("TEXT"); b.Property("Username") .IsRequired() + .HasMaxLength(50) .HasColumnType("TEXT"); b.HasKey("Id"); @@ -308,9 +337,17 @@ namespace Watcher.Migrations .WithMany("Containers") .HasForeignKey("ImageId"); + b.HasOne("Watcher.Models.Server", "Server") + .WithMany() + .HasForeignKey("ServerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + b.HasOne("Watcher.Models.Tag", null) .WithMany("Containers") .HasForeignKey("TagId"); + + b.Navigation("Server"); }); modelBuilder.Entity("Watcher.Models.LogEvent", b => diff --git a/Watcher/Models/Container.cs b/Watcher/Models/Container.cs index 13f1253..826dcbe 100644 --- a/Watcher/Models/Container.cs +++ b/Watcher/Models/Container.cs @@ -5,9 +5,13 @@ namespace Watcher.Models; public class Container { public int Id { get; set; } + [JsonPropertyName("Server_id")] public int ServerId { get; set; } + // Navigation Property + public Server Server { get; set; } = null!; + [JsonPropertyName("id")] public String? ContainerId { get; set; } diff --git a/Watcher/Models/User.cs b/Watcher/Models/User.cs index 13d366a..ce774d7 100644 --- a/Watcher/Models/User.cs +++ b/Watcher/Models/User.cs @@ -7,16 +7,18 @@ public class User { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public int Id { get; set; } // PK - public string? OIDC_Id { get; set; } = null!; - public string Username { get; set; } = null!; - public string? Email { get; set; } - public DateTime LastLogin { get; set; } + public int Id { get; set; } [Required] - public string IdentityProvider { get; set; } = "local"; - + [StringLength(50)] + public string Username { get; set; } = null!; + + [EmailAddress] + public string? Email { get; set; } + + public DateTime LastLogin { get; set; } = DateTime.UtcNow; + [Required] [DataType(DataType.Password)] - public String? Password { get; set; } = string.Empty; + public string Password { get; set; } = string.Empty; } diff --git a/Watcher/Program.cs b/Watcher/Program.cs index 466d1f1..d6fab21 100644 --- a/Watcher/Program.cs +++ b/Watcher/Program.cs @@ -1,4 +1,3 @@ -using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.EntityFrameworkCore; using Microsoft.OpenApi.Models; @@ -7,8 +6,6 @@ using Serilog; using Watcher.Data; using Watcher.Models; using Watcher.Services; -//using Watcher.Services; -//using Watcher.Workers; var builder = WebApplication.CreateBuilder(args); @@ -38,10 +35,14 @@ builder.Services.AddHttpContextAccessor(); // Storage Singleton builder.Services.AddSingleton(); builder.Services.AddSingleton(); +builder.Services.AddSingleton(); +builder.Services.AddSingleton(); // Background Services builder.Services.AddHostedService(); builder.Services.AddHostedService(); +builder.Services.AddHostedService(); +builder.Services.AddHostedService(); // Swagger API-Dokumentation builder.Services.AddSwaggerGen(options => @@ -62,106 +63,25 @@ var configuration = builder.Configuration; // ---------- DB-Kontext ---------- -var dbProvider = configuration["Database:Provider"] ?? "MySQL"; -var connectionString = configuration["Database:ConnectionString"]; +// Nur SQLite wird unterstützt +var sqliteConnectionString = configuration.GetConnectionString("Sqlite") + ?? configuration["Database:ConnectionStrings:Sqlite"] + ?? "Data Source=./persistence/watcher.db"; + builder.Services.AddDbContext((serviceProvider, options) => { - var config = serviceProvider.GetRequiredService(); - var provider = dbProvider; - - if (provider == "MySql") - { - var connStr = config.GetConnectionString("MySql") ?? config["Database:ConnectionStrings:MySql"]; - options.UseMySql(connStr, ServerVersion.AutoDetect(connStr)); - } - else if (provider == "Sqlite") - { - var connStr = config.GetConnectionString("Sqlite") ?? config["Database:ConnectionStrings:Sqlite"]; - options.UseSqlite(connStr); - } - else - { - throw new Exception("Unsupported database provider configured."); - } + options.UseSqlite(sqliteConnectionString); }); // ---------- Authentifizierung konfigurieren ---------- -// PocketID nur konfigurieren, wenn aktiviert -var pocketIdSection = builder.Configuration.GetSection("Authentication:PocketID"); -var pocketIdEnabled = pocketIdSection.GetValue("Enabled"); - - -var auth = builder.Services.AddAuthentication("Cookies"); -auth.AddCookie("Cookies", options => -{ - options.LoginPath = "/Auth/Login"; - options.AccessDeniedPath = "/Auth/AccessDenied"; -}); - - -builder.Services.AddAuthentication() -.AddOpenIdConnect("oidc", options => -{ - options.Authority = pocketIdSection["Authority"]; - options.ClientId = pocketIdSection["ClientId"]; - options.ClientSecret = pocketIdSection["ClientSecret"]; - options.ResponseType = "code"; - options.CallbackPath = pocketIdSection["CallbackPath"]; - options.SaveTokens = true; - - options.GetClaimsFromUserInfoEndpoint = true; - - options.Scope.Clear(); - options.Scope.Add("openid"); - options.Scope.Add("profile"); - options.Scope.Add("email"); - - options.Events = new OpenIdConnectEvents +// Nur Cookie-basierte lokale Authentifizierung +builder.Services.AddAuthentication("Cookies") + .AddCookie("Cookies", options => { - OnTokenValidated = async ctx => - { - var db = ctx.HttpContext.RequestServices.GetRequiredService(); - - var principal = ctx.Principal; -#pragma warning disable CS8602 // Dereference of a possibly null reference. - - var pocketId = principal.FindFirst("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier")?.Value; -#pragma warning restore CS8602 // Dereference of a possibly null reference. - - var preferredUsername = principal.FindFirst("preferred_username")?.Value; - var email = principal.FindFirst("email")?.Value; - - if (string.IsNullOrEmpty(pocketId)) - return; - - var user = await db.Users.FirstOrDefaultAsync(u => u.OIDC_Id == pocketId); - - if (user == null) - { - user = new User - { - OIDC_Id = pocketId, - Username = preferredUsername ?? "", - Email = email, - LastLogin = DateTime.UtcNow, - IdentityProvider = "oidc", - Password = string.Empty - }; - db.Users.Add(user); - } - else - { - user.LastLogin = DateTime.UtcNow; - user.Username = preferredUsername ?? user.Username; - user.Email = email ?? user.Email; - db.Users.Update(user); - } - - await db.SaveChangesAsync(); - } - }; -}); + options.LoginPath = "/Auth/Login"; + options.AccessDeniedPath = "/Auth/AccessDenied"; + }); var app = builder.Build(); @@ -175,7 +95,7 @@ using (var scope = app.Services.CreateScope()) } -// Standart-User in Datenbank schreiben +// Standard-Admin-User erstellen using (var scope = app.Services.CreateScope()) { var db = scope.ServiceProvider.GetRequiredService(); @@ -184,21 +104,19 @@ using (var scope = app.Services.CreateScope()) if (!db.Users.Any()) { - Console.WriteLine("No users found, creating default user..."); + Console.WriteLine("No users found, creating default admin user..."); var defaultUser = new User { - OIDC_Id = string.Empty, Username = "admin", - Email = string.Empty, + Email = "admin@localhost", LastLogin = DateTime.UtcNow, - IdentityProvider = "local", Password = BCrypt.Net.BCrypt.HashPassword("changeme") }; db.Users.Add(defaultUser); db.SaveChanges(); - Console.WriteLine("Default user created."); + Console.WriteLine("Default admin user created (username: admin, password: changeme)"); } else { diff --git a/Watcher/Services/IUpdateCheckStore.cs b/Watcher/Services/IUpdateCheckStore.cs new file mode 100644 index 0000000..ead0e00 --- /dev/null +++ b/Watcher/Services/IUpdateCheckStore.cs @@ -0,0 +1,8 @@ +namespace Watcher.Services; + +public interface IUpdateCheckStore +{ + bool IsUpdateAvailable { get; set; } + string? LatestVersion { get; set; } + DateTime LastChecked { get; set; } +} diff --git a/Watcher/Services/IVersionService.cs b/Watcher/Services/IVersionService.cs new file mode 100644 index 0000000..673754f --- /dev/null +++ b/Watcher/Services/IVersionService.cs @@ -0,0 +1,6 @@ +namespace Watcher.Services; + +public interface IVersionService +{ + string GetVersion(); +} diff --git a/Watcher/Services/MetricCleanupService.cs b/Watcher/Services/MetricCleanupService.cs new file mode 100644 index 0000000..a7cafa6 --- /dev/null +++ b/Watcher/Services/MetricCleanupService.cs @@ -0,0 +1,127 @@ +using Microsoft.EntityFrameworkCore; +using Watcher.Data; + +namespace Watcher.Services; + +public class MetricCleanupService : BackgroundService +{ + private readonly ILogger _logger; + private readonly IServiceProvider _serviceProvider; + private readonly int _retentionDays; + private readonly int _checkIntervalHours; + private readonly bool _enabled; + + public MetricCleanupService( + ILogger logger, + IServiceProvider serviceProvider, + IConfiguration configuration) + { + _logger = logger; + _serviceProvider = serviceProvider; + + // Konfiguration aus Environment Variablen laden + _retentionDays = int.TryParse( + configuration["DataRetention:MetricRetentionDays"] ?? + Environment.GetEnvironmentVariable("METRIC_RETENTION_DAYS"), + out var days) ? days : 30; // Default: 30 Tage + + _checkIntervalHours = int.TryParse( + configuration["DataRetention:CleanupIntervalHours"] ?? + Environment.GetEnvironmentVariable("METRIC_CLEANUP_INTERVAL_HOURS"), + out var hours) ? hours : 24; // Default: 24 Stunden + + _enabled = bool.TryParse( + configuration["DataRetention:Enabled"] ?? + Environment.GetEnvironmentVariable("METRIC_CLEANUP_ENABLED"), + out var enabled) ? enabled : true; // Default: aktiviert + + _logger.LogInformation( + "MetricCleanupService konfiguriert: Enabled={Enabled}, RetentionDays={Days}, IntervalHours={Hours}", + _enabled, _retentionDays, _checkIntervalHours); + } + + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + if (!_enabled) + { + _logger.LogInformation("MetricCleanupService ist deaktiviert."); + return; + } + + // Warte 1 Minute nach Start, bevor der erste Cleanup läuft + await Task.Delay(TimeSpan.FromMinutes(1), stoppingToken); + + var timer = new PeriodicTimer(TimeSpan.FromHours(_checkIntervalHours)); + + while (await timer.WaitForNextTickAsync(stoppingToken)) + { + try + { + await CleanupOldMetricsAsync(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Fehler beim Cleanup alter Metriken."); + } + + // Offset nach Cleanup + await Task.Delay(TimeSpan.FromSeconds(10), stoppingToken); + } + } + + private async Task CleanupOldMetricsAsync() + { + _logger.LogInformation("Starte Metric Cleanup für Daten älter als {Days} Tage...", _retentionDays); + + using var scope = _serviceProvider.CreateScope(); + var context = scope.ServiceProvider.GetRequiredService(); + + var cutoffDate = DateTime.UtcNow.AddDays(-_retentionDays); + + try + { + // Anzahl der zu löschenden Einträge ermitteln + var countToDelete = await context.Metrics + .Where(m => m.Timestamp < cutoffDate) + .CountAsync(); + + if (countToDelete == 0) + { + _logger.LogInformation("Keine alten Metriken zum Löschen gefunden."); + return; + } + + _logger.LogInformation("Lösche {Count} Metriken vor {Date}...", countToDelete, cutoffDate); + + // Metriken löschen + var deletedCount = await context.Metrics + .Where(m => m.Timestamp < cutoffDate) + .ExecuteDeleteAsync(); + + _logger.LogInformation( + "Metric Cleanup abgeschlossen: {DeletedCount} Einträge gelöscht.", + deletedCount); + + // Optional: ContainerMetrics auch bereinigen + var containerMetricsCount = await context.ContainerMetrics + .Where(cm => cm.Timestamp < cutoffDate) + .CountAsync(); + + if (containerMetricsCount > 0) + { + var deletedContainerMetrics = await context.ContainerMetrics + .Where(cm => cm.Timestamp < cutoffDate) + .ExecuteDeleteAsync(); + + _logger.LogInformation( + "ContainerMetrics Cleanup: {DeletedCount} Einträge gelöscht.", + deletedContainerMetrics); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Fehler beim Löschen alter Metriken aus der Datenbank."); + throw; + } + } +} diff --git a/Watcher/Services/UpdateCheckService.cs b/Watcher/Services/UpdateCheckService.cs new file mode 100644 index 0000000..27377cb --- /dev/null +++ b/Watcher/Services/UpdateCheckService.cs @@ -0,0 +1,159 @@ +using System.Text.Json; + +namespace Watcher.Services; + +public class UpdateCheckService : BackgroundService +{ + private readonly ILogger _logger; + private readonly IUpdateCheckStore _updateCheckStore; + private readonly IVersionService _versionService; + private readonly string _repositoryUrl; + private readonly int _checkIntervalHours; + private readonly bool _enabled; + private readonly HttpClient _httpClient; + + public UpdateCheckService( + ILogger logger, + IUpdateCheckStore updateCheckStore, + IVersionService versionService, + IConfiguration configuration) + { + _logger = logger; + _updateCheckStore = updateCheckStore; + _versionService = versionService; + _httpClient = new HttpClient(); + + // Konfiguration aus Environment Variablen laden + _repositoryUrl = configuration["UpdateCheck:RepositoryUrl"] + ?? Environment.GetEnvironmentVariable("UPDATE_CHECK_REPOSITORY_URL") + ?? "https://git.triggermeelmo.com/api/v1/repos/Watcher/watcher/releases/latest"; + + _checkIntervalHours = int.TryParse( + configuration["UpdateCheck:CheckIntervalHours"] + ?? Environment.GetEnvironmentVariable("UPDATE_CHECK_INTERVAL_HOURS"), + out var hours) ? hours : 24; // Default: 24 Stunden + + _enabled = bool.TryParse( + configuration["UpdateCheck:Enabled"] + ?? Environment.GetEnvironmentVariable("UPDATE_CHECK_ENABLED"), + out var enabled) ? enabled : true; // Default: aktiviert + + _logger.LogInformation( + "UpdateCheckService konfiguriert: Enabled={Enabled}, Repository={Repo}, IntervalHours={Hours}", + _enabled, _repositoryUrl, _checkIntervalHours); + } + + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + if (!_enabled) + { + _logger.LogInformation("UpdateCheckService ist deaktiviert."); + return; + } + + // Warte 2 Minuten nach Start, bevor der erste Check läuft + await Task.Delay(TimeSpan.FromMinutes(2), stoppingToken); + + var timer = new PeriodicTimer(TimeSpan.FromHours(_checkIntervalHours)); + + while (await timer.WaitForNextTickAsync(stoppingToken)) + { + try + { + await CheckForUpdatesAsync(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Fehler beim Update-Check."); + } + + await Task.Delay(TimeSpan.FromSeconds(10), stoppingToken); + } + } + + private async Task CheckForUpdatesAsync() + { + var currentVersion = _versionService.GetVersion(); + + _logger.LogInformation("Starte Update-Check. Aktuelle Version: {Version}", currentVersion); + + // Bei "development" oder "latest" immer als aktuell markieren + if (currentVersion == "development" || currentVersion == "latest") + { + _updateCheckStore.IsUpdateAvailable = false; + _updateCheckStore.LatestVersion = currentVersion; + _updateCheckStore.LastChecked = DateTime.UtcNow; + _logger.LogInformation("Development/Latest Build - keine Update-Prüfung nötig."); + return; + } + + try + { + // Gitea API abfragen + var response = await _httpClient.GetAsync(_repositoryUrl); + + if (!response.IsSuccessStatusCode) + { + _logger.LogWarning("Gitea API Fehler: {StatusCode}", response.StatusCode); + return; + } + + var jsonContent = await response.Content.ReadAsStringAsync(); + var releaseInfo = JsonSerializer.Deserialize(jsonContent); + + if (releaseInfo?.TagName == null) + { + _logger.LogWarning("Keine Release-Information gefunden."); + return; + } + + var latestVersion = releaseInfo.TagName; + _updateCheckStore.LatestVersion = latestVersion; + _updateCheckStore.LastChecked = DateTime.UtcNow; + + // Versionsvergleich + var isNewer = CompareVersions(latestVersion, currentVersion); + _updateCheckStore.IsUpdateAvailable = isNewer; + + if (isNewer) + { + _logger.LogInformation( + "Neue Version verfügbar: {Latest} (aktuell: {Current})", + latestVersion, currentVersion); + } + else + { + _logger.LogInformation( + "System ist auf dem neuesten Stand: {Version}", + currentVersion); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Fehler beim Abrufen der Release-Informationen von Gitea."); + } + } + + private bool CompareVersions(string latestVersion, string currentVersion) + { + // Entferne "v" Prefix falls vorhanden + latestVersion = latestVersion.TrimStart('v'); + currentVersion = currentVersion.TrimStart('v'); + + // Versuche semantic versioning zu parsen + if (Version.TryParse(latestVersion, out var latest) && + Version.TryParse(currentVersion, out var current)) + { + return latest > current; + } + + // Fallback: String-Vergleich + return string.Compare(latestVersion, currentVersion, StringComparison.Ordinal) > 0; + } + + // DTO für Gitea API Response + private class GiteaReleaseResponse + { + public string? TagName { get; set; } + } +} diff --git a/Watcher/Services/UpdateCheckStore.cs b/Watcher/Services/UpdateCheckStore.cs new file mode 100644 index 0000000..5cca773 --- /dev/null +++ b/Watcher/Services/UpdateCheckStore.cs @@ -0,0 +1,8 @@ +namespace Watcher.Services; + +public class UpdateCheckStore : IUpdateCheckStore +{ + public bool IsUpdateAvailable { get; set; } = false; + public string? LatestVersion { get; set; } = null; + public DateTime LastChecked { get; set; } = DateTime.MinValue; +} diff --git a/Watcher/Services/VersionService.cs b/Watcher/Services/VersionService.cs new file mode 100644 index 0000000..a7c13b6 --- /dev/null +++ b/Watcher/Services/VersionService.cs @@ -0,0 +1,19 @@ +namespace Watcher.Services; + +public class VersionService : IVersionService +{ + private readonly string _version; + + public VersionService(IConfiguration configuration) + { + // Priorität: Environment Variable > Configuration > Default + _version = Environment.GetEnvironmentVariable("WATCHER_VERSION") + ?? configuration["Application:Version"] + ?? "development"; + } + + public string GetVersion() + { + return _version; + } +} diff --git a/Watcher/Views/Container/Overview.cshtml b/Watcher/Views/Container/Overview.cshtml index e3edfc3..7e818fb 100644 --- a/Watcher/Views/Container/Overview.cshtml +++ b/Watcher/Views/Container/Overview.cshtml @@ -15,7 +15,7 @@ Container-ID Name Image - Host-ID + Host Aktionen @@ -25,8 +25,7 @@ @container.ContainerId @container.Name @container.Image - - @container.ServerId + @container.Server?.Name nicht verfügbar } diff --git a/Watcher/Views/Home/_DashboardStats.cshtml b/Watcher/Views/Home/_DashboardStats.cshtml index dc011e4..4b0a81a 100644 --- a/Watcher/Views/Home/_DashboardStats.cshtml +++ b/Watcher/Views/Home/_DashboardStats.cshtml @@ -1,4 +1,3 @@ -@using Microsoft.IdentityModel.Tokens @model Watcher.ViewModels.DashboardViewModel @{ @@ -58,7 +57,7 @@
Systemstatus
- @if (!Model.NetworkStatus.IsNullOrEmpty()) + @if (!string.IsNullOrEmpty(Model.NetworkStatus)) { @if (Model.NetworkStatus == "online") { @@ -81,7 +80,7 @@ } } - @if (!Model.DatabaseStatus.IsNullOrEmpty()) + @if (!string.IsNullOrEmpty(Model.DatabaseStatus)) { @if (Model.DatabaseStatus == "ok") { diff --git a/Watcher/Views/Shared/_Layout.cshtml b/Watcher/Views/Shared/_Layout.cshtml index a252560..23e61bf 100644 --- a/Watcher/Views/Shared/_Layout.cshtml +++ b/Watcher/Views/Shared/_Layout.cshtml @@ -1,7 +1,10 @@ @using Microsoft.AspNetCore.Authentication @using Microsoft.AspNetCore.Authorization @using Microsoft.AspNetCore.Http +@using Watcher.Services @inject IHttpContextAccessor HttpContextAccessor +@inject IVersionService VersionService +@inject IUpdateCheckStore UpdateCheckStore @{ var pictureUrl = User.FindFirst("picture")?.Value; @@ -98,7 +101,7 @@
- +
@User.Identity?.Name
Profil ansehen @@ -110,6 +113,19 @@ { Login } + +
+ + @{ + var statusColor = UpdateCheckStore.IsUpdateAvailable ? "#ffc107" : "#28a745"; + var statusTitle = UpdateCheckStore.IsUpdateAvailable + ? $"Update verfügbar: {UpdateCheckStore.LatestVersion}" + : "System ist aktuell"; + } + + Version: @VersionService.GetVersion() + +
diff --git a/Watcher/Views/System/Settings.cshtml b/Watcher/Views/System/Settings.cshtml index 23c0ef3..aa4b0c5 100644 --- a/Watcher/Views/System/Settings.cshtml +++ b/Watcher/Views/System/Settings.cshtml @@ -29,10 +29,14 @@
Datenbank-Engine: @(DbEngine ?? "nicht gefunden")
- + + @if (ViewBag.DatabaseSize != null) + { +
Datenbankgröße: @ViewBag.DatabaseSize
+ } - @if (DbEngine == "Microsoft.EntityFrameworkCore.Sqlite") + @if (DbEngine == "SQLite" || DbEngine == "Microsoft.EntityFrameworkCore.Sqlite") {
diff --git a/Watcher/Watcher.csproj b/Watcher/Watcher.csproj index 4ec814e..b150629 100644 --- a/Watcher/Watcher.csproj +++ b/Watcher/Watcher.csproj @@ -7,20 +7,13 @@ - - - - - - - - - + + + - diff --git a/Watcher/appsettings.json b/Watcher/appsettings.json index dff88f0..1cfd965 100644 --- a/Watcher/appsettings.json +++ b/Watcher/appsettings.json @@ -9,22 +9,8 @@ "AllowedHosts": "*", "Database": { - "Provider": "Sqlite", "ConnectionStrings": { - "MySql": "server=0.0.0.0;port=3306;database=db;user=user;password=password;", "Sqlite": "Data Source=./persistence/watcher.db" } - }, - - "Authentication": { - "UseLocal": true, - "PocketIDEnabled": false, - "PocketID": { - "Authority": "https://pocketid.triggermeelmo.com", - "ClientId": "629a5f42-ab02-4905-8311-cc7b64165cc0", - "ClientSecret": "QHUNaRyK2VVYdZVz1cQqv8FEf2qtL6QH", - "CallbackPath": "/signin-oidc", - "ResponseType": "code" - } - } + } } diff --git a/docker-compose.yaml b/docker-compose.yaml index 6eacc9c..347348f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,6 +1,6 @@ services: watcher: - image: git.triggermeelmo.com/watcher/watcher-server:v0.1.0 + image: git.triggermeelmo.com/watcher/watcher-server:${IMAGE_VERSION:-latest} container_name: watcher deploy: resources: @@ -8,6 +8,17 @@ services: memory: 200M restart: unless-stopped env_file: .env + environment: + # Application Version (wird aus Image-Tag übernommen) + - WATCHER_VERSION=${IMAGE_VERSION:-latest} + # Update Check + - UPDATE_CHECK_ENABLED=true + - UPDATE_CHECK_INTERVAL_HOURS=24 + - UPDATE_CHECK_REPOSITORY_URL=https://git.triggermeelmo.com/api/v1/repos/Watcher/watcher/releases/latest + # Data Retention Policy + - METRIC_RETENTION_DAYS=30 + - METRIC_CLEANUP_INTERVAL_HOURS=24 + - METRIC_CLEANUP_ENABLED=true ports: - "5000:5000" volumes: -- 2.49.1