<!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="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="getPageByCriteria()"
                                    mo:dict="ENVIRONMENT" mo-selected="${env}"></select>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="timo-table-wrap">
            <table class="layui-table timo-table">
                <thead>
                <tr>
                    <th class="sortable" data-field="appName">节点地址</th>
                    <th class="sortable" data-field="appId">HTTP 端口</th>
                    <th class="sortable" data-field="repoBranch">RPC 端口</th>
                    <th class="sortable" data-field="appName">节点域名</th>
                    <th class="sortable" data-field="appName">启用</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="item:${list}">
                    <td th:text="${item.nodeAddr}">应用名</td>
                    <td th:text="${item.httpPort}">应用 ID</td>
                    <td th:text="${item.rpcPort}">分支</td>
                    <td th:text="${item.domain}">应用名</td>
                    <td th:text="${item.enabled}">应用名</td>
                    <td>
                        <a class="open-popup" data-title="设置存储节点属性" th:attr="data-url=@{'/store/node/config/'+${item.id}}"
                           data-size="640,480" href="#">设置</a>
                        <a class="open-popup" data-title="存储节点详细信息" th:attr="data-url=@{'/store/node/detail/'+${item.id}}"
                           data-size="720,540" href="#">详细</a>
                        <a class="ajax-delete" th:attr="data-msg='确定要删除节点 '+ ${item.nodeAddr}"
                           th:href="@{'/api/store/node/' + ${item.id}}">删除</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 getPageByCriteria() {
        console.log('select 事件')

        var envSelectedOption = $("#getPageByEnv option:selected")
        var envParam = envSelectedOption.text()

        var typeSelectedOption = $("#getPageByType option:selected")
        var typeParam = typeSelectedOption.text()

        url = '?env=' + envParam + '&type=' + typeParam
        window.location.href = window.location.pathname + url;
    }
</script>
</body>
</html>