Partials erstellt und auto-repload auf 30 Sekunden Interval gesetzt

This commit is contained in:
2025-06-20 20:29:33 +02:00
parent 416a635610
commit 357cbb5b82
6 changed files with 151 additions and 134 deletions

View File

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