实现缓存策略部分管理功能

This commit is contained in:
GoEdgeLab
2020-10-02 17:22:24 +08:00
parent d44a0b1cbf
commit bfa6227a82
53 changed files with 1163 additions and 211 deletions

56
internal/errors/error.go Normal file
View File

@@ -0,0 +1,56 @@
package errors
import (
"errors"
"path/filepath"
"runtime"
"strconv"
)
type errorObj struct {
err error
file string
line int
funcName string
}
func (this *errorObj) Error() string {
s := this.err.Error() + "\n " + this.file
if len(this.funcName) > 0 {
s += ":" + this.funcName + "()"
}
s += ":" + strconv.Itoa(this.line)
return s
}
// 新错误
func New(errText string) error {
ptr, file, line, ok := runtime.Caller(1)
funcName := ""
if ok {
frame, _ := runtime.CallersFrames([]uintptr{ptr}).Next()
funcName = filepath.Base(frame.Function)
}
return &errorObj{
err: errors.New(errText),
file: file,
line: line,
funcName: funcName,
}
}
// 包装已有错误
func Wrap(err error) error {
ptr, file, line, ok := runtime.Caller(1)
funcName := ""
if ok {
frame, _ := runtime.CallersFrames([]uintptr{ptr}).Next()
funcName = filepath.Base(frame.Function)
}
return &errorObj{
err: err,
file: file,
line: line,
funcName: funcName,
}
}

View File

@@ -0,0 +1,22 @@
package errors
import (
"errors"
"testing"
)
func TestNew(t *testing.T) {
t.Log(New("hello"))
t.Log(Wrap(errors.New("hello")))
t.Log(testError1())
t.Log(Wrap(testError1()))
t.Log(Wrap(testError2()))
}
func testError1() error {
return New("test error1")
}
func testError2() error {
return Wrap(testError1())
}

View File

