mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-15 04:41:25 +08:00
服务 -- 缓存设置中增加清理和预热功能
This commit is contained in:
@@ -15,6 +15,8 @@ func init() {
|
|||||||
Prefix("/servers/server/settings/cache").
|
Prefix("/servers/server/settings/cache").
|
||||||
GetPost("", new(IndexAction)).
|
GetPost("", new(IndexAction)).
|
||||||
GetPost("/createPopup", new(CreatePopupAction)).
|
GetPost("/createPopup", new(CreatePopupAction)).
|
||||||
|
GetPost("/purge", new(PurgeAction)).
|
||||||
|
GetPost("/preheat", new(PreheatAction)).
|
||||||
EndAll()
|
EndAll()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
143
internal/web/actions/default/servers/server/settings/cache/preheat.go
vendored
Normal file
143
internal/web/actions/default/servers/server/settings/cache/preheat.go
vendored
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||||
|
|
||||||
|
package cache
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/nodeutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/messageconfigs"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
"github.com/iwind/TeaGo/actions"
|
||||||
|
"github.com/iwind/TeaGo/lists"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PreheatAction struct {
|
||||||
|
actionutils.ParentAction
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *PreheatAction) Init() {
|
||||||
|
this.Nav("", "setting", "preheat")
|
||||||
|
this.SecondMenu("cache")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *PreheatAction) RunGet(params struct {
|
||||||
|
ServerId int64
|
||||||
|
}) {
|
||||||
|
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithServerId(this.AdminContext(), params.ServerId)
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Data["webId"] = webConfig.Id
|
||||||
|
this.Data["webConfig"] = webConfig
|
||||||
|
|
||||||
|
this.Show()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *PreheatAction) RunPost(params struct {
|
||||||
|
ServerId int64
|
||||||
|
WebId int64
|
||||||
|
Keys string
|
||||||
|
|
||||||
|
Must *actions.Must
|
||||||
|
}) {
|
||||||
|
|
||||||
|
// 创建日志
|
||||||
|
defer this.CreateLog(oplogs.LevelInfo, "预热服务 %d 缓存", params.ServerId)
|
||||||
|
|
||||||
|
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithId(this.AdminContext(), params.WebId)
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if webConfig == nil {
|
||||||
|
this.NotFound("httpWeb", params.WebId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var cache = webConfig.Cache
|
||||||
|
if cache == nil || !cache.IsOn {
|
||||||
|
this.Fail("当前没有开启缓存")
|
||||||
|
}
|
||||||
|
|
||||||
|
serverResp, err := this.RPC().ServerRPC().FindEnabledUserServerBasic(this.AdminContext(), &pb.FindEnabledUserServerBasicRequest{ServerId: params.ServerId})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var server = serverResp.Server
|
||||||
|
if server == nil || server.NodeCluster == nil {
|
||||||
|
this.NotFound("server", params.ServerId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var clusterId = server.NodeCluster.Id
|
||||||
|
|
||||||
|
clusterResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeCluster(this.AdminContext(), &pb.FindEnabledNodeClusterRequest{NodeClusterId: clusterId})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var cluster = clusterResp.NodeCluster
|
||||||
|
if cluster == nil {
|
||||||
|
this.NotFound("nodeCluster", clusterId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var cachePolicyId = cluster.HttpCachePolicyId
|
||||||
|
if cachePolicyId == 0 {
|
||||||
|
this.Fail("当前集群没有设置缓存策略")
|
||||||
|
}
|
||||||
|
|
||||||
|
cachePolicyResp, err := this.RPC().HTTPCachePolicyRPC().FindEnabledHTTPCachePolicyConfig(this.AdminContext(), &pb.FindEnabledHTTPCachePolicyConfigRequest{HttpCachePolicyId: cachePolicyId})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cachePolicyJSON := cachePolicyResp.HttpCachePolicyJSON
|
||||||
|
if len(cachePolicyJSON) == 0 {
|
||||||
|
this.Fail("找不到要操作的缓存策略")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(params.Keys) == 0 {
|
||||||
|
this.Fail("请输入要预热的Key列表")
|
||||||
|
}
|
||||||
|
|
||||||
|
realKeys := []string{}
|
||||||
|
for _, key := range strings.Split(params.Keys, "\n") {
|
||||||
|
key = strings.TrimSpace(key)
|
||||||
|
if len(key) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if lists.ContainsString(realKeys, key) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
realKeys = append(realKeys, key)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送命令
|
||||||
|
msg := &messageconfigs.PreheatCacheMessage{
|
||||||
|
CachePolicyJSON: cachePolicyJSON,
|
||||||
|
Keys: realKeys,
|
||||||
|
}
|
||||||
|
results, err := nodeutils.SendMessageToCluster(this.AdminContext(), clusterId, messageconfigs.MessageCodePreheatCache, msg, 300)
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
isAllOk := true
|
||||||
|
for _, result := range results {
|
||||||
|
if !result.IsOK {
|
||||||
|
isAllOk = false
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Data["isAllOk"] = isAllOk
|
||||||
|
this.Data["results"] = results
|
||||||
|
|
||||||
|
this.Success()
|
||||||
|
}
|
||||||
149
internal/web/actions/default/servers/server/settings/cache/purge.go
vendored
Normal file
149
internal/web/actions/default/servers/server/settings/cache/purge.go
vendored
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||||
|
|
||||||
|
package cache
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/nodeutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/messageconfigs"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
"github.com/iwind/TeaGo/actions"
|
||||||
|
"github.com/iwind/TeaGo/lists"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PurgeAction struct {
|
||||||
|
actionutils.ParentAction
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *PurgeAction) Init() {
|
||||||
|
this.Nav("", "setting", "purge")
|
||||||
|
this.SecondMenu("cache")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *PurgeAction) RunGet(params struct {
|
||||||
|
ServerId int64
|
||||||
|
}) {
|
||||||
|
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithServerId(this.AdminContext(), params.ServerId)
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Data["webId"] = webConfig.Id
|
||||||
|
this.Data["webConfig"] = webConfig
|
||||||
|
|
||||||
|
this.Show()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *PurgeAction) RunPost(params struct {
|
||||||
|
ServerId int64
|
||||||
|
WebId int64
|
||||||
|
Type string
|
||||||
|
Keys string
|
||||||
|
|
||||||
|
Must *actions.Must
|
||||||
|
}) {
|
||||||
|
|
||||||
|
// 创建日志
|
||||||
|
defer this.CreateLog(oplogs.LevelInfo, "删除服务 %d 缓存", params.ServerId)
|
||||||
|
|
||||||
|
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithId(this.AdminContext(), params.WebId)
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if webConfig == nil {
|
||||||
|
this.NotFound("httpWeb", params.WebId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var cache = webConfig.Cache
|
||||||
|
if cache == nil || !cache.IsOn {
|
||||||
|
this.Fail("当前没有开启缓存")
|
||||||
|
}
|
||||||
|
|
||||||
|
serverResp, err := this.RPC().ServerRPC().FindEnabledUserServerBasic(this.AdminContext(), &pb.FindEnabledUserServerBasicRequest{ServerId: params.ServerId})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var server = serverResp.Server
|
||||||
|
if server == nil || server.NodeCluster == nil {
|
||||||
|
this.NotFound("server", params.ServerId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var clusterId = server.NodeCluster.Id
|
||||||
|
|
||||||
|
clusterResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeCluster(this.AdminContext(), &pb.FindEnabledNodeClusterRequest{NodeClusterId: clusterId})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var cluster = clusterResp.NodeCluster
|
||||||
|
if cluster == nil {
|
||||||
|
this.NotFound("nodeCluster", clusterId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var cachePolicyId = cluster.HttpCachePolicyId
|
||||||
|
if cachePolicyId == 0 {
|
||||||
|
this.Fail("当前集群没有设置缓存策略")
|
||||||
|
}
|
||||||
|
|
||||||
|
cachePolicyResp, err := this.RPC().HTTPCachePolicyRPC().FindEnabledHTTPCachePolicyConfig(this.AdminContext(), &pb.FindEnabledHTTPCachePolicyConfigRequest{HttpCachePolicyId: cachePolicyId})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cachePolicyJSON := cachePolicyResp.HttpCachePolicyJSON
|
||||||
|
if len(cachePolicyJSON) == 0 {
|
||||||
|
this.Fail("找不到要操作的缓存策略")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(params.Keys) == 0 {
|
||||||
|
this.Fail("请输入要删除的Key列表")
|
||||||
|
}
|
||||||
|
|
||||||
|
realKeys := []string{}
|
||||||
|
for _, key := range strings.Split(params.Keys, "\n") {
|
||||||
|
key = strings.TrimSpace(key)
|
||||||
|
if len(key) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if lists.ContainsString(realKeys, key) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
realKeys = append(realKeys, key)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送命令
|
||||||
|
msg := &messageconfigs.PurgeCacheMessage{
|
||||||
|
CachePolicyJSON: cachePolicyJSON,
|
||||||
|
Keys: realKeys,
|
||||||
|
}
|
||||||
|
if params.Type == "prefix" {
|
||||||
|
msg.Type = messageconfigs.PurgeCacheMessageTypeDir
|
||||||
|
} else {
|
||||||
|
msg.Type = messageconfigs.PurgeCacheMessageTypeFile
|
||||||
|
}
|
||||||
|
results, err := nodeutils.SendMessageToCluster(this.AdminContext(), clusterId, messageconfigs.MessageCodePurgeCache, msg, 10)
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
isAllOk := true
|
||||||
|
for _, result := range results {
|
||||||
|
if !result.IsOK {
|
||||||
|
isAllOk = false
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Data["isAllOk"] = isAllOk
|
||||||
|
this.Data["results"] = results
|
||||||
|
|
||||||
|
this.Success()
|
||||||
|
}
|
||||||
@@ -180,21 +180,16 @@ func (this *userMustAuth) modules(adminId int64) []maps.Map {
|
|||||||
"subtitle": "服务列表",
|
"subtitle": "服务列表",
|
||||||
"icon": "clone outsize",
|
"icon": "clone outsize",
|
||||||
"subItems": []maps.Map{
|
"subItems": []maps.Map{
|
||||||
|
{
|
||||||
|
"name": "证书管理",
|
||||||
|
"url": "/servers/certs",
|
||||||
|
"code": "cert",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "访问日志",
|
"name": "访问日志",
|
||||||
"url": "/servers/logs",
|
"url": "/servers/logs",
|
||||||
"code": "log",
|
"code": "log",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "通用设置",
|
|
||||||
"url": "/servers/components",
|
|
||||||
"code": "global",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "服务分组",
|
|
||||||
"url": "/servers/components/groups",
|
|
||||||
"code": "group",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "缓存策略",
|
"name": "缓存策略",
|
||||||
"url": "/servers/components/cache",
|
"url": "/servers/components/cache",
|
||||||
@@ -216,16 +211,21 @@ func (this *userMustAuth) modules(adminId int64) []maps.Map {
|
|||||||
"url": "/servers/iplists",
|
"url": "/servers/iplists",
|
||||||
"code": "iplist",
|
"code": "iplist",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "证书管理",
|
|
||||||
"url": "/servers/certs",
|
|
||||||
"code": "cert",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "统计指标",
|
"name": "统计指标",
|
||||||
"url": "/servers/metrics",
|
"url": "/servers/metrics",
|
||||||
"code": "metric",
|
"code": "metric",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "服务分组",
|
||||||
|
"url": "/servers/components/groups",
|
||||||
|
"code": "group",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "通用设置",
|
||||||
|
"url": "/servers/components",
|
||||||
|
"code": "global",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<div class="ui divider"></div>
|
<div class="ui divider"></div>
|
||||||
|
|
||||||
<h3>批量删除</h3>
|
<h3>批量删除</h3>
|
||||||
<p class="comment">可以批量删除一组Key。</p>
|
<p class="comment">可以在这里批量删除一组Key。</p>
|
||||||
<form method="post" class="ui form" data-tea-action="$" data-tea-before="before" data-tea-success="success" data-tea-fail="fail" data-tea-done="done" data-tea-timeout="300">
|
<form method="post" class="ui form" data-tea-action="$" data-tea-before="before" data-tea-success="success" data-tea-fail="fail" data-tea-done="done" data-tea-timeout="300">
|
||||||
<input type="hidden" name="cachePolicyId" :value="cachePolicyId"/>
|
<input type="hidden" name="cachePolicyId" :value="cachePolicyId"/>
|
||||||
<input type="hidden" name="clusterId" :value="clusterId"/>
|
<input type="hidden" name="clusterId" :value="clusterId"/>
|
||||||
|
|||||||
5
web/views/@default/servers/server/settings/cache/@menu.html
vendored
Normal file
5
web/views/@default/servers/server/settings/cache/@menu.html
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<first-menu>
|
||||||
|
<menu-item :href="'.?serverId=' + serverId" code="index">设置</menu-item>
|
||||||
|
<menu-item :href="'.purge?serverId=' + serverId" code="purge">清理</menu-item>
|
||||||
|
<menu-item :href="'.preheat?serverId=' + serverId" code="preheat">预热</menu-item>
|
||||||
|
</first-menu>
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
{$layout}
|
{$layout}
|
||||||
|
|
||||||
{$template "/left_menu"}
|
{$template "/left_menu"}
|
||||||
|
|
||||||
<div class="right-box">
|
<div class="right-box">
|
||||||
|
{$template "menu"}
|
||||||
|
|
||||||
<form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
|
<form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
|
||||||
<input type="hidden" name="webId" :value="webId"/>
|
<input type="hidden" name="webId" :value="webId"/>
|
||||||
<http-cache-config-box :v-cache-config="cacheConfig" :v-cache-policy="cachePolicy"></http-cache-config-box>
|
<http-cache-config-box :v-cache-config="cacheConfig" :v-cache-policy="cachePolicy"></http-cache-config-box>
|
||||||
|
|||||||
39
web/views/@default/servers/server/settings/cache/preheat.html
vendored
Normal file
39
web/views/@default/servers/server/settings/cache/preheat.html
vendored
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
{$layout}
|
||||||
|
{$template "/left_menu"}
|
||||||
|
|
||||||
|
<div class="right-box">
|
||||||
|
{$template "menu"}
|
||||||
|
|
||||||
|
<div class="margin"></div>
|
||||||
|
<div v-show="webConfig.cache == null || !webConfig.cache.isOn">
|
||||||
|
<p class="comment">没有开启缓存,不需要清理。</p>
|
||||||
|
</div>
|
||||||
|
<div v-show="webConfig.cache != null && webConfig.cache.isOn">
|
||||||
|
<p class="comment">可以在这里批量预热一组Key。</p>
|
||||||
|
<form method="post" class="ui form" data-tea-action="$" data-tea-before="before" data-tea-success="success" data-tea-fail="fail" data-tea-done="done" data-tea-timeout="3600">
|
||||||
|
<input type="hidden" name="serverId" :value="serverId"/>
|
||||||
|
<input type="hidden" name="webId" :value="webId"/>
|
||||||
|
<table class="ui table definition selectable">
|
||||||
|
<tr>
|
||||||
|
<td>Key列表</td>
|
||||||
|
<td>
|
||||||
|
<textarea name="keys" rows="10" ref="focus"></textarea>
|
||||||
|
<p class="comment">每行一个Key。</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="title">操作结果</td>
|
||||||
|
<td>
|
||||||
|
<div v-if="isRequesting">数据发送中...</div>
|
||||||
|
<span class="red" v-if="!isRequesting && !isOk && message.length > 0">失败:{{message}}</span>
|
||||||
|
<div v-if="!isRequesting && isOk">
|
||||||
|
<span v-if="results.length == 0" class="red">此集群下没有任何可用的节点。</span>
|
||||||
|
<div class="ui label tiny" v-for="one in results" :class="{green:one.isOk, red:!one.isOk}" style="margin-bottom: 0.5em">{{one.nodeName}}:{{one.message}}</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<submit-btn v-if="!isRequesting">提交</submit-btn>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
26
web/views/@default/servers/server/settings/cache/preheat.js
vendored
Normal file
26
web/views/@default/servers/server/settings/cache/preheat.js
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
Tea.context(function () {
|
||||||
|
this.isRequesting = false
|
||||||
|
this.isOk = false
|
||||||
|
this.message = ""
|
||||||
|
this.results = []
|
||||||
|
|
||||||
|
this.before = function () {
|
||||||
|
this.isRequesting = true
|
||||||
|
this.isOk = false
|
||||||
|
this.message = ""
|
||||||
|
this.results = []
|
||||||
|
}
|
||||||
|
|
||||||
|
this.success = function (resp) {
|
||||||
|
this.isOk = true
|
||||||
|
this.results = resp.data.results
|
||||||
|
}
|
||||||
|
|
||||||
|
this.fail = function (resp) {
|
||||||
|
this.message = resp.message
|
||||||
|
}
|
||||||
|
|
||||||
|
this.done = function () {
|
||||||
|
this.isRequesting = false
|
||||||
|
}
|
||||||
|
});
|
||||||
51
web/views/@default/servers/server/settings/cache/purge.html
vendored
Normal file
51
web/views/@default/servers/server/settings/cache/purge.html
vendored
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
{$layout}
|
||||||
|
{$template "/left_menu"}
|
||||||
|
|
||||||
|
<div class="right-box">
|
||||||
|
{$template "menu"}
|
||||||
|
|
||||||
|
<div class="margin"></div>
|
||||||
|
<div v-show="webConfig.cache == null || !webConfig.cache.isOn">
|
||||||
|
<p class="comment">没有开启缓存,不需要清理。</p>
|
||||||
|
</div>
|
||||||
|
<div v-show="webConfig.cache != null && webConfig.cache.isOn">
|
||||||
|
<p class="comment">可以在这里批量删除一组Key。</p>
|
||||||
|
|
||||||
|
<form method="post" class="ui form" data-tea-action="$" data-tea-before="before" data-tea-success="success" data-tea-fail="fail" data-tea-done="done" data-tea-timeout="300">
|
||||||
|
<input type="hidden" name="serverId" :value="serverId"/>
|
||||||
|
<input type="hidden" name="webId" :value="webId"/>
|
||||||
|
<table class="ui table definition selectable">
|
||||||
|
<tr>
|
||||||
|
<td class="title">操作类型</td>
|
||||||
|
<td>
|
||||||
|
<radio name="type" :v-value="'key'" v-model="type">根据Key</radio>
|
||||||
|
<radio name="type" :v-value="'prefix'" v-model="type">根据前缀</radio>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<span v-if="type == 'key'">Key列表</span>
|
||||||
|
<span v-if="type == 'prefix'">Key前缀列表</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<textarea name="keys" rows="10" ref="focus"></textarea>
|
||||||
|
<p class="comment" v-if="type == 'key'">每行一个Key,比如是一个完整的URL<code-label>https://example.com/hello/world.html</code-label>。</p>
|
||||||
|
<p class="comment" v-if="type == 'prefix'">每行一个Key前缀,比如是一个URL前缀<code-label>https://example.com/hello/</code-label>。</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>操作结果</td>
|
||||||
|
<td>
|
||||||
|
<div v-if="isRequesting">数据发送中...</div>
|
||||||
|
<span class="red" v-if="!isRequesting && !isOk && message.length > 0">失败:{{message}}</span>
|
||||||
|
<div v-if="!isRequesting && isOk">
|
||||||
|
<span v-if="results.length == 0" class="red">此集群下没有任何可用的节点。</span>
|
||||||
|
<div class="ui label tiny" v-for="one in results" :class="{green:one.isOk, red:!one.isOk}" style="margin-bottom: 0.5em">{{one.nodeName}}:{{one.message}}</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<submit-btn v-if="!isRequesting">提交</submit-btn>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
31
web/views/@default/servers/server/settings/cache/purge.js
vendored
Normal file
31
web/views/@default/servers/server/settings/cache/purge.js
vendored
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
Tea.context(function () {
|
||||||
|
this.isRequesting = false
|
||||||
|
this.isOk = false
|
||||||
|
this.message = ""
|
||||||
|
this.results = []
|
||||||
|
|
||||||
|
this.before = function () {
|
||||||
|
this.isRequesting = true
|
||||||
|
this.isOk = false
|
||||||
|
this.message = ""
|
||||||
|
this.results = []
|
||||||
|
}
|
||||||
|
|
||||||
|
this.success = function (resp) {
|
||||||
|
this.isOk = true
|
||||||
|
this.results = resp.data.results
|
||||||
|
}
|
||||||
|
|
||||||
|
this.fail = function (resp) {
|
||||||
|
this.message = resp.message
|
||||||
|
}
|
||||||
|
|
||||||
|
this.done = function () {
|
||||||
|
this.isRequesting = false
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作类型
|
||||||
|
*/
|
||||||
|
this.type = "key" // key | prefix
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user