缓存策略可以使用存储类型筛选

This commit is contained in:
GoEdgeLab
2022-03-14 15:42:10 +08:00
parent f0541994bf
commit da5fbcca49
3 changed files with 29 additions and 6 deletions

View File

@@ -17,15 +17,18 @@ func (this *IndexAction) Init() {
} }
func (this *IndexAction) RunGet(params struct { func (this *IndexAction) RunGet(params struct {
ClusterId int64 ClusterId int64
Keyword string Keyword string
StorageType string
}) { }) {
this.Data["keyword"] = params.Keyword this.Data["keyword"] = params.Keyword
this.Data["clusterId"] = params.ClusterId this.Data["clusterId"] = params.ClusterId
this.Data["storageType"] = params.StorageType
countResp, err := this.RPC().HTTPCachePolicyRPC().CountAllEnabledHTTPCachePolicies(this.AdminContext(), &pb.CountAllEnabledHTTPCachePoliciesRequest{ countResp, err := this.RPC().HTTPCachePolicyRPC().CountAllEnabledHTTPCachePolicies(this.AdminContext(), &pb.CountAllEnabledHTTPCachePoliciesRequest{
NodeClusterId: params.ClusterId, NodeClusterId: params.ClusterId,
Keyword: params.Keyword, Keyword: params.Keyword,
Type: params.StorageType,
}) })
if err != nil { if err != nil {
this.ErrorPage(err) this.ErrorPage(err)
@@ -38,6 +41,7 @@ func (this *IndexAction) RunGet(params struct {
listResp, err := this.RPC().HTTPCachePolicyRPC().ListEnabledHTTPCachePolicies(this.AdminContext(), &pb.ListEnabledHTTPCachePoliciesRequest{ listResp, err := this.RPC().HTTPCachePolicyRPC().ListEnabledHTTPCachePolicies(this.AdminContext(), &pb.ListEnabledHTTPCachePoliciesRequest{
Keyword: params.Keyword, Keyword: params.Keyword,
NodeClusterId: params.ClusterId, NodeClusterId: params.ClusterId,
Type: params.StorageType,
Offset: page.Offset, Offset: page.Offset,
Size: page.Size, Size: page.Size,
}) })
@@ -70,5 +74,8 @@ func (this *IndexAction) RunGet(params struct {
} }
this.Data["infos"] = infos this.Data["infos"] = infos
// 所有的存储类型
this.Data["storageTypes"] = serverconfigs.AllCachePolicyStorageTypes
this.Show() this.Show()
} }

View File

@@ -35,7 +35,7 @@
<tr> <tr>
<td class="color-border">内存最大容量</td> <td class="color-border">内存最大容量</td>
<td> <td>
<size-capacity-box :v-name="'fileMemoryCapacityJSON'" :v-count="0" :v-unit="'gb'" :key="'fileMemoryCapacityJSON'"></size-capacity-box> <size-capacity-box :v-name="'fileMemoryCapacityJSON'" :v-count="1" :v-unit="'gb'" :key="'fileMemoryCapacityJSON'"></size-capacity-box>
<p class="comment">作为一级缓存的内存最大容量如果为0表示不使用内存作为一级缓存。</p> <p class="comment">作为一级缓存的内存最大容量如果为0表示不使用内存作为一级缓存。</p>
</td> </td>
</tr> </tr>

View File

@@ -16,10 +16,16 @@
<div class="ui field"> <div class="ui field">
<input type="text" name="keyword" v-model="keyword" placeholder="策略名称..."/> <input type="text" name="keyword" v-model="keyword" placeholder="策略名称..."/>
</div> </div>
<div class="ui field">
<select class="ui dropdown" name="storageType" v-model="storageType">
<option value="">[存储类型]</option>
<option v-for="storageType in storageTypes" :value="storageType.type">{{storageType.name}}</option>
</select>
</div>
<div class="ui field"> <div class="ui field">
<button type="submit" class="ui button">搜索</button> <button type="submit" class="ui button">搜索</button>
&nbsp; &nbsp;
<a :href="Tea.url('.')" v-if="keyword.length > 0 || clusterId > 0">[清除条件]</a> <a :href="Tea.url('.')" v-if="keyword.length > 0 || clusterId > 0 || storageType.length > 0">[清除条件]</a>
</div> </div>
</div> </div>
</form> </form>
@@ -38,10 +44,20 @@
</tr> </tr>
</thead> </thead>
<tr v-for="(policy, index) in cachePolicies"> <tr v-for="(policy, index) in cachePolicies">
<td><a :href="'/servers/components/cache/policy?cachePolicyId=' + policy.id"><keyword :v-word="keyword">{{policy.name}}</keyword></a></td> <td>
<a :href="'/servers/components/cache/policy?cachePolicyId=' + policy.id"><keyword :v-word="keyword">{{policy.name}}</keyword>
&nbsp;
<i class="icon disk small blue" v-if="policy.type == 'file'" title="硬盘"></i>
</a>
</td>
<td>{{infos[index].typeName}} <span class="small">{{policy.type}}</span></td> <td>{{infos[index].typeName}} <span class="small">{{policy.type}}</span></td>
<td> <td>
<span v-if="policy.capacity != null && policy.capacity.count > 0">{{policy.capacity.count}}{{policy.capacity.unit.toUpperCase()}}</span> <span v-if="policy.capacity != null && policy.capacity.count > 0">
{{policy.capacity.count}}{{policy.capacity.unit.toUpperCase()}}
<span v-if="policy.type == 'file' && policy.options.memoryPolicy != null && policy.options.memoryPolicy.capacity != null && policy.options.memoryPolicy.capacity.count > 0" class="small grey" title="内存容量">
(内存:{{policy.options.memoryPolicy.capacity.count}}{{policy.options.memoryPolicy.capacity.unit.toUpperCase()}}
</span>
</span>
<span v-else class="disabled">不限</span> <span v-else class="disabled">不限</span>
</td> </td>
<td class="center">{{infos[index].countClusters}}</td> <td class="center">{{infos[index].countClusters}}</td>