diff --git a/watcher-monitoring/Controllers/MonitoringController.cs b/watcher-monitoring/Controllers/MonitoringController.cs index 3460401..a70aeb2 100644 --- a/watcher-monitoring/Controllers/MonitoringController.cs +++ b/watcher-monitoring/Controllers/MonitoringController.cs @@ -1,10 +1,8 @@ using Microsoft.AspNetCore.Mvc; -using Microsoft.Data.Sqlite; -using Microsoft.EntityFrameworkCore; -using System.Text.Json; using watcher_monitoring.Payloads; using watcher_monitoring.Data; +using watcher_monitoring.Models; namespace watcher_monitoring.Controllers; @@ -55,6 +53,19 @@ public class MonitoringController : Controller _logger.LogError("Invalid hardware configuration"); return BadRequest(new { error = "Invalid Hardware Configuration Payload", details = errors }); } + try + { + // Find Server in Database + Server server = await _context.Servers.FindAsync(dto.Id); + + // Add Hardware Configuration + + } + catch (Exception ex) + { + _logger.LogError(ex.Message); + } + return Ok(); } diff --git a/watcher-monitoring/Migrations/20251205161855_ServerHardware.Designer.cs b/watcher-monitoring/Migrations/20251205161855_ServerHardware.Designer.cs new file mode 100644 index 0000000..3fcae25 --- /dev/null +++ b/watcher-monitoring/Migrations/20251205161855_ServerHardware.Designer.cs @@ -0,0 +1,71 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using watcher_monitoring.Data; + +#nullable disable + +namespace watcher_monitoring.Migrations +{ + [DbContext(typeof(WatcherDbContext))] + [Migration("20251205161855_ServerHardware")] + partial class ServerHardware + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.6"); + + modelBuilder.Entity("watcher_monitoring.Models.Server", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("IPAddress") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Servers"); + }); + + modelBuilder.Entity("watcher_monitoring.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("LastLogin") + .HasColumnType("TEXT"); + + b.Property("Password") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/watcher-monitoring/Migrations/20251205161855_ServerHardware.cs b/watcher-monitoring/Migrations/20251205161855_ServerHardware.cs new file mode 100644 index 0000000..d52727a --- /dev/null +++ b/watcher-monitoring/Migrations/20251205161855_ServerHardware.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace watcher_monitoring.Migrations +{ + /// + public partial class ServerHardware : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/watcher-monitoring/Models/ServerHardware.cs b/watcher-monitoring/Models/ServerHardware.cs new file mode 100644 index 0000000..9a46ba9 --- /dev/null +++ b/watcher-monitoring/Models/ServerHardware.cs @@ -0,0 +1,18 @@ +namespace watcher_monitoring.Models +{ + public class ServerHardware + { + // CPU + public required string CpuType { get; set; } + public required int CpuCores { get; set; } + + // RAM + public required double RamSize { get; set; } + + // GPU + + // Disks + + + } +} diff --git a/watcher-monitoring/Payloads/HardwareDto.cs b/watcher-monitoring/Payloads/HardwareDto.cs index deff668..9f799be 100644 --- a/watcher-monitoring/Payloads/HardwareDto.cs +++ b/watcher-monitoring/Payloads/HardwareDto.cs @@ -1,6 +1,10 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + namespace watcher_monitoring.Payloads; public class HardwareDto { + [Required] public required int Id; } \ No newline at end of file diff --git a/watcher-monitoring/Storage/DashboardStore.cs b/watcher-monitoring/Storage/DashboardStore.cs index 4226c86..769bba3 100644 --- a/watcher-monitoring/Storage/DashboardStore.cs +++ b/watcher-monitoring/Storage/DashboardStore.cs @@ -2,17 +2,5 @@ namespace watcher_monitoring.Storage; public class DashboardStore : IDashboardStore { - public string? NetworkStatus { get; set; } = "offline"; - - public string? DatabaseStatus { get; set; } = "ok"; - - public int ServerTotalCount { get; set; } = 0; - - public int ServerOnlineCount { get; set; } = 0; - - public int ServerOfflineCount { get; set; } = 0; - - public int ServiceTotalCount { get; set; } = 0; - - public DateTime ServerUptime { get; set; } + } \ No newline at end of file diff --git a/watcher-monitoring/watcher-monitoring.csproj b/watcher-monitoring/watcher-monitoring.csproj index 350355f..79f1c9c 100644 --- a/watcher-monitoring/watcher-monitoring.csproj +++ b/watcher-monitoring/watcher-monitoring.csproj @@ -20,4 +20,8 @@ + + + +