Merge branch 'development' of https://git.triggermeelmo.com/daniel-hbn/Watcher into enhancement/overview-pages

This commit is contained in:
2025-06-21 21:12:15 +02:00
60 changed files with 3392 additions and 1823 deletions

9
.gitignore vendored
View File

@@ -1,3 +1,12 @@
# Per-Use special Files and Directories
/persistance/*.db
/logs
*.env
/wwwroot/downloads/sqlite/*.sql
/persistence/*.db-shm
/persistence/*.db-wal
# Build-Ordner # Build-Ordner
bin/ bin/
obj/ obj/

8
Watcher/.env.example Normal file
View File

@@ -0,0 +1,8 @@
# 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

View File

@@ -1,21 +1,69 @@
using System.Net.Mail;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Watcher.Data;
using Watcher.ViewModels;
namespace Watcher.Controllers; namespace Watcher.Controllers;
public class AuthController : Controller public class AuthController : Controller
{ {
public IActionResult Login() private readonly AppDbContext _context;
public AuthController(AppDbContext context)
{ {
return View(); _context = context;
} }
[HttpGet]
public IActionResult Login(string? returnUrl = null)
{
var model = new LoginViewModel
{
ReturnUrl = returnUrl
};
return View(model);
}
[HttpPost]
public async Task<IActionResult> Login(LoginViewModel model)
{
if (!ModelState.IsValid)
return View(model);
var user = await _context.Users.FirstOrDefaultAsync(u => u.Username == model.Username);
if (user == null || !BCrypt.Net.BCrypt.Verify(model.Password, user.Password))
{
ModelState.AddModelError("", "Benutzername oder Passwort ist falsch.");
return View(model);
}
var claims = new List<Claim>
{
new Claim(ClaimTypes.Name, user.Username),
new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()),
};
var identity = new ClaimsIdentity(claims, "local");
var principal = new ClaimsPrincipal(identity);
await HttpContext.SignInAsync("Cookies", principal);
return Redirect("Home/Index");
}
public IActionResult SignIn() public IActionResult SignIn()
{ {
return Challenge(new AuthenticationProperties return Challenge(new AuthenticationProperties
{ {
RedirectUri = "/" RedirectUri = "/Home/Index"
}, "oidc"); }, "oidc");
} }
@@ -23,19 +71,132 @@ public class AuthController : Controller
[ValidateAntiForgeryToken] [ValidateAntiForgeryToken]
public async Task<IActionResult> Logout() public async Task<IActionResult> Logout()
{ {
await HttpContext.SignOutAsync(); var props = new AuthenticationProperties
return RedirectToAction("Index", "Home"); {
RedirectUri = Url.Action("Login", "Auth")
};
await HttpContext.SignOutAsync("Cookies");
await HttpContext.SignOutAsync("oidc", props);
return Redirect("/"); // nur als Fallback
} }
[Authorize] [Authorize]
public IActionResult Info() public IActionResult Info()
{ {
var name = User.Identity?.Name; var username = User.Identity?.Name;
Console.WriteLine("gefundener User: " + username);
var claims = User.Claims.Select(c => new { c.Type, c.Value }).ToList(); var claims = User.Claims.Select(c => new { c.Type, c.Value }).ToList();
ViewBag.Name = name; var user = _context.Users.FirstOrDefault(u => u.Username == username);
if (user == null) return NotFound();
var DbProvider = _context.Database.ProviderName;
var mail = user.Email;
var Id = user.Id;
ViewBag.Name = username;
ViewBag.Claims = claims; ViewBag.Claims = claims;
ViewBag.Mail = mail;
ViewBag.Id = Id;
return View(); return View();
} }
// Edit-Form anzeigen
[Authorize]
[HttpGet]
public IActionResult Edit()
{
var username = User.Identity?.Name;
var user = _context.Users.FirstOrDefault(u => u.Username == username);
if (user == null) return NotFound();
var model = new EditUserViewModel
{
Username = user.Username
};
return View(model);
}
// Edit speichern
[Authorize]
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult Edit(EditUserViewModel model)
{
if (!ModelState.IsValid) return View(model);
var username = User.Identity?.Name;
var user = _context.Users.FirstOrDefault(u => u.Username == username);
if (user == null) return NotFound();
user.Username = model.Username;
if (!string.IsNullOrWhiteSpace(model.NewPassword))
{
user.Password = BCrypt.Net.BCrypt.HashPassword(model.NewPassword);
}
_context.SaveChanges();
// Eventuell hier das Auth-Cookie erneuern, wenn Username sich ändert
return RedirectToAction("Index", "Home");
}
// Edit-Form anzeigen
[Authorize]
[HttpGet]
public IActionResult UserSettings()
{
var username = User.Identity?.Name;
Console.WriteLine("gefundener User: " + username);
var claims = User.Claims.Select(c => new { c.Type, c.Value }).ToList();
var user = _context.Users.FirstOrDefault(u => u.Username == username);
if (user == null) return NotFound();
var DbProvider = _context.Database.ProviderName;
var mail = user.Email;
ViewBag.Name = username;
ViewBag.mail = mail;
ViewBag.Claims = claims;
ViewBag.IdentityProvider = user.IdentityProvider;
ViewBag.DbProvider = DbProvider;
return View();
}
// Edit speichern
[Authorize]
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult UserSettings(EditUserViewModel model)
{
if (!ModelState.IsValid) return View(model);
var username = User.Identity?.Name;
var user = _context.Users.FirstOrDefault(u => u.Username == username);
if (user == null) return NotFound();
var databaseProvider = _context.Database.ProviderName;
user.Username = model.Username;
// Passwort ändern
if (!string.IsNullOrWhiteSpace(model.NewPassword))
{
user.Username = BCrypt.Net.BCrypt.HashPassword(model.NewPassword);
}
_context.SaveChanges();
// Eventuell hier das Auth-Cookie erneuern, wenn Username sich ändert
return RedirectToAction("Index", "Home");
}
} }

View File

@@ -7,7 +7,7 @@ using Watcher.ViewModels;
namespace Watcher.Controllers; namespace Watcher.Controllers;
[Authorize]
public class ContainerController : Controller public class ContainerController : Controller
{ {
private readonly AppDbContext _context; private readonly AppDbContext _context;

View File

@@ -0,0 +1,185 @@
using System.Runtime.InteropServices;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using System.IO;
using System.Diagnostics;
namespace Watcher.Controllers
{
[Authorize]
public class DatabaseController : Controller
{
private readonly string _dbPath = Path.Combine(Directory.GetCurrentDirectory(), "persistence", "watcher.db");
private readonly string _backupFolder = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "downloads", "sqlite");
public class DumpFileInfo
{
public string? FileName { get; set; }
public long SizeKb { get; set; }
public DateTime Created { get; set; }
}
public DatabaseController(IWebHostEnvironment env)
{
_backupFolder = Path.Combine(env.WebRootPath, "downloads", "sqlite");
if (!Directory.Exists(_backupFolder))
Directory.CreateDirectory(_backupFolder);
}
[HttpPost("/maintenance/sqlite-dump")]
public IActionResult CreateSqlDump()
{
try
{
// Zielordner sicherstellen
if (!Directory.Exists(_backupFolder))
Directory.CreateDirectory(_backupFolder);
// Ziel-Dateiname z.B. mit Zeitstempel
var timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");
var dumpFileName = $"watcher_dump_{timestamp}.sql";
var dumpFilePath = Path.Combine(_backupFolder, dumpFileName);
using var connection = new SqliteConnection($"Data Source={_dbPath}");
connection.Open();
using var command = connection.CreateCommand();
command.CommandText = "SELECT sql FROM sqlite_master WHERE type='table' AND sql IS NOT NULL;";
using var writer = new StreamWriter(dumpFilePath);
// Write schema
using (var schemaCmd = connection.CreateCommand())
{
schemaCmd.CommandText = "SELECT sql FROM sqlite_master WHERE type='table'";
using var reader = schemaCmd.ExecuteReader();
while (reader.Read())
{
writer.WriteLine(reader.GetString(0) + ";");
}
}
// Write content
using (var tableCmd = connection.CreateCommand())
{
tableCmd.CommandText = "SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'";
using var tableReader = tableCmd.ExecuteReader();
while (tableReader.Read())
{
var tableName = tableReader.GetString(0);
using var dataCmd = connection.CreateCommand();
dataCmd.CommandText = $"SELECT * FROM {tableName}";
using var dataReader = dataCmd.ExecuteReader();
while (dataReader.Read())
{
var columns = new string[dataReader.FieldCount];
var values = new string[dataReader.FieldCount];
for (int i = 0; i < dataReader.FieldCount; i++)
{
columns[i] = dataReader.GetName(i);
var val = dataReader.GetValue(i);
values[i] = val == null || val == DBNull.Value
? "NULL"
: $"'{val.ToString().Replace("'", "''")}'";
}
writer.WriteLine($"INSERT INTO {tableName} ({string.Join(",", columns)}) VALUES ({string.Join(",", values)});");
}
}
}
writer.Flush();
//return Ok($"Dump erfolgreich erstellt: {dumpFileName}");
TempData["DumpMessage"] = "SQLite-Dump erfolgreich erstellt.";
return RedirectToAction("UserSettings", "Auth");
}
catch (Exception ex)
{
//return StatusCode(500, $"Fehler beim Erstellen des Dumps: {ex.Message}");
TempData["DumpError"] = $"Fehler beim Erstellen des Dumps: {ex.Message}";
return RedirectToAction("UserSettings", "Auth");
}
}
public IActionResult ManageSqlDumps()
{
var files = Directory.GetFiles(_backupFolder, "*.sql")
.Select(f => new DumpFileInfo
{
FileName = Path.GetFileName(f),
SizeKb = new FileInfo(f).Length / 1024,
Created = System.IO.File.GetCreationTime(f)
})
.OrderByDescending(f => f.Created)
.ToList();
return View(files);
}
[HttpPost]
public IActionResult Delete(string fileName)
{
var filePath = Path.Combine(_backupFolder, fileName);
if (System.IO.File.Exists(filePath))
{
System.IO.File.Delete(filePath);
TempData["Success"] = $"Backup {fileName} wurde gelöscht.";
}
return RedirectToAction("ManageSqlDumps");
}
// 🔹 4. Dump wiederherstellen
[HttpPost]
public IActionResult Restore(string fileName)
{
var filePath = Path.Combine(_backupFolder, fileName);
if (!System.IO.File.Exists(filePath))
{
TempData["Error"] = "Dump nicht gefunden.";
return RedirectToAction("ManageSqlDumps");
}
try
{
var dbPath = Path.Combine(Directory.GetCurrentDirectory(), "persistence", "watcher.db"); // anpassen
// Leere Datenbank
System.IO.File.WriteAllText(dbPath, "");
var psi = new ProcessStartInfo
{
FileName = "sqlite3",
Arguments = $"\"{dbPath}\" \".read \\\"{filePath}\\\"\"",
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true,
};
using var proc = Process.Start(psi);
proc.WaitForExit();
TempData["Success"] = $"Backup {fileName} wurde wiederhergestellt.";
}
catch (Exception ex)
{
TempData["Error"] = $"Fehler beim Wiederherstellen: {ex.Message}";
}
return RedirectToAction("ManageSqlDumps");
}
}
}

View File

@@ -0,0 +1,37 @@
using System.Runtime.InteropServices;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace Watcher.Controllers;
[Authorize]
public class DownloadController : Controller
{
[HttpGet("Download/File/{type}/{filename}")]
public IActionResult FileDownload(string type, string filename)
{
// Nur erlaubte Endungen zulassen (Sicherheit!)
var allowedExtensions = new[] { ".exe", "", ".sql" };
var extension = Path.GetExtension(filename).ToLowerInvariant();
if (!allowedExtensions.Contains(extension))
return BadRequest("Dateityp nicht erlaubt");
var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "downloads", type, filename);
if (!System.IO.File.Exists(path))
return NotFound("Datei nicht gefunden");
// .exe MIME-Typ: application/octet-stream
var mimeType = "application/octet-stream";
var fileBytes = System.IO.File.ReadAllBytes(path);
return File(fileBytes, mimeType, filename);
//return File(fileBytes, filename);
}
}

View File

@@ -20,10 +20,11 @@ namespace Watcher.Controllers
public async Task<IActionResult> Index() public async Task<IActionResult> Index()
{ {
var userId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value; var preferredUserName = User.FindFirst("preferred_username")?.Value;
var user = await _context.Users var user = await _context.Users
.Where(u => u.PocketId == userId) .Where(u => u.Username == preferredUserName)
.FirstOrDefaultAsync(); .FirstOrDefaultAsync();
var viewModel = new DashboardViewModel var viewModel = new DashboardViewModel
@@ -37,5 +38,26 @@ namespace Watcher.Controllers
return View(viewModel); return View(viewModel);
} }
public IActionResult DashboardStats()
{
Console.WriteLine("Dashboard aktualisiert");
var servers = _context.Servers.ToList();
var containers = _context.Containers.ToList();
var now = DateTime.UtcNow;
var model = new DashboardViewModel
{
ActiveServers = servers.Count(s => (now - s.LastSeen).TotalSeconds <= 120),
OfflineServers = servers.Count(s => (now - s.LastSeen).TotalSeconds > 120),
//RunningContainers = containers.Count(c => (now - c.LastSeen).TotalSeconds <= 120),
//FailedContainers = containers.Count(c => (now - c.LastSeen).TotalSeconds > 120),
LastLogin = DateTime.Now // Oder was auch immer hier richtig ist
};
return PartialView("_DashboardStats", model);
}
} }
} }

View File

@@ -0,0 +1,131 @@
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.CodeAnalysis;
using Microsoft.EntityFrameworkCore;
using Microsoft.IdentityModel.Tokens;
using Watcher.Data;
using Watcher.Models;
using Watcher.ViewModels;
namespace Watcher.Controllers;
public class RegistrationDto
{
// Server Identity
[Required]
public int Id { get; set; }
[Required]
public string? IpAddress { get; set; }
// Hardware Info
[Required]
public string? CpuType { get; set; }
[Required]
public int CpuCores { get; set; }
[Required]
public string? GpuType { get; set; }
[Required]
public double RamSize { get; set; }
}
public class MetricDto
{
// Server Identity
[Required]
public int Id { get; set; }
[Required]
public string? IpAddress { get; set; }
// Metrics
// CPU Auslastung, CPU Temperatur
// GPU Auslastung, GPU Temperatur
// RAM Auslastung
// Disks?
}
[ApiController]
[Route("[controller]")]
public class MonitoringController : Controller
{
private readonly AppDbContext _context;
public MonitoringController(AppDbContext context)
{
_context = context;
}
[HttpPost("register")]
public async Task<IActionResult> Register([FromBody] RegistrationDto dto)
{
// Gültigkeit des Payloads prüfen
if (!ModelState.IsValid)
{
var errors = ModelState.Values
.SelectMany(v => v.Errors)
.Select(e => e.ErrorMessage)
.ToList();
return BadRequest(new { error = "Ungültiger Payload", details = errors });
}
// Server in Datenbank finden
var server = await _context.Servers
.FirstOrDefaultAsync(s => s.IPAddress == dto.IpAddress);
if (server != null)
{
// Serverdaten in Datenbank eintragen
server.CpuType = dto.CpuType;
server.CpuCores = dto.CpuCores;
server.GpuType = dto.GpuType;
server.RamSize = dto.RamSize;
// Änderungen in Datenbank speichern
await _context.SaveChangesAsync();
// Success
return Ok();
}
return NotFound("No Matching Server found.");
}
[HttpPost("metric")]
public async Task<IActionResult> Receive([FromBody] MetricDto dto)
{
// Gültigkeit des Payloads prüfen
if (!ModelState.IsValid)
{
var errors = ModelState.Values
.SelectMany(v => v.Errors)
.Select(e => e.ErrorMessage)
.ToList();
return BadRequest(new { error = "Ungültiger Payload", details = errors });
}
// Server in Datenbank finden
var server = await _context.Servers
.FirstOrDefaultAsync(s => s.IPAddress == dto.IpAddress);
if (server != null)
{
// Serverdaten in Datenbank eintragen
// Success
return Ok();
}
return NotFound("No Matching Server found.");
}
}

View File

@@ -1,3 +1,4 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@@ -48,7 +49,7 @@ public class ServerController : Controller
_context.Servers.Add(server); _context.Servers.Add(server);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync();
return RedirectToAction("Overview"); return RedirectToAction(nameof(Overview));
} }
[HttpPost] [HttpPost]
@@ -103,4 +104,18 @@ public class ServerController : Controller
return View(vm); return View(vm);
} }
public async Task<IActionResult> ServerCardsPartial()
{
var servers = _context.Servers.ToList();
foreach (var server in servers)
{
server.IsOnline = (DateTime.UtcNow - server.LastSeen).TotalSeconds <= 120;
await _context.SaveChangesAsync();
}
return PartialView("_ServerCard", servers); // korrekt
}
} }

View File

@@ -1,11 +1,18 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Watcher.Models; using Watcher.Models;
namespace Watcher.Data; namespace Watcher.Data;
public class AppDbContext : DbContext public class AppDbContext : DbContext
{ {
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { } private readonly IConfiguration _configuration;
public AppDbContext(DbContextOptions<AppDbContext> options, IConfiguration configuration)
: base(options)
{
_configuration = configuration;
}
public DbSet<Container> Containers { get; set; } public DbSet<Container> Containers { get; set; }
@@ -21,6 +28,29 @@ public class AppDbContext : DbContext
public DbSet<User> Users { get; set; } public DbSet<User> Users { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
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.");
}
}
}
} }

View File

@@ -1,57 +0,0 @@
// <auto-generated />
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("20250613213714_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("Hostname")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("Id");
b.ToTable("Containers");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,48 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Watcher.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterDatabase()
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Containers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Status = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
Hostname = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Type = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Containers", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Containers");
}
}
}

View File

@@ -1,57 +0,0 @@
// <auto-generated />
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("20250613215617_ModelsAdded")]
partial class ModelsAdded
{
/// <inheritdoc />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("Hostname")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("Id");
b.ToTable("Containers");
});
#pragma warning restore 612, 618
}
}
}

View File

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

View File

@@ -1,87 +0,0 @@
// <auto-generated />
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("20250614153746_ServerModelAdded")]
partial class ServerModelAdded
{
/// <inheritdoc />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("Hostname")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("Id");
b.ToTable("Containers");
});
modelBuilder.Entity("Watcher.Models.Server", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("Hostname")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("Id");
b.ToTable("Servers");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,45 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Watcher.Migrations
{
/// <inheritdoc />
public partial class ServerModelAdded : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Servers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Status = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
Hostname = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Type = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Servers", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Servers");
}
}
}

View File

@@ -1,87 +0,0 @@
// <auto-generated />
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("20250614154943_InitialModelsAdded")]
partial class InitialModelsAdded
{
/// <inheritdoc />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("Hostname")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("Id");
b.ToTable("Containers");
});
modelBuilder.Entity("Watcher.Models.Server", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("Hostname")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("Id");
b.ToTable("Servers");
});
#pragma warning restore 612, 618
}
}
}

View File

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

View File

@@ -1,271 +0,0 @@
// <auto-generated />
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("20250614155203_InitialModelsAdded_1")]
partial class InitialModelsAdded_1
{
/// <inheritdoc />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("Hostname")
.IsRequired()
.HasColumnType("longtext");
b.Property<int?>("ImageId")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("longtext");
b.Property<int?>("TagId")
.HasColumnType("int");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("Id");
b.HasIndex("ImageId");
b.HasIndex("TagId");
b.ToTable("Containers");
});
modelBuilder.Entity("Watcher.Models.Image", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("Name")
.HasColumnType("longtext");
b.Property<string>("Tag")
.HasColumnType("longtext");
b.HasKey("Id");
b.ToTable("Images");
});
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int?>("ContainerId")
.HasColumnType("int");
b.Property<string>("Level")
.HasColumnType("longtext");
b.Property<string>("Message")
.HasColumnType("longtext");
b.Property<int?>("ServerId")
.HasColumnType("int");
b.Property<DateTime>("Timestamp")
.HasColumnType("datetime(6)");
b.HasKey("Id");
b.HasIndex("ContainerId");
b.HasIndex("ServerId");
b.ToTable("LogEvents");
});
modelBuilder.Entity("Watcher.Models.Metric", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int?>("ContainerId")
.HasColumnType("int");
b.Property<int?>("ServerId")
.HasColumnType("int");
b.Property<DateTime>("Timestamp")
.HasColumnType("datetime(6)");
b.Property<string>("Type")
.HasColumnType("longtext");
b.Property<double>("Value")
.HasColumnType("double");
b.HasKey("Id");
b.HasIndex("ContainerId");
b.HasIndex("ServerId");
b.ToTable("Metrics");
});
modelBuilder.Entity("Watcher.Models.Server", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("Hostname")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("longtext");
b.Property<int?>("TagId")
.HasColumnType("int");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("Id");
b.HasIndex("TagId");
b.ToTable("Servers");
});
modelBuilder.Entity("Watcher.Models.Tag", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("Name")
.HasColumnType("longtext");
b.HasKey("Id");
b.ToTable("Tags");
});
modelBuilder.Entity("Watcher.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("PocketId")
.HasColumnType("longtext");
b.Property<string>("Role")
.IsRequired()
.HasColumnType("longtext");
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.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
}
}
}

View File

@@ -1,278 +0,0 @@
// <auto-generated />
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("20250614173150_UserChanges")]
partial class UserChanges
{
/// <inheritdoc />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("Hostname")
.IsRequired()
.HasColumnType("longtext");
b.Property<int?>("ImageId")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("longtext");
b.Property<int?>("TagId")
.HasColumnType("int");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("Id");
b.HasIndex("ImageId");
b.HasIndex("TagId");
b.ToTable("Containers");
});
modelBuilder.Entity("Watcher.Models.Image", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("Name")
.HasColumnType("longtext");
b.Property<string>("Tag")
.HasColumnType("longtext");
b.HasKey("Id");
b.ToTable("Images");
});
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int?>("ContainerId")
.HasColumnType("int");
b.Property<string>("Level")
.HasColumnType("longtext");
b.Property<string>("Message")
.HasColumnType("longtext");
b.Property<int?>("ServerId")
.HasColumnType("int");
b.Property<DateTime>("Timestamp")
.HasColumnType("datetime(6)");
b.HasKey("Id");
b.HasIndex("ContainerId");
b.HasIndex("ServerId");
b.ToTable("LogEvents");
});
modelBuilder.Entity("Watcher.Models.Metric", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int?>("ContainerId")
.HasColumnType("int");
b.Property<int?>("ServerId")
.HasColumnType("int");
b.Property<DateTime>("Timestamp")
.HasColumnType("datetime(6)");
b.Property<string>("Type")
.HasColumnType("longtext");
b.Property<double>("Value")
.HasColumnType("double");
b.HasKey("Id");
b.HasIndex("ContainerId");
b.HasIndex("ServerId");
b.ToTable("Metrics");
});
modelBuilder.Entity("Watcher.Models.Server", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("Hostname")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("longtext");
b.Property<int?>("TagId")
.HasColumnType("int");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("Id");
b.HasIndex("TagId");
b.ToTable("Servers");
});
modelBuilder.Entity("Watcher.Models.Tag", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("Name")
.HasColumnType("longtext");
b.HasKey("Id");
b.ToTable("Tags");
});
modelBuilder.Entity("Watcher.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("Email")
.HasColumnType("longtext");
b.Property<DateTime>("LastLogin")
.HasColumnType("datetime(6)");
b.Property<string>("PocketId")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("PreferredUsername")
.IsRequired()
.HasColumnType("longtext");
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.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
}
}
}

View File

@@ -1,79 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Watcher.Migrations
{
/// <inheritdoc />
public partial class UserChanges : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "Role",
table: "Users",
newName: "PreferredUsername");
migrationBuilder.UpdateData(
table: "Users",
keyColumn: "PocketId",
keyValue: null,
column: "PocketId",
value: "");
migrationBuilder.AlterColumn<string>(
name: "PocketId",
table: "Users",
type: "longtext",
nullable: false,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "Email",
table: "Users",
type: "longtext",
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<DateTime>(
name: "LastLogin",
table: "Users",
type: "datetime(6)",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Email",
table: "Users");
migrationBuilder.DropColumn(
name: "LastLogin",
table: "Users");
migrationBuilder.RenameColumn(
name: "PreferredUsername",
table: "Users",
newName: "Role");
migrationBuilder.AlterColumn<string>(
name: "PocketId",
table: "Users",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
}
}
}

View File

@@ -1,40 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Watcher.Migrations
{
/// <inheritdoc />
public partial class ServerContainerIsRunningValue : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IsOnline",
table: "Servers",
type: "tinyint(1)",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "IsRunning",
table: "Containers",
type: "tinyint(1)",
nullable: false,
defaultValue: false);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IsOnline",
table: "Servers");
migrationBuilder.DropColumn(
name: "IsRunning",
table: "Containers");
}
}
}

View File

@@ -1,30 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Watcher.Migrations
{
/// <inheritdoc />
public partial class ServerAnpassung : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "LastSeen",
table: "Servers",
type: "datetime(6)",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "LastSeen",
table: "Servers");
}
}
}

View File

@@ -1,51 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Watcher.Migrations
{
/// <inheritdoc />
public partial class ServerCleanUp : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Hostname",
table: "Servers");
migrationBuilder.DropColumn(
name: "Status",
table: "Servers");
migrationBuilder.AddColumn<string>(
name: "Description",
table: "Servers",
type: "longtext",
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Description",
table: "Servers");
migrationBuilder.AddColumn<string>(
name: "Hostname",
table: "Servers",
type: "longtext",
nullable: false)
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "Status",
table: "Servers",
type: "longtext",
nullable: false)
.Annotation("MySql:CharSet", "utf8mb4");
}
}
}

View File

@@ -11,8 +11,8 @@ using Watcher.Data;
namespace Watcher.Migrations namespace Watcher.Migrations
{ {
[DbContext(typeof(AppDbContext))] [DbContext(typeof(AppDbContext))]
[Migration("20250615114821_ServerCleanUp")] [Migration("20250617153602_InitialMigration")]
partial class ServerCleanUp partial class InitialMigration
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -148,12 +148,21 @@ namespace Watcher.Migrations
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("CpuCores")
.HasColumnType("int");
b.Property<string>("CpuType")
.HasColumnType("longtext");
b.Property<DateTime>("CreatedAt") b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)"); .HasColumnType("datetime(6)");
b.Property<string>("Description") b.Property<string>("Description")
.HasColumnType("longtext"); .HasColumnType("longtext");
b.Property<string>("GpuType")
.HasColumnType("longtext");
b.Property<string>("IPAddress") b.Property<string>("IPAddress")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("longtext");
@@ -168,6 +177,9 @@ namespace Watcher.Migrations
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("longtext");
b.Property<double>("RamSize")
.HasColumnType("double");
b.Property<int?>("TagId") b.Property<int?>("TagId")
.HasColumnType("int"); .HasColumnType("int");

View File

@@ -7,28 +7,13 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace Watcher.Migrations namespace Watcher.Migrations
{ {
/// <inheritdoc /> /// <inheritdoc />
public partial class InitialModelsAdded_1 : Migration public partial class InitialMigration : Migration
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.AddColumn<int>( migrationBuilder.AlterDatabase()
name: "TagId", .Annotation("MySql:CharSet", "utf8mb4");
table: "Servers",
type: "int",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "ImageId",
table: "Containers",
type: "int",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "TagId",
table: "Containers",
type: "int",
nullable: true);
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Images", name: "Images",
@@ -47,6 +32,112 @@ namespace Watcher.Migrations
}) })
.Annotation("MySql:CharSet", "utf8mb4"); .Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Tags",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(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<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
PocketId = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
PreferredUsername = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Email = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
LastLogin = table.Column<DateTime>(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<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Status = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ImageId = table.Column<int>(type: "int", nullable: true),
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
Hostname = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Type = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
IsRunning = table.Column<bool>(type: "tinyint(1)", nullable: false),
TagId = table.Column<int>(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<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
IPAddress = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
Type = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
IsOnline = table.Column<bool>(type: "tinyint(1)", nullable: false),
LastSeen = table.Column<DateTime>(type: "datetime(6)", nullable: false),
Description = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
CpuType = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
CpuCores = table.Column<int>(type: "int", nullable: false),
GpuType = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
RamSize = table.Column<double>(type: "double", nullable: false),
TagId = table.Column<int>(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( migrationBuilder.CreateTable(
name: "LogEvents", name: "LogEvents",
columns: table => new columns: table => new
@@ -106,43 +197,6 @@ namespace Watcher.Migrations
}) })
.Annotation("MySql:CharSet", "utf8mb4"); .Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Tags",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(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<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
PocketId = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Role = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_Servers_TagId",
table: "Servers",
column: "TagId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Containers_ImageId", name: "IX_Containers_ImageId",
table: "Containers", table: "Containers",
@@ -173,81 +227,35 @@ namespace Watcher.Migrations
table: "Metrics", table: "Metrics",
column: "ServerId"); column: "ServerId");
migrationBuilder.AddForeignKey( migrationBuilder.CreateIndex(
name: "FK_Containers_Images_ImageId", name: "IX_Servers_TagId",
table: "Containers",
column: "ImageId",
principalTable: "Images",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Containers_Tags_TagId",
table: "Containers",
column: "TagId",
principalTable: "Tags",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Servers_Tags_TagId",
table: "Servers", table: "Servers",
column: "TagId", column: "TagId");
principalTable: "Tags",
principalColumn: "Id");
} }
/// <inheritdoc /> /// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.DropForeignKey(
name: "FK_Containers_Images_ImageId",
table: "Containers");
migrationBuilder.DropForeignKey(
name: "FK_Containers_Tags_TagId",
table: "Containers");
migrationBuilder.DropForeignKey(
name: "FK_Servers_Tags_TagId",
table: "Servers");
migrationBuilder.DropTable(
name: "Images");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "LogEvents"); name: "LogEvents");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Metrics"); name: "Metrics");
migrationBuilder.DropTable(
name: "Tags");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Users"); name: "Users");
migrationBuilder.DropIndex( migrationBuilder.DropTable(
name: "IX_Servers_TagId", name: "Containers");
table: "Servers");
migrationBuilder.DropIndex( migrationBuilder.DropTable(
name: "IX_Containers_ImageId", name: "Servers");
table: "Containers");
migrationBuilder.DropIndex( migrationBuilder.DropTable(
name: "IX_Containers_TagId", name: "Images");
table: "Containers");
migrationBuilder.DropColumn( migrationBuilder.DropTable(
name: "TagId", name: "Tags");
table: "Servers");
migrationBuilder.DropColumn(
name: "ImageId",
table: "Containers");
migrationBuilder.DropColumn(
name: "TagId",
table: "Containers");
} }
} }
} }

View File

@@ -11,50 +11,48 @@ using Watcher.Data;
namespace Watcher.Migrations namespace Watcher.Migrations
{ {
[DbContext(typeof(AppDbContext))] [DbContext(typeof(AppDbContext))]
[Migration("20250615102649_ServerAnpassung")] [Migration("20250617165126_ServerPrimaryKey")]
partial class ServerAnpassung partial class ServerPrimaryKey
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder.HasAnnotation("ProductVersion", "8.0.6");
.HasAnnotation("ProductVersion", "8.0.6")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Watcher.Models.Container", b => modelBuilder.Entity("Watcher.Models.Container", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<DateTime>("CreatedAt") b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)"); .HasColumnType("TEXT");
b.Property<string>("Hostname") b.Property<string>("Hostname")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<int?>("ImageId") b.Property<int?>("ImageId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<bool>("IsRunning") b.Property<bool>("IsRunning")
.HasColumnType("tinyint(1)"); .HasColumnType("INTEGER");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<string>("Status") b.Property<string>("Status")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<int?>("TagId") b.Property<int?>("TagId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("Type") b.Property<string>("Type")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@@ -69,13 +67,13 @@ namespace Watcher.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<string>("Tag") b.Property<string>("Tag")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@@ -86,22 +84,22 @@ namespace Watcher.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<int?>("ContainerId") b.Property<int?>("ContainerId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("Level") b.Property<string>("Level")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<string>("Message") b.Property<string>("Message")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<int?>("ServerId") b.Property<int?>("ServerId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<DateTime>("Timestamp") b.Property<DateTime>("Timestamp")
.HasColumnType("datetime(6)"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@@ -116,22 +114,22 @@ namespace Watcher.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<int?>("ContainerId") b.Property<int?>("ContainerId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<int?>("ServerId") b.Property<int?>("ServerId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<DateTime>("Timestamp") b.Property<DateTime>("Timestamp")
.HasColumnType("datetime(6)"); .HasColumnType("TEXT");
b.Property<string>("Type") b.Property<string>("Type")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<double>("Value") b.Property<double>("Value")
.HasColumnType("double"); .HasColumnType("REAL");
b.HasKey("Id"); b.HasKey("Id");
@@ -146,39 +144,46 @@ namespace Watcher.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<int>("CpuCores")
.HasColumnType("INTEGER");
b.Property<string>("CpuType")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedAt") b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)"); .HasColumnType("TEXT");
b.Property<string>("Hostname") b.Property<string>("Description")
.IsRequired() .HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<string>("GpuType")
.HasColumnType("TEXT");
b.Property<string>("IPAddress") b.Property<string>("IPAddress")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<bool>("IsOnline") b.Property<bool>("IsOnline")
.HasColumnType("tinyint(1)"); .HasColumnType("INTEGER");
b.Property<DateTime>("LastSeen") b.Property<DateTime>("LastSeen")
.HasColumnType("datetime(6)"); .HasColumnType("TEXT");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<string>("Status") b.Property<double>("RamSize")
.IsRequired() .HasColumnType("REAL");
.HasColumnType("longtext");
b.Property<int?>("TagId") b.Property<int?>("TagId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("Type") b.Property<string>("Type")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@@ -191,10 +196,10 @@ namespace Watcher.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@@ -205,21 +210,21 @@ namespace Watcher.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("Email") b.Property<string>("Email")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<DateTime>("LastLogin") b.Property<DateTime>("LastLogin")
.HasColumnType("datetime(6)"); .HasColumnType("TEXT");
b.Property<string>("PocketId") b.Property<string>("PocketId")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<string>("PreferredUsername") b.Property<string>("PreferredUsername")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");

View File

@@ -0,0 +1,785 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Watcher.Migrations
{
/// <inheritdoc />
public partial class ServerPrimaryKey : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "PreferredUsername",
table: "Users",
type: "TEXT",
nullable: false,
oldClrType: typeof(string),
oldType: "longtext");
migrationBuilder.AlterColumn<string>(
name: "PocketId",
table: "Users",
type: "TEXT",
nullable: false,
oldClrType: typeof(string),
oldType: "longtext");
migrationBuilder.AlterColumn<DateTime>(
name: "LastLogin",
table: "Users",
type: "TEXT",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "datetime(6)");
migrationBuilder.AlterColumn<string>(
name: "Email",
table: "Users",
type: "TEXT",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "Users",
type: "INTEGER",
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.Annotation("Sqlite:Autoincrement", true)
.OldAnnotation("Sqlite:Autoincrement", true);
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "Tags",
type: "TEXT",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "Tags",
type: "INTEGER",
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.Annotation("Sqlite:Autoincrement", true)
.OldAnnotation("Sqlite:Autoincrement", true);
migrationBuilder.AlterColumn<string>(
name: "Type",
table: "Servers",
type: "TEXT",
nullable: false,
oldClrType: typeof(string),
oldType: "longtext");
migrationBuilder.AlterColumn<int>(
name: "TagId",
table: "Servers",
type: "INTEGER",
nullable: true,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AlterColumn<double>(
name: "RamSize",
table: "Servers",
type: "REAL",
nullable: false,
oldClrType: typeof(double),
oldType: "double");
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "Servers",
type: "TEXT",
nullable: false,
oldClrType: typeof(string),
oldType: "longtext");
migrationBuilder.AlterColumn<DateTime>(
name: "LastSeen",
table: "Servers",
type: "TEXT",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "datetime(6)");
migrationBuilder.AlterColumn<bool>(
name: "IsOnline",
table: "Servers",
type: "INTEGER",
nullable: false,
oldClrType: typeof(bool),
oldType: "tinyint(1)");
migrationBuilder.AlterColumn<string>(
name: "IPAddress",
table: "Servers",
type: "TEXT",
nullable: false,
oldClrType: typeof(string),
oldType: "longtext");
migrationBuilder.AlterColumn<string>(
name: "GpuType",
table: "Servers",
type: "TEXT",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Description",
table: "Servers",
type: "TEXT",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "CreatedAt",
table: "Servers",
type: "TEXT",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "datetime(6)");
migrationBuilder.AlterColumn<string>(
name: "CpuType",
table: "Servers",
type: "TEXT",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "CpuCores",
table: "Servers",
type: "INTEGER",
nullable: false,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "Servers",
type: "INTEGER",
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.Annotation("Sqlite:Autoincrement", true)
.OldAnnotation("Sqlite:Autoincrement", true);
migrationBuilder.AlterColumn<double>(
name: "Value",
table: "Metrics",
type: "REAL",
nullable: false,
oldClrType: typeof(double),
oldType: "double");
migrationBuilder.AlterColumn<string>(
name: "Type",
table: "Metrics",
type: "TEXT",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "Timestamp",
table: "Metrics",
type: "TEXT",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "datetime(6)");
migrationBuilder.AlterColumn<int>(
name: "ServerId",
table: "Metrics",
type: "INTEGER",
nullable: true,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "ContainerId",
table: "Metrics",
type: "INTEGER",
nullable: true,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "Metrics",
type: "INTEGER",
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.Annotation("Sqlite:Autoincrement", true)
.OldAnnotation("Sqlite:Autoincrement", true);
migrationBuilder.AlterColumn<DateTime>(
name: "Timestamp",
table: "LogEvents",
type: "TEXT",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "datetime(6)");
migrationBuilder.AlterColumn<int>(
name: "ServerId",
table: "LogEvents",
type: "INTEGER",
nullable: true,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Message",
table: "LogEvents",
type: "TEXT",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Level",
table: "LogEvents",
type: "TEXT",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "ContainerId",
table: "LogEvents",
type: "INTEGER",
nullable: true,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "LogEvents",
type: "INTEGER",
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.Annotation("Sqlite:Autoincrement", true)
.OldAnnotation("Sqlite:Autoincrement", true);
migrationBuilder.AlterColumn<string>(
name: "Tag",
table: "Images",
type: "TEXT",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "Images",
type: "TEXT",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "Images",
type: "INTEGER",
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.Annotation("Sqlite:Autoincrement", true)
.OldAnnotation("Sqlite:Autoincrement", true);
migrationBuilder.AlterColumn<string>(
name: "Type",
table: "Containers",
type: "TEXT",
nullable: false,
oldClrType: typeof(string),
oldType: "longtext");
migrationBuilder.AlterColumn<int>(
name: "TagId",
table: "Containers",
type: "INTEGER",
nullable: true,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Status",
table: "Containers",
type: "TEXT",
nullable: false,
oldClrType: typeof(string),
oldType: "longtext");
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "Containers",
type: "TEXT",
nullable: false,
oldClrType: typeof(string),
oldType: "longtext");
migrationBuilder.AlterColumn<bool>(
name: "IsRunning",
table: "Containers",
type: "INTEGER",
nullable: false,
oldClrType: typeof(bool),
oldType: "tinyint(1)");
migrationBuilder.AlterColumn<int>(
name: "ImageId",
table: "Containers",
type: "INTEGER",
nullable: true,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Hostname",
table: "Containers",
type: "TEXT",
nullable: false,
oldClrType: typeof(string),
oldType: "longtext");
migrationBuilder.AlterColumn<DateTime>(
name: "CreatedAt",
table: "Containers",
type: "TEXT",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "datetime(6)");
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "Containers",
type: "INTEGER",
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.Annotation("Sqlite:Autoincrement", true)
.OldAnnotation("Sqlite:Autoincrement", true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "PreferredUsername",
table: "Users",
type: "longtext",
nullable: false,
oldClrType: typeof(string),
oldType: "TEXT");
migrationBuilder.AlterColumn<string>(
name: "PocketId",
table: "Users",
type: "longtext",
nullable: false,
oldClrType: typeof(string),
oldType: "TEXT");
migrationBuilder.AlterColumn<DateTime>(
name: "LastLogin",
table: "Users",
type: "datetime(6)",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "TEXT");
migrationBuilder.AlterColumn<string>(
name: "Email",
table: "Users",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "Users",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "INTEGER")
.Annotation("Sqlite:Autoincrement", true)
.OldAnnotation("Sqlite:Autoincrement", true);
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "Tags",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "Tags",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "INTEGER")
.Annotation("Sqlite:Autoincrement", true)
.OldAnnotation("Sqlite:Autoincrement", true);
migrationBuilder.AlterColumn<string>(
name: "Type",
table: "Servers",
type: "longtext",
nullable: false,
oldClrType: typeof(string),
oldType: "TEXT");
migrationBuilder.AlterColumn<int>(
name: "TagId",
table: "Servers",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "INTEGER",
oldNullable: true);
migrationBuilder.AlterColumn<double>(
name: "RamSize",
table: "Servers",
type: "double",
nullable: false,
oldClrType: typeof(double),
oldType: "REAL");
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "Servers",
type: "longtext",
nullable: false,
oldClrType: typeof(string),
oldType: "TEXT");
migrationBuilder.AlterColumn<DateTime>(
name: "LastSeen",
table: "Servers",
type: "datetime(6)",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "TEXT");
migrationBuilder.AlterColumn<bool>(
name: "IsOnline",
table: "Servers",
type: "tinyint(1)",
nullable: false,
oldClrType: typeof(bool),
oldType: "INTEGER");
migrationBuilder.AlterColumn<string>(
name: "IPAddress",
table: "Servers",
type: "longtext",
nullable: false,
oldClrType: typeof(string),
oldType: "TEXT");
migrationBuilder.AlterColumn<string>(
name: "GpuType",
table: "Servers",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Description",
table: "Servers",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "CreatedAt",
table: "Servers",
type: "datetime(6)",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "TEXT");
migrationBuilder.AlterColumn<string>(
name: "CpuType",
table: "Servers",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "CpuCores",
table: "Servers",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "INTEGER");
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "Servers",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "INTEGER")
.Annotation("Sqlite:Autoincrement", true)
.OldAnnotation("Sqlite:Autoincrement", true);
migrationBuilder.AlterColumn<double>(
name: "Value",
table: "Metrics",
type: "double",
nullable: false,
oldClrType: typeof(double),
oldType: "REAL");
migrationBuilder.AlterColumn<string>(
name: "Type",
table: "Metrics",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "Timestamp",
table: "Metrics",
type: "datetime(6)",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "TEXT");
migrationBuilder.AlterColumn<int>(
name: "ServerId",
table: "Metrics",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "INTEGER",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "ContainerId",
table: "Metrics",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "INTEGER",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "Metrics",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "INTEGER")
.Annotation("Sqlite:Autoincrement", true)
.OldAnnotation("Sqlite:Autoincrement", true);
migrationBuilder.AlterColumn<DateTime>(
name: "Timestamp",
table: "LogEvents",
type: "datetime(6)",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "TEXT");
migrationBuilder.AlterColumn<int>(
name: "ServerId",
table: "LogEvents",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "INTEGER",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Message",
table: "LogEvents",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Level",
table: "LogEvents",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "ContainerId",
table: "LogEvents",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "INTEGER",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "LogEvents",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "INTEGER")
.Annotation("Sqlite:Autoincrement", true)
.OldAnnotation("Sqlite:Autoincrement", true);
migrationBuilder.AlterColumn<string>(
name: "Tag",
table: "Images",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "Images",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "Images",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "INTEGER")
.Annotation("Sqlite:Autoincrement", true)
.OldAnnotation("Sqlite:Autoincrement", true);
migrationBuilder.AlterColumn<string>(
name: "Type",
table: "Containers",
type: "longtext",
nullable: false,
oldClrType: typeof(string),
oldType: "TEXT");
migrationBuilder.AlterColumn<int>(
name: "TagId",
table: "Containers",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "INTEGER",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Status",
table: "Containers",
type: "longtext",
nullable: false,
oldClrType: typeof(string),
oldType: "TEXT");
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "Containers",
type: "longtext",
nullable: false,
oldClrType: typeof(string),
oldType: "TEXT");
migrationBuilder.AlterColumn<bool>(
name: "IsRunning",
table: "Containers",
type: "tinyint(1)",
nullable: false,
oldClrType: typeof(bool),
oldType: "INTEGER");
migrationBuilder.AlterColumn<int>(
name: "ImageId",
table: "Containers",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "INTEGER",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Hostname",
table: "Containers",
type: "longtext",
nullable: false,
oldClrType: typeof(string),
oldType: "TEXT");
migrationBuilder.AlterColumn<DateTime>(
name: "CreatedAt",
table: "Containers",
type: "datetime(6)",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "TEXT");
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "Containers",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "INTEGER")
.Annotation("Sqlite:Autoincrement", true)
.OldAnnotation("Sqlite:Autoincrement", true);
}
}
}

View File

@@ -11,50 +11,48 @@ using Watcher.Data;
namespace Watcher.Migrations namespace Watcher.Migrations
{ {
[DbContext(typeof(AppDbContext))] [DbContext(typeof(AppDbContext))]
[Migration("20250614224113_Container-Server-Update")] [Migration("20250617174242_UserPasswordAdded")]
partial class ContainerServerUpdate partial class UserPasswordAdded
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder.HasAnnotation("ProductVersion", "8.0.6");
.HasAnnotation("ProductVersion", "8.0.6")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Watcher.Models.Container", b => modelBuilder.Entity("Watcher.Models.Container", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<DateTime>("CreatedAt") b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)"); .HasColumnType("TEXT");
b.Property<string>("Hostname") b.Property<string>("Hostname")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<int?>("ImageId") b.Property<int?>("ImageId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<bool>("IsRunning") b.Property<bool>("IsRunning")
.HasColumnType("tinyint(1)"); .HasColumnType("INTEGER");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<string>("Status") b.Property<string>("Status")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<int?>("TagId") b.Property<int?>("TagId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("Type") b.Property<string>("Type")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@@ -69,13 +67,13 @@ namespace Watcher.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<string>("Tag") b.Property<string>("Tag")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@@ -86,22 +84,22 @@ namespace Watcher.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<int?>("ContainerId") b.Property<int?>("ContainerId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("Level") b.Property<string>("Level")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<string>("Message") b.Property<string>("Message")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<int?>("ServerId") b.Property<int?>("ServerId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<DateTime>("Timestamp") b.Property<DateTime>("Timestamp")
.HasColumnType("datetime(6)"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@@ -116,22 +114,22 @@ namespace Watcher.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<int?>("ContainerId") b.Property<int?>("ContainerId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<int?>("ServerId") b.Property<int?>("ServerId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<DateTime>("Timestamp") b.Property<DateTime>("Timestamp")
.HasColumnType("datetime(6)"); .HasColumnType("TEXT");
b.Property<string>("Type") b.Property<string>("Type")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<double>("Value") b.Property<double>("Value")
.HasColumnType("double"); .HasColumnType("REAL");
b.HasKey("Id"); b.HasKey("Id");
@@ -146,36 +144,46 @@ namespace Watcher.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<int>("CpuCores")
.HasColumnType("INTEGER");
b.Property<string>("CpuType")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedAt") b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)"); .HasColumnType("TEXT");
b.Property<string>("Hostname") b.Property<string>("Description")
.IsRequired() .HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<string>("GpuType")
.HasColumnType("TEXT");
b.Property<string>("IPAddress") b.Property<string>("IPAddress")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<bool>("IsOnline") b.Property<bool>("IsOnline")
.HasColumnType("tinyint(1)"); .HasColumnType("INTEGER");
b.Property<DateTime>("LastSeen")
.HasColumnType("TEXT");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<string>("Status") b.Property<double>("RamSize")
.IsRequired() .HasColumnType("REAL");
.HasColumnType("longtext");
b.Property<int?>("TagId") b.Property<int?>("TagId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("Type") b.Property<string>("Type")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@@ -188,10 +196,10 @@ namespace Watcher.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@@ -202,21 +210,29 @@ namespace Watcher.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("Email") b.Property<string>("Email")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<string>("IdentityProvider")
.IsRequired()
.HasColumnType("TEXT");
b.Property<DateTime>("LastLogin") b.Property<DateTime>("LastLogin")
.HasColumnType("datetime(6)"); .HasColumnType("TEXT");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("PocketId") b.Property<string>("PocketId")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<string>("PreferredUsername") b.Property<string>("PreferredUsername")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");

View File

@@ -0,0 +1,40 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Watcher.Migrations
{
/// <inheritdoc />
public partial class UserPasswordAdded : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "IdentityProvider",
table: "Users",
type: "TEXT",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "Password",
table: "Users",
type: "TEXT",
nullable: false,
defaultValue: "");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IdentityProvider",
table: "Users");
migrationBuilder.DropColumn(
name: "Password",
table: "Users");
}
}
}

View File

@@ -11,50 +11,48 @@ using Watcher.Data;
namespace Watcher.Migrations namespace Watcher.Migrations
{ {
[DbContext(typeof(AppDbContext))] [DbContext(typeof(AppDbContext))]
[Migration("20250614183243_Server-Container-IsRunning-Value")] [Migration("20250621124832_DB-Update Issue#32")]
partial class ServerContainerIsRunningValue partial class DBUpdateIssue32
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder.HasAnnotation("ProductVersion", "8.0.6");
.HasAnnotation("ProductVersion", "8.0.6")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Watcher.Models.Container", b => modelBuilder.Entity("Watcher.Models.Container", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<DateTime>("CreatedAt") b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)"); .HasColumnType("TEXT");
b.Property<string>("Hostname") b.Property<string>("Hostname")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<int?>("ImageId") b.Property<int?>("ImageId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<bool>("IsRunning") b.Property<bool>("IsRunning")
.HasColumnType("tinyint(1)"); .HasColumnType("INTEGER");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<string>("Status") b.Property<string>("Status")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<int?>("TagId") b.Property<int?>("TagId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("Type") b.Property<string>("Type")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@@ -69,13 +67,13 @@ namespace Watcher.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<string>("Tag") b.Property<string>("Tag")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@@ -86,22 +84,22 @@ namespace Watcher.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<int?>("ContainerId") b.Property<int?>("ContainerId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("Level") b.Property<string>("Level")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<string>("Message") b.Property<string>("Message")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<int?>("ServerId") b.Property<int?>("ServerId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<DateTime>("Timestamp") b.Property<DateTime>("Timestamp")
.HasColumnType("datetime(6)"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@@ -116,29 +114,55 @@ namespace Watcher.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<int?>("ContainerId") b.Property<double>("CPU_Load")
.HasColumnType("int"); .HasColumnType("REAL");
b.Property<double>("CPU_Temp")
.HasColumnType("REAL");
b.Property<double>("DISK_Size")
.HasColumnType("REAL");
b.Property<double>("DISK_Temp")
.HasColumnType("REAL");
b.Property<double>("DISK_Usage")
.HasColumnType("REAL");
b.Property<double>("GPU_Load")
.HasColumnType("REAL");
b.Property<double>("GPU_Temp")
.HasColumnType("REAL");
b.Property<double>("GPU_Vram_Size")
.HasColumnType("REAL");
b.Property<double>("GPU_Vram_Usage")
.HasColumnType("REAL");
b.Property<double>("NET_In")
.HasColumnType("REAL");
b.Property<double>("NET_Out")
.HasColumnType("REAL");
b.Property<double>("RAM_Load")
.HasColumnType("REAL");
b.Property<double>("RAM_Size")
.HasColumnType("REAL");
b.Property<int?>("ServerId") b.Property<int?>("ServerId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<DateTime>("Timestamp") b.Property<DateTime>("Timestamp")
.HasColumnType("datetime(6)"); .HasColumnType("TEXT");
b.Property<string>("Type")
.HasColumnType("longtext");
b.Property<double>("Value")
.HasColumnType("double");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("ContainerId");
b.HasIndex("ServerId");
b.ToTable("Metrics"); b.ToTable("Metrics");
}); });
@@ -146,32 +170,46 @@ namespace Watcher.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<int>("CpuCores")
.HasColumnType("INTEGER");
b.Property<string>("CpuType")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedAt") b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)"); .HasColumnType("TEXT");
b.Property<string>("Hostname") b.Property<string>("Description")
.HasColumnType("TEXT");
b.Property<string>("GpuType")
.HasColumnType("TEXT");
b.Property<string>("IPAddress")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<bool>("IsOnline") b.Property<bool>("IsOnline")
.HasColumnType("tinyint(1)"); .HasColumnType("INTEGER");
b.Property<DateTime>("LastSeen")
.HasColumnType("TEXT");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<string>("Status") b.Property<double>("RamSize")
.IsRequired() .HasColumnType("REAL");
.HasColumnType("longtext");
b.Property<int?>("TagId") b.Property<int?>("TagId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("Type") b.Property<string>("Type")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@@ -184,10 +222,10 @@ namespace Watcher.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@@ -198,21 +236,28 @@ namespace Watcher.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("Email") b.Property<string>("Email")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<string>("IdentityProvider")
.IsRequired()
.HasColumnType("TEXT");
b.Property<DateTime>("LastLogin") b.Property<DateTime>("LastLogin")
.HasColumnType("datetime(6)"); .HasColumnType("TEXT");
b.Property<string>("PocketId") b.Property<string>("OIDC_Id")
.IsRequired() .HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<string>("PreferredUsername") b.Property<string>("Password")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<string>("Username")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@@ -221,13 +266,15 @@ namespace Watcher.Migrations
modelBuilder.Entity("Watcher.Models.Container", b => modelBuilder.Entity("Watcher.Models.Container", b =>
{ {
b.HasOne("Watcher.Models.Image", null) b.HasOne("Watcher.Models.Image", "Image")
.WithMany("Containers") .WithMany("Containers")
.HasForeignKey("ImageId"); .HasForeignKey("ImageId");
b.HasOne("Watcher.Models.Tag", null) b.HasOne("Watcher.Models.Tag", null)
.WithMany("Containers") .WithMany("Containers")
.HasForeignKey("TagId"); .HasForeignKey("TagId");
b.Navigation("Image");
}); });
modelBuilder.Entity("Watcher.Models.LogEvent", b => modelBuilder.Entity("Watcher.Models.LogEvent", b =>
@@ -245,21 +292,6 @@ namespace Watcher.Migrations
b.Navigation("Server"); 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 => modelBuilder.Entity("Watcher.Models.Server", b =>
{ {
b.HasOne("Watcher.Models.Tag", null) b.HasOne("Watcher.Models.Tag", null)

View File

@@ -0,0 +1,251 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Watcher.Migrations
{
/// <inheritdoc />
public partial class DBUpdateIssue32 : Migration
{
/// <inheritdoc />
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<string>(
name: "OIDC_Id",
table: "Users",
type: "TEXT",
nullable: true);
migrationBuilder.AddColumn<double>(
name: "CPU_Load",
table: "Metrics",
type: "REAL",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<double>(
name: "CPU_Temp",
table: "Metrics",
type: "REAL",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<double>(
name: "DISK_Size",
table: "Metrics",
type: "REAL",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<double>(
name: "DISK_Temp",
table: "Metrics",
type: "REAL",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<double>(
name: "DISK_Usage",
table: "Metrics",
type: "REAL",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<double>(
name: "GPU_Load",
table: "Metrics",
type: "REAL",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<double>(
name: "GPU_Temp",
table: "Metrics",
type: "REAL",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<double>(
name: "GPU_Vram_Size",
table: "Metrics",
type: "REAL",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<double>(
name: "GPU_Vram_Usage",
table: "Metrics",
type: "REAL",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<double>(
name: "NET_In",
table: "Metrics",
type: "REAL",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<double>(
name: "NET_Out",
table: "Metrics",
type: "REAL",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<double>(
name: "RAM_Load",
table: "Metrics",
type: "REAL",
nullable: false,
defaultValue: 0.0);
}
/// <inheritdoc />
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<string>(
name: "PocketId",
table: "Users",
type: "TEXT",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<int>(
name: "ContainerId",
table: "Metrics",
type: "INTEGER",
nullable: true);
migrationBuilder.AddColumn<string>(
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");
}
}
}

View File

@@ -0,0 +1,319 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("CreatedAt")
.HasColumnType("TEXT");
b.Property<string>("Hostname")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int?>("ImageId")
.HasColumnType("INTEGER");
b.Property<bool>("IsRunning")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int?>("TagId")
.HasColumnType("INTEGER");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("ImageId");
b.HasIndex("TagId");
b.ToTable("Containers");
});
modelBuilder.Entity("Watcher.Models.Image", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Tag")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Images");
});
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int?>("ContainerId")
.HasColumnType("INTEGER");
b.Property<string>("Level")
.HasColumnType("TEXT");
b.Property<string>("Message")
.HasColumnType("TEXT");
b.Property<int?>("ServerId")
.HasColumnType("INTEGER");
b.Property<DateTime>("Timestamp")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("ContainerId");
b.HasIndex("ServerId");
b.ToTable("LogEvents");
});
modelBuilder.Entity("Watcher.Models.Metric", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<double>("CPU_Load")
.HasColumnType("REAL");
b.Property<double>("CPU_Temp")
.HasColumnType("REAL");
b.Property<double>("DISK_Size")
.HasColumnType("REAL");
b.Property<double>("DISK_Temp")
.HasColumnType("REAL");
b.Property<double>("DISK_Usage")
.HasColumnType("REAL");
b.Property<double>("GPU_Load")
.HasColumnType("REAL");
b.Property<double>("GPU_Temp")
.HasColumnType("REAL");
b.Property<double>("GPU_Vram_Size")
.HasColumnType("REAL");
b.Property<double>("GPU_Vram_Usage")
.HasColumnType("REAL");
b.Property<double>("NET_In")
.HasColumnType("REAL");
b.Property<double>("NET_Out")
.HasColumnType("REAL");
b.Property<double>("RAM_Load")
.HasColumnType("REAL");
b.Property<double>("RAM_Size")
.HasColumnType("REAL");
b.Property<int?>("ServerId")
.HasColumnType("INTEGER");
b.Property<DateTime>("Timestamp")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Metrics");
});
modelBuilder.Entity("Watcher.Models.Server", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("CpuCores")
.HasColumnType("INTEGER");
b.Property<string>("CpuType")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedAt")
.HasColumnType("TEXT");
b.Property<string>("Description")
.HasColumnType("TEXT");
b.Property<string>("GpuType")
.HasColumnType("TEXT");
b.Property<string>("IPAddress")
.IsRequired()
.HasColumnType("TEXT");
b.Property<bool>("IsOnline")
.HasColumnType("INTEGER");
b.Property<bool>("IsVerified")
.HasColumnType("INTEGER");
b.Property<DateTime>("LastSeen")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<double>("RamSize")
.HasColumnType("REAL");
b.Property<int?>("TagId")
.HasColumnType("INTEGER");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("TagId");
b.ToTable("Servers");
});
modelBuilder.Entity("Watcher.Models.Tag", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Tags");
});
modelBuilder.Entity("Watcher.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Email")
.HasColumnType("TEXT");
b.Property<string>("IdentityProvider")
.IsRequired()
.HasColumnType("TEXT");
b.Property<DateTime>("LastLogin")
.HasColumnType("TEXT");
b.Property<string>("OIDC_Id")
.HasColumnType("TEXT");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("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
}
}
}

View File

@@ -5,24 +5,24 @@
namespace Watcher.Migrations namespace Watcher.Migrations
{ {
/// <inheritdoc /> /// <inheritdoc />
public partial class ContainerServerUpdate : Migration public partial class DBUpdateIssue32IsVerifiedServers : Migration
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.AddColumn<string>( migrationBuilder.AddColumn<bool>(
name: "IPAddress", name: "IsVerified",
table: "Servers", table: "Servers",
type: "longtext", type: "INTEGER",
nullable: false) nullable: false,
.Annotation("MySql:CharSet", "utf8mb4"); defaultValue: false);
} }
/// <inheritdoc /> /// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.DropColumn( migrationBuilder.DropColumn(
name: "IPAddress", name: "IsVerified",
table: "Servers"); table: "Servers");
} }
} }

View File

@@ -15,43 +15,41 @@ namespace Watcher.Migrations
protected override void BuildModel(ModelBuilder modelBuilder) protected override void BuildModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder.HasAnnotation("ProductVersion", "8.0.6");
.HasAnnotation("ProductVersion", "8.0.6")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Watcher.Models.Container", b => modelBuilder.Entity("Watcher.Models.Container", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<DateTime>("CreatedAt") b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)"); .HasColumnType("TEXT");
b.Property<string>("Hostname") b.Property<string>("Hostname")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<int?>("ImageId") b.Property<int?>("ImageId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<bool>("IsRunning") b.Property<bool>("IsRunning")
.HasColumnType("tinyint(1)"); .HasColumnType("INTEGER");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<string>("Status") b.Property<string>("Status")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<int?>("TagId") b.Property<int?>("TagId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("Type") b.Property<string>("Type")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@@ -66,13 +64,13 @@ namespace Watcher.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<string>("Tag") b.Property<string>("Tag")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@@ -83,22 +81,22 @@ namespace Watcher.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<int?>("ContainerId") b.Property<int?>("ContainerId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("Level") b.Property<string>("Level")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<string>("Message") b.Property<string>("Message")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<int?>("ServerId") b.Property<int?>("ServerId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<DateTime>("Timestamp") b.Property<DateTime>("Timestamp")
.HasColumnType("datetime(6)"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@@ -113,29 +111,55 @@ namespace Watcher.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<int?>("ContainerId") b.Property<double>("CPU_Load")
.HasColumnType("int"); .HasColumnType("REAL");
b.Property<double>("CPU_Temp")
.HasColumnType("REAL");
b.Property<double>("DISK_Size")
.HasColumnType("REAL");
b.Property<double>("DISK_Temp")
.HasColumnType("REAL");
b.Property<double>("DISK_Usage")
.HasColumnType("REAL");
b.Property<double>("GPU_Load")
.HasColumnType("REAL");
b.Property<double>("GPU_Temp")
.HasColumnType("REAL");
b.Property<double>("GPU_Vram_Size")
.HasColumnType("REAL");
b.Property<double>("GPU_Vram_Usage")
.HasColumnType("REAL");
b.Property<double>("NET_In")
.HasColumnType("REAL");
b.Property<double>("NET_Out")
.HasColumnType("REAL");
b.Property<double>("RAM_Load")
.HasColumnType("REAL");
b.Property<double>("RAM_Size")
.HasColumnType("REAL");
b.Property<int?>("ServerId") b.Property<int?>("ServerId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<DateTime>("Timestamp") b.Property<DateTime>("Timestamp")
.HasColumnType("datetime(6)"); .HasColumnType("TEXT");
b.Property<string>("Type")
.HasColumnType("longtext");
b.Property<double>("Value")
.HasColumnType("double");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("ContainerId");
b.HasIndex("ServerId");
b.ToTable("Metrics"); b.ToTable("Metrics");
}); });
@@ -143,34 +167,49 @@ namespace Watcher.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<int>("CpuCores")
.HasColumnType("INTEGER");
b.Property<string>("CpuType")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedAt") b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)"); .HasColumnType("TEXT");
b.Property<string>("Description") b.Property<string>("Description")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<string>("GpuType")
.HasColumnType("TEXT");
b.Property<string>("IPAddress") b.Property<string>("IPAddress")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<bool>("IsOnline") b.Property<bool>("IsOnline")
.HasColumnType("tinyint(1)"); .HasColumnType("INTEGER");
b.Property<bool>("IsVerified")
.HasColumnType("INTEGER");
b.Property<DateTime>("LastSeen") b.Property<DateTime>("LastSeen")
.HasColumnType("datetime(6)"); .HasColumnType("TEXT");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<double>("RamSize")
.HasColumnType("REAL");
b.Property<int?>("TagId") b.Property<int?>("TagId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("Type") b.Property<string>("Type")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@@ -183,10 +222,10 @@ namespace Watcher.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@@ -197,21 +236,28 @@ namespace Watcher.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("Email") b.Property<string>("Email")
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<string>("IdentityProvider")
.IsRequired()
.HasColumnType("TEXT");
b.Property<DateTime>("LastLogin") b.Property<DateTime>("LastLogin")
.HasColumnType("datetime(6)"); .HasColumnType("TEXT");
b.Property<string>("PocketId") b.Property<string>("OIDC_Id")
.IsRequired() .HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<string>("PreferredUsername") b.Property<string>("Password")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("TEXT");
b.Property<string>("Username")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@@ -246,21 +292,6 @@ namespace Watcher.Migrations
b.Navigation("Server"); 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 => modelBuilder.Entity("Watcher.Models.Server", b =>
{ {
b.HasOne("Watcher.Models.Tag", null) b.HasOne("Watcher.Models.Tag", null)

View File

@@ -2,15 +2,47 @@ namespace Watcher.Models;
public class Metric public class Metric
{ {
// Metric Metadata
public int Id { get; set; } public int Id { get; set; }
public DateTime Timestamp { get; set; } public DateTime Timestamp { get; set; }
public string? Type { get; set; } // z.B. "CPU", "RAM", "Disk", "Network"
public double Value { get; set; }
// Zuordnung zu einem Server -- Foreign Key
public int? ServerId { get; set; } public int? ServerId { get; set; }
public Server? Server { get; set; }
public int? ContainerId { get; set; }
public Container? Container { get; set; } // CPU-Daten
public double CPU_Load { get; set; } = 0.0; // %
public double CPU_Temp { get; set; } = 0.0; // deg C
// GPU-Daten
public double GPU_Load { get; set; } = 0.0; // %
public double GPU_Temp { get; set; } = 0.0; // deg C
public double GPU_Vram_Size { get; set; } // GB
public double GPU_Vram_Usage { get; set; } // %
// RAM-Daten
public double RAM_Size { get; set; } = 0.0; // GB
public double RAM_Load { get; set; } = 0.0; // %
// HDD-Daten
public double DISK_Size { get; set; } = 0.0; // GB
public double DISK_Usage { get; set; } = 0.0; // %
public double DISK_Temp { get; set; } = 0.0; // deg C
// Network-Daten
public double NET_In { get; set; } = 0.0; // Bit
public double NET_Out { get; set; } = 0.0; // Bit
} }

View File

@@ -1,23 +1,39 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Watcher.Models; namespace Watcher.Models;
public class Server public class Server
{ {
// System Infos
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } = string.Empty; [Required]
public required string Name { get; set; }
public string IPAddress { get; set; } = string.Empty; public required string IPAddress { get; set; }
public required string Type { get; set; }
public string? Description { get; set; } = String.Empty;
// Hardware Infos
public string? CpuType { get; set; } = string.Empty;
public int CpuCores { get; set; } = 0;
public string? GpuType { get; set; } = string.Empty;
public double RamSize { get; set; } = 0;
// Database
public DateTime CreatedAt { get; set; } = DateTime.UtcNow; public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
// z.B. "VPS", "standalone", "VM", etc.
public string Type { get; set; } = "VPS";
public Boolean IsOnline { get; set; } = false; public Boolean IsOnline { get; set; } = false;
public DateTime LastSeen { get; set; } public DateTime LastSeen { get; set; }
public string? Description { get; set; } public Boolean IsVerified { get; set; } = false;
} }

View File

@@ -1,10 +1,22 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Watcher.Models; namespace Watcher.Models;
public class User public class User
{ {
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; } // PK public int Id { get; set; } // PK
public string PocketId { get; set; } = null!; public string? OIDC_Id { get; set; } = null!;
public string PreferredUsername { get; set; } = null!; public string Username { get; set; } = null!;
public string? Email { get; set; } public string? Email { get; set; }
public DateTime LastLogin { get; set; } public DateTime LastLogin { get; set; }
[Required]
public string IdentityProvider { get; set; } = "local";
[Required]
[DataType(DataType.Password)]
public String? Password { get; set; } = string.Empty;
} }

View File

@@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Sqlite;
using Microsoft.IdentityModel.Tokens; using Microsoft.IdentityModel.Tokens;
using Watcher.Data; using Watcher.Data;
using Watcher.Models; using Watcher.Models;
@@ -14,32 +15,63 @@ builder.Services.AddControllersWithViews();
// HttpContentAccessor // HttpContentAccessor
builder.Services.AddHttpContextAccessor(); builder.Services.AddHttpContextAccessor();
// ---------- Konfiguration laden ---------- // ---------- Konfiguration ----------
DotNetEnv.Env.Load();
builder.Configuration
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddEnvironmentVariables();
// Konfiguration laden
var configuration = builder.Configuration; var configuration = builder.Configuration;
// ---------- DB-Kontext mit MySQL ---------- // ---------- DB-Kontext ----------
builder.Services.AddDbContext<AppDbContext>(options =>
options.UseMySql( var dbProvider = configuration["Database:Provider"] ?? "MySQL";
configuration.GetConnectionString("DefaultConnection"), var connectionString = configuration["Database:ConnectionString"];
ServerVersion.AutoDetect(configuration.GetConnectionString("DefaultConnection"))
) builder.Services.AddDbContext<AppDbContext>((serviceProvider, options) =>
); {
var config = serviceProvider.GetRequiredService<IConfiguration>();
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.");
}
});
// ---------- Authentifizierung konfigurieren ---------- // ---------- Authentifizierung konfigurieren ----------
builder.Services.AddAuthentication(options => // PocketID nur konfigurieren, wenn aktiviert
var pocketIdSection = builder.Configuration.GetSection("Authentication:PocketID");
var pocketIdEnabled = pocketIdSection.GetValue<bool>("Enabled");
var auth = builder.Services.AddAuthentication("Cookies");
auth.AddCookie("Cookies", options =>
{ {
options.DefaultScheme = "Cookies"; options.LoginPath = "/Auth/Login";
options.DefaultChallengeScheme = "oidc"; options.AccessDeniedPath = "/Auth/AccessDenied";
}) });
.AddCookie("Cookies")
builder.Services.AddAuthentication()
.AddOpenIdConnect("oidc", options => .AddOpenIdConnect("oidc", options =>
{ {
var config = builder.Configuration.GetSection("Authentication:PocketID"); options.Authority = pocketIdSection["Authority"];
options.Authority = config["Authority"]; options.ClientId = pocketIdSection["ClientId"];
options.ClientId = config["ClientId"]; options.ClientSecret = pocketIdSection["ClientSecret"];
options.ClientSecret = config["ClientSecret"];
options.ResponseType = "code"; options.ResponseType = "code";
options.CallbackPath = config["CallbackPath"]; options.CallbackPath = pocketIdSection["CallbackPath"];
options.SaveTokens = true; options.SaveTokens = true;
options.GetClaimsFromUserInfoEndpoint = true; options.GetClaimsFromUserInfoEndpoint = true;
@@ -50,7 +82,7 @@ builder.Services.AddAuthentication(options =>
options.Scope.Add("email"); options.Scope.Add("email");
options.Events = new OpenIdConnectEvents options.Events = new OpenIdConnectEvents
{ {
OnTokenValidated = async ctx => OnTokenValidated = async ctx =>
{ {
var db = ctx.HttpContext.RequestServices.GetRequiredService<AppDbContext>(); var db = ctx.HttpContext.RequestServices.GetRequiredService<AppDbContext>();
@@ -63,36 +95,80 @@ builder.Services.AddAuthentication(options =>
if (string.IsNullOrEmpty(pocketId)) if (string.IsNullOrEmpty(pocketId))
return; return;
var user = await db.Users.FirstOrDefaultAsync(u => u.PocketId == pocketId); var user = await db.Users.FirstOrDefaultAsync(u => u.OIDC_Id == pocketId);
if (user == null) if (user == null)
{ {
user = new User user = new User
{ {
PocketId = pocketId, OIDC_Id = pocketId,
PreferredUsername = preferredUsername ?? "", Username = preferredUsername ?? "",
Email = email, Email = email,
LastLogin = DateTime.UtcNow LastLogin = DateTime.UtcNow,
IdentityProvider = "oidc",
Password = string.Empty
}; };
db.Users.Add(user); db.Users.Add(user);
} }
else else
{ {
user.LastLogin = DateTime.UtcNow; user.LastLogin = DateTime.UtcNow;
user.PreferredUsername = preferredUsername ?? user.PreferredUsername; user.Username = preferredUsername ?? user.Username;
user.Email = email ?? user.Email; user.Email = email ?? user.Email;
db.Users.Update(user); db.Users.Update(user);
} }
await db.SaveChangesAsync(); await db.SaveChangesAsync();
} }
}; };
}); });
var app = builder.Build(); var app = builder.Build();
// Migrationen anwenden (für SQLite oder andere DBs)
using (var scope = app.Services.CreateScope())
{
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
db.Database.Migrate();
}
// Standart-User in Datenbank schreiben
using (var scope = app.Services.CreateScope())
{
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
Console.WriteLine("Checking for users...");
if (!db.Users.Any())
{
Console.WriteLine("No users found, creating default user...");
var defaultUser = new User
{
OIDC_Id = string.Empty,
Username = "admin",
Email = string.Empty,
LastLogin = DateTime.UtcNow,
IdentityProvider = "local",
Password = BCrypt.Net.BCrypt.HashPassword("changeme")
};
db.Users.Add(defaultUser);
db.SaveChanges();
Console.WriteLine("Default user created.");
}
else
{
Console.WriteLine("Users already exist.");
}
}
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment()) if (!app.Environment.IsDevelopment())
{ {
@@ -101,6 +177,11 @@ if (!app.Environment.IsDevelopment())
app.UseHsts(); app.UseHsts();
} }
app.UseHttpsRedirection(); app.UseHttpsRedirection();
app.UseRouting(); app.UseRouting();
@@ -112,7 +193,7 @@ app.UseStaticFiles();
app.MapControllerRoute( app.MapControllerRoute(
name: "default", name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}" pattern: "{controller=Auth}/{action=Login}/"
); );

View File

@@ -0,0 +1,18 @@
using System.ComponentModel.DataAnnotations;
namespace Watcher.ViewModels;
public class EditUserSettingsViewModel
{
[Required]
public string? Username { get; set; }
[Required]
[DataType(DataType.Password)]
public string? NewPassword { get; set; }
[Required]
[DataType(DataType.Password)]
[Compare("NewPassword", ErrorMessage = "Passwörter stimmen nicht überein.")]
public string? ConfirmPassword { get; set; }
}

View File

@@ -0,0 +1,18 @@
using System.ComponentModel.DataAnnotations;
namespace Watcher.ViewModels;
public class EditUserViewModel
{
[Required]
public string? Username { get; set; }
[Required]
[DataType(DataType.Password)]
public string? NewPassword { get; set; }
[Required]
[DataType(DataType.Password)]
[Compare("NewPassword", ErrorMessage = "Passwörter stimmen nicht überein.")]
public string? ConfirmPassword { get; set; }
}

View File

@@ -0,0 +1,15 @@
using System.ComponentModel.DataAnnotations;
namespace Watcher.ViewModels;
public class LoginViewModel
{
[Required]
public string Username { get; set; } = string.Empty;
[Required]
[DataType(DataType.Password)]
public string Password { get; set; } = string.Empty;
public string? ReturnUrl { get; set; }
}

View File

View File

@@ -1,67 +1,76 @@
@{ @{
ViewData["Title"] = "Account Info"; ViewData["Title"] = "Account Info";
var pictureUrl = User.Claims.FirstOrDefault(c => c.Type == "picture")?.Value ?? "123"; var pictureUrl = User.Claims.FirstOrDefault(c => c.Type == "picture")?.Value ?? "";
var preferredUsername = User.Claims.FirstOrDefault(c => c.Type == "preferred_username")?.Value ?? "admin";
var isAdmin = preferredUsername == "admin";
var preferred_username = ViewBag.name;
} }
<h2>Account Info</h2> <div class="container mt-5">
<div class="card shadow-lg rounded-3 p-4" style="max-width: 700px; margin: auto;">
<div class="card" style="max-width: 600px; margin: auto; padding: 1rem; box-shadow: 0 0 10px #ccc; text-align:center;"> <div class="text-center mb-4">
@if (!string.IsNullOrEmpty(pictureUrl)) @if (!string.IsNullOrEmpty(pictureUrl))
{ {
<img src="@pictureUrl" alt="Profilbild" style="width:120px; height:120px; border-radius:50%; object-fit:cover; margin-bottom:1rem;" /> <img src="@pictureUrl" alt="Profilbild" class="rounded-circle shadow" style="width: 120px; height: 120px; object-fit: cover;" />
} }
else else
{ {
<div style="width:120px; height:120px; border-radius:50%; background:#ccc; display:inline-block; line-height:120px; font-size:48px; color:#fff; margin-bottom:1rem;"> <div class="bg-secondary text-white rounded-circle d-inline-flex align-items-center justify-content-center"
style="width: 120px; height: 120px; font-size: 48px;">
<span>@(User.Identity?.Name?.Substring(0,1).ToUpper() ?? "?")</span> <span>@(User.Identity?.Name?.Substring(0,1).ToUpper() ?? "?")</span>
</div> </div>
} }
<h3 class="mt-3">
<i class="bi bi-person-circle me-1"></i>@(User.FindFirst("PreferredUsername")?.Value ?? "Unbekannter Nutzer")
</h3>
<h3>@(User.FindFirst("name")?.Value ?? "Unbekannter Nutzer")</h3> </div>
<table class="table" style="margin-top: 1rem;"> <table class="table table-hover">
<tbody> <tbody>
<tr></tr> <tr>
<th>Username</th> <th><i class="bi bi-person-badge me-1"></i>Username</th>
<td>@(@User.Claims.FirstOrDefault(c => c.Type == "preferred_username")?.Value ?? "Nicht verfügbar")</td> <td>@preferredUsername</td>
</tr> </tr>
<tr> <tr>
<th>E-Mail</th> <th><i class="bi bi-envelope me-1"></i>E-Mail</th>
<td>@(@User.Claims.FirstOrDefault(c => c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress")?.Value ?? "Nicht verfügbar")</td> <td>@(ViewBag.Mail ?? "Nicht verfügbar")</td>
</tr> </tr>
<tr> <tr>
<th>Benutzer-ID</th> <th><i class="bi bi-fingerprint me-1"></i>Benutzer-ID</th>
<td>@(User.FindFirst("sub")?.Value ?? "Nicht verfügbar")</td> <td>@(ViewBag.Id ?? "Nicht verfügbar")</td>
</tr> </tr>
<tr> <tr>
<th>Login-Zeit</th> <th><i class="bi bi-clock-history me-1"></i>Login-Zeit</th>
<td>@(User.FindFirst("iat") != null <td>
@(User.FindFirst("iat") != null
? DateTimeOffset.FromUnixTimeSeconds(long.Parse(User.FindFirst("iat").Value)).ToLocalTime().ToString() ? DateTimeOffset.FromUnixTimeSeconds(long.Parse(User.FindFirst("iat").Value)).ToLocalTime().ToString()
: "Nicht verfügbar") : "Nicht verfügbar")
</td> </td>
</tr> </tr>
<tr> <tr>
<th>Token läuft ab</th> <th><i class="bi bi-hourglass-split me-1"></i>Token läuft ab</th>
<td>@(User.FindFirst("exp") != null <td>
@(User.FindFirst("exp") != null
? DateTimeOffset.FromUnixTimeSeconds(long.Parse(User.FindFirst("exp").Value)).ToLocalTime().ToString() ? DateTimeOffset.FromUnixTimeSeconds(long.Parse(User.FindFirst("exp").Value)).ToLocalTime().ToString()
: "Nicht verfügbar") : "Nicht verfügbar")
</td> </td>
</tr> </tr>
<tr> <tr>
<th>Rollen</th> <th><i class="bi bi-shield-lock me-1"></i>Rollen</th>
<td> <td>
@{ @{
var roles = User.FindAll("role").Select(r => r.Value); var roles = User.FindAll("role").Select(r => r.Value);
if (!roles.Any()) if (!roles.Any())
{ {
<text>Keine Rollen</text> <span class="text-muted">Keine Rollen</span>
} }
else else
{ {
<ul> <ul class="mb-0">
@foreach (var role in roles) @foreach (var role in roles)
{ {
<li>@role</li> <li><i class="bi bi-tag me-1 text-primary"></i>@role</li>
} }
</ul> </ul>
} }
@@ -70,17 +79,17 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<div>
<form method="post" asp-controller="Auth" asp-action="Logout"> <form method="get" asp-controller="Auth" asp-action="UserSettings" class="text-center mt-4">
<button type="submit" class="btn btn-danger">Abmelden</button> <button type="submit" class="btn btn-info">
<i class="bi bi-gear-wide-connected me-1"></i>Einstellungen
</button>
</form> </form>
<form method="post" asp-controller="Auth" asp-action="Logout" class="text-center mt-4">
<button type="submit" class="btn btn-danger">
<i class="bi bi-box-arrow-right me-1"></i>Abmelden
</button>
</form>
</div>
</div>
</div> </div>
<h3>Alle Claims</h3>
<ul>
@foreach (var claim in User.Claims)
{
<li>@claim.Type: @claim.Value</li>
}
</ul>

View File

@@ -1,9 +1,87 @@
@model Watcher.ViewModels.LoginViewModel
@{ @{
Layout = "~/Views/Shared/_LoginLayout.cshtml";
ViewData["Title"] = "Login"; ViewData["Title"] = "Login";
} }
<h2>Willkommen beim Watcher</h2> <style>
body {
background-color: #0d1b2a;
}
<p>Bitte melde dich über PocketID an:</p> .login-card {
background-color: #1b263b;
color: #ffffff;
padding: 2rem;
border-radius: 1rem;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
max-width: 400px;
margin: auto;
}
<a class="btn btn-primary" href="/Account/SignIn">Mit PocketID anmelden</a> .form-control {
background-color: #415a77;
border: none;
color: white;
}
.form-control::placeholder {
color: #c0c0c0;
}
.btn-primary {
background-color: #0d6efd;
border: none;
}
.btn-pocketid {
background-color: #14a44d;
color: white;
border: none;
}
.btn-pocketid:hover {
background-color: #0f8c3c;
}
label {
margin-top: 1rem;
}
.form-error {
color: #ff6b6b;
font-size: 0.875rem;
}
</style>
<div class="login-card">
<h2 class="text-center mb-4">Anmelden</h2>
<form asp-controller="Auth" asp-action="Login" method="post">
<input type="hidden" asp-for="ReturnUrl" />
<div class="mb-3">
<label asp-for="Username" class="form-label">Benutzername</label>
<input asp-for="Username" class="form-control" placeholder="admin" />
<span asp-validation-for="Username" class="form-error"></span>
</div>
<div class="mb-3">
<label asp-for="Password" class="form-label">Passwort</label>
<input asp-for="Password" type="password" class="form-control" placeholder="••••••••" />
<span asp-validation-for="Password" class="form-error"></span>
</div>
<div class="d-grid gap-2">
<button type="submit" class="btn btn-primary">Login</button>
</div>
</form>
<hr class="my-4" />
<form asp-controller="Auth" asp-action="SignIn" method="get">
<div class="d-grid gap-2">
<button type="submit" class="btn btn-pocketid">Mit PocketID anmelden</button>
</div>
</form>
</div>

View File

@@ -0,0 +1,130 @@
@{
ViewData["Title"] = "Settings";
var pictureUrl = User.Claims.FirstOrDefault(c => c.Type == "picture")?.Value ?? "";
var preferredUsername = User.Claims.FirstOrDefault(c => c.Type == "preferred_username")?.Value ?? "admin";
var isLocalUser = ViewBag.IdentityProvider == "local";
var DbEngine = ViewBag.DbProvider;
}
<style>
.Settingscontainer {
display: flex;
flex-wrap: wrap;
/* Wichtig: erlaubt Umbruch */
gap: 1rem;
/* optionaler Abstand */
}
.Settingscontainer>* {
flex: 1 1 calc(50% - 0.5rem);
/* 2 Elemente pro Zeile, inkl. Gap */
box-sizing: border-box;
}
</style>
<div class="Settingscontainer">
@if (isLocalUser)
{
<div class="card shadow mt-5 p-4" style="width: 40%; margin: auto;">
<h4><i class="bi bi-pencil-square me-2"></i>Benutzerdaten ändern</h4>
<form asp-action="Edit" method="post" asp-controller="Auth">
<div class="mb-3">
<label for="Username" class="form-label">Neuer Benutzername</label>
<input type="text" class="form-control" id="Username" name="Username" value="@preferredUsername" />
</div>
<div class="mb-3">
<label for="NewPassword" class="form-label">Neues Passwort</label>
<input type="password" class="form-control" id="NewPassword" name="NewPassword" />
</div>
<div class="mb-3">
<label for="ConfirmPassword" class="form-label">Passwort bestätigen</label>
<input type="password" class="form-control" id="ConfirmPassword" name="ConfirmPassword" />
</div>
<button type="submit" class="btn btn-primary">
<i class="bi bi-save me-1"></i>Speichern
</button>
</form>
</div>
}
else
{
<div class="alert alert-info mt-4 text-center" style="width: 40%; margin: auto;">
<i class="bi bi-info-circle me-1"></i>Benutzerdaten können nur für lokal angemeldete Nutzer geändert werden.
</div>
}
<div class="card shadow mt-5 p-4" style="width: 55%; margin: auto;">
<h4><i class="bi bi-pencil-square me-2"></i>Systemeinformationen</h4>
<br>
<h5>Watcher Version: v0.1.0</h5>
<hr class="my-4" />
<h5>Authentifizierungsmethode: </h5>
<p><strong>@(ViewBag.IdentityProvider ?? "nicht gefunden")</strong></p>
<hr class="my-4" />
<h5>Datenbank-Engine: </h5>
<strong>@(DbEngine ?? "nicht gefunden")</strong>
<!-- Falls Sqlite verwendet wird können Backups erstellt werden -->
@if (DbEngine == "Microsoft.EntityFrameworkCore.Sqlite")
{
<div class="d-flex gap-2">
<form asp-action="CreateSqlDump" method="post" asp-controller="Database">
<button type="submit" class="btn btn-primary">
<i class="bi bi-save me-1"></i> Backup erstellen
</button>
</form>
<form asp-action="ManageSqlDumps" method="post" asp-controller="Database">
<button type="submit" class="btn btn-primary">
<i class="bi bi-save me-1"></i> Backups verwalten
</button>
</form>
</div>
}
else if (DbEngine == "Microsoft.EntityFrameworkCore.MySQL")
{
<p> MySQL Dump aktuell nicht möglich </p>
}
<!-- Status für Erstellung eines Backups -->
@if (TempData["DumpMessage"] != null)
{
<div class="alert alert-success">
<i class="bi bi-check-circle me-1"></i>@TempData["DumpMessage"]
</div>
}
@if (TempData["DumpError"] != null)
{
<div class="alert alert-danger">
<i class="bi bi-exclamation-circle me-1"></i>@TempData["DumpError"]
</div>
}
</div>
<div class="card shadow mt-5 p-4" style="width: 55%; margin: auto;">
<h4><i class="bi bi-pencil-square me-2"></i>Systemeinstellungen ändern</h4>
<h5>Anzeigeeinstellungen: </h5>
<hr class="my-4" />
<h5>Benachrichtigungen: </h5>
<p>Registrierte E-Mail Adresse: <strong>@(ViewBag.mail ?? "nicht gefunden")</strong></p>
<hr class="my-4" />
<h5>...: </h5>
</div>
</div>