@@ -134,6 +134,10 @@ func (this *RPCClient) SSLPolicyRPC() pb.SSLPolicyServiceClient {
return pb.NewSSLPolicyServiceClient(this.pickConn())
}
func (this *RPCClient) SysSettingRPC() pb.SysSettingServiceClient {
return pb.NewSysSettingServiceClient(this.pickConn())
}
// 构造上下文
func (this *RPCClient) Context(adminId int64) context.Context {
ctx := context.Background()

View File

@@ -2,8 +2,8 @@ package clusters
import (
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/logs"
"github.com/iwind/TeaGo/maps"
@@ -48,9 +48,13 @@ func (this *ClusterHelper) BeforeAction(action *actions.ActionObject) {
}
tabbar := actionutils.NewTabbar()
tabbar.Add("当前集群:"+cluster.Name, "", "/clusters", "left long alternate arrow", false)
tabbar.Add("集群列表", "", "/clusters", "", false)
tabbar.Add("节点", "", "/clusters/cluster?clusterId="+clusterIdString, "server", selectedTabbar == "node")
tabbar.Add("设置", "", "/clusters/cluster/settings?clusterId="+clusterIdString, "setting", selectedTabbar == "setting")
{
m := tabbar.Add("当前集群:"+cluster.Name, "", "/clusters/cluster?clusterId="+clusterIdString, "", false)
m["right"] = true
}
actionutils.SetTabbar(action, tabbar)
// 左侧菜单

View File

@@ -0,0 +1,15 @@
package cache
import "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
type CleanAction struct {
actionutils.ParentAction
}
func (this *CleanAction) Init() {
this.Nav("", "", "")
}
func (this *CleanAction) RunGet(params struct{}) {
this.Show()
}

View File

@@ -0,0 +1,82 @@
package cache
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/iwind/TeaGo/actions"
)
type CreatePopupAction struct {
actionutils.ParentAction
}
func (this *CreatePopupAction) Init() {
this.Nav("", "", "")
}
func (this *CreatePopupAction) RunGet(params struct{}) {
this.Data["types"] = serverconfigs.AllCachePolicyTypes
this.Show()
}
func (this *CreatePopupAction) RunPost(params struct {
Name string
Type string
// file
FileDir string
CapacityJSON []byte
MaxSizeJSON []byte
MaxKeys int64
Description string
IsOn bool
Must *actions.Must
}) {
params.Must.
Field("name", params.Name).
Require("请输入策略名称")
// 校验选项
var options interface{}
switch params.Type {
case serverconfigs.CachePolicyTypeFile:
params.Must.
Field("fileDir", params.FileDir).
Require("请输入缓存目录")
options = &serverconfigs.HTTPFileCacheConfig{
Dir: params.FileDir,
}
case serverconfigs.CachePolicyTypeMemory:
options = &serverconfigs.HTTPMemoryCacheConfig{
}
default:
this.Fail("请选择正确的缓存类型")
}
optionsJSON, err := json.Marshal(options)
if err != nil {
this.ErrorPage(err)
return
}
_, err = this.RPC().HTTPCachePolicyRPC().CreateHTTPCachePolicy(this.AdminContext(), &pb.CreateHTTPCachePolicyRequest{
IsOn: params.IsOn,
Name: params.Name,
Description: params.Description,
CapacityJSON: params.CapacityJSON,
MaxKeys: params.MaxKeys,
MaxSizeJSON: params.MaxSizeJSON,
Type: params.Type,
OptionsJSON: optionsJSON,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}

View File

@@ -0,0 +1,32 @@
package cache
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
)
type DeleteAction struct {
actionutils.ParentAction
}
func (this *DeleteAction) RunPost(params struct {
CachePolicyId int64
}) {
// 检查是否被引用
countResp, err := this.RPC().ServerRPC().CountAllEnabledServersWithCachePolicyId(this.AdminContext(), &pb.CountAllEnabledServersWithCachePolicyIdRequest{CachePolicyId: params.CachePolicyId})
if err != nil {
this.ErrorPage(err)
return
}
if countResp.Count > 0 {
this.Fail("此缓存策略正在被别的服务引用,请修改后再删除。")
}
_, err = this.RPC().HTTPCachePolicyRPC().DeleteHTTPCachePolicy(this.AdminContext(), &pb.DeleteHTTPCachePolicyRequest{CachePolicyId: params.CachePolicyId})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}

View File

@@ -1,7 +1,11 @@
package cache
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/iwind/TeaGo/maps"
)
type IndexAction struct {
@@ -13,6 +17,47 @@ func (this *IndexAction) Init() {
}
func (this *IndexAction) RunGet(params struct{}) {
countResp, err := this.RPC().HTTPCachePolicyRPC().CountAllEnabledHTTPCachePolicies(this.AdminContext(), &pb.CountAllEnabledHTTPCachePoliciesRequest{})
if err != nil {
this.ErrorPage(err)
return
}
count := countResp.Count
page := this.NewPage(count)
this.Data["page"] = page.AsHTML()
listResp, err := this.RPC().HTTPCachePolicyRPC().ListEnabledHTTPCachePolicies(this.AdminContext(), &pb.ListEnabledHTTPCachePoliciesRequest{
Offset: page.Offset,
Size: page.Size,
})
if err != nil {
this.ErrorPage(err)
return
}
cachePoliciesJSON := listResp.CachePoliciesJSON
cachePolicies := []*serverconfigs.HTTPCachePolicy{}
err = json.Unmarshal(cachePoliciesJSON, &cachePolicies)
if err != nil {
this.ErrorPage(err)
return
}
this.Data["cachePolicies"] = cachePolicies
infos := []maps.Map{}
for _, cachePolicy := range cachePolicies {
countServersResp, err := this.RPC().ServerRPC().CountAllEnabledServersWithCachePolicyId(this.AdminContext(), &pb.CountAllEnabledServersWithCachePolicyIdRequest{CachePolicyId: cachePolicy.Id})
if err != nil {
this.ErrorPage(err)
return
}
countServers := countServersResp.Count
infos = append(infos, maps.Map{
"typeName": serverconfigs.FindCachePolicyTypeName(cachePolicy.Type),
"countServers": countServers,
})
}
this.Data["infos"] = infos
this.Show()
}

View File

@@ -14,6 +14,15 @@ func init() {
Helper(componentutils.NewComponentHelper()).
Prefix("/servers/components/cache").
Get("", new(IndexAction)).
GetPost("/createPopup", new(CreatePopupAction)).
Get("/policy", new(PolicyAction)).
GetPost("/updatePopup", new(UpdatePopupAction)).
GetPost("/clean", new(CleanAction)).
GetPost("/preheat", new(PreheatAction)).
GetPost("/purge", new(PurgeAction)).
GetPost("/stat", new(StatAction)).
GetPost("/test", new(TestAction)).
Post("/delete", new(DeleteAction)).
EndAll()
})
}

