Container-Übersicht
This commit is contained in:
@@ -29,32 +29,4 @@ public class ContainerController : Controller
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
@@ -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; }
|
||||
}
|
||||
|
@@ -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>
|
@@ -3,33 +3,14 @@
|
||||
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)
|
||||
{
|
||||
<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>
|
||||
|
||||
<p class="text-sm text-gray-600"><strong>Status:</strong> @(container.IsRunning ? "online" : "offline")</p>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
@@ -30,14 +30,6 @@
|
||||
<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 class="col-md-7">
|
||||
<div class="card bg-secondary text-white p-3 h-100 d-flex flex-column justify-content-center align-items-center">
|
||||
<h6 class="mb-3"><i class="bi bi-graph-up me-2"></i>Metrics letzte 24h</h6>
|
||||
<div style="width: 100%; height: 250px;">
|
||||
<canvas id="uptimeChart-@s.Id"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex flex-wrap gap-2">
|
||||
|
@@ -73,10 +73,10 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/Server/Overview">Servers</a>
|
||||
</li>
|
||||
<!-- Noch nicht implementiert
|
||||
<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>
|
||||
|
Reference in New Issue
Block a user