View File

@@ -0,0 +1,54 @@
@model List<Watcher.Controllers.DatabaseController.DumpFileInfo>
@{
ViewData["Title"] = "Datenbank-Dumps";
}
<h2 class="mb-4 text-xl font-bold"><i class="bi bi-hdd me-1"></i>Datenbank-Dumps</h2>
@if (TempData["Success"] != null)
{
<div class="alert alert-success">@TempData["Success"]</div>
}
@if (TempData["Error"] != null)
{
<div class="alert alert-danger">@TempData["Error"]</div>
}
<table class="table table-striped">
<thead>
<tr>
<th>Dateiname</th>
<th>Größe (KB)</th>
<th>Erstellt</th>
<th>Aktionen</th>
</tr>
</thead>
<tbody>
@foreach (var dump in Model)
{
<tr>
<td>@dump.FileName</td>
<td>@dump.SizeKb</td>
<td>@dump.Created.ToString("dd.MM.yyyy HH:mm")</td>
<td class="d-flex gap-2">
<a class="btn btn-outline-primary btn-sm"
href="@Url.Action("FileDownload", "Download", new { type= "sqlite", fileName = dump.FileName })">
<i class="bi bi-download me-1"></i>Download
</a>
<form method="post" asp-action="Delete" asp-controller="Database" asp-route-fileName="@dump.FileName" onsubmit="return confirm('Diesen Dump wirklich löschen?');">
<button type="submit" class="btn btn-outline-danger btn-sm">
<i class="bi bi-trash me-1"></i>Löschen
</button>
</form>
<form method="post" asp-action="Restore" asp-controller="Database" asp-route-fileName="@dump.FileName" onsubmit="return confirm('Achtung! Der aktuelle DB-Stand wird überschrieben. Fortfahren?');">
<button type="submit" class="btn btn-outline-warning btn-sm">
<i class="bi bi-arrow-clockwise me-1"></i>Wiederherstellen
</button>
</form>
</td>
</tr>
}
</tbody>
</table>

