节点在线、应用在线、配置在线使用令牌查询
大石头 authored at 2021-12-16 19:49:30
6.86 KiB
Stardust
@model IList<AppDeployNode>
@using Stardust.Data.Deployment
@using NewLife;
@using NewLife.Web;
@using XCode;
@using XCode.Configuration;
@using XCode.Membership;
@using NewLife.Cube;
@{
    var fact = ViewBag.Factory as IEntityFactory;
    var page = ViewBag.Page as Pager;
    var fields = ViewBag.Fields as IList<FieldItem>;
    var ukey = fact.Unique;
    var set = ViewBag.PageSetting as PageSetting;
    //var provider = ManageProvider.Provider;

    var nodeId = Context.Request.Query["nodeId"].ToInt(0);
    var appId = Context.Request.Query["appId"].ToInt(0);
}
<table class="table table-bordered table-hover table-striped table-condensed">
    <thead>
        <tr>
            @if (set.EnableSelect && ukey != null)
            {
                <th class="text-center" style="width:10px;"><input type="checkbox" id="chkAll" title="@L.T("全选")" /></th>
            }
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("Id"))">@L.T("编号")</a></th>
            <th class="text-center" title="@L.T("默认为空,使用部署集上名字。可用于单节点多发布场景")"><a href="@Html.Raw(page.GetSortUrl("DeployName"))">@L.T("发布名")</a></th>
            @if (appId == 0)
            {
                <th class="text-center" title="@L.T("应用。原始应用")"><a href="@Html.Raw(page.GetSortUrl("DeployId"))">@L.T("应用")</a></th>
            }
            @if (nodeId == 0)
            {
                <th class="text-center" title="@L.T("节点。节点服务器")"><a href="@Html.Raw(page.GetSortUrl("NodeId"))">@L.T("节点")</a></th>
            }
            <th class="text-center" title="@L.T("IP地址")"><a href="@Html.Raw(page.GetSortUrl("IP"))">IP</a></th>
            <th class="text-center" title="@L.T("延迟。发布下去后,延迟执行时间,单位秒")"><a href="@Html.Raw(page.GetSortUrl("Delay"))">@L.T("延迟")</a></th>
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("Enable"))">@L.T("启用")</a></th>
            <th class="text-center" title="@L.T("进程")"><a href="@Html.Raw(page.GetSortUrl("ProcessId"))">@L.T("进程")</a></th>
            <th class="text-center" title="@L.T("进程时间")"><a href="@Html.Raw(page.GetSortUrl("StartTime"))">@L.T("进程时间")</a></th>
            <th class="text-center" title="@L.T("版本。当前使用的部署版本,点击发布后记录本次下发的版本,开启MultiVersion时可能不同节点使用不同版本")"><a href="@Html.Raw(page.GetSortUrl("Version"))">@L.T("版本")</a></th>
            <th class="text-center" title="@L.T("应用程序版本。该节点上应用在线实例上报的文件版本(应用入口程序集FileVersion),随心跳自动更新")"><a href="@Html.Raw(page.GetSortUrl("AppVersion"))">@L.T("应用程序版本")</a></th>
            <th class="text-center" title="@L.T("编译时间。客户端")"><a href="@Html.Raw(page.GetSortUrl("Compile"))">@L.T("编译时间")</a></th>
            <th class="text-center" title="@L.T("最后活跃。最后一次上报心跳的时间")"><a href="@Html.Raw(page.GetSortUrl("LastActive"))">@L.T("最后活跃")</a></th>
            <th class="text-center">@L.T("远程操作")</th>
            @if (this.Has(PermissionFlags.Detail, PermissionFlags.Update, PermissionFlags.Delete))
            {
                <th class="text-center">@L.T("操作")</th>
            }
        </tr>
    </thead>
    <tbody>
        @foreach (var entity in Model)
        {
            var name = entity.DeployName;
            if (name.IsNullOrEmpty()) name = entity.Deploy?.Name;
            <tr>
                @if (set.EnableSelect && ukey != null)
                {
                    <td class="text-center"><input type="checkbox" name="keys" value="@entity.Id" /></td>
                }
                <td class="text-center">@entity.Id</td>
                <td class="text-center">@entity.DeployName</td>
                @if (appId == 0)
                {
                    <td class="text-center"><a href="/Deployment/AppDeploy?Id=@entity.DeployId" target="_blank">@name</a></td>
                }
                @if (nodeId == 0)
                {
                    <td class="text-center"><a href="/Nodes/Node?Id=@entity.NodeId" target="_blank">@entity.NodeName</a></td>
                }
                <td class="text-center">@entity.IP</td>
                <td class="text-right">@entity.Delay</td>
                <td class="text-center">
                    <i class="glyphicon glyphicon-@(entity.Enable ? "ok" : "remove")" style="color: @(entity.Enable ? "green" : "red");"></i>
                </td>
                <td>@entity.ProcessId</td>
                <td>@entity.StartTime.ToFullString("")</td>
                <td>@entity.Version</td>
                <td>@entity.AppVersion</td>
                <td>@entity.Compile.ToFullString("")</td>
                <td>@entity.LastActive.ToFullString("")</td>
                <td class="text-center">
                    <i class="glyphicon glyphicon-save" style="color: green;"></i>
                    <a data-action="action" data-url="@Url.Action("Operate", new { act = "install", id = entity.Id })" data-confirm="@L.T("危险操作!确认执行?")" title="@L.T("发布应用服务")">@L.T("发布")</a>
                    &nbsp;
                    <i class="glyphicon glyphicon-play" style="color: green;"></i>
                    <a data-action="action" data-url="@Url.Action("Operate", new { act = "start", id = entity.Id })" data-confirm="@L.T("危险操作!确认执行?")" title="@L.T("拉起应用服务")">@L.T("启动")</a>
                    &nbsp;
                    <i class="glyphicon glyphicon-stop" style="color: red;"></i>
                    <a data-action="action" data-url="@Url.Action("Operate", new { act = "stop", id = entity.Id })" data-confirm="@L.T("危险操作!确认执行?")" title="@L.T("终止应用服务")">@L.T("终止")</a>
                    &nbsp;
                    <i class="glyphicon glyphicon-refresh" style="color: coral;"></i>
                    <a data-action="action" data-url="@Url.Action("Operate", new { act = "restart", id = entity.Id })" data-confirm="@L.T("危险操作!确认执行?")" title="@L.T("重启应用服务")">@L.T("重启")</a>
                    &nbsp;
                    <i class="glyphicon glyphicon-remove" style="color: red;"></i>
                    <a data-action="action" data-url="@Url.Action("Operate", new { act = "uninstall", id = entity.Id })" data-confirm="@L.T("危险操作!确认执行?")" title="@L.T("卸载应用服务")">@L.T("卸载")</a>
                </td>
                @if (this.Has(PermissionFlags.Detail, PermissionFlags.Update, PermissionFlags.Delete))
                {
                    <td class="text-center">
                        @await Html.PartialAsync("_List_Data_Action", (Object)entity)
                    </td>
                }
            </tr>
        }
    </tbody>
</table>