节点在线、应用在线、配置在线使用令牌查询
大石头 authored at 2021-12-16 19:49:30
3.82 KiB
Stardust
@model PickerPageModel
@using Stardust.Web.Models.Dashboard
@{
    Layout = "~/Views/Shared/_Layout_Dashboard.cshtml";
}
<div class="scope-notice">
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
        <path d="M12 3l9 4v6c0 4.6-3.4 7.4-9 8-5.6-.6-9-3.4-9-8V7z" /><path d="M12 9v4M12 16h.01" />
    </svg>
    <span class="notice--limited">当前为受限数据视角:仅显示你被授权的节点。</span>
    <span class="notice--none">当前账号未授权任何项目。</span>
</div>

<section class="scope-empty">
    <div class="scope-empty__icon">
        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6">
            <rect x="4" y="10" width="16" height="10" rx="2" /><path d="M8 10V7a4 4 0 0 1 8 0v3" /><path d="M12 14v3" />
        </svg>
    </div>
    <h2>暂无授权项目</h2>
    <p>你的账号还没有被加入任何项目。请联系项目管理员在「项目成员」中授权。</p>
    <a class="btn btn--primary" href="/Platform/ProjectUser">去申请项目权限</a>
</section>

<section class="scope-bar">
    <div>
        <div class="crumbs"><a href="/Dashboard/System">看板总览</a><span class="sep">/</span><span>节点</span></div>
        <h1 class="page-title">@Model.Title</h1>
        <p class="page-sub">@Model.Subtitle · 当前在线 <strong>@Model.Nodes.Count</strong> 台</p>
    </div>
    <div class="toolbar">
        <a class="btn" href="/Nodes/Node">节点管理</a>
        <a class="btn btn--primary" href="/Dashboard/System">返回系统看板</a>
    </div>
</section>

<section class="sd-card col-24">
    <div class="sd-card__head">
        <h2 class="sd-card__title">在线节点</h2>
        <span class="sd-card__hint">按 CPU 使用率排序 · 点击进入节点看板</span>
    </div>
    <div class="table-wrap table-wrap--scroll" style="max-height:640px;">
        <table class="sd-table sd-table--compact">
            <thead>
                <tr>
                    <th>节点</th>
                    <th>机房</th>
                    <th class="num">CPU</th>
                    <th class="num">内存</th>
                    <th class="num">磁盘</th>
                    <th>水位</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var node in Model.Nodes)
                {
                    <tr class="row-link" onclick="location.href='@node.Url'">
                        <td>
                            <div class="strong">@node.Name</div>
                            <div class="muted mono">@(node.Ip.IsNullOrEmpty() ? "—" : node.Ip)</div>
                        </td>
                        <td class="muted">@(node.Location.IsNullOrEmpty() ? "未标注" : node.Location)</td>
                        <td class="num">@node.Cpu.ToString("n0")%</td>
                        <td class="num">@node.Memory.ToString("n0")%</td>
                        <td class="num">@node.Disk.ToString("n0")%</td>
                        <td>
                            <div class="meter @(DashboardMath.Level(Math.Max(node.Cpu, Math.Max(node.Memory, node.Disk))) == "ok" ? "meter--ok" : DashboardMath.Level(Math.Max(node.Cpu, Math.Max(node.Memory, node.Disk))) == "warn" ? "meter--warn" : "meter--bad")" style="width:90px">
                                <i style="width:@(Math.Min(Math.Max(node.Cpu, Math.Max(node.Memory, node.Disk)), 100))%"></i>
                            </div>
                        </td>
                    </tr>
                }
                @if (Model.Nodes.Count == 0)
                {
                    <tr><td colspan="6"><div class="empty" style="padding:24px;"><div class="empty__title">暂无在线节点</div><div class="empty__desc">节点安装 StarAgent 并启动后自动出现</div></div></td></tr>
                }
            </tbody>
        </table>
    </div>
</section>