cs2-web/Pages/Server.cshtml
Kamal Tufekcic 2d966b8198 initial commit
2026-07-05 12:14:39 +03:00

71 lines
2.3 KiB
Text

@page "/s/{id}"
@using CsWeb.Services
@model ServerModel
@{
var s = Model.Status!;
var d = s.Data;
var title = d?.Hostname is { Length: > 0 } h ? h : Model.Id;
ViewData["Title"] = title;
var ogDesc = d is null
? "Outnumbered CS2 server"
: $"{Fmt.ModeName(d.Mode)} on {d.Map} — {d.Humans.Count}/{d.MaxHumans} players, {d.Bots} bots."
+ (Fmt.ExtraLine(d) is { Length: > 0 } ex ? $" {ex}." : "");
}
@section Meta {
<meta property="og:title" content="@title" />
<meta property="og:description" content="@ogDesc" />
<meta property="og:type" content="website" />
}
<h1>@title</h1>
<p class="muted">
<span class="badge mode">@Fmt.ModeName(d?.Mode)</span>
@if (!s.Online) { <span class="badge off">@Fmt.Age(s)</span> }
</p>
@if (d is null)
{
<div class="notice err">This server hasn't reported yet. If it just started, give it a few seconds.</div>
}
else
{
<div class="row">
<p>
Map <code>@d.Map</code> · @d.Humans.Count/@d.MaxHumans players · @d.Bots bots
@if (Fmt.ExtraLine(d) is { Length: > 0 } extra) { <span> · @extra</span> }
</p>
</div>
@if (d.Port > 0)
{
<p>
<a class="btn" href="steam://connect/@Model.Fleet.PublicHost:@d.Port">Join now</a>
&nbsp; or paste in console: <span class="connect">connect @Model.Fleet.PublicHost:@d.Port</span>
</p>
}
@if (d.Humans.Count > 0)
{
<h2>Players</h2>
<div class="tablewrap">
<table>
<tr>
<th>Name</th><th class="num">Level</th><th class="num">Prestige</th>
<th class="num">K</th><th class="num">D</th><th class="num">Streak</th>
@if (d.Mode == "gungame") { <th>Weapon</th> }
</tr>
@foreach (var p in d.Humans)
{
<tr>
<td>@p.Name</td><td class="num">@p.Level</td><td class="num">@p.Prestige</td>
<td class="num">@p.Kills</td><td class="num">@p.Deaths</td><td class="num">@p.Streak</td>
@if (d.Mode == "gungame") { <td>@(Fmt.RungWeapon(d, p) ?? "—")</td> }
</tr>
}
</table>
</div>
}
else
{
<p class="muted">Nobody in game right now — free server, all yours.</p>
}
}