<%inherit file="base.html"/>

<%def name="head()">
<script>
    function deleteRoster(roster_id)
    {
        if(confirm("确认删除吗？"))
        {
            window.location.href = "/roster/delete?roster_id="+roster_id;
        }
    }

</script>
</%def>

<%def name="body()">
<div class="panel panel-default">
    <div class="panel-heading"><span class="glyphicon glyphicon-th"></span> 黑白名单列表</div>
    <div class="panel-body">
        <div class="container">    
            <div class="pull-right bottom10">
                % if permit.match('/roster/add'):
                <a href="/roster/add" class="btn btn-sm btn-default">增加黑白名单</a>
                % endif
            </div>

            <table class="table table-hover">
                <thead>
                <tr>
                    <th>MAC地址</th>
                    <th>黑白名单类型</th>
                    <th>开始时间</th>
                    <th>结束时间</th>
                </tr>
                </thead>
                <tbody>
                    % for roster in page_data.result:
                        <tr>
                            <td>${roster.mac_addr}</td>
                            <td>${{0:u'白名单',1:u'黑名单'}.get(roster.roster_type)}</td>
                            <td>${roster.begin_time}</td>
                            <td>${roster.end_time}</td>
                            <td>
                                % if permit.match('/roster/update'):
                                <a class="opt-btn btn-default" href="/roster/update?roster_id=${roster.id}">修改</a>
                                % endif
                                % if permit.match('/roster/delete'):
                                <a class="opt-btn btn-default" href="javascript:deleteRoster('${roster.id}')">删除</a>
                                % endif
                            </td>
                        </tr>
                    % endfor
                </tbody>
            </table>
             ${page_data.render()}
        </div>
    </div>
</div>
</%def>