View File

@@ -3,34 +3,51 @@
ViewData["Title"] = "Dashboard"; ViewData["Title"] = "Dashboard";
} }
<h1 class="text-2xl font-bold mb-4">Dashboard</h1> <h1 class="mb-4"><i class="bi bi-speedometer2 me-2"></i>Dashboard</h1>
<div class="grid grid-cols-2 gap-6"> <div id="dashboard-stats">
<div class="bg-white shadow rounded-2xl p-4"> @await Html.PartialAsync("_DashboardStats", Model)
<h2 class="text-xl font-semibold mb-2">Server</h2> </div>
<p>🟢 Online: <strong>@Model.ActiveServers</strong></p>
<p>🔴 Offline: <strong>@Model.OfflineServers</strong></p>
<a href="/Server/Overview" class="text-blue-500 hover:underline mt-2 inline-block">→ Zu den Servern</a>
</div>
<div class="bg-white shadow rounded-2xl p-4">
<h2 class="text-xl font-semibold mb-2">Container</h2>
<p>🟢 Laufend: <strong>@Model.RunningContainers</strong></p>
<p>🔴 Fehlerhaft: <strong>@Model.FailedContainers</strong></p>
<a href="/Container/Overview" class="text-blue-500 hover:underline mt-2 inline-block">→ Zu den Containern</a>
</div>
<div class="col-span-2 bg-white shadow rounded-2xl p-4"> <div class="row g-4 mt-4">
<h2 class="text-xl font-semibold mb-2">Uptime letzte 24h</h2> <div class="col-12">
<div class="bg-gray-100 h-32 rounded-lg flex items-center justify-center text-gray-500"> <div class="card p-3">
<h2 class="h5"><i class="bi bi-graph-up me-2"></i>Uptime letzte 24h</h2>
<div class="bg-secondary rounded p-5 text-center text-muted">
<i class="bi bi-bar-chart-line" style="font-size: 2rem;"></i><br />
(Diagramm folgt hier) (Diagramm folgt hier)
</div> </div>
</div> </div>
</div>
<div class="col-span-2 bg-white shadow rounded-2xl p-4"> <div class="col-12">
<h2 class="text-xl font-semibold mb-2">Systeminfo</h2> <div class="card p-3">
<p>Benutzer: <strong>@User.FindFirst("preferred_username")?.Value</strong></p> <h2 class="h5"><i class="bi bi-person-circle me-2"></i>Systeminfo</h2>
<p>Letzter Login: <strong>@Model.LastLogin.ToString("g")</strong></p> <p><i class="bi bi-person-badge me-1"></i>Benutzer: <strong>@User.FindFirst("preferred_username")?.Value</strong></p>
<a href="/Auth/Info" class="text-blue-500 hover:underline mt-2 inline-block">→ Account-Verwaltung</a> <p><i class="bi bi-clock me-1"></i>Letzter Login: <strong>@Model.LastLogin.ToString("g")</strong></p>
</div>
</div> </div>
</div> </div>
@section Scripts {
<script>
async function loadDashboardStats() {
try {
const response = await fetch('/Home/DashboardStats');
if (response.ok) {
const html = await response.text();
document.getElementById('dashboard-stats').innerHTML = html;
} else {
console.error('Fehler beim Nachladen der Dashboard-Statistiken');
}
} catch (err) {
console.error('Netzwerkfehler beim Nachladen der Dashboard-Statistiken:', err);
}
}
// Initial laden und dann alle 30 Sekunden
loadDashboardStats();
setInterval(loadDashboardStats, 30000);
</script>
}

