{$layout}
{$template "waf_menu"}

<table class="ui table definition selectable">
    <tr>
        <td class="title">策略名称</td>
        <td>{{firewallPolicy.name}}</td>
    </tr>
    <tr>
        <td>状态</td>
        <td>
            <span v-if="!firewallPolicy.isOn" class="red">已停用</span>
            <div v-else-if="firewallPolicy.modeInfo != null">
                <span :class="{green: firewallPolicy.modeInfo.code == 'defend', blue: firewallPolicy.modeInfo.code == 'observe', grey: firewallPolicy.modeInfo.code == 'bypass'}">{{firewallPolicy.modeInfo.name}}</span>
                <p class="comment">{{firewallPolicy.modeInfo.description}}</p>
            </div>
        </td>
    </tr>
    <tr>
        <td>预置的规则分组</td>
        <td>
            <span class="ui label tiny basic" v-for="group in firewallPolicy.groups" style="margin-bottom:0.5em" :class="{disabled:!group.isOn}">{{group.name}}</span>
           <div v-if="upgradeItems.length > 0">
               <div class="ui divider"></div>
               <a href=""><span class="red">升级提醒：官方提供了新的规则，是否要加入以下规则：<span class="ui label tiny basic" v-for="item in upgradeItems" style="margin-bottom: 0.2em">{{item.name}}<span v-if="!item.isOn" class="small">（默认不启用）</span></span></span></a> &nbsp; &nbsp; <a href="" @click.prevent="upgradeTemplate">[加入]</a>
           </div>
        </td>
    </tr>
    <tr>
        <td>阻止动作设置</td>
        <td>
            <span v-if="firewallPolicy.blockOptions == null" class="disabled">还没有设置。</span>
            <div v-else>
                <table class="ui table">
                    <tr>
                        <td class="title">状态码</td>
                        <td>{{firewallPolicy.blockOptions.statusCode}}</td>
                    </tr>
                    <tr>
                        <td>提示内容</td>
                        <td>{{firewallPolicy.blockOptions.body}}</td>
                    </tr>
                    <tr>
                        <td>超时时间</td>
                        <td>
                            <span v-if="firewallPolicy.blockOptions.timeout <= 0" class="disabled">使用默认时间。</span>
                            <span v-else>{{firewallPolicy.blockOptions.timeout}}秒</span>
                        </td>
                    </tr>
                </table>
            </div>
        </td>
    </tr>
    <tr>
        <td>使用系统防火墙</td>
        <td>
            <span class="green" v-if="firewallPolicy.useLocalFirewall">启用</span>
            <span class="disabled" v-if="!firewallPolicy.useLocalFirewall">不启用</span>
            <p class="comment" v-if="firewallPolicy.useLocalFirewall">可以在合适的时候自动使用系统自带防火墙进行防御。</p>
        </td>
    </tr>
    <tr>
        <td>SYN Flood防御</td>
        <td>
            <span v-if="firewallPolicy.synFlood == null || !firewallPolicy.synFlood.isOn" class="disabled">未启用</span>
            <table class="ui table selectable" v-if="firewallPolicy.synFlood != null && firewallPolicy.synFlood.isOn">
                <tr>
                    <td class="title">是否启用</td>
                    <td>
                       <span class="green">启用</span>
                    </td>
                </tr>
                <tr>
                    <td>空连接次数</td>
                    <td>
                        {{firewallPolicy.synFlood.minAttempts}}次/分钟
                    </td>
                </tr>
                <tr>
                    <td>封禁时间</td>
                    <td>
                        {{firewallPolicy.synFlood.timeoutSeconds}}秒
                    </td>
                </tr>
                <tr>
                    <td>忽略局域网访问</td>
                    <td>
                        <span v-if="firewallPolicy.synFlood.ignoreLocal" class="green">Y</span>
                        <span class="disabled" v-else>N</span>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td>描述</td>
        <td>
            <span v-if="firewallPolicy.description.length > 0">{{firewallPolicy.description}}</span>
            <span v-else class="disabled">暂时还没有描述。</span>
        </td>
    </tr>
</table>

<h4>使用此策略的集群</h4>
<p class="comment" v-if="clusters.length == 0">暂时还没有集群使用此策略。</p>
<table class="ui table selectable" v-if="clusters.length > 0">
    <tr v-for="cluster in clusters">
        <td>{{cluster.name}}<link-icon :href="'/clusters/cluster?clusterId=' + cluster.id"></link-icon></td>
    </tr>
</table>