{$layout}
{$template "policy_menu"}

<table class="ui table definition selectable">
    <tr>
        <td class="title">策略名称</td>
        <td>{{cachePolicy.name}}</td>
    </tr>
    <tr>
        <td>状态</td>
        <td><label-on :v-is-on="cachePolicy.isOn"></label-on></td>
    </tr>
    <tr>
        <td class="color-border">缓存类型</td>
        <td>
            {{typeName}}<span class="small">（{{cachePolicy.type}}）</span>
        </td>
    </tr>

    <!-- 文件缓存选项 -->
    <tbody v-if="cachePolicy.type == 'file'">
        <tr>
            <td class="color-border">缓存目录</td>
            <td>
                {{cachePolicy.options.dir}}
                <p class="comment">存放文件缓存的目录，通常填写绝对路径。</p>
            </td>
        </tr>
        <tr>
            <td class="color-border">缓存硬盘最大用量</td>
            <td>
                <size-capacity-view :v-value="cachePolicy.capacity" :v-default-text="'不限'"></size-capacity-view>
                <p class="comment">单个节点上缓存所在硬盘的最大用量，如果为0表示没有限制。</p>
            </td>
        </tr>
        <tr v-if="cachePolicy.options.memoryPolicy != null && cachePolicy.options.memoryPolicy.capacity != null && cachePolicy.options.memoryPolicy.capacity.count > 0">
            <td class="color-border">内存最大容量</td>
            <td>
                <size-capacity-view :v-value="cachePolicy.options.memoryPolicy.capacity"></size-capacity-view>
                <p class="comment">作为一级缓存的内存最大容量，可以作为硬盘缓冲区和存储热点缓存内容，如果为0表示不使用内存作为一级缓存。</p>
            </td>
        </tr>
        <tr v-else>
            <td class="color-border">内存最大容量</td>
            <td>
                <a :href="Tea.url('.update', {cachePolicyId:cachePolicy.id})"><span class="red">请设置一个内存容量作为缓冲区，以提升缓存写入性能。</span></a>
            </td>
        </tr>
        <tr v-if="cachePolicy.options.openFileCache != null && cachePolicy.options.openFileCache.isOn && cachePolicy.options.openFileCache.max > 0">
            <td class="color-border">缓存文件句柄缓存</td>
            <td>{{cachePolicy.options.openFileCache.max}}</td>
        </tr>
        <tr v-if="cachePolicy.options.enableSendfile">
            <td class="color-border">开启Sendfile</td>
            <td><span v-if="cachePolicy.options.enableSendfile" class="green">Y</span><span v-else class="disabled">N</span></td>
        </tr>
        <tr v-if="cachePolicy.options.minFreeSize != null && cachePolicy.options.minFreeSize.count > 0">
            <td class="color-border">缓存硬盘最小空余空间</td>
            <td><size-capacity-view :v-value="cachePolicy.options.minFreeSize"></size-capacity-view></td>
        </tr>
        <tr v-if="cachePolicy.options.enableIncompletePartialContent">
            <td class="color-border">允许读取不完整的Partial Content</td>
            <td>
                <span class="green">Y</span>
            </td>
        </tr>
        <!--<tr v-if="cachePolicy.options.enableMMAP">
            <td class="color-border">启用MMAP</td>
            <td>
                <span>Y</span>
            </td>
        </tr>-->
    </tbody>

   <tbody v-if="cachePolicy.type != 'file'">
       <tr>
           <td>缓存最大容量</td>
           <td>
               <size-capacity-view :v-value="cachePolicy.capacity" :v-default-text="'不限'"></size-capacity-view>
               <p class="comment">允许缓存的最大容量，如果为0表示没有限制。</p>
           </td>
       </tr>
   </tbody>
    <tr>
        <td colspan="2"><more-options-indicator></more-options-indicator></td>
    </tr>
    <tbody v-show="moreOptionsVisible">
        <tr>
            <td>最大内容长度</td>
            <td>
                <size-capacity-view :v-value="cachePolicy.maxSize" :v-default-text="'不限'"></size-capacity-view>
                <p class="comment">允许缓存的单个内容最大尺寸，如果为0表示没有限制。</p>
            </td>
        </tr>
        <tr>
            <td>同步写入压缩缓存</td>
            <td>
                <span v-if="cachePolicy.syncCompressionCache" class="green">Y</span>
                <span v-else class="disabled">N</span>
            </td>
        </tr>
        <tr>
            <td>预热超时时间</td>
            <td><span v-if="fetchTimeoutString.length > 0">{{fetchTimeoutString}}</span><span v-else class="disabled">使用默认</span></td>
        </tr>
        <tr>
            <td>描述</td>
            <td>
                <span v-if="cachePolicy.description.length > 0">{{cachePolicy.description}}</span>
                <b-empty v-else>暂时还没有描述。</b-empty>
            </td>
        </tr>
    </tbody>
</table>


<!-- 默认缓存条件 -->
<b-settings-header>默认缓存条件</b-settings-header>
<!-- <h4>默认缓存条件</h4> -->
<http-cache-refs-box :v-cache-refs="cachePolicy.cacheRefs"></http-cache-refs-box>

<!-- 使用此策略的集群 -->
<b-settings-header>使用此策略的集群</b-settings-header>
<!-- <h4>使用此策略的集群</h4> -->
<b-empty v-if="clusters.length == 0">暂时还没有集群使用此策略。</b-empty>
<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>