Database Update + Local Storage Start
Some checks failed
Gitea CI/CD / dotnet-build-and-test (push) Has been cancelled
Gitea CI/CD / Set Tag Name (push) Has been cancelled
Gitea CI/CD / docker-build-and-push (push) Has been cancelled
Gitea CI/CD / Create Tag (push) Has been cancelled

This commit is contained in:
2025-12-06 12:47:28 +01:00
parent e72bc48cc4
commit 24538d8030
7 changed files with 134 additions and 16 deletions

View File

@@ -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();
}

View File

@@ -0,0 +1,71 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("IPAddress")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Servers");
});
modelBuilder.Entity("watcher_monitoring.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("TEXT");
b.Property<DateTime>("LastLogin")
.HasColumnType("TEXT");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Users");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace watcher_monitoring.Migrations
{
/// <inheritdoc />
public partial class ServerHardware : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@@ -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
}
}

View File

@@ -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;
}

View File

@@ -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; }
}

View File

@@ -20,4 +20,8 @@
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.6" />
</ItemGroup>
<ItemGroup>
<Folder Include="persistence\" />
</ItemGroup>
</Project>