Database Update + Local Storage Start
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
71
watcher-monitoring/Migrations/20251205161855_ServerHardware.Designer.cs
generated
Normal file
71
watcher-monitoring/Migrations/20251205161855_ServerHardware.Designer.cs
generated
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
18
watcher-monitoring/Models/ServerHardware.cs
Normal file
18
watcher-monitoring/Models/ServerHardware.cs
Normal 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
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
@@ -20,4 +20,8 @@
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.6" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="persistence\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user