Merge pull request 'Release v0.1.0' (#68) from development into main

Reviewed-on: watcher/Watcher#68
This commit is contained in:
2025-08-22 23:01:36 +02:00
88 changed files with 6005 additions and 2021 deletions

View File

@@ -1,46 +0,0 @@
name: Build and Deploy
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup .NET 8 SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test (optional)
run: dotnet test --no-build --verbosity normal
- name: Publish
run: dotnet publish -c Release -o out
- name: Build Docker Image
run: docker build -t watcher:latest .
- name: Docker Login
run: echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- name: Push Docker Image
run: docker push watcher:latest
- name: Deploy (Beispiel - via SSH)
run: |
ssh daniel-hbn@git.triggermeelmo.com "docker pull deine-app:latest && docker stop watcher || true && docker rm watcher || true && docker run -d --name watcher -p 5000:5000 deine-app:latest"
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}

View File

@@ -0,0 +1,62 @@
name: Development Build and Release
on:
push:
branches:
- development
env:
DOTNET_VERSION: '8.0.x'
DOCKER_IMAGE_NAME: 'watcher-server'
REGISTRY_URL: 'git.triggermeelmo.com/watcher'
DOCKER_PLATFORMS: 'linux/amd64,linux/arm64'
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
continue-on-error: true
- name: Publish
run: dotnet publish -c Release -o out
docker-build-and-push:
runs-on: ubuntu-latest
needs: build-and-test
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Gitea Container Registry
uses: docker/login-action@v2
with:
registry: git.triggermeelmo.com
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and Push Multi-Arch Docker Image
run: |
docker buildx build \
--platform ${{ env.DOCKER_PLATFORMS }} \
-t ${{ env.REGISTRY_URL }}/${{ env.DOCKER_IMAGE_NAME }}:development \
-t ${{ env.REGISTRY_URL }}/${{ env.DOCKER_IMAGE_NAME }}:${{ github.sha }} \
--push .

View File

@@ -0,0 +1,49 @@
name: Development Build
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup .NET 8 SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test (optional)
run: dotnet test --no-build --verbosity normal
- name: Publish
run: dotnet publish -c Release -o out
- name: Build Docker Image
run: docker build -t watcher:v0.1.0 .
- name: Login to Gitea Container Registry
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login git.triggermeelmo.com -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Tag image
run: docker tag watcher:v0.1.0 git.triggermeelmo.com/daniel-hbn/watcher/watcher:v0.1.0
- name: Push image
run: docker push git.triggermeelmo.com/daniel-hbn/watcher/watcher:v0.1.0
- name: Tag image
run: docker tag watcher:v0.1.0 git.triggermeelmo.com/daniel-hbn/watcher/watcher:latest
- name: Push image
run: docker push git.triggermeelmo.com/daniel-hbn/watcher/watcher:latest

11
.gitignore vendored
View File

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

View File

@@ -13,13 +13,20 @@ WORKDIR /app/Watcher
RUN dotnet publish -c Release -o /app/publish /p:UseAppHost=false
# 2. Laufzeit-Phase: ASP.NET Core Runtime
FROM mcr.microsoft.com/dotnet/aspnet:9.0
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build /app/publish .
# Exponiere Port 80 und 443 (HTTP + HTTPS)
EXPOSE 80
EXPOSE 443
# Stelle sicher, dass Verzeichnisse existieren
RUN mkdir -p /app/persistence /app/wwwroot/downloads/sqlite /app/logs
# Volumes
VOLUME ["/app/persistence", "/app/wwwroot/downloads/sqlite", "/app/logs"]
# Expose Port 5000
EXPOSE 5000
ENV ASPNETCORE_URLS=http://*:5000
ENV ASPNETCORE_ENVIRONMENT=Development
# Anwendung starten
ENTRYPOINT ["dotnet", "Watcher.dll"]

View File

@@ -1,3 +1,34 @@
# Watcher
# 🖥️ Server Monitoring Software
Monitoring Tool für Server, VMs und Docker Container.
Dieses Projekt ist eine umfassende Monitoring-Lösung für Server und Host-Geräte.
Die Software besteht aus zwei Teilen:
- **Host Agent**: Sammelt Hardware-Daten von den Hosts
- **Zentrale Monitoring-Software**: Visualisiert und verwaltet die gesammelten Daten
Die Lösung unterstützt moderne Authentifizierungsverfahren und flexible Datenbankanbindungen alles bequem verteilt als Docker Image.
---
## ✨ Features
- Erfassung von Hardware-Daten aller wichtigen Komponenten
- Lokale Authentifizierung oder OIDC (OpenID Connect)
- Wahlweise Speicherung der Daten in:
- Lokaler SQLite-Datenbank
- Remote MySQL-Datenbank
- Einfache Bereitstellung via Docker & docker-compose
---
## ⚙️ Installation & Start
Voraussetzung:
- [Docker](https://www.docker.com/)
- [docker-compose](https://docs.docker.com/compose/)
1. Image herunterladen:
```bash
docker pull git.triggermeelmo.com/daniel-hbn/watcher/watcher:latest
2. Docker Container starten
```bash
docker compose up -d

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,41 +1,119 @@
using System.Net.Mail;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.Extensions.Options;
using Watcher.Data;
using Watcher.ViewModels;
namespace Watcher.Controllers;
public class AppSettings
{
public Boolean oidc { get; set; }
}
public class AuthController : Controller
{
public IActionResult Login()
private readonly AppDbContext _context;
private readonly AppSettings _settings;
// Logging einbinden
private readonly ILogger<AuthController> _logger;
public AuthController(AppDbContext context, IOptions<AppSettings> options, ILogger<AuthController> logger)
{
return View();
_context = context;
_settings = options.Value;
_logger = logger;
}
// Login Seite anzeigen
[HttpGet("/Auth/Login")]
public IActionResult Login(string? returnUrl = null)
{
var model = new LoginViewModel
{
ReturnUrl = returnUrl
};
ViewBag.oidc = _settings.oidc;
return View(model);
}
// Login mit lokalem User
[HttpPost]
public async Task<IActionResult> Login(LoginViewModel model)
{
if (!ModelState.IsValid)
return View(model);
try
{
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);
_logger.LogInformation("lokaler User angemeldet: " + user.Username);
return Redirect("/");
}
catch (Exception ex)
{
_logger.LogError(ex, "Fehler beim Login. User: {UserName}", model.Username);
ModelState.AddModelError("", "Es ist ein Fehler aufgetreten. Bitte versuchen Sie es erneut.");
return View(model);
}
}
// Login mit OIDC-Provider
public IActionResult SignIn()
{
return Challenge(new AuthenticationProperties
{
RedirectUri = "/"
RedirectUri = "/Home/Index"
}, "oidc");
}
// Logout
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Logout()
{
await HttpContext.SignOutAsync();
return RedirectToAction("Index", "Home");
}
var props = new AuthenticationProperties
{
RedirectUri = Url.Action("Login", "Auth")
};
[Authorize]
public IActionResult Info()
{
var name = User.Identity?.Name;
var claims = User.Claims.Select(c => new { c.Type, c.Value }).ToList();
await HttpContext.SignOutAsync("Cookies");
await HttpContext.SignOutAsync("oidc", props);
ViewBag.Name = name;
ViewBag.Claims = claims;
_logger.LogInformation("User abgemeldet");
return View();
return Redirect("/"); // nur als Fallback
}
}

View File

@@ -7,7 +7,7 @@ using Watcher.ViewModels;
namespace Watcher.Controllers;
[Authorize]
public class ContainerController : Controller
{
private readonly AppDbContext _context;
@@ -20,41 +20,15 @@ public class ContainerController : Controller
public async Task<IActionResult> Overview()
{
var containers = await _context.Containers.ToListAsync();
var servers = await _context.Servers.ToListAsync();
var viewModel = new ContainerOverviewViewModel
{
Servers = servers,
Containers = containers
};
return View(viewModel);
}
[HttpGet]
public IActionResult AddContainer()
{
return View();
}
[HttpPost]
public async Task<IActionResult> AddContainer(AddContainerViewModel vm)
{
if (!ModelState.IsValid)
return View(vm);
var container = new Container
{
Name = vm.Name,
Image = vm.Image,
Status = vm.Status,
Hostname = vm.Hostname,
IsRunning = vm.IsRunning,
CreatedAt = DateTime.UtcNow
};
_context.Containers.Add(container);
await _context.SaveChangesAsync();
return RedirectToAction("Index");
}
}

View File

@@ -0,0 +1,200 @@
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
{
// Backup Infos
private readonly string _dbPath = Path.Combine(Directory.GetCurrentDirectory(), "persistence", "watcher.db");
private readonly string _backupFolder = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "downloads", "sqlite");
// Services
private readonly ILogger<DatabaseController> _logger;
public class DumpFileInfo
{
public string? FileName { get; set; }
public long SizeKb { get; set; }
public DateTime Created { get; set; }
}
public DatabaseController(IWebHostEnvironment env, ILogger<DatabaseController> logger)
{
_logger = logger;
_backupFolder = Path.Combine(env.WebRootPath, "downloads", "sqlite");
if (!Directory.Exists(_backupFolder))
{
_logger.LogInformation("Backup-Directory neu erstellt");
Directory.CreateDirectory(_backupFolder);
}
else
{
_logger.LogInformation("Backup-Directory existiert bereits");
}
}
[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.";
_logger.LogInformation("SQLite-Dump erfolgreich erstellt.");
return RedirectToAction("UserSettings", "User");
}
catch (Exception ex)
{
//return StatusCode(500, $"Fehler beim Erstellen des Dumps: {ex.Message}");
TempData["DumpError"] = $"Fehler beim Erstellen des Dumps: {ex.Message}";
_logger.LogError("Fehler beim Erstellen des Dumps: {message}", ex.Message);
return RedirectToAction("UserSettings", "User");
}
}
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,52 @@
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
{
// Logging einbinden
private readonly ILogger<AuthController> _logger;
public DownloadController(ILogger<AuthController> logger)
{
_logger = logger;
}
// Allgemeiner Download von Dateien
[Authorize]
[HttpGet("Download/File/{type}/{filename}")]
public IActionResult FileDownload(string type, string filename)
{
// Nur erlaubte Endungen zulassen (Sicherheit!)
// TODO: aktuelles "" für Binaries ist das absolute Gegenteil von sicher, ich hab aber keine bessere Idee
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))
{
_logger.LogError("Download fehlgeschlagen: Datei nicht gefunden ({path})", path);
return NotFound("Datei nicht gefunden");
}
// .exe MIME-Typ: application/octet-stream
var mimeType = "application/octet-stream";
var fileBytes = System.IO.File.ReadAllBytes(path);
_logger.LogTrace("Download ausgeführt: {filename}", filename);
return File(fileBytes, mimeType, filename);
//return File(fileBytes, filename);
}
}

View File

