<!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="username" th:value="${param.username}" 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">
                    <div class="btn-group-right">
                        <div class="btn-group">
                            <button class="layui-btn">批量处理<span class="caret"></span></button>
                            <dl class="layui-nav-child layui-anim layui-anim-upbit">
                                <dd><a class="ajax-status" th:href="@{/api/machine/host/delete}">批量删除</a></dd>
                            </dl>
                        </div>
                    </div>
                </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 data-field="avatarUrl">头像</th>
                    <th data-field="userId">用户 ID</th>
                    <th data-field="screenName">用户名</th>
                    <th data-field="gender">性别</th>
                    <th data-field="signature">签名</th>
                    <th data-field="following">关注</th>
                    <th data-field="follower">粉丝</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="item:${list}">
                    <td><label class="timo-checkbox"><input type="checkbox" th:value="${item.userId}">
                        <i class="layui-icon layui-icon-ok"></i></label></td>
                    <td>
                        <img class="layui-side-user-avatar" data-size="320,240" th:src="@{${item.avatarUrl}}" alt="头像">
                    </td>
                    <td th:text="${item.userId}"></td>
                    <td th:text="${item.screenName}"></td>
                    <!--<td class="machine-status" th:text="${item.status}">当前状态</td>-->
                    <td th:text="${item.gender}"></td>
                    <td th:text="${item.signature}"></td>
                    <td th:text="${item.following}"></td>
                    <td th:text="${item.follower}"></td>
                    <td>
                        <a class="open-popup" data-title="机器详细信息" th:attr="data-url=@{'/machine/host/detail/'+${item.userId}}"
                           data-size="960,480" href="#">详细</a>
                        <a class="ajax-delete" th:attr="data-msg='确定要删除 '+ ${item.userId} + ' 机器?'"
                           th:href="@{'/api/machine/host/' + ${item.userId}}">删除</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;
    }

    $(".machine-status").each(function () {
        var text = $(this).text().trim()
        if (text === 'Online') {
            $(this).css("color", "#009688")
        } else {
            $(this).css("color", "#ff0000")
        }
    })
</script>
</body>
</html>