View File

@@ -0,0 +1,15 @@
package cache
import "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
type PolicyAction struct {
actionutils.ParentAction
}
func (this *PolicyAction) Init() {
this.Nav("", "", "")
}
func (this *PolicyAction) RunGet(params struct{}) {
this.Show()
}

View File

@@ -0,0 +1,15 @@
package cache
import "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
type PreheatAction struct {
actionutils.ParentAction
}
func (this *PreheatAction) Init() {
this.Nav("", "", "")
}
func (this *PreheatAction) RunGet(params struct{}) {
this.Show()
}

View File

@@ -0,0 +1,15 @@
package cache
import "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
type PurgeAction struct {
actionutils.ParentAction
}
func (this *PurgeAction) Init() {
this.Nav("", "", "")
}
func (this *PurgeAction) RunGet(params struct{}) {
this.Show()
}

View File

@@ -0,0 +1,15 @@
package cache
import "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
type StatAction struct {
actionutils.ParentAction
}
func (this *StatAction) Init() {
this.Nav("", "", "")
}
func (this *StatAction) RunGet(params struct{}) {
this.Show()
}

View File

@@ -0,0 +1,15 @@
package cache
import "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
type TestAction struct {
actionutils.ParentAction
}
func (this *TestAction) Init() {
this.Nav("", "", "")
}
func (this *TestAction) RunGet(params struct{}) {
this.Show()
}

View File

