<!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})"></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="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="machineIpv4" th:value="${param.machineIpv4}" 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>
        </div>
        <div class="timo-table-wrap">
            <table class="layui-table timo-table">
                <thead>
                    <tr>
                        <th data-field="machineIpv4">机器地址</th>
                        <th data-field="status">当前状态</th>
                        <th data-field="status">系统负载</th>
                        <th data-field="lastCheck">网络状态</th>
                        <th data-field="memAvail">CPU 使用率</th>
                        <th data-field="memAvail">内存详情</th>
                        <th data-field="diskAvail">磁盘详情</th>
                    </tr>
                </thead>
                <tbody>
                    <tr th:each="item:${list}">
                        <td th:text="${item.machineIpv4}">机器地址</td>
                        <td th:text="${item.status}">当前状态</td>
                        <td>
                            <a class="open-popup" data-title="系统负载"
                               th:attr="data-url=@{'/machine/status/sys/'+${item.machineId}}"
                               href="#">查看</a>
                        </td>
                        <td>
                            <a class="open-popup" data-title="网络状态"
                               th:attr="data-url=@{'/machine/status/network/'+${item.machineId}}" data-size="1200,600"
                               href="#">查看</a>
                        </td>
                        <td>
                            <a class="open-popup" data-title="CPU 使用率"
                               th:attr="data-url=@{'/machine/status/cpu/'+${item.machineId}}" href="#">查看</a>
                        </td>
                        <td>
                            <a class="open-popup" data-title="内存详情"
                               th:attr="data-url=@{'/machine/status/mem/'+${item.machineId}}" href="#">查看</a>
                        </td>
                        <td>
                            <a class="open-popup" data-title="磁盘详情"
                               th:attr="data-url=@{'/machine/status/disk/'+${item.machineId}}" href="#">查看</a>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <div th:replace="/common/fragment :: page"></div>
    </div>
</div>

<script th:replace="/common/template :: script"></script>
<script type="text/javascript" th:src="@{/js/plugins/jquery-2.2.4.min.js}"></script>
<script type="text/javascript">
    function getPageByEnv() {
        var selectedOption = $("#getPageByEnv option:selected")
        var param = selectedOption.text()
        url = '?env=' + param
        window.location.href = window.location.pathname + url;
    }
</script>
</body>
</html>