{$layout}
{$template "/datepicker"}

<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>
    <span class="item disabled">|</span>
    <menu-item :href="'/servers/logs/settings'" code="settings">设置</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-cluster-id="clusterId" :v-node-id="nodeId" :v-ip="ip" :v-domain="domain" :v-keyword="keyword">
        <div class="ui field">
            <div class="ui right labeled input">
                <input type="text" name="day" maxlength="10" placeholder="选择日期" style="width:7.8em" id="day-input" v-model="day"/>
                <span class="ui label">日</span>
            </div>
        </div>
        <div class="ui field">
            <div class="ui right labeled input">
                <input type="text" name="hour" maxlength="2" style="width: 3.5em" v-model="hour"/>
                <span class="ui label">时</span>
            </div>
        </div>
    </http-access-log-search-box>
</form>

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

<warning-message v-if="isSlowQuery">看起来你的访问日志查询非常慢（{{slowQueryCost}}s），建议<span v-if="domain.length == 0"> 1）指定具体域名查询；2）</span>通过添加新的 <a href="/db">[日志节点]</a> 来分散存储访问日志。</warning-message>

<p class="comment" v-if="accessLogs.length == 0">暂时还没有访问日志。</p>

<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" :v-show-server-link="true"></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>