62 lines
1.7 KiB
C#
62 lines
1.7 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Watcher.Data;
|
|
using Watcher.Services;
|
|
using Watcher.ViewModels;
|
|
|
|
namespace Watcher.Controllers;
|
|
|
|
[Authorize]
|
|
[Route("[controller]")]
|
|
public class SystemController : Controller
|
|
{
|
|
private readonly AppDbContext _context;
|
|
private readonly ILogger<SystemController> _logger;
|
|
private readonly IVersionService _versionService;
|
|
|
|
public SystemController(AppDbContext context, ILogger<SystemController> logger, IVersionService versionService)
|
|
{
|
|
_context = context;
|
|
_logger = logger;
|
|
_versionService = versionService;
|
|
}
|
|
|
|
// Edit-Form anzeigen
|
|
[HttpGet("Settings")]
|
|
//public async Task<IActionResult> Settings()
|
|
public IActionResult Settings()
|
|
{
|
|
ViewBag.DbProvider = "SQLite";
|
|
ViewBag.mail = "test@mail.com";
|
|
ViewBag.IdentityProvider = "Local";
|
|
ViewBag.ServerVersion = _versionService.GetVersion();
|
|
|
|
// Datenbankgröße ermitteln
|
|
try
|
|
{
|
|
var dbPath = "./persistence/watcher.db";
|
|
if (System.IO.File.Exists(dbPath))
|
|
{
|
|
var fileInfo = new System.IO.FileInfo(dbPath);
|
|
var sizeInMiB = fileInfo.Length / (1024.0 * 1024.0);
|
|
ViewBag.DatabaseSize = $"{sizeInMiB:F2} MiB";
|
|
}
|
|
else
|
|
{
|
|
ViewBag.DatabaseSize = "Nicht gefunden";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Fehler beim Ermitteln der Datenbankgröße.");
|
|
ViewBag.DatabaseSize = "Fehler beim Laden";
|
|
}
|
|
|
|
return View();
|
|
}
|
|
|
|
// HttpPost
|
|
// public IActionResult UpdateNotifications(){}
|
|
|
|
}
|