<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:mo="https://gitee.com/aun/Timo">
<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})">
    <link rel="stylesheet" th:href="@{/lib/zTree_v3/css/zTreeStyle/zTreeStyle.css}" type="text/css">
</head>
<body class="timo-layout-page">
<div class="layui-card">
    <div class="layui-card-header timo-card-header">
        <span><i class="fa fa-bars"></i> 应用状态</span>
        <i class="layui-icon layui-icon-refresh refresh-btn"></i>
    </div>
    <div class="layui-card-body">
        <div class="layui-row timo-card-screen put-row">
            <div class="pull-left layui-form-pane">
                <div class="layui-inline">
                    <label class="layui-form-label">环境</label>
                    <div class="layui-input-block timo-search-status">
                        <select id="getPageByEnv" class="timo-search-select" name="env" onchange="getPageByEnv()"
                                mo:dict="ENVIRONMENT" mo-selected="${env}"></select>
                    </div>
                </div>
                <div class="layui-inline timo-search-box">
                    <label class="layui-form-label">应用名</label>
                    <div class="layui-input-block">
                        <input type="text" name="appName" th:value="${param.appName}" placeholder="请输入应用名"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn timo-search-btn">
                        <i class="fa fa-search"></i>
                    </button>
                </div>
            </div>
            <div class="pull-right screen-btn-group">
                <div class="btn-group-right">
                    <a class="ajax-post" th:href="@{'/api/app/status/refresh'}">刷新状态列表</a>
                </div>
            </div>
        </div>
        <div class="timo-table-wrap">
            <table class="layui-table timo-table">
                <thead>
                <tr>
                    <th class="timo-table-checkbox">
                        <label class="timo-checkbox"><input type="checkbox">
                            <i class="layui-icon layui-icon-ok"></i></label>
                    </th>
                    <th class="sortable" data-field="appName">应用</th>
                    <th class="sortable" data-field="machineIpv4">机器地址</th>
                    <th class="sortable" data-field="httpPort">HTTP 端口</th>
                    <th class="sortable" data-field="healthCheck">健康检查地址</th>
                    <th class="sortable" data-field="packagePath">包路径</th>
                    <th class="sortable" data-field="isRunning">运行状态</th>
                    <th class="sortable" data-field="startTime">启动时间</th>
                    <th class="sortable" data-field="pid">PID</th>
                    <th class="sortable" data-field="lastCheck">上次健康检查</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="item:${list}">
                    <td><label class="timo-checkbox"><input type="checkbox" th:value="${item.appId}">
                        <i class="layui-icon layui-icon-ok"></i></label></td>
                    <td>
                        <a class="open-popup" data-title="应用配置详情" data-size="1000,500" href="#"
                           th:text="${item.appName}" th:attr="data-url=@{'/app/config/app/detail/'+${item.appId}}"></a>
                    </td>
                    <td th:text="${item.machineIpv4}">机器地址</td>
                    <td th:text="${item.httpPort}">HTTP 端口</td>
                    <td th:text="${item.healthCheck}">健康检查地址</td>
                    <td th:text="${item.packagePath}">包路径</td>
                    <td th:text="${item.isRunning}">运行状态</td>
                    <td th:text="${item.startTime}">启动时间</td>
                    <td th:text="${item.pid}">PID</td>
                    <td th:text="${item.lastCheck}">上次健康检查</td>
                    <td>
                        <a class="open-popup" data-title="应用日志"
                           th:attr="data-url=@{'/app/status/applog/'+${item.appId}+'/'+${item.machineId}}"
                           data-size="1000,500" href="#">日志</a>
                        <a class="ajax-post" th:href="@{'/api/app/status/restart/'+${item.appId}+'/'+${item.machineId}}">重启</a>
                        <a class="ajax-post" th:href="@{'/api/app/status/stop/'+${item.appId}+'/'+${item.machineId}}">停止</a>
                        <a class="ajax-post" th:href="@{'/api/app/status/start/'+${item.appId}+'/'+${item.machineId}}">启动</a>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
        <div th:replace="/common/fragment :: page"></div>
    </div>
</div>
<script th:replace="/common/template :: script"></script>
</body>
</html>