57 lines
1.7 KiB
C#
57 lines
1.7 KiB
C#
using System.Diagnostics;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using watcher_monitoring.Models;
|
|
|
|
using watcher_monitoring.Data;
|
|
|
|
namespace watcher_monitoring.Controllers;
|
|
|
|
public class HomeController : Controller
|
|
{
|
|
private readonly WatcherDbContext _dbContext;
|
|
private readonly ILogger<HomeController> _logger;
|
|
|
|
public HomeController(ILogger<HomeController> logger, WatcherDbContext dbContext)
|
|
{
|
|
_logger = logger;
|
|
_dbContext = dbContext;
|
|
}
|
|
|
|
// Dashboard
|
|
public IActionResult Index()
|
|
{
|
|
var servers = new List<dynamic>
|
|
{
|
|
new { Name = "Web Server 01", IPAddress = "192.168.1.10", IsOnline = true },
|
|
new { Name = "Database Server", IPAddress = "192.168.1.20", IsOnline = true },
|
|
new { Name = "API Gateway", IPAddress = "192.168.1.30", IsOnline = true },
|
|
new { Name = "Cache Server", IPAddress = "192.168.1.40", IsOnline = false },
|
|
new { Name = "Backup Server", IPAddress = "192.168.1.50", IsOnline = true }
|
|
};
|
|
|
|
ViewBag.TotalServers = servers.Count;
|
|
ViewBag.OnlineServers = servers.Count(s => s.IsOnline);
|
|
ViewBag.OfflineServers = servers.Count(s => !s.IsOnline);
|
|
ViewBag.ServiceCount = 8;
|
|
ViewBag.Servers = servers;
|
|
|
|
return View();
|
|
}
|
|
|
|
public IActionResult Privacy()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public IActionResult SystemInformation()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
|
public IActionResult Error()
|
|
{
|
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
|
}
|
|
}
|