@@ -1,13 +1,10 @@
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;
// eingehender Heartbeat-Payload
public class HeartbeatDto
{
public string? IpAddress { get; set; }
@@ -18,18 +15,27 @@ public class HeartbeatDto
public class HeartbeatController : Controller
{
// Datenbankverbindung
private readonly AppDbContext _context;
public HeartbeatController(AppDbContext context)
// Logging einbinden
private readonly ILogger<HeartbeatController> _logger;
public HeartbeatController(AppDbContext context, ILogger<HeartbeatController> logger)
{
_context = context;
_logger = logger;
}
// Endpoint um Heartbeat-Payloads zu empfangen
[HttpPost("receive")]
public async Task<IActionResult> Receive([FromBody] HeartbeatDto dto)
{
_logger.LogInformation("Heartbeat empfangen");
if (string.IsNullOrWhiteSpace(dto.IpAddress))
{
_logger.LogWarning("Eingehender Payload enthält keine IP-Adresse");
return BadRequest("Missing IP address.");
}
@@ -40,9 +46,11 @@ public class HeartbeatController : Controller
{
server.LastSeen = DateTime.UtcNow;
await _context.SaveChangesAsync();
_logger.LogInformation("Heartbeat von {server} in Datenbank eingetragen.", server.Name);
return Ok();
}
_logger.LogWarning("Eingehender Payload kann keiner bekannten IP-Adresse zugewiesen werden.");
return NotFound("No matching server found.");
}
}

View File

@@ -1,9 +1,9 @@
// .NET Packages
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.Security.Claims;
// Local Namespaces
using Watcher.Data;
using Watcher.Models;
using Watcher.ViewModels;
namespace Watcher.Controllers
@@ -11,19 +11,28 @@ namespace Watcher.Controllers
[Authorize]
public class HomeController : Controller
{
// Datenbankverbindung
private readonly AppDbContext _context;
public HomeController(AppDbContext context)
// Logging einbinden
private readonly ILogger<HomeController> _logger;
// HomeController Constructor
public HomeController(AppDbContext context, ILogger<HomeController> logger)
{
_context = context;
_logger = logger;
}
// Dashboard unter /home/index
[HttpGet("/")]
public async Task<IActionResult> Index()
{
var userId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
var preferredUserName = User.FindFirst("preferred_username")?.Value;
var user = await _context.Users
.Where(u => u.PocketId == userId)
.Where(u => u.Username == preferredUserName)
.FirstOrDefaultAsync();
var viewModel = new DashboardViewModel
@@ -37,5 +46,30 @@ namespace Watcher.Controllers
return View(viewModel);
}
// Funktion für /Views/Home/Index.cshtml um das DashboardStats-Partial neu zu laden.
// Die Funktion wird nicht direkt aufgerufen, sondern nur der /Home/DashboardStats Endpoint angefragt.
public IActionResult DashboardStats()
{
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),
//TODO: anwendbar, wenn Container implementiert wurden.
//RunningContainers = containers.Count(c => (now - c.LastSeen).TotalSeconds <= 120),
//FailedContainers = containers.Count(c => (now - c.LastSeen).TotalSeconds > 120),
LastLogin = DateTime.Now
};
return PartialView("_DashboardStats", model);
}
}
}

View File

@@ -0,0 +1,284 @@
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 ServerId { get; set; }
[Required]
public string? IpAddress { get; set; }
// Hardware Metrics
// CPU
public double CPU_Load { get; set; } // %
public double CPU_Temp { get; set; } // deg C
// GPU
public double GPU_Load { get; set; } // %
public double GPU_Temp { get; set; } // deg C
public double GPU_Vram_Size { get; set; } // GB
public double GPU_Vram_Usage { get; set; } // %
// RAM
public double RAM_Size { get; set; } // GB
public double RAM_Load { get; set; } // %
// Disks
public double DISK_Size { get; set; } // GB
public double DISK_Usage { get; set; } // %
public double DISK_Temp { get; set; } // deg C
// Network
public double NET_In { get; set; } // Bit
public double NET_Out { get; set; } // Bit
}
[ApiController]
[Route("[controller]")]
public class MonitoringController : Controller
{
private readonly AppDbContext _context;
private readonly ILogger<MonitoringController> _logger;
public MonitoringController(AppDbContext context, ILogger<MonitoringController> logger)
{
_context = context;
_logger = logger;
}
// Endpoint, an dem sich neue Agents registrieren
[HttpPost("register-agent-by-id")]
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();
_logger.LogError("Fehlerhafter Registrierungs-Payload.");
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
_logger.LogInformation("Agent für '{server}' erfolgreich registriert.", server.Name);
return Ok();
}
_logger.LogError("Kein Server für Registrierung gefunden");
return NotFound("No Matching Server found.");
}
[HttpGet("server-id-by-ip")]
public async Task<IActionResult> GetServerIdByIp([FromQuery] string IpAddress)
{
var server = await _context.Servers
.FirstOrDefaultAsync(s => s.IPAddress == IpAddress);
if (server == null)
return NotFound();
return Ok(new
{
id = server.Id,
IpAddress = server.IPAddress
});
}
// Enpoint, an den Agents Ihre gesammelten Daten senden
[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();
_logger.LogError("Ungültiger Monitoring-Payload.");
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)
{
var NewMetric = new Metric
{
Timestamp = DateTime.UtcNow,
ServerId = dto.ServerId,
CPU_Load = dto.CPU_Load,
CPU_Temp = dto.CPU_Temp,
GPU_Load = dto.GPU_Load,
GPU_Temp = dto.GPU_Temp,
GPU_Vram_Size = dto.GPU_Vram_Size,
GPU_Vram_Usage = dto.GPU_Vram_Usage,
RAM_Load = dto.RAM_Load,
RAM_Size = dto.RAM_Size,
DISK_Size = dto.RAM_Size,
DISK_Usage = dto.DISK_Usage,
DISK_Temp = dto.DISK_Temp,
NET_In = dto.NET_In,
NET_Out = dto.NET_Out
};
try
{
_context.Metrics.Add(NewMetric);
await _context.SaveChangesAsync();
_logger.LogInformation("Monitoring-Daten für '{server}' empfangen", server.Name);
return Ok();
}
catch
{
// Alert triggern
_logger.LogError("Metric für {server} konnte nicht in Datenbank geschrieben werden.", server.Name);
return BadRequest();
}
}
_logger.LogError("Kein Server für eingegangenen Monitoring-Payload gefunden");
return NotFound("No Matching Server found.");
}
// Durchschnittliche Werte Berechnen
[HttpGet("median")]
public async Task<IActionResult> CalculateMedian(string Metric, int HoursToMonitor, int ServerId)
{
// Aktuelle Zeit - X Stunden = letzter Wert, der berücksichtigt werden soll
DateTime TimeToMonitor = DateTime.Now.AddHours(-HoursToMonitor);
// Alle Metrics von Server "ServerId" finden, die in der festgelegten Zeitspanne liegen
var MetricsInTimeFrame = await _context.Metrics
.Where(e => e.Timestamp >= TimeToMonitor && e.ServerId == ServerId)
.ToListAsync();
// return Action (MetricsInTimeFrame)
return NotFound();
}
[HttpGet("cpu-usage")]
public async Task<IActionResult> GetCpuUsageData(int serverId)
{
var oneDayAgo = DateTime.UtcNow.AddDays(-1);
var data = await _context.Metrics
.Where(m => m.Timestamp >= oneDayAgo && m.ServerId == serverId)
.OrderBy(m => m.Timestamp)
.Select(m => new
{
label = m.Timestamp.ToUniversalTime().ToString("o"),
data = m.CPU_Load
})
.ToListAsync();
return Ok(data);
}
[HttpGet("ram-usage")]
public async Task<IActionResult> GetRamUsageData(int serverId)
{
var oneDayAgo = DateTime.UtcNow.AddDays(-1);
var data = await _context.Metrics
.Where(m => m.Timestamp >= oneDayAgo && m.ServerId == serverId)
.OrderBy(m => m.Timestamp)
.Select(m => new
{
label = m.Timestamp.ToUniversalTime().ToString("o"),
data = m.RAM_Load
})
.ToListAsync();
return Ok(data);
}
[HttpGet("gpu-usage")]
public async Task<IActionResult> GetGpuUsageData(int serverId)
{
var oneDayAgo = DateTime.UtcNow.AddDays(-1);
var data = await _context.Metrics
.Where(m => m.Timestamp >= oneDayAgo && m.ServerId == serverId)
.OrderBy(m => m.Timestamp)
.Select(m => new
{
label = m.Timestamp.ToUniversalTime().ToString("o"),
data = m.GPU_Load
})
.ToListAsync();
return Ok(data);
}
}

View File

@@ -6,15 +6,22 @@ using Watcher.Models;
using Watcher.ViewModels;
[Authorize]
[Route("[controller]")]
public class ServerController : Controller
{
private readonly AppDbContext _context;
public ServerController(AppDbContext context)
private readonly ILogger<ServerController> _logger;
public ServerController(AppDbContext context, ILogger<ServerController> logger)
{
_context = context;
_logger = logger;
}
[HttpGet("Overview")]
public async Task<IActionResult> Overview()
{
var vm = new ServerOverviewViewModel
@@ -25,13 +32,16 @@ public class ServerController : Controller
return View(vm);
}
[HttpGet]
[HttpGet("AddServer")]
public IActionResult AddServer()
{
return View();
}
[HttpPost]
// POST: Server/AddServer
[HttpPost("AddServer")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> AddServer(AddServerViewModel vm)
{
if (!ModelState.IsValid)
@@ -48,25 +58,34 @@ public class ServerController : Controller
_context.Servers.Add(server);
await _context.SaveChangesAsync();
_logger.LogInformation("Neuer Server erstellt: {server}", server.Name);
return RedirectToAction("Overview");
}
[HttpPost]
// POST: Server/Delete/5
[HttpPost("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Delete(int id)
{
var server = await _context.Servers.FindAsync(id);
if (server == null)
{
_logger.LogError("Server nicht gefunden");
return NotFound();
}
_context.Servers.Remove(server);
await _context.SaveChangesAsync();
_logger.LogInformation("Server '{server}' erfolgreich gelöscht", server.Name);
return RedirectToAction(nameof(Overview));
}
// GET: Server/Edit/5
[HttpGet("EditServer/{id}")]
public async Task<IActionResult> EditServer(int id)
{
var server = await _context.Servers.FindAsync(id);
@@ -82,25 +101,92 @@ public class ServerController : Controller
return View(vm);
}
// POST: Server/Edit/5
[HttpPost]
[HttpPost("EditServer/{id}")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> EditServer(int id, EditServerViewModel vm)
{
if (ModelState.IsValid)
if (!ModelState.IsValid)
{
var server = await _context.Servers.FindAsync(id);
if (server == null) return NotFound();
return View(vm);
}
server.Name = vm.Name;
server.IPAddress = vm.IPAddress;
server.Type = vm.Type;
var server = await _context.Servers.FindAsync(id);
if (server == null)
{
return NotFound();
}
server.Name = vm.Name;
server.IPAddress = vm.IPAddress;
server.Type = vm.Type;
try
{
await _context.SaveChangesAsync();
_logger.LogInformation("Server '{server}' erfolgreich aktualisiert", server.Name);
return RedirectToAction(nameof(Overview));
}
catch (Exception ex)
{
_logger.LogError(ex, "Fehler beim Speichern des Servers");
ModelState.AddModelError("", "Fehler beim Speichern");
return View(vm);
}
}
// GET: Server/Details/5
[HttpGet("Details/{id}")]
public async Task<IActionResult> Details(int id)
{
var s = await _context.Servers.FindAsync(id);
if (s == null) return NotFound();
var vm = new ServerDetailsViewModel
{
Id = s.Id,
Name = s.Name,
IPAddress = s.IPAddress,
Type = s.Type,
Description = s.Description,
CpuType = s.CpuType,
CpuCores = s.CpuCores,
GpuType = s.GpuType,
RamSize = s.RamSize,
CreatedAt = s.CreatedAt,
IsOnline = s.IsOnline,
LastSeen = s.LastSeen,
IsVerified = s.IsVerified
};
return View(vm);
}
[HttpGet("ServerCardPartial")]
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);
}
[HttpGet("ServerDetailPartial")]
public IActionResult ServerDetailPartial()
{
_logger.LogInformation("Server Detail Seite neu geladen");
return PartialView("_ServerDetails");
}
}

View File

@@ -0,0 +1,146 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Watcher.Data;
using Watcher.ViewModels;
namespace Watcher.Controllers;
public class UserController : Controller
{
private readonly AppDbContext _context;
private readonly ILogger<UserController> _logger;
public UserController(AppDbContext context, ILogger<UserController> logger)
{
_context = context;
_logger = logger;
}
// Anzeigen der User-Informationen
[Authorize]
public IActionResult Info()
{
var claims = User.Claims.Select(c => new { c.Type, c.Value }).ToList();
var Identity_User = User.Identity?.Name;
var user = _context.Users.FirstOrDefault(u => u.Username == Identity_User);
if (user == null) return NotFound();
// Anzeigedaten
var DbProvider = _context.Database.ProviderName;
var username = user.Username;
var mail = user.Email;
var Id = user.Id;
var IdProvider = user.IdentityProvider;
// Anzeigedaten an View übergeben
ViewBag.Claims = claims;
ViewBag.Name = username;
ViewBag.Mail = mail;
ViewBag.Id = Id;
ViewBag.IdProvider = IdProvider;
return View();
}
// 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
_logger.LogTrace("Passwort-Change durchgeführt");
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

@@ -1,11 +1,18 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Watcher.Models;
namespace Watcher.Data;
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; }
@@ -21,6 +28,29 @@ public class AppDbContext : DbContext
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,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
{
[DbContext(typeof(AppDbContext))]
[Migration("20250615114821_ServerCleanUp")]
partial class ServerCleanUp
[Migration("20250617153602_InitialMigration")]
partial class InitialMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -148,12 +148,21 @@ namespace Watcher.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("CpuCores")
.HasColumnType("int");
b.Property<string>("CpuType")
.HasColumnType("longtext");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("Description")
.HasColumnType("longtext");
b.Property<string>("GpuType")
.HasColumnType("longtext");
b.Property<string>("IPAddress")
.IsRequired()
.HasColumnType("longtext");
@@ -168,6 +177,9 @@ namespace Watcher.Migrations
.IsRequired()
.HasColumnType("longtext");
b.Property<double>("RamSize")
.HasColumnType("double");
b.Property<int?>("TagId")
.HasColumnType("int");

View File

@@ -7,28 +7,13 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace Watcher.Migrations
{
/// <inheritdoc />
public partial class InitialModelsAdded_1 : Migration
public partial class InitialMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "TagId",
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.AlterDatabase()
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Images",
@@ -47,6 +32,112 @@ namespace Watcher.Migrations
})
.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(
name: "LogEvents",
columns: table => new
@@ -106,43 +197,6 @@ namespace Watcher.Migrations
})
.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(
name: "IX_Containers_ImageId",
table: "Containers",
@@ -173,81 +227,35 @@ namespace Watcher.Migrations
table: "Metrics",
column: "ServerId");
migrationBuilder.AddForeignKey(
name: "FK_Containers_Images_ImageId",
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",
migrationBuilder.CreateIndex(
name: "IX_Servers_TagId",
table: "Servers",
column: "TagId",
principalTable: "Tags",
principalColumn: "Id");
column: "TagId");
}
/// <inheritdoc />
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(
name: "LogEvents");
migrationBuilder.DropTable(
name: "Metrics");
migrationBuilder.DropTable(
name: "Tags");
migrationBuilder.DropTable(
name: "Users");
migrationBuilder.DropIndex(
name: "IX_Servers_TagId",
table: "Servers");
migrationBuilder.DropTable(
name: "Containers");
migrationBuilder.DropIndex(
name: "IX_Containers_ImageId",
table: "Containers");
migrationBuilder.DropTable(
name: "Servers");
migrationBuilder.DropIndex(
name: "IX_Containers_TagId",
table: "Containers");
migrationBuilder.DropTable(
name: "Images");
migrationBuilder.DropColumn(
name: "TagId",
table: "Servers");
migrationBuilder.DropColumn(
name: "ImageId",
table: "Containers");
migrationBuilder.DropColumn(
name: "TagId",
table: "Containers");
migrationBuilder.DropTable(
name: "Tags");
}
}
}

