CRUD-Operation für Server implementiert

This commit is contained in:
2025-06-15 14:20:21 +02:00
parent f362dc9e3a
commit 1f1a1fddbd
10 changed files with 507 additions and 74 deletions

View File

@@ -5,7 +5,8 @@
<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">
<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>
@@ -13,31 +14,35 @@
<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.Name</h2>
<p class="text-sm text-gray-500">@s.Hostname</p>
@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.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>
<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> Ip</div>
<div><strong>Typ:</strong> @s.Type</div>
<div><strong>Status:</strong> @(string.IsNullOrEmpty(s.Status) ? "-" : s.Status)</div>
<div><strong>Erstellt:</strong> @s.CreatedAt.ToLocalTime().ToString("dd.MM.yyyy HH:mm")</div>
</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="Edit" asp-route-id="@s.Id" class="text-blue-600 hover:underline text-sm">Bearbeiten</a>
<a asp-action="Delete" asp-route-id="@s.Id" class="text-red-600 hover:underline text-sm">Löschen</a>
<div class="mt-4 flex justify-end gap-2">
<a asp-action="EditServer" asp-route-id="@s.Id" class="btn btn-sm btn-primary">Bearbeiten</a>
<form asp-action="Delete" asp-route-id="@s.Id" method="post"
onsubmit="return confirm('Diesen Server wirklich löschen?');">
<button type="submit" class="text-red-600 hover:text-red-800 font-semibold">Löschen</button>
</form>
</div>
</div>
</div>
}
}
</div>