View File

@@ -0,0 +1,17 @@
@model Watcher.ViewModels.DashboardViewModel
<div class="grid grid-cols-2 gap-6">
<div class="bg-white shadow rounded-2xl p-4">
<h2 class="text-xl font-semibold mb-2">Server</h2>
<p>🟢 Online: <strong>@Model.ActiveServers</strong></p>
<p>🔴 Offline: <strong>@Model.OfflineServers</strong></p>
<a href="/Server/Overview" class="text-blue-500 hover:underline mt-2 inline-block">→ Zu den Servern</a>
</div>
<div class="bg-white shadow rounded-2xl p-4">
<h2 class="text-xl font-semibold mb-2">Container</h2>
<p>🟢 Laufend: <strong>@Model.RunningContainers</strong></p>
<p>🔴 Fehlerhaft: <strong>@Model.FailedContainers</strong></p>
<a href="/Container/Overview" class="text-blue-500 hover:underline mt-2 inline-block">→ Zu den Containern</a>
</div>
</div>

View File

@@ -3,38 +3,44 @@
ViewData["Title"] = "Neuen Server hinzufügen"; ViewData["Title"] = "Neuen Server hinzufügen";
} }
<div class="max-w-2xl mx-auto mt-10 bg-white rounded-2xl shadow-md p-8"> <div class="container mt-5" style="max-width: 700px;">
<h1 class="text-2xl font-bold text-gray-800 mb-6">Neuen Server hinzufügen</h1> <div class="card shadow rounded-3 p-4">
<h1 class="mb-4 text-primary-emphasis">
<i class="bi bi-plus-circle me-2"></i>Neuen Server hinzufügen
</h1>
<form asp-action="AddServer" method="post" class="space-y-5"> <form asp-action="AddServer" method="post" novalidate>
<div> <div class="mb-3">
<label asp-for="Name" class="block text-sm font-medium text-gray-700">Name</label> <label asp-for="Name" class="form-label"><i class="bi bi-terminal me-1"></i>Servername</label>
<input asp-for="Name" class="mt-1 block w-full border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500" /> <input asp-for="Name" class="form-control" placeholder="z.B. Webserver-01" />
<span asp-validation-for="Name" class="text-red-500 text-sm" /> <span asp-validation-for="Name" class="text-danger small"></span>
</div> </div>
<div> <div class="mb-3">
<label asp-for="IPAddress" class="block text-sm font-medium text-gray-700">IP-Adresse</label> <label asp-for="IPAddress" class="form-label"><i class="bi bi-globe me-1"></i>IP-Adresse</label>
<input asp-for="IPAddress" class="mt-1 block w-full border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500" /> <input asp-for="IPAddress" class="form-control" placeholder="z.B. 192.168.1.10" />
<span asp-validation-for="IPAddress" class="text-red-500 text-sm" /> <span asp-validation-for="IPAddress" class="text-danger small"></span>
</div> </div>
<div> <div class="mb-4">
<label asp-for="Type" class="block text-sm font-medium text-gray-700">Typ</label> <label asp-for="Type" class="form-label"><i class="bi bi-hdd-network me-1"></i>Typ</label>
<select asp-for="Type" class="mt-1 block w-full border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500"> <select asp-for="Type" class="form-select">
<option>VPS</option> <option>VPS</option>
<option>VM</option> <option>VM</option>
<option>Standalone</option> <option>Standalone</option>
</select> </select>
</div> </div>
<div class="flex justify-end"> <div class="d-flex justify-content-end">
<a asp-action="Overview" class="mr-3 inline-block px-4 py-2 text-gray-600 hover:text-blue-600">Abbrechen</a> <a asp-action="Overview" class="btn btn-outline-secondary me-2">
<button type="submit" class="px-5 py-2 bg-blue-600 text-white font-semibold rounded hover:bg-blue-700"> <i class="bi bi-x-circle me-1"></i>Abbrechen
Speichern </a>
<button type="submit" class="btn btn-primary">
<i class="bi bi-save me-1"></i>Speichern
</button> </button>
</div> </div>
</form> </form>
</div>
</div> </div>
@section Scripts { @section Scripts {

View File

@@ -0,0 +1,55 @@
@model IEnumerable<Watcher.Models.Server>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
@foreach (var s in Model)
{
<div class="bg-blue rounded-xl shadow p-5 border border-gray-200 flex flex-col gap-4">
<div class="flex justify-between items-center">
<h2 class="text-lg font-semibold text-gray-800">
<i class="bi bi-cpu me-1 text-gray-600"></i>(#@s.Id) @s.Name
</h2>
<span class="text-sm px-2 py-1 rounded font-medium
@(s.IsOnline ? "bg-green-100 text-green-700" : "bg-red-100 text-red-700")">
<i class="bi @(s.IsOnline ? "bi-check-circle" : "bi-x-circle") me-1"></i>
@(s.IsOnline ? "Online" : "Offline")
</span>
</div>
<div class="flex gap-6">
<!-- Linke Seite: Infos, nimmt ca. 40% Breite -->
<div class="flex-1 max-w-[40%] text-sm space-y-1 text-gray-700">
<div><i class="bi bi-globe me-1 text-gray-500"></i><strong>IP:</strong> @s.IPAddress</div>
<div><i class="bi bi-hdd me-1 text-gray-500"></i><strong>Typ:</strong> @s.Type</div>
<div><i class="bi bi-calendar-check me-1 text-gray-500"></i><strong>Erstellt:</strong>
@s.CreatedAt.ToLocalTime().ToString("dd.MM.yyyy HH:mm")</div>
<div><i class="bi bi-clock me-1 text-gray-500"></i><strong>Last-Seen:</strong>
@s.LastSeen.ToLocalTime().ToString("dd.MM.yyyy HH:mm")</div>
</div>
<!-- Rechte Seite: Zwei Diagramme nebeneinander, je ca. 50% von 60% = 30% insgesamt -->
<div class="flex-1 flex gap-4 max-w-[60%]">
</div>
</div>
<div class="flex justify-end gap-3">
<a asp-action="EditServer" asp-route-id="@s.Id" class="text-blue-600 hover:text-blue-800 font-medium">
<i class="bi bi-pencil-square me-1"></i>Bearbeiten
</a>
<form asp-action="Delete" asp-route-id="@s.Id" method="post"
onsubmit="return confirm('Diesen Server wirklich löschen?');">
<button type="submit" class="text-red-600 hover:text-red-800 font-medium">
<i class="bi bi-trash me-1"></i>Löschen
</button>
</form>
<a href="/Download/File/Linux/heartbeat" class="btn btn-success">
🖥️ Linux Tool herunterladen
</a>
</div>
</div>
}
</div>

View File

@@ -4,44 +4,37 @@
} }
<div class="flex items-center justify-between mb-6"> <div class="flex items-center justify-between mb-6">
<h1 class="text-2xl font-bold">Serverübersicht</h1> <h1 class="text-2xl font-bold">
<i class="bi bi-hdd-network me-2 text-blue-700"></i>Serverübersicht
</h1>
<a asp-controller="Server" asp-action="AddServer" <a asp-controller="Server" asp-action="AddServer"
class="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700 transition"> class="bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 px-4 rounded transition">
+ Server hinzufügen <i class="bi bi-plus-circle me-1"></i>Server hinzufügen
</a> </a>
</div> </div>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 min-h-screen overflow-y-auto bg-gray-50"> <div id="server-cards-container">
@foreach (var s in Model.Servers) @await Html.PartialAsync("_ServerCard", Model.Servers)
{
<div class="bg-white rounded-xl shadow p-4 border border-gray-200">
<div class="flex justify-between items-start">
<div>
<h2 class="text-lg font-semibold">(#@s.Id) @s.Name</h2>
</div>
<span class="text-sm px-2 py-1 rounded
@(s.IsOnline ? "bg-green-100 text-green-700" : "bg-red-100 text-red-700")">
@(s.IsOnline ? "Online" : "Offline")
</span>
</div>
<div class="mt-4 text-sm space-y-1 text-gray-700">
<div><strong>IP:</strong> @s.IPAddress</div>
<div><strong>Typ:</strong> @s.Type</div>
<div><strong>Status:</strong> @((s.IsOnline) ? "Online" : "Offline")</div>
<div><strong>Erstellt:</strong> @s.CreatedAt.ToLocalTime().ToString("dd.MM.yyyy HH:mm")</div>
<div><strong>Last-Seen:</strong> @(s.LastSeen.ToLocalTime().ToString("dd.MM.yyyy HH:mm") ?? "Never")
</div>
</div>
<div class="mt-4 flex justify-end gap-2">
<a asp-action="EditServer" asp-route-id="@s.Id" class="btn btn-sm btn-primary">Bearbeiten</a>
<form asp-action="Delete" asp-route-id="@s.Id" method="post"
onsubmit="return confirm('Diesen Server wirklich löschen?');">
<button type="submit" class="text-red-600 hover:text-red-800 font-semibold">Löschen</button>
</form>
</div>
</div>
}
</div> </div>
@section Scripts {
<script>
async function loadServerCards() {
try {
const response = await fetch('/Server/ServerCardsPartial');
if (response.ok) {
const html = await response.text();
document.getElementById('server-cards-container').innerHTML = html;
} else {
console.error('Fehler beim Nachladen der Serverkarten');
}
} catch (err) {
console.error('Netzwerkfehler beim Nachladen der Serverkarten:', err);
}
}
// Initial laden und dann alle 30 Sekunden
loadServerCards();
setInterval(loadServerCards, 30000);
</script>
}

View File

@@ -14,6 +14,7 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<title>@ViewData["Title"] - Watcher</title> <title>@ViewData["Title"] - Watcher</title>
<link rel="stylesheet" href="~/css/site.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" /> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet"> <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet">
@@ -59,20 +60,27 @@
<body> <body>
<div class="sidebar"> <div class="sidebar">
<div> <div>
<h4>Watcher</h4> <h4>
<a href="https://git.triggermeelmo.com/daniel-hbn/Watcher" target="_blank" rel="noopener noreferrer" style="text-decoration: none;">
Watcher
</a>
</h4>
<ul class="nav flex-column"> <ul class="nav flex-column">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="/">Dashboard</a> <a class="nav-link" href="/Home/Index">Dashboard</a>
</li>
<li class="nav-item"></li>
<a class="nav-link" href="/Uptime">Uptime</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="/Server/Overview">Servers</a> <a class="nav-link" href="/Server/Overview">Servers</a>
</li> </li>
<!-- Noch nicht implementiert
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="/Container/Overview">Container</a> <a class="nav-link" href="/Container/Overview">Container</a>
</li> </li>
<li class="nav-item"></li>
<a class="nav-link" href="/Uptime/Overview">Uptime</a>
</li>
-->
</ul> </ul>
</div> </div>

View File

@@ -1,6 +1,11 @@
/* Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification /* Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification
for details on configuring this project to bundle and minify static web assets. */ for details on configuring this project to bundle and minify static web assets. */
html, body {
min-height: 100vh;
overflow-y: auto;
}
a.navbar-brand { a.navbar-brand {
white-space: normal; white-space: normal;
text-align: center; text-align: center;

View File

@@ -0,0 +1,24 @@
@{
Layout = null;
}
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - Login</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" />
</head>
<body class="bg-light d-flex align-items-center justify-content-center" style="min-height: 100vh;">
<div class="container">
<div class="row justify-content-center">
<div class="col-md-6">
@RenderBody()
</div>
</div>
</div>
@RenderSection("Scripts", required: false)
</body>
</html>

View File

@@ -8,7 +8,11 @@
<ItemGroup> <ItemGroup>
<!-- EF Core Design Tools --> <!-- EF Core Design Tools -->
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.6" /> <PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="DotNetEnv" Version="3.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.6" />
<!-- Pomelo MySQL EF Core Provider --> <!-- Pomelo MySQL EF Core Provider -->
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.0" /> <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.0" />

View File

@@ -5,11 +5,20 @@
"Microsoft.AspNetCore": "Warning" "Microsoft.AspNetCore": "Warning"
} }
}, },
"AllowedHosts": "*", "AllowedHosts": "*",
"Database": {
"Provider": "Sqlite",
"ConnectionStrings": { "ConnectionStrings": {
"DefaultConnection": "server=100.64.0.5;port=3306;database=watcher;user=monitoringuser;password=ssp123;" "MySql": "server=0.0.0.0;port=3306;database=db;user=user;password=password;",
"Sqlite": "Data Source=./persistence/watcher.db"
}
}, },
"Authentication": { "Authentication": {
"UseLocal": true,
"PocketIDEnabled": true,
"PocketID": { "PocketID": {
"Authority": "https://pocketid.triggermeelmo.com", "Authority": "https://pocketid.triggermeelmo.com",
"ClientId": "629a5f42-ab02-4905-8311-cc7b64165cc0", "ClientId": "629a5f42-ab02-4905-8311-cc7b64165cc0",
@@ -17,5 +26,5 @@
"CallbackPath": "/signin-oidc", "CallbackPath": "/signin-oidc",
"ResponseType": "code" "ResponseType": "code"
} }
} }
} }

