diff --git a/watcher-monitoring/Controllers/MonitoringController.cs b/watcher-monitoring/Controllers/MonitoringController.cs index 03be13a..aa11dee 100644 --- a/watcher-monitoring/Controllers/MonitoringController.cs +++ b/watcher-monitoring/Controllers/MonitoringController.cs @@ -1,7 +1,11 @@ -using Microsoft.AspNetCore.Mvc; +using System.Diagnostics; using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using watcher_monitoring.Models; using watcher_monitoring.Data; +using watcher_monitoring.ViewModels; +using Microsoft.EntityFrameworkCore; namespace watcher_monitoring.Controllers; @@ -28,7 +32,12 @@ public class MonitoringController : Controller [HttpGet("server")] public async Task ServerIndex() { - return View(); + var ServerIndexViewModel = new ServerIndexViewModel + { + servers = await _context.Servers.ToListAsync() + }; + + return View(ServerIndexViewModel); } } \ No newline at end of file diff --git a/watcher-monitoring/ViewModels/ServerIndexViewModel.cs b/watcher-monitoring/ViewModels/ServerIndexViewModel.cs new file mode 100644 index 0000000..ab2dd60 --- /dev/null +++ b/watcher-monitoring/ViewModels/ServerIndexViewModel.cs @@ -0,0 +1,10 @@ +using watcher_monitoring.Data; +using watcher_monitoring.Models; + +namespace watcher_monitoring.ViewModels; + +public class ServerIndexViewModel +{ + public List servers { get; set; } = new(); + +} \ No newline at end of file diff --git a/watcher-monitoring/Views/Monitoring/ServerIndex.cshtml b/watcher-monitoring/Views/Monitoring/ServerIndex.cshtml index 819fb99..b6b3abf 100644 --- a/watcher-monitoring/Views/Monitoring/ServerIndex.cshtml +++ b/watcher-monitoring/Views/Monitoring/ServerIndex.cshtml @@ -11,251 +11,48 @@
- -
-
-
-
-

test

- 192.168.1.100 -
- Online -
- -
- -
-
- CPU Load - 400% + @foreach (var server in Model.servers) + { +
+
+
+
+

@server.Name

+ @server.IPAddress
- + @server.State
- -
-
- RAM Load - 400 MB +
+ +
+
+ CPU Load + 400% +
+
- -
- -
-
- Uptime - 400 days + +
+
+ RAM Load + 400 MB +
+ +
+ + +
+
+ Uptime + 400 days +
-
- - -
-
-
-
-

test

- 192.168.1.101 -
- Online -
- -
- -
-
- CPU Load - 400% -
- -
- - -
-
- RAM Load - 400 MB -
- -
- - -
-
- Uptime - 400 days -
-
-
-
-
- - -
-
-
-
-

test

- 192.168.1.102 -
- Warning -
- -
- -
-
- CPU Load - 400% -
- -
- - -
-
- RAM Load - 400 MB -
- -
- - -
-
- Uptime - 400 days -
-
-
-
-
- - -
-
-
-
-

test

- 192.168.1.103 -
- Online -
- -
- -
-
- CPU Load - 400% -
- -
- - -
-
- RAM Load - 400 MB -
- -
- - -
-
- Uptime - 400 days -
-
-
-
-
- - -
-
-
-
-

test

- 192.168.1.104 -
- Offline -
- -
- -
-
- CPU Load - 400% -
- -
- - -
-
- RAM Load - 400 MB -
- -
- - -
-
- Uptime - 400 days -
-
-
-
-
- - -
-
-
-
-

test

- 192.168.1.105 -
- Online -
- -
- -
-
- CPU Load - 400% -
- -
- - -
-
- RAM Load - 400 MB -
- -
- - -
-
- Uptime - 400 days -
-
-
-
-
+ }
@@ -346,7 +143,7 @@ } // Auto-refresh every 30 seconds - setInterval(function() { + setInterval(function () { location.reload(); }, 30000); @@ -395,4 +192,4 @@ max-height: 50px !important; margin-top: 0.5rem; } - + \ No newline at end of file