initial commit

This commit is contained in:
Kamal Tufekcic 2026-07-05 12:14:39 +03:00
commit 2d966b8198
28 changed files with 2901 additions and 0 deletions

21
Pages/Index.cshtml.cs Normal file
View file

@ -0,0 +1,21 @@
using CsWeb.Services;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace CsWeb.Pages;
public class IndexModel(Fleet fleet) : PageModel
{
public Fleet Fleet => fleet;
public List<(string Id, Cached<StatusPayload> Status)> Servers { get; private set; } = [];
public int HumansOnline { get; private set; }
public int ServersUp { get; private set; }
public async Task OnGetAsync()
{
var ids = fleet.Instances();
var fetched = await Task.WhenAll(ids.Select(fleet.Status));
Servers = ids.Zip(fetched, (id, s) => (id, s)).ToList();
HumansOnline = Servers.Sum(s => s.Status.Online ? s.Status.Data?.Humans.Count ?? 0 : 0);
ServersUp = Servers.Count(s => s.Status.Online);
}
}