View File

@@ -0,0 +1 @@

View File

@@ -1,22 +1,66 @@
html { :root {
font-size: 14px; --color-bg: #0d1b2a;
} --color-surface: #1b263b;
--color-accent: #415a77;
@media (min-width: 768px) { --color-primary: #0d6efd;
html { --color-text: #ffffff;
font-size: 16px; --color-muted: #c0c0c0;
} --color-success: #14a44d;
} --color-danger: #ff6b6b;
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}
html {
position: relative;
min-height: 100%;
} }
body { body {
margin-bottom: 60px; background-color: var(--color-bg);
color: var(--color-text);
}
a {
color: var(--color-primary);
}
.card, .navbar, .form-control, .dropdown-menu {
background-color: var(--color-surface);
color: var(--color-text);
border: none;
}
.form-control {
background-color: var(--color-accent);
color: var(--color-text);
}
.form-control::placeholder {
color: var(--color-muted);
}
.navbar .nav-link,
.dropdown-item {
color: var(--color-text);
}
.btn-primary {
background-color: var(--color-primary);
border: none;
}
.btn-danger {
background-color: var(--color-danger);
border: none;
}
.btn-pocketid {
background-color: var(--color-success);
color: white;
}
.btn-pocketid:hover {
background-color: #0f8c3c;
}
.table {
color: var(--color-text);
}
hr {
border-top: 1px solid var(--color-accent);
} }

Binary file not shown.