View File

@@ -11,50 +11,48 @@ using Watcher.Data;
namespace Watcher.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20250615102649_ServerAnpassung")]
partial class ServerAnpassung
[Migration("20250617165126_ServerPrimaryKey")]
partial class ServerPrimaryKey
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.6")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.HasAnnotation("ProductVersion", "8.0.6");
modelBuilder.Entity("Watcher.Models.Container", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
.HasColumnType("TEXT");
b.Property<string>("Hostname")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<int?>("ImageId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<bool>("IsRunning")
.HasColumnType("tinyint(1)");
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<int?>("TagId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.HasKey("Id");
@@ -69,13 +67,13 @@ namespace Watcher.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("Tag")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.HasKey("Id");
@@ -86,22 +84,22 @@ namespace Watcher.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<int?>("ContainerId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Level")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("Message")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<int?>("ServerId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<DateTime>("Timestamp")
.HasColumnType("datetime(6)");
.HasColumnType("TEXT");
b.HasKey("Id");
@@ -116,22 +114,22 @@ namespace Watcher.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<int?>("ContainerId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<int?>("ServerId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<DateTime>("Timestamp")
.HasColumnType("datetime(6)");
.HasColumnType("TEXT");
b.Property<string>("Type")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<double>("Value")
.HasColumnType("double");
.HasColumnType("REAL");
b.HasKey("Id");
@@ -146,39 +144,46 @@ namespace Watcher.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<int>("CpuCores")
.HasColumnType("INTEGER");
b.Property<string>("CpuType")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
.HasColumnType("TEXT");
b.Property<string>("Hostname")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Description")
.HasColumnType("TEXT");
b.Property<string>("GpuType")
.HasColumnType("TEXT");
b.Property<string>("IPAddress")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<bool>("IsOnline")
.HasColumnType("tinyint(1)");
.HasColumnType("INTEGER");
b.Property<DateTime>("LastSeen")
.HasColumnType("datetime(6)");
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("longtext");
b.Property<double>("RamSize")
.HasColumnType("REAL");
b.Property<int?>("TagId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.HasKey("Id");
@@ -191,10 +196,10 @@ namespace Watcher.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.HasKey("Id");
@@ -205,21 +210,21 @@ namespace Watcher.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Email")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<DateTime>("LastLogin")
.HasColumnType("datetime(6)");
.HasColumnType("TEXT");
b.Property<string>("PocketId")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("PreferredUsername")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
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
{
[DbContext(typeof(AppDbContext))]
[Migration("20250614224113_Container-Server-Update")]
partial class ContainerServerUpdate
[Migration("20250617174242_UserPasswordAdded")]
partial class UserPasswordAdded
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.6")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.HasAnnotation("ProductVersion", "8.0.6");
modelBuilder.Entity("Watcher.Models.Container", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
.HasColumnType("TEXT");
b.Property<string>("Hostname")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<int?>("ImageId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<bool>("IsRunning")
.HasColumnType("tinyint(1)");
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<int?>("TagId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.HasKey("Id");
@@ -69,13 +67,13 @@ namespace Watcher.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("Tag")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.HasKey("Id");
@@ -86,22 +84,22 @@ namespace Watcher.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<int?>("ContainerId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Level")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("Message")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<int?>("ServerId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<DateTime>("Timestamp")
.HasColumnType("datetime(6)");
.HasColumnType("TEXT");
b.HasKey("Id");
@@ -116,22 +114,22 @@ namespace Watcher.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<int?>("ContainerId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<int?>("ServerId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<DateTime>("Timestamp")
.HasColumnType("datetime(6)");
.HasColumnType("TEXT");
b.Property<string>("Type")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<double>("Value")
.HasColumnType("double");
.HasColumnType("REAL");
b.HasKey("Id");
@@ -146,36 +144,46 @@ namespace Watcher.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<int>("CpuCores")
.HasColumnType("INTEGER");
b.Property<string>("CpuType")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
.HasColumnType("TEXT");
b.Property<string>("Hostname")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Description")
.HasColumnType("TEXT");
b.Property<string>("GpuType")
.HasColumnType("TEXT");
b.Property<string>("IPAddress")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<bool>("IsOnline")
.HasColumnType("tinyint(1)");
.HasColumnType("INTEGER");
b.Property<DateTime>("LastSeen")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("longtext");
b.Property<double>("RamSize")
.HasColumnType("REAL");
b.Property<int?>("TagId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.HasKey("Id");
@@ -188,10 +196,10 @@ namespace Watcher.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.HasKey("Id");
@@ -202,21 +210,29 @@ namespace Watcher.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Email")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("IdentityProvider")
.IsRequired()
.HasColumnType("TEXT");
b.Property<DateTime>("LastLogin")
.HasColumnType("datetime(6)");
.HasColumnType("TEXT");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("PocketId")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("PreferredUsername")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
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
{
[DbContext(typeof(AppDbContext))]
[Migration("20250614183243_Server-Container-IsRunning-Value")]
partial class ServerContainerIsRunningValue
[Migration("20250621124832_DB-Update Issue#32")]
partial class DBUpdateIssue32
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.6")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.HasAnnotation("ProductVersion", "8.0.6");
modelBuilder.Entity("Watcher.Models.Container", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
.HasColumnType("TEXT");
b.Property<string>("Hostname")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<int?>("ImageId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<bool>("IsRunning")
.HasColumnType("tinyint(1)");
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<int?>("TagId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.HasKey("Id");
@@ -69,13 +67,13 @@ namespace Watcher.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("Tag")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.HasKey("Id");
@@ -86,22 +84,22 @@ namespace Watcher.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<int?>("ContainerId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Level")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("Message")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<int?>("ServerId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<DateTime>("Timestamp")
.HasColumnType("datetime(6)");
.HasColumnType("TEXT");
b.HasKey("Id");
@@ -116,29 +114,55 @@ namespace Watcher.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<int?>("ContainerId")
.HasColumnType("int");
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("int");
.HasColumnType("INTEGER");
b.Property<DateTime>("Timestamp")
.HasColumnType("datetime(6)");
b.Property<string>("Type")
.HasColumnType("longtext");
b.Property<double>("Value")
.HasColumnType("double");
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("ContainerId");
b.HasIndex("ServerId");
b.ToTable("Metrics");
});
@@ -146,32 +170,46 @@ namespace Watcher.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<int>("CpuCores")
.HasColumnType("INTEGER");
b.Property<string>("CpuType")
.HasColumnType("TEXT");
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()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<bool>("IsOnline")
.HasColumnType("tinyint(1)");
.HasColumnType("INTEGER");
b.Property<DateTime>("LastSeen")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("longtext");
b.Property<double>("RamSize")
.HasColumnType("REAL");
b.Property<int?>("TagId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.HasKey("Id");
@@ -184,10 +222,10 @@ namespace Watcher.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.HasKey("Id");
@@ -198,21 +236,28 @@ namespace Watcher.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Email")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("IdentityProvider")
.IsRequired()
.HasColumnType("TEXT");
b.Property<DateTime>("LastLogin")
.HasColumnType("datetime(6)");
.HasColumnType("TEXT");
b.Property<string>("PocketId")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("OIDC_Id")
.HasColumnType("TEXT");
b.Property<string>("PreferredUsername")
b.Property<string>("Password")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("Username")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
@@ -221,13 +266,15 @@ namespace Watcher.Migrations
modelBuilder.Entity("Watcher.Models.Container", b =>
{
b.HasOne("Watcher.Models.Image", null)
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 =>
@@ -245,21 +292,6 @@ namespace Watcher.Migrations
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)

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

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

View File

@@ -0,0 +1,332 @@
// <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("20250710090920_container-attribute")]
partial class containerattribute
{
/// <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<int>("ExposedPort")
.HasColumnType("INTEGER");
b.Property<string>("Health")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int?>("HostServerId")
.HasColumnType("INTEGER");
b.Property<string>("Image")
.HasColumnType("TEXT");
b.Property<int?>("ImageId")
.HasColumnType("INTEGER");
b.Property<int>("InternalPort")
.HasColumnType("INTEGER");
b.Property<bool>("IsRunning")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int?>("TagId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("HostServerId");
b.HasIndex("ImageId");
b.HasIndex("TagId");
b.ToTable("Containers");
});
modelBuilder.Entity("Watcher.Models.Image", b =>
{
b.Property<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.Server", "HostServer")
.WithMany()
.HasForeignKey("HostServerId");
b.HasOne("Watcher.Models.Image", null)
.WithMany("Containers")
.HasForeignKey("ImageId");
b.HasOne("Watcher.Models.Tag", null)
.WithMany("Containers")
.HasForeignKey("TagId");
b.Navigation("HostServer");
});
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
{
b.HasOne("Watcher.Models.Container", "Container")
.WithMany()
.HasForeignKey("ContainerId");
b.HasOne("Watcher.Models.Server", "Server")
.WithMany()
.HasForeignKey("ServerId");
b.Navigation("Container");
b.Navigation("Server");
});
modelBuilder.Entity("Watcher.Models.Server", b =>
{
b.HasOne("Watcher.Models.Tag", null)
.WithMany("Servers")
.HasForeignKey("TagId");
});
modelBuilder.Entity("Watcher.Models.Image", b =>
{
b.Navigation("Containers");
});
modelBuilder.Entity("Watcher.Models.Tag", b =>
{
b.Navigation("Containers");
b.Navigation("Servers");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,119 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Watcher.Migrations
{
/// <inheritdoc />
public partial class containerattribute : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Hostname",
table: "Containers");
migrationBuilder.RenameColumn(
name: "Type",
table: "Containers",
newName: "Health");
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "Containers",
type: "TEXT",
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT");
migrationBuilder.AddColumn<int>(
name: "ExposedPort",
table: "Containers",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "HostServerId",
table: "Containers",
type: "INTEGER",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Image",
table: "Containers",
type: "TEXT",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "InternalPort",
table: "Containers",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateIndex(
name: "IX_Containers_HostServerId",
table: "Containers",
column: "HostServerId");
migrationBuilder.AddForeignKey(
name: "FK_Containers_Servers_HostServerId",
table: "Containers",
column: "HostServerId",
principalTable: "Servers",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Containers_Servers_HostServerId",
table: "Containers");
migrationBuilder.DropIndex(
name: "IX_Containers_HostServerId",
table: "Containers");
migrationBuilder.DropColumn(
name: "ExposedPort",
table: "Containers");
migrationBuilder.DropColumn(
name: "HostServerId",
table: "Containers");
migrationBuilder.DropColumn(
name: "Image",
table: "Containers");
migrationBuilder.DropColumn(
name: "InternalPort",
table: "Containers");
migrationBuilder.RenameColumn(
name: "Health",
table: "Containers",
newName: "Type");
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "Containers",
type: "TEXT",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "TEXT",
oldNullable: true);
migrationBuilder.AddColumn<string>(
name: "Hostname",
table: "Containers",
type: "TEXT",
nullable: false,
defaultValue: "");
}
}
}

View File

@@ -0,0 +1,335 @@
// <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("20250730113936_DiskSpace-ServerAttribute")]
partial class DiskSpaceServerAttribute
{
/// <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<int>("ExposedPort")
.HasColumnType("INTEGER");
b.Property<string>("Health")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int?>("HostServerId")
.HasColumnType("INTEGER");
b.Property<string>("Image")
.HasColumnType("TEXT");
b.Property<int?>("ImageId")
.HasColumnType("INTEGER");
b.Property<int>("InternalPort")
.HasColumnType("INTEGER");
b.Property<bool>("IsRunning")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int?>("TagId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("HostServerId");
b.HasIndex("ImageId");
b.HasIndex("TagId");
b.ToTable("Containers");
});
modelBuilder.Entity("Watcher.Models.Image", b =>
{
b.Property<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>("DiskSpace")
.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.Server", "HostServer")
.WithMany()
.HasForeignKey("HostServerId");
b.HasOne("Watcher.Models.Image", null)
.WithMany("Containers")
.HasForeignKey("ImageId");
b.HasOne("Watcher.Models.Tag", null)
.WithMany("Containers")
.HasForeignKey("TagId");
b.Navigation("HostServer");
});
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
{
b.HasOne("Watcher.Models.Container", "Container")
.WithMany()
.HasForeignKey("ContainerId");
b.HasOne("Watcher.Models.Server", "Server")
.WithMany()
.HasForeignKey("ServerId");
b.Navigation("Container");
b.Navigation("Server");
});
modelBuilder.Entity("Watcher.Models.Server", b =>
{
b.HasOne("Watcher.Models.Tag", null)
.WithMany("Servers")
.HasForeignKey("TagId");
});
modelBuilder.Entity("Watcher.Models.Image", b =>
{
b.Navigation("Containers");
});
modelBuilder.Entity("Watcher.Models.Tag", b =>
{
b.Navigation("Containers");
b.Navigation("Servers");
});
#pragma warning restore 612, 618
}
}
}

View File

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

View File

@@ -0,0 +1,377 @@
// <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("20250730172010_MeasurementWarnings")]
partial class MeasurementWarnings
{
/// <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<int>("ExposedPort")
.HasColumnType("INTEGER");
b.Property<string>("Health")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int?>("HostServerId")
.HasColumnType("INTEGER");
b.Property<string>("Image")
.HasColumnType("TEXT");
b.Property<int?>("ImageId")
.HasColumnType("INTEGER");
b.Property<int>("InternalPort")
.HasColumnType("INTEGER");
b.Property<bool>("IsRunning")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int?>("TagId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("HostServerId");
b.HasIndex("ImageId");
b.HasIndex("TagId");
b.ToTable("Containers");
});
modelBuilder.Entity("Watcher.Models.Image", b =>
{
b.Property<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<double>("CPU_Load_Critical")
.HasColumnType("REAL");
b.Property<double>("CPU_Load_Warning")
.HasColumnType("REAL");
b.Property<double>("CPU_Temp_Critical")
.HasColumnType("REAL");
b.Property<double>("CPU_Temp_Warning")
.HasColumnType("REAL");
b.Property<int>("CpuCores")
.HasColumnType("INTEGER");
b.Property<string>("CpuType")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedAt")
.HasColumnType("TEXT");
b.Property<double>("DISK_Temp_Critical")
.HasColumnType("REAL");
b.Property<double>("DISK_Temp_Warning")
.HasColumnType("REAL");
b.Property<string>("Description")
.HasColumnType("TEXT");
b.Property<string>("DiskSpace")
.HasColumnType("TEXT");
b.Property<double>("Disk_Usage_Critical")
.HasColumnType("REAL");
b.Property<double>("Disk_Usage_Warning")
.HasColumnType("REAL");
b.Property<double>("GPU_Load_Critical")
.HasColumnType("REAL");
b.Property<double>("GPU_Load_Warning")
.HasColumnType("REAL");
b.Property<double>("GPU_Temp_Critical")
.HasColumnType("REAL");
b.Property<double>("GPU_Temp_Warning")
.HasColumnType("REAL");
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>("RAM_Load_Critical")
.HasColumnType("REAL");
b.Property<double>("RAM_Load_Warning")
.HasColumnType("REAL");
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.Server", "HostServer")
.WithMany()
.HasForeignKey("HostServerId");
b.HasOne("Watcher.Models.Image", null)
.WithMany("Containers")
.HasForeignKey("ImageId");
b.HasOne("Watcher.Models.Tag", null)
.WithMany("Containers")
.HasForeignKey("TagId");
b.Navigation("HostServer");
});
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
{
b.HasOne("Watcher.Models.Container", "Container")
.WithMany()
.HasForeignKey("ContainerId");
b.HasOne("Watcher.Models.Server", "Server")
.WithMany()
.HasForeignKey("ServerId");
b.Navigation("Container");
b.Navigation("Server");
});
modelBuilder.Entity("Watcher.Models.Server", b =>
{
b.HasOne("Watcher.Models.Tag", null)
.WithMany("Servers")
.HasForeignKey("TagId");
});
modelBuilder.Entity("Watcher.Models.Image", b =>
{
b.Navigation("Containers");
});
modelBuilder.Entity("Watcher.Models.Tag", b =>
{
b.Navigation("Containers");
b.Navigation("Servers");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,172 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Watcher.Migrations
{
/// <inheritdoc />
public partial class MeasurementWarnings : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<double>(
name: "CPU_Load_Critical",
table: "Servers",
type: "REAL",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<double>(
name: "CPU_Load_Warning",
table: "Servers",
type: "REAL",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<double>(
name: "CPU_Temp_Critical",
table: "Servers",
type: "REAL",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<double>(
name: "CPU_Temp_Warning",
table: "Servers",
type: "REAL",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<double>(
name: "DISK_Temp_Critical",
table: "Servers",
type: "REAL",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<double>(
name: "DISK_Temp_Warning",
table: "Servers",
type: "REAL",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<double>(
name: "Disk_Usage_Critical",
table: "Servers",
type: "REAL",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<double>(
name: "Disk_Usage_Warning",
table: "Servers",
type: "REAL",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<double>(
name: "GPU_Load_Critical",
table: "Servers",
type: "REAL",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<double>(
name: "GPU_Load_Warning",
table: "Servers",
type: "REAL",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<double>(
name: "GPU_Temp_Critical",
table: "Servers",
type: "REAL",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<double>(
name: "GPU_Temp_Warning",
table: "Servers",
type: "REAL",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<double>(
name: "RAM_Load_Critical",
table: "Servers",
type: "REAL",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<double>(
name: "RAM_Load_Warning",
table: "Servers",
type: "REAL",
nullable: false,
defaultValue: 0.0);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "CPU_Load_Critical",
table: "Servers");
migrationBuilder.DropColumn(
name: "CPU_Load_Warning",
table: "Servers");
migrationBuilder.DropColumn(
name: "CPU_Temp_Critical",
table: "Servers");
migrationBuilder.DropColumn(
name: "CPU_Temp_Warning",
table: "Servers");
migrationBuilder.DropColumn(
name: "DISK_Temp_Critical",
table: "Servers");
migrationBuilder.DropColumn(
name: "DISK_Temp_Warning",
table: "Servers");
migrationBuilder.DropColumn(
name: "Disk_Usage_Critical",
table: "Servers");
migrationBuilder.DropColumn(
name: "Disk_Usage_Warning",
table: "Servers");
migrationBuilder.DropColumn(
name: "GPU_Load_Critical",
table: "Servers");
migrationBuilder.DropColumn(
name: "GPU_Load_Warning",
table: "Servers");
migrationBuilder.DropColumn(
name: "GPU_Temp_Critical",
table: "Servers");
migrationBuilder.DropColumn(
name: "GPU_Temp_Warning",
table: "Servers");
migrationBuilder.DropColumn(
name: "RAM_Load_Critical",
table: "Servers");
migrationBuilder.DropColumn(
name: "RAM_Load_Warning",
table: "Servers");
}
}
}

View File

@@ -15,46 +15,53 @@ namespace Watcher.Migrations
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.6")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.HasAnnotation("ProductVersion", "8.0.6");
modelBuilder.Entity("Watcher.Models.Container", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
.HasColumnType("TEXT");
b.Property<string>("Hostname")
b.Property<int>("ExposedPort")
.HasColumnType("INTEGER");
b.Property<string>("Health")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<int?>("HostServerId")
.HasColumnType("INTEGER");
b.Property<string>("Image")
.HasColumnType("TEXT");
b.Property<int?>("ImageId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<int>("InternalPort")
.HasColumnType("INTEGER");
b.Property<bool>("IsRunning")
.HasColumnType("tinyint(1)");
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<int?>("TagId")
.HasColumnType("int");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("HostServerId");
b.HasIndex("ImageId");
b.HasIndex("TagId");
@@ -66,13 +73,13 @@ namespace Watcher.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("Tag")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.HasKey("Id");
@@ -83,22 +90,22 @@ namespace Watcher.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<int?>("ContainerId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Level")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("Message")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<int?>("ServerId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<DateTime>("Timestamp")
.HasColumnType("datetime(6)");
.HasColumnType("TEXT");
b.HasKey("Id");
@@ -113,29 +120,55 @@ namespace Watcher.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<int?>("ContainerId")
.HasColumnType("int");
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("int");
.HasColumnType("INTEGER");
b.Property<DateTime>("Timestamp")
.HasColumnType("datetime(6)");
b.Property<string>("Type")
.HasColumnType("longtext");
b.Property<double>("Value")
.HasColumnType("double");
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("ContainerId");
b.HasIndex("ServerId");
b.ToTable("Metrics");
});
@@ -143,34 +176,94 @@ namespace Watcher.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<double>("CPU_Load_Critical")
.HasColumnType("REAL");
b.Property<double>("CPU_Load_Warning")
.HasColumnType("REAL");
b.Property<double>("CPU_Temp_Critical")
.HasColumnType("REAL");
b.Property<double>("CPU_Temp_Warning")
.HasColumnType("REAL");
b.Property<int>("CpuCores")
.HasColumnType("INTEGER");
b.Property<string>("CpuType")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
.HasColumnType("TEXT");
b.Property<double>("DISK_Temp_Critical")
.HasColumnType("REAL");
b.Property<double>("DISK_Temp_Warning")
.HasColumnType("REAL");
b.Property<string>("Description")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("DiskSpace")
.HasColumnType("TEXT");
b.Property<double>("Disk_Usage_Critical")
.HasColumnType("REAL");
b.Property<double>("Disk_Usage_Warning")
.HasColumnType("REAL");
b.Property<double>("GPU_Load_Critical")
.HasColumnType("REAL");
b.Property<double>("GPU_Load_Warning")
.HasColumnType("REAL");
b.Property<double>("GPU_Temp_Critical")
.HasColumnType("REAL");
b.Property<double>("GPU_Temp_Warning")
.HasColumnType("REAL");
b.Property<string>("GpuType")
.HasColumnType("TEXT");
b.Property<string>("IPAddress")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<bool>("IsOnline")
.HasColumnType("tinyint(1)");
.HasColumnType("INTEGER");
b.Property<bool>("IsVerified")
.HasColumnType("INTEGER");
b.Property<DateTime>("LastSeen")
.HasColumnType("datetime(6)");
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<double>("RAM_Load_Critical")
.HasColumnType("REAL");
b.Property<double>("RAM_Load_Warning")
.HasColumnType("REAL");
b.Property<double>("RamSize")
.HasColumnType("REAL");
b.Property<int?>("TagId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.HasKey("Id");
@@ -183,10 +276,10 @@ namespace Watcher.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.HasKey("Id");
@@ -197,21 +290,28 @@ namespace Watcher.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Email")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("IdentityProvider")
.IsRequired()
.HasColumnType("TEXT");
b.Property<DateTime>("LastLogin")
.HasColumnType("datetime(6)");
.HasColumnType("TEXT");
b.Property<string>("PocketId")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("OIDC_Id")
.HasColumnType("TEXT");
b.Property<string>("PreferredUsername")
b.Property<string>("Password")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("Username")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
@@ -220,7 +320,11 @@ namespace Watcher.Migrations
modelBuilder.Entity("Watcher.Models.Container", b =>
{
b.HasOne("Watcher.Models.Image", "Image")
b.HasOne("Watcher.Models.Server", "HostServer")
.WithMany()
.HasForeignKey("HostServerId");
b.HasOne("Watcher.Models.Image", null)
.WithMany("Containers")
.HasForeignKey("ImageId");
@@ -228,7 +332,7 @@ namespace Watcher.Migrations
.WithMany("Containers")
.HasForeignKey("TagId");
b.Navigation("Image");
b.Navigation("HostServer");
});
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
@@ -246,21 +350,6 @@ namespace Watcher.Migrations
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)

View File

@@ -4,17 +4,22 @@ public class Container
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
// Container Details
public string? Name { get; set; }
public int ExposedPort { get; set; }
public int InternalPort { get; set; }
public string Status { get; set; } = string.Empty;
public Image? Image { get; set; }
public string Health { get; set; } = string.Empty;
public string? Image { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public string Hostname { get; set; } = string.Empty;
public Boolean IsRunning { get; set; } = true;
public string Type { get; set; } = "docker"; // z.B. "docker", "vm", "lxc", etc.
public Boolean IsRunning { get; set; } = false;
public Server? HostServer { get; set; }
}

View File

@@ -2,15 +2,47 @@ namespace Watcher.Models;
public class Metric
{
// Metric Metadata
public int Id { 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 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,60 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Watcher.Models;
public class Server
{
// System Infos
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
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;
public string? DiskSpace { get; set; } = string.Empty;
// Hardware Measurment Warning/Crit Values
public double CPU_Load_Warning { get; set; } = 75.0;
public double CPU_Load_Critical { get; set; } = 90.0;
public double CPU_Temp_Warning { get; set; } = 80.0;
public double CPU_Temp_Critical { get; set; } = 90.0;
public double RAM_Load_Warning { get; set; } = 85.0;
public double RAM_Load_Critical { get; set; } = 95.0;
public double GPU_Load_Warning { get; set; } = 75.0;
public double GPU_Load_Critical { get; set; } = 90.0;
public double GPU_Temp_Warning { get; set; } = 70.0;
public double GPU_Temp_Critical { get; set; } = 80.0;
public double Disk_Usage_Warning { get; set; } = 75.0;
public double Disk_Usage_Critical { get; set; } = 90.0;
public double DISK_Temp_Warning { get; set; } = 34.0;
public double DISK_Temp_Critical { get; set; } = 36.0;
// Database
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 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;
public class User
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; } // PK
public string PocketId { get; set; } = null!;
public string PreferredUsername { get; set; } = null!;
public string? OIDC_Id { get; set; } = null!;
public string Username { get; set; } = null!;
public string? Email { 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,44 +2,100 @@ using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Sqlite;
using Microsoft.IdentityModel.Tokens;
using Serilog;
using Watcher.Data;
using Watcher.Models;
var builder = WebApplication.CreateBuilder(args);
// Serilog konfigurieren nur Logs, die nicht von Microsoft stammen
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Information()
.MinimumLevel.Override("Microsoft", Serilog.Events.LogEventLevel.Warning) // <--
.Enrich.FromLogContext()
.WriteTo.File(
"logs/watcher-.log",
outputTemplate: "[{Timestamp:yyyy-MM-dd HH:mm:ss}] [{Level:u3}] {Message:lj}{NewLine}{Exception}",
rollingInterval: RollingInterval.Day
)
.CreateLogger();
builder.Host.UseSerilog();
// Add services to the container.
builder.Services.AddControllersWithViews();
// HttpContentAccessor
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;
// ---------- DB-Kontext mit MySQL ----------
builder.Services.AddDbContext<AppDbContext>(options =>
options.UseMySql(
configuration.GetConnectionString("DefaultConnection"),
ServerVersion.AutoDetect(configuration.GetConnectionString("DefaultConnection"))
)
);
// ---------- DB-Kontext ----------
var dbProvider = configuration["Database:Provider"] ?? "MySQL";
var connectionString = configuration["Database:ConnectionString"];
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 ----------
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.DefaultChallengeScheme = "oidc";
})
.AddCookie("Cookies")
options.LoginPath = "/Auth/Login";
options.AccessDeniedPath = "/Auth/AccessDenied";
});
builder.Services.AddAuthentication()
.AddOpenIdConnect("oidc", options =>
{
var config = builder.Configuration.GetSection("Authentication:PocketID");
options.Authority = config["Authority"];
options.ClientId = config["ClientId"];
options.ClientSecret = config["ClientSecret"];
options.Authority = pocketIdSection["Authority"];
options.ClientId = pocketIdSection["ClientId"];
options.ClientSecret = pocketIdSection["ClientSecret"];
options.ResponseType = "code";
options.CallbackPath = config["CallbackPath"];
options.CallbackPath = pocketIdSection["CallbackPath"];
options.SaveTokens = true;
options.GetClaimsFromUserInfoEndpoint = true;
@@ -50,49 +106,91 @@ builder.Services.AddAuthentication(options =>
options.Scope.Add("email");
options.Events = new OpenIdConnectEvents
{
OnTokenValidated = async ctx =>
{
var db = ctx.HttpContext.RequestServices.GetRequiredService<AppDbContext>();
var principal = ctx.Principal;
var pocketId = principal.FindFirst("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier")?.Value;
var preferredUsername = principal.FindFirst("preferred_username")?.Value;
var email = principal.FindFirst("email")?.Value;
if (string.IsNullOrEmpty(pocketId))
return;
var user = await db.Users.FirstOrDefaultAsync(u => u.PocketId == pocketId);
if (user == null)
OnTokenValidated = async ctx =>
{
user = new User
var db = ctx.HttpContext.RequestServices.GetRequiredService<AppDbContext>();
var principal = ctx.Principal;
var pocketId = principal.FindFirst("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier")?.Value;
var preferredUsername = principal.FindFirst("preferred_username")?.Value;
var email = principal.FindFirst("email")?.Value;
if (string.IsNullOrEmpty(pocketId))
return;
var user = await db.Users.FirstOrDefaultAsync(u => u.OIDC_Id == pocketId);
if (user == null)
{
PocketId = pocketId,
PreferredUsername = preferredUsername ?? "",
Email = email,
LastLogin = DateTime.UtcNow
};
db.Users.Add(user);
}
else
{
user.LastLogin = DateTime.UtcNow;
user.PreferredUsername = preferredUsername ?? user.PreferredUsername;
user.Email = email ?? user.Email;
db.Users.Update(user);
}
await db.SaveChangesAsync();
}
};
user = new User
{
OIDC_Id = pocketId,
Username = preferredUsername ?? "",
Email = email,
LastLogin = DateTime.UtcNow,
IdentityProvider = "oidc",
Password = string.Empty
};
db.Users.Add(user);
}
else
{
user.LastLogin = DateTime.UtcNow;
user.Username = preferredUsername ?? user.Username;
user.Email = email ?? user.Email;
db.Users.Update(user);
}
await db.SaveChangesAsync();
}
};
});
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.
if (!app.Environment.IsDevelopment())
{
@@ -101,6 +199,7 @@ if (!app.Environment.IsDevelopment())
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseRouting();
@@ -109,11 +208,9 @@ app.UseAuthorization();
app.UseStaticFiles();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}"
);
app.Run();

View File

@@ -13,16 +13,7 @@
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5258",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7050;http://localhost:5258",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}

View File

@@ -1,6 +1,7 @@
using Watcher.Models;
namespace Watcher.ViewModels;
public class AddContainerViewModel
{
public string Name { get; set; } = string.Empty;
@@ -10,4 +11,7 @@ public class AddContainerViewModel
public string IPAddress { get; set; } = string.Empty;
public string ServerName { get; set; } = string.Empty; // oder ID, je nach Relation
public bool IsRunning { get; set; } = false;
}

View File

@@ -3,8 +3,10 @@ using Watcher.Models;
namespace Watcher.ViewModels
{
public class ContainerOverviewViewModel
{
public List<Container> Containers { get; set; } = new();
}
{
public List<Container> Containers { get; set; } = new();
public List<Server> Servers { get; set; } = new();
}
}

View File

@@ -1,10 +1,38 @@
namespace Watcher.ViewModels;
using System.ComponentModel.DataAnnotations;
public class EditServerViewModel
namespace Watcher.ViewModels
{
public string Name { get; set; } = string.Empty;
public class EditServerViewModel
{
public int Id { get; set; }
public string IPAddress { get; set; } = string.Empty;
[Required(ErrorMessage = "Name ist erforderlich")]
public string? Name { get; set; }
public string Type { get; set; } = "VPS";
[Required(ErrorMessage = "IP-Adresse ist erforderlich")]
[RegularExpression(@"^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$", ErrorMessage = "Ungültige IP-Adresse")]
public required string IPAddress { get; set; }
[Required(ErrorMessage = "Typ ist erforderlich")]
public string? Type { get; set; }
// Hardware Measurment Warning/Crit Values
public double CPU_Load_Warning { get; set; } = 75.0;
public double CPU_Load_Critical { get; set; } = 90.0;
public double CPU_Temp_Warning { get; set; } = 80.0;
public double CPU_Temp_Critical { get; set; } = 90.0;
public double RAM_Load_Warning { get; set; } = 85.0;
public double RAM_Load_Critical { get; set; } = 95.0;
public double GPU_Load_Warning { get; set; } = 75.0;
public double GPU_Load_Critical { get; set; } = 90.0;
public double GPU_Temp_Warning { get; set; } = 70.0;
public double GPU_Temp_Critical { get; set; } = 80.0;
public double Disk_Usage_Warning { get; set; } = 75.0;
public double Disk_Usage_Critical { get; set; } = 90.0;
public double DISK_Temp_Warning { get; set; } = 34.0;
public double DISK_Temp_Critical { get; set; } = 36.0;
}
}

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

@@ -0,0 +1,39 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Watcher.ViewModels;
public class ServerDetailsViewModel
{
// System Infos
[Required]
public int Id { get; set; }
[Required]
public required string Name { get; set; }
[Required]
public required string IPAddress { get; set; }
[Required]
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 Boolean IsOnline { get; set; } = false;
public DateTime LastSeen { get; set; }
public Boolean IsVerified { get; set; } = false;
}

View File

@@ -1,86 +0,0 @@
@{
ViewData["Title"] = "Account Info";
var pictureUrl = User.Claims.FirstOrDefault(c => c.Type == "picture")?.Value ?? "123";
}
<h2>Account Info</h2>
<div class="card" style="max-width: 600px; margin: auto; padding: 1rem; box-shadow: 0 0 10px #ccc; text-align:center;">
@if (!string.IsNullOrEmpty(pictureUrl))
{
<img src="@pictureUrl" alt="Profilbild" style="width:120px; height:120px; border-radius:50%; object-fit:cover; margin-bottom:1rem;" />
}
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;">
<span>@(User.Identity?.Name?.Substring(0,1).ToUpper() ?? "?")</span>
</div>
}
<h3>@(User.FindFirst("name")?.Value ?? "Unbekannter Nutzer")</h3>
<table class="table" style="margin-top: 1rem;">
<tbody>
<tr></tr>
<th>Username</th>
<td>@(@User.Claims.FirstOrDefault(c => c.Type == "preferred_username")?.Value ?? "Nicht verfügbar")</td>
</tr>
<tr>
<th>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>
</tr>
<tr>
<th>Benutzer-ID</th>
<td>@(User.FindFirst("sub")?.Value ?? "Nicht verfügbar")</td>
</tr>
<tr>
<th>Login-Zeit</th>
<td>@(User.FindFirst("iat") != null
? DateTimeOffset.FromUnixTimeSeconds(long.Parse(User.FindFirst("iat").Value)).ToLocalTime().ToString()
: "Nicht verfügbar")
</td>
</tr>
<tr>
<th>Token läuft ab</th>
<td>@(User.FindFirst("exp") != null
? DateTimeOffset.FromUnixTimeSeconds(long.Parse(User.FindFirst("exp").Value)).ToLocalTime().ToString()
: "Nicht verfügbar")
</td>
</tr>
<tr>
<th>Rollen</th>
<td>
@{
var roles = User.FindAll("role").Select(r => r.Value);
if (!roles.Any())
{
<text>Keine Rollen</text>
}
else
{
<ul>
@foreach (var role in roles)
{
<li>@role</li>
}
</ul>
}
}
</td>
</tr>
</tbody>
</table>
<form method="post" asp-controller="Auth" asp-action="Logout">
<button type="submit" class="btn btn-danger">Abmelden</button>
</form>
</div>
<h3>Alle Claims</h3>
<ul>
@foreach (var claim in User.Claims)
{
<li>@claim.Type: @claim.Value</li>
}
</ul>

View File

@@ -1,9 +1,92 @@
@model Watcher.ViewModels.LoginViewModel
@{
Layout = "~/Views/Shared/_LoginLayout.cshtml";
ViewData["Title"] = "Login";
var oidc = ViewBag.oidc;
}
<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" />
@if (ViewBag.oidc == true)
{
<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

@@ -1,22 +0,0 @@
@model Watcher.ViewModels.AddContainerViewModel
@{
ViewData["Title"] = "Neuen Container hinzufügen";
}
<h1 class="text-2xl font-bold mb-4">Neuen Container hinzufügen</h1>
<form asp-action="Add" method="post" class="space-y-4 max-w-xl">
<div>
<label asp-for="Name" class="block font-medium">Name</label>
<input asp-for="Name" class="w-full border rounded px-3 py-2" />
</div>
<div>
<label asp-for="Image" class="block font-medium">Image</label>
<input asp-for="Image" class="w-full border rounded px-3 py-2" />
</div>
<div>
<label asp-for="ServerName" class="block font-medium">Server</label>
<input asp-for="ServerName" class="w-full border rounded px-3 py-2" />
</div>
<button type="submit" class="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700">Speichern</button>
</form>

View File

@@ -3,33 +3,31 @@
ViewData["Title"] = "Containerübersicht";
}
<div class="flex items-center justify-between mb-6">
<h1 class="text-3xl font-bold">Containerübersicht</h1>
<a asp-action="AddContainer" class="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700">
+ Container hinzufügen
</a>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
@foreach (var container in Model.Containers)
@foreach (var server in Model.Servers)
{
<div class="bg-white shadow-md rounded-xl p-5 border border-gray-200 hover:shadow-lg transition duration-200">
<h2 class="text-xl font-semibold mb-1">@container.Name</h2>
<p class="text-sm text-gray-600 mb-2"><strong>Image:</strong> @container.Image</p>
<p class="text-sm text-gray-600"><strong>Hostname:</strong> @container.Hostname</p>
<p class="text-sm text-gray-600"><strong>Status:</strong> @container.Status</p>
<p class="text-sm text-gray-600 mb-3">
<strong>Läuft:</strong>
<span class="@(container.IsRunning ? "text-green-600" : "text-red-600")">
@(container.IsRunning ? "Ja" : "Nein")
</span>
</p>
<div class="flex justify-end gap-2">
<a asp-action="Edit" asp-route-id="@container.Id"
class="text-blue-600 hover:underline text-sm">Bearbeiten</a>
<a asp-action="Delete" asp-route-id="@container.Id"
class="text-red-600 hover:underline text-sm">Löschen</a>
</div>
<h2 class="text-xl font-semibold mb-1">@server.Name</h2>
</div>
<div class="bg-white">
@if (Model.Containers.Count > 0)
{
<table>
@foreach (var container in Model.Containers)
{
<tr>test</tr>
if (container.HostServer.Equals(server.Name))
{
}
}
</table>
} else
{
<p> keine Container gefunden </p>
}
</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,52 @@
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 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 id="dashboard-stats">
@await Html.PartialAsync("_DashboardStats", Model)
</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="row g-4 mt-4">
<div class="col-span-2 bg-white shadow rounded-2xl p-4">
<h2 class="text-xl font-semibold mb-2">Uptime letzte 24h</h2>
<div class="bg-gray-100 h-32 rounded-lg flex items-center justify-center text-gray-500">
(Diagramm folgt hier)
<div class="col-12">
<div class="card p-3">
<h2 class="h5">
<i class="bi bi-person-circle me-2"></i>Systeminfo
</h2>
<p>
<i class="bi bi-person-badge me-1"></i>
Benutzer: <strong>@User.FindFirst("preferred_username")?.Value</strong>
</p>
<p>
<i class="bi bi-clock me-1"></i>
Letzter Login: <strong>@Model.LastLogin.ToString("g")</strong>
</p>
</div>
</div>
<div class="col-span-2 bg-white shadow rounded-2xl p-4">
<h2 class="text-xl font-semibold mb-2">Systeminfo</h2>
<p>Benutzer: <strong>@User.FindFirst("preferred_username")?.Value</strong></p>
<p>Letzter Login: <strong>@Model.LastLogin.ToString("g")</strong></p>
<a href="/Auth/Info" class="text-blue-500 hover:underline mt-2 inline-block">→ Account-Verwaltung</a>
</div>
</div>
@section Scripts {
<script>
async function loadDashboardStats() {
try {
const response = await fetch('/Home/DashboardStats');
if (response.ok) {
console.log("reload")
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,25 @@
@model Watcher.ViewModels.DashboardViewModel
<div class="row g-4">
<div class="col-12 col-md-6">
<div class="bg-white shadow rounded-3 p-4 h-100">
<h2 class="h5 fw-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-primary text-decoration-none mt-2 d-inline-block">
→ Zu den Servern
</a>
</div>
</div>
<div class="col-12 col-md-6">
<div class="bg-white shadow rounded-3 p-4 h-100">
<h2 class="h5 fw-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-primary text-decoration-none mt-2 d-inline-block">
→ Zu den Containern
</a>
</div>
</div>
</div>

View File

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

View File

@@ -0,0 +1,272 @@
@model Watcher.ViewModels.ServerDetailsViewModel
@{
ViewData["Title"] = "Serverübersicht";
}
<div id="server-cards-container">
<div class="container mt-4"></div>
<div class="card shadow-sm">
<div class="card-header d-flex justify-content-between align-items-center">
<h5 class="mb-0">
<i class="bi bi-hdd-network me-2 text-primary"></i>Serverdetails: @Model.Name
</h5>
<span class="badge @(Model.IsOnline ? "bg-success" : "bg-danger")">
<i class="bi @(Model.IsOnline ? "bi-check-circle" : "bi-x-circle") me-1"></i>
@(Model.IsOnline ? "Online" : "Offline")
</span>
</div>
<div class="card-body">
<dl class="row mb-0">
<dt class="col-sm-3">ID</dt>
<dd class="col-sm-9">@Model.Id</dd>
<dt class="col-sm-3">IP-Adresse</dt>
<dd class="col-sm-9">@Model.IPAddress</dd>
<dt class="col-sm-3">Typ</dt>
<dd class="col-sm-9">@Model.Type</dd>
<dt class="col-sm-3">Erstellt am</dt>
<dd class="col-sm-9">@Model.CreatedAt.ToLocalTime().ToString("dd.MM.yyyy HH:mm")</dd>
<dt class="col-sm-3">Zuletzt gesehen</dt>
<dd class="col-sm-9">@Model.LastSeen.ToLocalTime().ToString("dd.MM.yyyy HH:mm")</dd>
</dl>
</div>
<div class="card-footer text-end">
<a asp-action="EditServer" asp-route-id="@Model.Id" class="btn btn-outline-primary me-2">
<i class="bi bi-pencil"></i> Bearbeiten
</a>
<form asp-action="Delete" asp-route-id="@Model.Id" method="post" class="d-inline"
onsubmit="return confirm('Diesen Server wirklich löschen?');">
<button type="submit" class="btn btn-outline-danger">
<i class="bi bi-trash"></i> Löschen
</button>
</form>
</div>
</div>
<div class="mt-4">
<h6><i class="bi bi-graph-up me-1"></i>CPU Last</h6>
<div class="bg-light border rounded p-4 text-center text-muted" style="height: 500px; width: 100%">
<canvas id="cpuUsageChart" style="width: 800px; height: 400px; border: 1px solid red;"></canvas>
</div>
</div>
</div>
<h6><i class="bi bi-graph-up me-1"></i>RAM Last</h6>
<div class="bg-light border rounded p-4 text-center text-muted" style="height: 500px; width: 100%">
<canvas id="ramUsageChart" style="width: 800px; height: 400px; border: 1px solid red;"></canvas>
</div>
</div>
<div class="mt-4"></div>
<h6><i class="bi bi-graph-up me-1"></i>GPU Last</h6>
<div class="bg-light border rounded p-4 text-center text-muted" style="height: 500px; width: 100%">
<canvas id="gpuUsageChart" style="width: 800px; height: 400px; border: 1px solid red;"></canvas>
</div>
</div>
</div>
</div>
@section Scripts {
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function () {
const ctx_cpu = document.getElementById('cpuUsageChart').getContext('2d');
const ctx_ram = document.getElementById('ramUsageChart').getContext('2d');
const ctx_gpu = document.getElementById('gpuUsageChart').getContext('2d');
const cpuChart = new Chart(ctx_cpu, {
type: 'line',
data: {
labels: [],
datasets: [{
label: 'CPU Last (%)',
data: [],
borderColor: 'rgb(255, 99, 132)',
backgroundColor: 'rgba(255, 99, 132, 0.2)',
fill: true,
tension: 0.3,
pointRadius: 3
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true,
max: 100,
title: {
display: true,
text: 'Auslastung in %'
}
},
x: {
title: {
display: true,
text: 'Zeit'
}
}
}
}
});
const ramChart = new Chart(ctx_ram, {
type: 'line',
data: {
labels: [],
datasets: [{
label: 'RAM Last (%)',
data: [],
borderColor: 'rgb(255, 99, 132)',
backgroundColor: 'rgba(255, 99, 132, 0.2)',
fill: true,
tension: 0.3,
pointRadius: 3
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true,
max: 100,
title: {
display: true,
text: 'Prozent'
}
},
x: {
title: {
display: true,
text: 'Zeit'
}
}
}
}
});
const gpuChart = new Chart(ctx_gpu, {
type: 'line',
data: {
labels: [],
datasets: [{
label: 'GPU Last (%)',
data: [],
borderColor: 'rgb(255, 99, 132)',
backgroundColor: 'rgba(255, 99, 132, 0.2)',
fill: true,
tension: 0.3,
pointRadius: 3
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true,
max: 100,
title: {
display: true,
text: 'Prozent'
}
},
x: {
title: {
display: true,
text: 'Zeit'
}
}
}
}
});
async function loadCpuData() {
try {
const response = await fetch('/monitoring/cpu-usage?serverId=@Model.Id');
if (!response.ok) {
throw new Error(`HTTP-Fehler: ${response.status}`);
}
const data = await response.json();
if (!Array.isArray(data) || data.length === 0) {
console.warn('Keine CPU-Daten empfangen.');
return;
}
cpuChart.data.labels = data.map(d => d.label ?? '');
cpuChart.data.datasets[0].data = data.map(d => Number(d.data));
cpuChart.update();
} catch (err) {
console.error('Fehler beim Laden der CPU-Daten:', err);
}
}
async function loadRamData() {
try {
const response = await fetch('/monitoring/ram-usage?serverId=@Model.Id');
if (!response.ok) {
throw new Error(`HTTP-Fehler: ${response.status}`);
}
const data = await response.json();
if (!Array.isArray(data) || data.length === 0) {
console.warn('Keine RAM-Daten empfangen.');
return;
}
ramChart.data.labels = data.map(d => d.label ?? '');
ramChart.data.datasets[0].data = data.map(d => Number(d.data));
ramChart.update();
} catch (err) {
console.error('Fehler beim Laden der RAM-Daten:', err);
}
}
async function loadGpuData() {
try {
const response = await fetch('/monitoring/gpu-usage?serverId=@Model.Id');
if (!response.ok) {
throw new Error(`HTTP-Fehler: ${response.status}`);
}
const data = await response.json();
if (!Array.isArray(data) || data.length === 0) {
console.warn('Keine GPU-Daten empfangen.');
return;
}
gpuChart.data.labels = data.map(d => d.label ?? '');
gpuChart.data.datasets[0].data = data.map(d => Number(d.data));
gpuChart.update();
} catch (err) {
console.error('Fehler beim Laden der GPU-Daten:', err);
}
}
// Initiales Laden
loadCpuData();
loadRamData();
loadGpuData();
// Alle 30 Sekunden aktualisieren
setInterval(loadCpuData, 30000);
setInterval(loadRamData, 30000);
setInterval(loadGpuData, 30000);
});
</script>
}

View File

@@ -1,31 +1,181 @@
@model Watcher.ViewModels.EditServerViewModel;
@model Watcher.ViewModels.EditServerViewModel
@{
ViewData["Title"] = "Server bearbeiten";
}
<h2>Server bearbeiten</h2>
<h2 class="mb-4">Server bearbeiten</h2>
<form asp-action="EditServer" method="post">
<form asp-action="EditServer" asp-controller="Server" method="post">
@Html.AntiForgeryToken()
<input type="hidden" asp-for="Id" />
<div class="mb-3">
<label asp-for="Name"></label>
<input asp-for="Name" class="form-control" />
<div class="card mb-4">
<div class="card-header">
<h4 class="mb-0">Allgemeine Informationen</h4>
</div>
<div class="card-body">
<div class="mb-3">
<label asp-for="Name" class="form-label"></label>
<input asp-for="Name" class="form-control" />
<span asp-validation-for="Name" class="text-danger"></span>
</div>
<div class="mb-3">
<label asp-for="IPAddress" class="form-label"></label>
<input asp-for="IPAddress" class="form-control" />
<span asp-validation-for="IPAddress" class="text-danger"></span>
</div>
<div class="mb-4">
<label asp-for="Type" class="form-label"><i class="bi bi-hdd-network me-1"></i>Typ</label>
<select asp-for="Type" class="form-select">
<option>VPS</option>
<option>VM</option>
<option>Standalone</option>
</select>
</div>
</div>
</div>
<div class="mb-3">
<label asp-for="IPAddress"></label>
<input asp-for="IPAddress" class="form-control" />
<div class="card mb-4">
<div class="card-header">
<h4 class="mb-0">Grenzwerte festlegen</h4>
</div>
<div class="card-body">
<fieldset class="mb-4">
<legend class="h5 mb-3">CPU-Grenzwerte</legend>
<div class="row">
<div class="col-md-6">
<div class="mb-3">
<label asp-for="CPU_Load_Warning" class="form-label"><i class="bi bi-graph-up me-1"></i>Warnung bei Auslastung (%)</label>
<input asp-for="CPU_Load_Warning" class="form-control" placeholder="z.B. 80" />
<span asp-validation-for="CPU_Load_Warning" class="text-danger small"></span>
</div>
</div>
<div class="col-md-6">
<div class="mb-3">
<label asp-for="CPU_Load_Critical" class="form-label"><i class="bi bi-graph-up me-1"></i>Kritische Auslastung (%)</label>
<input asp-for="CPU_Load_Critical" class="form-control" placeholder="z.B. 95" />
<span asp-validation-for="CPU_Load_Critical" class="text-danger small"></span>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="mb-3">
<label asp-for="CPU_Temp_Warning" class="form-label"><i class="bi bi-thermometer-half me-1"></i>Warnung bei Temperatur (°C)</label>
<input asp-for="CPU_Temp_Warning" class="form-control" placeholder="z.B. 75" />
<span asp-validation-for="CPU_Temp_Warning" class="text-danger small"></span>
</div>
</div>
<div class="col-md-6">
<div class="mb-3">
<label asp-for="CPU_Temp_Critical" class="form-label"><i class="bi bi-thermometer-high me-1"></i>Kritische Temperatur (°C)</label>
<input asp-for="CPU_Temp_Critical" class="form-control" placeholder="z.B. 90" />
<span asp-validation-for="CPU_Temp_Critical" class="text-danger small"></span>
</div>
</div>
</div>
</fieldset>
<fieldset class="mb-4">
<legend class="h5 mb-3">RAM-Grenzwerte</legend>
<div class="row">
<div class="col-md-6">
<div class="mb-3">
<label asp-for="RAM_Load_Warning" class="form-label"><i class="bi bi-graph-up me-1"></i>Warnung bei Auslastung (%)</label>
<input asp-for="RAM_Load_Warning" class="form-control" placeholder="z.B. 85" />
<span asp-validation-for="RAM_Load_Warning" class="text-danger small"></span>
</div>
</div>
<div class="col-md-6">
<div class="mb-3">
<label asp-for="RAM_Load_Critical" class="form-label"><i class="bi bi-graph-up me-1"></i>Kritische Auslastung (%)</label>
<input asp-for="RAM_Load_Critical" class="form-control" placeholder="z.B. 98" />
<span asp-validation-for="RAM_Load_Critical" class="text-danger small"></span>
</div>
</div>
</div>
</fieldset>
<fieldset class="mb-4">
<legend class="h5 mb-3">Festplatten-Grenzwerte</legend>
<div class="row">
<div class="col-md-6">
<div class="mb-3">
<label asp-for="Disk_Usage_Warning" class="form-label"><i class="bi bi-disc-fill me-1"></i>Warnung bei Auslastung (%)</label>
<input asp-for="Disk_Usage_Warning" class="form-control" placeholder="z.B. 90" />
<span asp-validation-for="Disk_Usage_Warning" class="text-danger small"></span>
</div>
</div>
<div class="col-md-6">
<div class="mb-3">
<label asp-for="Disk_Usage_Critical" class="form-label"><i class="bi bi-disc-fill me-1"></i>Kritische Auslastung (%)</label>
<input asp-for="Disk_Usage_Critical" class="form-control" placeholder="z.B. 98" />
<span asp-validation-for="Disk_Usage_Critical" class="text-danger small"></span>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="mb-3">
<label asp-for="DISK_Temp_Warning" class="form-label"><i class="bi bi-thermometer-half me-1"></i>Warnung bei Temperatur (°C)</label>
<input asp-for="DISK_Temp_Warning" class="form-control" placeholder="z.B. 45" />
<span asp-validation-for="DISK_Temp_Warning" class="text-danger small"></span>
</div>
</div>
<div class="col-md-6">
<div class="mb-3">
<label asp-for="DISK_Temp_Critical" class="form-label"><i class="bi bi-thermometer-high me-1"></i>Kritische Temperatur (°C)</label>
<input asp-for="DISK_Temp_Critical" class="form-control" placeholder="z.B. 55" />
<span asp-validation-for="DISK_Temp_Critical" class="text-danger small"></span>
</div>
</div>
</div>
</fieldset>
<fieldset class="mb-4">
<legend class="h5 mb-3">GPU-Grenzwerte</legend>
<div class="row">
<div class="col-md-6">
<div class="mb-3">
<label asp-for="GPU_Load_Warning" class="form-label"><i class="bi bi-graph-up me-1"></i>Warnung bei Auslastung (%)</label>
<input asp-for="GPU_Load_Warning" class="form-control" placeholder="z.B. 80" />
<span asp-validation-for="GPU_Load_Warning" class="text-danger small"></span>
</div>
</div>
<div class="col-md-6">
<div class="mb-3">
<label asp-for="GPU_Load_Critical" class="form-label"><i class="bi bi-graph-up me-1"></i>Kritische Auslastung (%)</label>
<input asp-for="GPU_Load_Critical" class="form-control" placeholder="z.B. 95" />
<span asp-validation-for="GPU_Load_Critical" class="text-danger small"></span>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="mb-3">
<label asp-for="GPU_Temp_Warning" class="form-label"><i class="bi bi-thermometer-half me-1"></i>Warnung bei Temperatur (°C)</label>
<input asp-for="GPU_Temp_Warning" class="form-control" placeholder="z.B. 70" />
<span asp-validation-for="GPU_Temp_Warning" class="text-danger small"></span>
</div>
</div>
<div class="col-md-6">
<div class="mb-3">
<label asp-for="GPU_Temp_Critical" class="form-label"><i class="bi bi-thermometer-high me-1"></i>Kritische Temperatur (°C)</label>
<input asp-for="GPU_Temp_Critical" class="form-control" placeholder="z.B. 85" />
<span asp-validation-for="GPU_Temp_Critical" class="text-danger small"></span>
</div>
</div>
</div>
</fieldset>
</div>
</div>
<div class="d-flex justify-content-end gap-2">
<button type="submit" class="btn btn-primary"><i class="bi bi-save me-1"></i>Speichern</button>
<a asp-action="Overview" class="btn btn-secondary"><i class="bi bi-x-circle me-1"></i>Abbrechen</a>
</div>
<div class="mb-3">
<label asp-for="Type"></label>
<input asp-for="Type" class="form-control" />
</div>
<button type="submit" class="btn btn-primary mt-3">Speichern</button>
<a asp-action="Overview" class="btn btn-secondary mt-3">Abbrechen</a>
</form>

View File

@@ -0,0 +1,67 @@
@model IEnumerable<Watcher.Models.Server>
<div class="container py-4">
<div class="row g-4">
@foreach (var s in Model)
{
<div class="col-12 col-sm-6">
<div class="card h-100 border-secondary shadow-sm">
<div class="card-body d-flex flex-column gap-3">
<div class="d-flex justify-content-between align-items-center mb-3">
<h5 class="card-title text-dark mb-0">
<i class="bi bi-pc-display me-2 text-muted"></i>(#@s.Id) @s.Name
</h5>
<span class="badge
@(s.IsOnline ? "bg-success text-light" : "bg-danger text-light")">
<i class="bi @(s.IsOnline ? "bi-check-circle" : "bi-x-circle") me-1"></i>
@(s.IsOnline ? "Online" : "Offline")
</span>
</div>
<div class="row mb-3">
<div class="col-md-5 text-muted small">
<div><i class="bi bi-globe me-1"></i><strong>IP:</strong> @s.IPAddress</div>
<div><i class="bi bi-pc-display me-1"></i><strong>Typ:</strong> @s.Type</div>
<div><i class="bi bi-calendar-check me-1"></i><strong>Erstellt:</strong>
@s.CreatedAt.ToLocalTime().ToString("dd.MM.yyyy HH:mm")</div>
<div><i class="bi bi-clock me-1"></i><strong>Last-Seen:</strong>
@s.LastSeen.ToLocalTime().ToString("dd.MM.yyyy HH:mm")</div>
<div><i class="bi bi-cpu me-1"></i><strong>CPU:</strong> @(s.CpuType ?? "not found") </div>
<div><i class="bi bi-cpu me-1"></i><strong>CPU-Kerne: </strong> @s.CpuCores </div>
<div><i class="bi bi-gpu-card me-1"></i><strong>GPU:</strong> @(s.GpuType ?? "not found")
</div>
<div><i class="bi bi-memory me-1"></i><strong>RAM:</strong> @(s.RamSize) </div>
<div><i class="bi bi-hdd me-1"></i><strong>Disk Space:</strong> ... </div>
</div>
</div>
<div class="d-flex flex-wrap gap-2">
<a asp-action="EditServer" asp-route-id="@s.Id" class="btn btn-outline-primary">
<i class="bi bi-pencil-square me-1"></i> Bearbeiten
</a>
<a asp-asp-controller="Server" asp-action="Details" asp-route-id="@s.Id"
class="btn btn-outline-primary">
<i class="bi bi-bar-chart-fill me-1"></i> Metrics
</a>
<a asp-asp-controller="Container" asp-action="Overview" asp-route-id="@s.Id"
class="btn btn-outline-primary">
<i class="bi bi-box-fill me-1"></i> Container
</a>
<form asp-action="Delete" asp-controller="Server" asp-route-id="@s.Id" method="post"
onsubmit="return confirm('Diesen Server wirklich löschen?');" class="m-0">
<button type="submit" class="btn btn-outline-danger">
<i class="bi bi-trash me-1"></i> Löschen
</button>
</form>
</div>
</div>
</div>
</div>
}
</div>
</div>

View File

@@ -3,46 +3,39 @@
ViewData["Title"] = "Serverübersicht";
}
<div class="flex items-center justify-between mb-6">
<h1 class="text-2xl font-bold">Serverübersicht</h1>
<a asp-controller="Server" asp-action="AddServer"
class="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700">
+ Server hinzufügen
</a>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
@foreach (var s in 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>
<div class="d-flex align-items-center justify-content-between mb-4">
<h1 class="h2 fw-bold mb-0">
<i class="bi bi-hdd-network me-2 text-primary"></i>Serverübersicht
</h1>
<form asp-action="AddServer" method="get" asp-controller="Server">
<button type="submit" class="btn btn-primary">
<i class="bi"></i> neuen Server erstellen
</button>
</form>
</div>
</div>
}
</div>
<div id="server-cards-container">
@await Html.PartialAsync("_ServerCard", Model.Servers)
</div>
@section Scripts {
<script>
async function loadServerCards() {
try {
const response = await fetch('/Server/ServerCardPartial');
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,12 +14,13 @@
<head>
<meta charset="utf-8" />
<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 href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet">
<style>
body {
overflow: hidden;
overflow-y: auto;
}
.sidebar {
@@ -59,33 +60,40 @@
<body>
<div class="sidebar">
<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">
<li class="nav-item">
<a class="nav-link" href="/">Dashboard</a>
</li>
<li class="nav-item"></li>
<a class="nav-link" href="/Uptime">Uptime</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/Server/Overview">Servers</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/Container/Overview">Container</a>
</li>
<!-- Noch nicht implementiert
<li class="nav-item"></li>
<a class="nav-link" href="/Uptime/Overview">Uptime</a>
</li>
-->
</ul>
</div>
<div class="account-box mt-auto">
@if (User.Identity?.IsAuthenticated ?? false)
{
<a href="/Auth/Info" class="d-block text-decoration-none text-light">
<a href="/User/Info" class="d-block text-decoration-none text-light">
<div class="d-flex align-items-center gap-2">
<div class="rounded-circle bg-secondary text-white px-2 py-1">
<i class="bi bi-person"></i>
</div>
<div>
<strong>@User.Claims.FirstOrDefault(c => c.Type == "name")?.Value</strong><br />
<strong>@User.Identity?.Name</strong><br />
<small class="text-muted">Profil ansehen</small>
</div>
</div>

View File

@@ -1,6 +1,11 @@
/* 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. */
html, body {
min-height: 100vh;
overflow-y: auto;
}
a.navbar-brand {
white-space: normal;
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

View File

@@ -0,0 +1,99 @@
@{
ViewData["Title"] = "Account Info";
var pictureUrl = User.Claims.FirstOrDefault(c => c.Type == "picture")?.Value ?? "";
var Id = ViewBag.Id;
var preferredUsername = ViewBag.name;
var IdProvider = ViewBag.IdProvider;
}
<div class="container mt-5">
<div class="card shadow-lg rounded-3 p-4" style="max-width: 700px; margin: auto;">
<div class="text-center mb-4">
@if (!string.IsNullOrEmpty(pictureUrl))
{
<img src="@pictureUrl" alt="Profilbild" class="rounded-circle shadow" style="width: 120px; height: 120px; object-fit: cover;" />
}
else
{
<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>
</div>
}
<h3 class="mt-3">
<i class="bi bi-person-circle me-1"></i>@preferredUsername
</h3>
</div>
<table class="table table-hover">
<tbody>
<tr>
<th><i class="bi bi-person-badge me-1"></i>Username</th>
<td>@preferredUsername</td>
</tr>
<tr>
<th><i class="bi bi-envelope me-1"></i>E-Mail</th>
<td>@(ViewBag.Mail ?? "Nicht verfügbar")</td>
</tr>
<tr>
<th><i class="bi bi-fingerprint me-1"></i>Benutzer-ID</th>
<td>@(ViewBag.Id ?? "Nicht verfügbar")</td>
</tr>
@if(IdProvider != "local")
{
<tr>
<th><i class="bi bi-clock-history me-1"></i>Login-Zeit</th>
<td>
@(User.FindFirst("iat") != null
? DateTimeOffset.FromUnixTimeSeconds(long.Parse(User.FindFirst("iat").Value)).ToLocalTime().ToString()
: "Nicht verfügbar")
</td>
</tr>
<tr>
<th><i class="bi bi-hourglass-split me-1"></i>Token läuft ab</th>
<td>
@(User.FindFirst("exp") != null
? DateTimeOffset.FromUnixTimeSeconds(long.Parse(User.FindFirst("exp").Value)).ToLocalTime().ToString()
: "Nicht verfügbar")
</td>
</tr>
<tr>
<th><i class="bi bi-shield-lock me-1"></i>Rollen</th>
<td>
@{
var roles = User.FindAll("role").Select(r => r.Value);
if (!roles.Any())
{
<span class="text-muted">Keine Rollen</span>
}
else
{
<ul class="mb-0">
@foreach (var role in roles)
{
<li><i class="bi bi-tag me-1 text-primary"></i>@role</li>
}
</ul>
}
}
</td>
</tr>
}
</tbody>
</table>
<div>
<form method="get" asp-controller="User" asp-action="UserSettings" class="text-center mt-4">
<button type="submit" class="btn btn-info">
<i class="bi bi-gear-wide-connected me-1"></i>Einstellungen
</button>
</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>

View File

@@ -0,0 +1,155 @@
@{
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="User">
<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</h4>
<h5>Benachrichtigungen: </h5>
<p>Registrierte E-Mail Adresse: <strong>@(ViewBag.mail ?? "nicht gefunden")</strong></p>
<!-- action="/Notification/UpdateSettings" existiert noch nicht-->
<form method="post" action="#">
<div class="card p-4 shadow-sm" style="max-width: 500px;">
<h5 class="card-title mb-3">
<i class="bi bi-bell me-2"></i>Benachrichtigungseinstellungen
</h5>
<div class="form-check form-switch mb-3">
<input class="form-check-input" type="checkbox" id="notifyOffline" name="NotifyOffline" checked>
<label class="form-check-label" for="notifyOffline">Benachrichtigung bei Server-Offline</label>
</div>
<div class="form-check form-switch mb-3">
<input class="form-check-input" type="checkbox" id="notifyUpdates" name="NotifyUpdates">
<label class="form-check-label" for="notifyUpdates">Benachrichtigung bei neuen Updates</label>
</div>
<div class="form-check form-switch mb-3">
<input class="form-check-input" type="checkbox" id="notifyUser" name="NotifyUser">
<label class="form-check-label" for="notifyUser">Benachrichtigung bei neuen Benutzern</label>
</div>
<div class="form-check form-switch mb-3">
<input class="form-check-input" type="checkbox" id="notifyMaintenance" name="NotifyMaintenance">
<label class="form-check-label" for="notifyMaintenance">Wartungsinformationen erhalten</label>
</div>
<button type="submit" class="btn btn-primary mt-3">
<i class="bi bi-save me-1"></i>Speichern
</button>
</div>
</form>
<hr class="my-4" />
</div>
</div>

View File

@@ -1,3 +1,4 @@
@{
Layout = "_Layout";
}
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

View File

@@ -8,7 +8,12 @@
<ItemGroup>
<!-- 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" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="9.0.8" />
<!-- Pomelo MySQL EF Core Provider -->
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.0" />
@@ -16,6 +21,8 @@
<!-- Auth via OpenID Connect + Cookies -->
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.6" />
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
</ItemGroup>
</Project>

View File

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

View File

@@ -0,0 +1 @@

View File

@@ -1,22 +1,66 @@
html {
font-size: 14px;
}
@media (min-width: 768px) {
html {
font-size: 16px;
}
}
.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%;
:root {
--color-bg: #0d1b2a;
--color-surface: #1b263b;
--color-accent: #415a77;
--color-primary: #0d6efd;
--color-text: #ffffff;
--color-muted: #c0c0c0;
--color-success: #14a44d;
--color-danger: #ff6b6b;
}
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.

View File

View File

@@ -1,4 +0,0 @@
// 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.
// Write your JavaScript code.

18
docker-compose.yaml Normal file
View File

@@ -0,0 +1,18 @@
services:
watcher:
image: git.triggermeelmo.com/daniel-hbn/watcher/watcher:development
container_name: watcher
restart: unless-stopped
env_file: .env
ports:
- "5000:5000"
volumes:
- ./data:/app/persistence
- ./dumps:/app/wwwroot/downloads/sqlite
- ./logs:/app/logs
healthcheck:
test: "curl -f http://localhost:5000"
interval: 1m30s
timeout: 30s
retries: 5
start_period: 30s