@@ -0,0 +1,108 @@
package cache
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/iwind/TeaGo/actions"
)
type UpdatePopupAction struct {
actionutils.ParentAction
}
func (this *UpdatePopupAction) Init() {
this.Nav("", "", "")
}
func (this *UpdatePopupAction) RunGet(params struct {
CachePolicyId int64
}) {
configResp, err := this.RPC().HTTPCachePolicyRPC().FindEnabledHTTPCachePolicyConfig(this.AdminContext(), &pb.FindEnabledHTTPCachePolicyConfigRequest{CachePolicyId: params.CachePolicyId})
if err != nil {
this.ErrorPage(err)
return
}
configJSON := configResp.CachePolicyJSON
if len(configJSON) == 0 {
this.NotFound("cachePolicy", params.CachePolicyId)
return
}
cachePolicy := &serverconfigs.HTTPCachePolicy{}
err = json.Unmarshal(configJSON, cachePolicy)
if err != nil {
this.ErrorPage(err)
return
}
this.Data["cachePolicy"] = cachePolicy
// 其他选项
this.Data["types"] = serverconfigs.AllCachePolicyTypes
this.Show()
}
func (this *UpdatePopupAction) RunPost(params struct {
CachePolicyId int64
Name string
Type string
// file
FileDir string
CapacityJSON []byte
MaxSizeJSON []byte
MaxKeys int64
Description string
IsOn bool
Must *actions.Must
}) {
params.Must.
Field("name", params.Name).
Require("请输入策略名称")
// 校验选项
var options interface{}
switch params.Type {
case serverconfigs.CachePolicyTypeFile:
params.Must.
Field("fileDir", params.FileDir).
Require("请输入缓存目录")
options = &serverconfigs.HTTPFileCacheConfig{
Dir: params.FileDir,
}
case serverconfigs.CachePolicyTypeMemory:
options = &serverconfigs.HTTPMemoryCacheConfig{
}
default:
this.Fail("请选择正确的缓存类型")
}
optionsJSON, err := json.Marshal(options)
if err != nil {
this.ErrorPage(err)
return
}
_, err = this.RPC().HTTPCachePolicyRPC().UpdateHTTPCachePolicy(this.AdminContext(), &pb.UpdateHTTPCachePolicyRequest{
CachePolicyId: params.CachePolicyId,
IsOn: params.IsOn,
Name: params.Name,
Description: params.Description,
CapacityJSON: params.CapacityJSON,
MaxKeys: params.MaxKeys,
MaxSizeJSON: params.MaxSizeJSON,
Type: params.Type,
OptionsJSON: optionsJSON,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}

View File

@@ -25,7 +25,7 @@ func (this *ComponentHelper) BeforeAction(action *actions.ActionObject) {
selectedTabbar := action.Data.GetString("mainTab")
tabbar := actionutils.NewTabbar()
tabbar.Add("服务", "", "/servers", "", selectedTabbar == "server")
tabbar.Add("组件", "", "/servers/components", "", selectedTabbar == "component")
tabbar.Add("通用", "", "/servers/components", "", selectedTabbar == "component")
actionutils.SetTabbar(action, tabbar)
// 创建左侧菜单
@@ -39,11 +39,11 @@ func (this *ComponentHelper) createLeftMenus(secondMenuItem string) (items []map
"url": "/servers/components",
"isActive": secondMenuItem == "global",
})
items = append(items, maps.Map{
/**items = append(items, maps.Map{
"name": "分组设置",
"url": "/servers/components/group",
"isActive": secondMenuItem == "group",
})
})**/
items = append(items, maps.Map{
"name": "缓存策略",
"url": "/servers/components/cache",

View File

@@ -19,6 +19,6 @@ func (this *Helper) BeforeAction(action *actions.ActionObject) {
tabbar := actionutils.NewTabbar()
tabbar.Add("服务", "", "/servers", "", selectedTabbar == "server")
tabbar.Add("组件", "", "/servers/components", "", selectedTabbar == "component")
tabbar.Add("通用", "", "/servers/components", "", selectedTabbar == "component")
actionutils.SetTabbar(action, tabbar)
}

View File

@@ -1,7 +1,15 @@
package components
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/iwind/TeaGo/actions"
)
const (
SettingCodeGlobalConfig = "globalConfig"
)
type IndexAction struct {
@@ -14,6 +22,48 @@ func (this *IndexAction) Init() {
}
func (this *IndexAction) RunGet(params struct{}) {
valueJSONResp, err := this.RPC().SysSettingRPC().ReadSysSetting(this.AdminContext(), &pb.ReadSysSettingRequest{Code: SettingCodeGlobalConfig})
if err != nil {
this.ErrorPage(err)
return
}
valueJSON := valueJSONResp.ValueJSON
globalConfig := &serverconfigs.GlobalConfig{}
if len(valueJSON) > 0 {
err = json.Unmarshal(valueJSON, globalConfig)
if err != nil {
this.ErrorPage(err)
return
}
}
this.Data["globalConfig"] = globalConfig
this.Show()
}
func (this *IndexAction) RunPost(params struct {
GlobalConfigJSON []byte
Must *actions.Must
}) {
if len(params.GlobalConfigJSON) == 0 {
this.Fail("错误的配置信息,请刷新当前页面后重试")
}
globalConfig := &serverconfigs.GlobalConfig{}
err := json.Unmarshal(params.GlobalConfigJSON, globalConfig)
if err != nil {
this.Fail("配置校验失败:" + err.Error())
}
// 修改配置
_, err = this.RPC().SysSettingRPC().UpdateSysSetting(this.AdminContext(), &pb.UpdateSysSettingRequest{
Code: SettingCodeGlobalConfig,
ValueJSON: params.GlobalConfigJSON,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}

View File

@@ -13,7 +13,7 @@ func init() {
Helper(NewHelper()).
Helper(componentutils.NewComponentHelper()).
Prefix("/servers/components").
Get("", new(IndexAction)).
GetPost("", new(IndexAction)).
EndAll()
})
}

View File

@@ -57,7 +57,7 @@ func (this *CertPopupAction) RunGet(params struct {
}
// 引入的服务
serversResp, err := this.RPC().ServerRPC().FindAllServersWithSSLCertId(this.AdminContext(), &pb.FindAllServersWithSSLCertIdRequest{CertId: params.CertId})
serversResp, err := this.RPC().ServerRPC().FindAllEnabledServersWithSSLCertId(this.AdminContext(), &pb.FindAllEnabledServersWithSSLCertIdRequest{CertId: params.CertId})
if err != nil {
this.ErrorPage(err)
return

View File

@@ -13,7 +13,7 @@ func (this *DeleteAction) RunPost(params struct {
CertId int64
}) {
// 是否正在被使用
countResp, err := this.RPC().ServerRPC().CountServersWithSSLCertId(this.AdminContext(), &pb.CountServersWithSSLCertIdRequest{CertId: params.CertId})
countResp, err := this.RPC().ServerRPC().CountAllEnabledServersWithSSLCertId(this.AdminContext(), &pb.CountAllEnabledServersWithSSLCertIdRequest{CertId: params.CertId})
if err != nil {
this.ErrorPage(err)
return

View File

@@ -141,13 +141,14 @@ func (this *IndexAction) RunGet(params struct {
certMaps := []maps.Map{}
nowTime := time.Now().Unix()
for _, certConfig := range certConfigs {
countServersResp, err := this.RPC().ServerRPC().CountServersWithSSLCertId(this.AdminContext(), &pb.CountServersWithSSLCertIdRequest{CertId: certConfig.Id})
countServersResp, err := this.RPC().ServerRPC().CountAllEnabledServersWithSSLCertId(this.AdminContext(), &pb.CountAllEnabledServersWithSSLCertIdRequest{CertId: certConfig.Id})
if err != nil {
this.ErrorPage(err)
return
}
certMaps = append(certMaps, maps.Map{
"isOn": certConfig.IsOn,
"beginDay": timeutil.FormatTime("Y-m-d", certConfig.TimeBeginAt),
"endDay": timeutil.FormatTime("Y-m-d", certConfig.TimeEndAt),
"isExpired": nowTime > certConfig.TimeEndAt,

View File

@@ -48,7 +48,7 @@ func (this *SelectPopupAction) RunGet(params struct{}) {
certMaps := []maps.Map{}
nowTime := time.Now().Unix()
for _, certConfig := range certConfigs {
countServersResp, err := this.RPC().ServerRPC().CountServersWithSSLCertId(this.AdminContext(), &pb.CountServersWithSSLCertIdRequest{CertId: certConfig.Id})
countServersResp, err := this.RPC().ServerRPC().CountAllEnabledServersWithSSLCertId(this.AdminContext(), &pb.CountAllEnabledServersWithSSLCertIdRequest{CertId: certConfig.Id})
if err != nil {
this.ErrorPage(err)
return

View File

@@ -1,6 +1,12 @@
package ssl
import "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs"
"github.com/iwind/TeaGo/actions"
)
type UpdatePopupAction struct {
actionutils.ParentAction
@@ -10,6 +16,114 @@ func (this *UpdatePopupAction) Init() {
this.Nav("", "", "")
}
func (this *UpdatePopupAction) RunGet(params struct{}) {
func (this *UpdatePopupAction) RunGet(params struct {
CertId int64
}) {
certConfigResp, err := this.RPC().SSLCertRPC().FindEnabledSSLCertConfig(this.AdminContext(), &pb.FindEnabledSSLCertConfigRequest{CertId: params.CertId})
if err != nil {
this.ErrorPage(err)
return
}
certConfigJSON := certConfigResp.CertJSON
if len(certConfigJSON) == 0 {
this.NotFound("cert", params.CertId)
return
}
certConfig := &sslconfigs.SSLCertConfig{}
err = json.Unmarshal(certConfigJSON, certConfig)
if err != nil {
this.ErrorPage(err)
return
}
this.Data["certConfig"] = certConfig
this.Show()
}
func (this *UpdatePopupAction) RunPost(params struct {
CertId int64
Name string
IsCA bool
Description string
IsOn bool
CertFile *actions.File
KeyFile *actions.File
Must *actions.Must
}) {
// 查询Cert
certConfigResp, err := this.RPC().SSLCertRPC().FindEnabledSSLCertConfig(this.AdminContext(), &pb.FindEnabledSSLCertConfigRequest{CertId: params.CertId})
if err != nil {
this.ErrorPage(err)
return
}
certConfigJSON := certConfigResp.CertJSON
if len(certConfigJSON) == 0 {
this.NotFound("cert", params.CertId)
return
}
certConfig := &sslconfigs.SSLCertConfig{}
err = json.Unmarshal(certConfigJSON, certConfig)
if err != nil {
this.ErrorPage(err)
return
}
// 校验参数
params.Must.
Field("name", params.Name).
Require("请输入证书说明")
if params.CertFile != nil {
certConfig.CertData, err = params.CertFile.Read()
if err != nil {
this.Fail("读取证书文件内容错误,请重新上传")
}
}
if !params.IsCA {
if params.KeyFile != nil {
certConfig.KeyData, err = params.KeyFile.Read()
if err != nil {
this.Fail("读取密钥文件内容错误,请重新上传")
}
}
}
// 校验
certConfig.IsCA = params.IsCA
err = certConfig.Init()
if err != nil {
if params.IsCA {
this.Fail("证书校验错误:" + err.Error())
} else {
this.Fail("证书或密钥校验错误:" + err.Error())
}
}
// 保存
_, err = this.RPC().SSLCertRPC().UpdateSSLCert(this.AdminContext(), &pb.UpdateSSLCertRequest{
CertId: params.CertId,
IsOn: params.IsOn,
Name: params.Name,
Description: params.Description,
ServerName: "",
IsCA: params.IsCA,
CertData: certConfig.CertData,
KeyData: certConfig.KeyData,
TimeBeginAt: certConfig.TimeBeginAt,
TimeEndAt: certConfig.TimeEndAt,
DnsNames: certConfig.DNSNames,
CommonNames: certConfig.CommonNames,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}

View File

@@ -19,6 +19,6 @@ func (this *Helper) BeforeAction(action *actions.ActionObject) {
tabbar := actionutils.NewTabbar()
tabbar.Add("服务", "", "/servers", "", selectedTabbar == "server")
tabbar.Add("组件", "", "/servers/components", "", selectedTabbar == "component")
tabbar.Add("通用", "", "/servers/components", "", selectedTabbar == "component")
actionutils.SetTabbar(action, tabbar)
}

View File

@@ -27,7 +27,7 @@ func (this *IndexAction) RunGet(params struct {
}
this.Data["webId"] = webConfig.Id
this.Data["cacheConfig"] = webConfig.CacheRef
this.Data["cacheConfig"] = webConfig.CacheRefs
// 所有缓存策略
cachePoliciesResp, err := this.RPC().HTTPCachePolicyRPC().FindAllEnabledHTTPCachePolicies(this.AdminContext(), &pb.FindAllEnabledHTTPCachePoliciesRequest{})

View File

@@ -25,7 +25,7 @@ func (this *IndexAction) RunGet(params struct {
}
this.Data["webId"] = webConfig.Id
this.Data["cacheConfig"] = webConfig.CacheRef
this.Data["cacheConfig"] = webConfig.CacheRefs
// 所有缓存策略
cachePoliciesResp, err := this.RPC().HTTPCachePolicyRPC().FindAllEnabledHTTPCachePolicies(this.AdminContext(), &pb.FindAllEnabledHTTPCachePoliciesRequest{})

View File

@@ -100,7 +100,7 @@ func (this *LocationHelper) createMenus(serverIdString string, locationIdString
"name": "缓存",
"url": "/servers/server/settings/locations/cache?serverId=" + serverIdString + "&locationId=" + locationIdString,
"isActive": secondMenuItem == "cache",
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.CacheRef != nil && locationConfig.Web.CacheRef.IsPrior,
"isOn": locationConfig != nil && locationConfig.Web != nil && len(locationConfig.Web.CacheRefs) > 0,
})
menuItems = append(menuItems, maps.Map{
"name": "访问控制",

View File

@@ -78,12 +78,16 @@ func (this *ServerHelper) createLeftMenu(action *actions.ActionObject) {
// TABBAR
selectedTabbar, _ := action.Data["mainTab"]
tabbar := actionutils.NewTabbar()
tabbar.Add("当前服务:"+server.Name, "", "/servers", "left long alternate arrow", false)
tabbar.Add("服务首页", "", "/servers", "", false)
//tabbar.Add("看板", "", "/servers/server/board?serverId="+serverIdString, "dashboard", selectedTabbar == "board")
tabbar.Add("日志", "", "/servers/server/log?serverId="+serverIdString, "history", selectedTabbar == "log")
//tabbar.Add("统计", "", "/servers/server/stat?serverId="+serverIdString, "chart area", selectedTabbar == "stat")
tabbar.Add("设置", "", "/servers/server/settings?serverId="+serverIdString, "setting", selectedTabbar == "setting")
tabbar.Add("删除", "", "/servers/server/delete?serverId="+serverIdString, "trash", selectedTabbar == "delete")
{
m := tabbar.Add("当前服务:"+server.Name, "", "/servers/server?serverId="+serverIdString, "", false)
m["right"] = true
}
actionutils.SetTabbar(action, tabbar)
@@ -207,7 +211,7 @@ func (this *ServerHelper) createSettingsMenu(secondMenuItem string, serverIdStri
"name": "缓存",
"url": "/servers/server/settings/cache?serverId=" + serverIdString,
"isActive": secondMenuItem == "cache",
"isOn": serverConfig.Web != nil && serverConfig.Web.CacheRef != nil && serverConfig.Web.CacheRef.IsOn,
"isOn": serverConfig.Web != nil && len(serverConfig.Web.CacheRefs) > 0,
})
menuItems = append(menuItems, maps.Map{
"name": "访问控制",