{$layout}
{$template "menu"}

<b-empty v-if="policies.length == 0">暂时还没有访问日志策略。</b-empty>

<table class="ui table celled selectable" v-if="policies.length > 0">
    <thead>
        <tr>
            <th>策略名称</th>
            <th class="three op">类型</th>
            <th>主要参数</th>
            <th class="two wide">状态</th>
            <th class="two op">操作</th>
        </tr>
    </thead>
    <tr v-for="policy in policies">
        <td><a :href="Tea.url('.policy', {policyId: policy.id})">{{policy.name}}</a>
            <div style="margin-top: 0.3em" v-if="policy.isPublic || policy.firewallOnly">
                <span class="ui label olive tiny basic" v-if="policy.isPublic">公用</span>
                <span class="ui label tiny basic" v-if="policy.firewallOnly">只记录WAF</span>
                <span class="ui label tiny basic" v-if="policy.disableDefaultDB">停用默认数据库</span>
            </div>
        </td>
        <td>{{policy.typeName}}</td>
        <td>
            <span v-if="policy.options == null" class="disabled">-</span>
            <span v-else-if="policy.type == 'es'">Endpoint: {{policy.options.endpoint}}</span>
            <span v-else-if="policy.type == 'file'">文件路径：{{policy.options.path}}</span>
            <span v-else-if="policy.type == 'tcp'">网络地址：{{policy.options.addr}}</span>
            <span v-else-if="policy.type == 'command'">可执行命令：{{policy.options.command}}</span>
            <span v-else-if="policy.type == 'syslog'">
                <span v-if="policy.options.protocol == 'tcp'">TCP {{policy.options.serverAddr}}</span>
                <span v-if="policy.options.protocol == 'udp'">UDP {{policy.options.serverAddr}}</span>
                <span v-if="policy.options.protocol == 'socket'">SOCK {{policy.options.socket}}</span>
            </span>
        </td>
        <td>
            <label-on :v-is-on="policy.isOn"></label-on>
        </td>
        <td>
            <a :href="Tea.url('.policy', {policyId: policy.id})">详情</a> &nbsp; <a href="" @click.prevent="deletePolicy(policy.id)">删除</a>
        </td>
    </tr>
</table>

<div class="page" v-html="filterPageContent(page)"></div>