{$layout}

<first-menu>
    <menu-item href="/servers">网站列表</menu-item>
    <span class="item disabled">|</span>
    <menu-item :href="'/servers/server/log?serverId=' + server.id" active="true">"{{server.name}}"日志</menu-item>
    <span class="separator">|</span>
    <more-items-angle
            :v-data-url="'/servers/nearby?serverId=' + server.id"
            :v-url="'/servers/server/log?serverId=${serverId}'"></more-items-angle>
</first-menu>

<div class="left-right-box-container">
    {$template "/left_menu"}
    <div class="right-box">
        <!-- 集群设置提醒 -->
        <div v-if="!clusterAccessLogIsOn">
            <div class="margin"></div>
            <warning-message>当前集群已经设置不允许网站记录访问日志，可以在"集群设置" -- "网站设置"中修改此选项。</warning-message>
        </div>

        <!-- 网站设置提醒 -->
        <div v-if="!serverAccessLogIsOn">
            <div class="margin"></div>
            <warning-message>当前网站尚未启用访问日志，可以在 <a :href="'/servers/server/settings/accessLog?serverId=' + serverId">[这里]</a> 修改。</warning-message>
        </div>

        <first-menu>
            <menu-item :href="path + '?' + query()" :active="hasError == 0 && hasWAF == 0">所有日志</menu-item>
            <menu-item :href="path + '?' + query('hasError=1')" :active="hasError > 0">错误日志</menu-item>
            <menu-item :href="path + '?' + query('hasWAF=1')" :active="hasWAF > 0">WAF日志</menu-item>
        </first-menu>

        <form method="get" class="ui form small" :action="path">
            <input type="hidden" name="serverId" :value="serverId"/>
            <input type="hidden" name="hasError" :value="hasError"/>
            <input type="hidden" name="hasWAF" :value="hasWAF"/>
            <http-access-log-search-box :v-ip="ip" :v-domain="domain" :v-keyword="keyword" :v-cluster-id="clusterId" :v-node-id="nodeId"></http-access-log-search-box>
        </form>

        <!-- 分区 -->
        <http-access-log-partitions-box :v-day="day" :v-partition="partition" :v-query="currentQuery"></http-access-log-partitions-box>

        <b-empty v-if="accessLogs.length == 0">今天暂时还没有访问日志。</b-empty>

        <table class="ui table selectable" v-if="accessLogs.length > 0">
            <!-- 这里之所以需要添加 :key，是因为要不然不会刷新显示 -->
            <tr v-for="accessLog in accessLogs" :key="accessLog.requestId">
                <td><http-access-log-box :v-access-log="accessLog" :v-keyword="keyword"></http-access-log-box></td>
            </tr>
        </table>

        <div v-if="accessLogs.length > 0">
            <a :href="path + '?' + query('requestId=' + lastRequestId + '&hasError=' + hasError + '&hasWAF=' + hasWAF + '&partition=' + partition)" v-if="hasPrev">上一页</a>
            <span v-else class="disabled">上一页</span>
            <span class="disabled">&nbsp; | &nbsp;</span>
            <a :href="path + '?' + query('&requestId=' + nextRequestId + '&hasError=' + hasError + '&hasWAF=' + hasWAF + '&partition=' + partition)" v-if="hasMore">下一页</a>
            <span v-else class="disabled">下一页</span>
            <page-size-selector></page-size-selector>
        </div>
    </div>
</div>