mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-12 03:04:01 +08:00
缓存策略里的默认缓存条件增加、修改或者删除后自动保存
This commit is contained in:
@@ -28,7 +28,7 @@ func init() {
|
|||||||
Post("/testWrite", new(TestWriteAction)).
|
Post("/testWrite", new(TestWriteAction)).
|
||||||
Get("/selectPopup", new(SelectPopupAction)).
|
Get("/selectPopup", new(SelectPopupAction)).
|
||||||
Post("/count", new(CountAction)).
|
Post("/count", new(CountAction)).
|
||||||
|
Post("/updateRefs", new(UpdateRefsAction)).
|
||||||
EndAll()
|
EndAll()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
35
internal/web/actions/default/servers/components/cache/updateRefs.go
vendored
Normal file
35
internal/web/actions/default/servers/components/cache/updateRefs.go
vendored
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||||
|
|
||||||
|
package cache
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UpdateRefsAction struct {
|
||||||
|
actionutils.ParentAction
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *UpdateRefsAction) Init() {
|
||||||
|
this.Nav("", "", "")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *UpdateRefsAction) RunPost(params struct {
|
||||||
|
CachePolicyId int64
|
||||||
|
RefsJSON []byte
|
||||||
|
}) {
|
||||||
|
// 修改缓存条件
|
||||||
|
if params.CachePolicyId > 0 && len(params.RefsJSON) > 0 {
|
||||||
|
_, err := this.RPC().HTTPCachePolicyRPC().UpdateHTTPCachePolicyRefs(this.AdminContext(), &pb.UpdateHTTPCachePolicyRefsRequest{
|
||||||
|
HttpCachePolicyId: params.CachePolicyId,
|
||||||
|
RefsJSON: params.RefsJSON,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Success()
|
||||||
|
}
|
||||||
@@ -56,7 +56,7 @@ Vue.component("http-cache-config-box", {
|
|||||||
|
|
||||||
<div v-show="isOn()">
|
<div v-show="isOn()">
|
||||||
<h4>缓存条件</h4>
|
<h4>缓存条件</h4>
|
||||||
<http-cache-refs-config-box :v-cache-config="cacheConfig" :v-cache-refs="cacheConfig.cacheRefs"></http-cache-refs-config-box>
|
<http-cache-refs-config-box :v-cache-config="cacheConfig" :v-cache-refs="cacheConfig.cacheRefs" ></http-cache-refs-config-box>
|
||||||
</div>
|
</div>
|
||||||
<div class="margin"></div>
|
<div class="margin"></div>
|
||||||
</div>`
|
</div>`
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
Vue.component("http-cache-refs-config-box", {
|
Vue.component("http-cache-refs-config-box", {
|
||||||
props: ["v-cache-refs", "v-cache-config"],
|
props: ["v-cache-refs", "v-cache-config", "v-cache-policy-id"],
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
let that = this
|
let that = this
|
||||||
sortTable(function (ids) {
|
sortTable(function (ids) {
|
||||||
@@ -12,6 +12,7 @@ Vue.component("http-cache-refs-config-box", {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
that.updateRefs(newRefs)
|
that.updateRefs(newRefs)
|
||||||
|
that.change()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
data: function () {
|
data: function () {
|
||||||
@@ -73,6 +74,8 @@ Vue.component("http-cache-refs-config-box", {
|
|||||||
} else {
|
} else {
|
||||||
that.refs.push(newRef)
|
that.refs.push(newRef)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
that.change()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -97,6 +100,8 @@ Vue.component("http-cache-refs-config-box", {
|
|||||||
|
|
||||||
// 通知子组件更新
|
// 通知子组件更新
|
||||||
that.$refs.cacheRef[index].notifyChange()
|
that.$refs.cacheRef[index].notifyChange()
|
||||||
|
|
||||||
|
that.change()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -104,6 +109,7 @@ Vue.component("http-cache-refs-config-box", {
|
|||||||
let that = this
|
let that = this
|
||||||
teaweb.confirm("确定要删除此缓存设置吗?", function () {
|
teaweb.confirm("确定要删除此缓存设置吗?", function () {
|
||||||
that.refs.$remove(index)
|
that.refs.$remove(index)
|
||||||
|
that.change()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
updateRefs: function (newRefs) {
|
updateRefs: function (newRefs) {
|
||||||
@@ -128,6 +134,17 @@ Vue.component("http-cache-refs-config-box", {
|
|||||||
return "周 "
|
return "周 "
|
||||||
}
|
}
|
||||||
return unit
|
return unit
|
||||||
|
},
|
||||||
|
change: function () {
|
||||||
|
// 自动保存
|
||||||
|
if (this.vCachePolicyId != null && this.vCachePolicyId > 0) {
|
||||||
|
Tea.action("/servers/components/cache/updateRefs")
|
||||||
|
.params({
|
||||||
|
cachePolicyId: this.vCachePolicyId,
|
||||||
|
refsJSON: JSON.stringify(this.refs)
|
||||||
|
})
|
||||||
|
.post()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
template: `<div>
|
template: `<div>
|
||||||
|
|||||||
@@ -96,7 +96,7 @@
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h4>默认缓存条件</h4>
|
<h4>默认缓存条件</h4>
|
||||||
<http-cache-refs-config-box :v-cache-refs="cachePolicy.cacheRefs"></http-cache-refs-config-box>
|
<http-cache-refs-config-box :v-cache-refs="cachePolicy.cacheRefs" :v-cache-policy-id="cachePolicy.id"></http-cache-refs-config-box>
|
||||||
|
|
||||||
<submit-btn></submit-btn>
|
<submit-btn></submit-btn>
|
||||||
</form>
|
</form>
|
||||||
Reference in New Issue
Block a user