diff --git a/internal/errors/error.go b/internal/errors/error.go new file mode 100644 index 00000000..e44a22f6 --- /dev/null +++ b/internal/errors/error.go @@ -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, + } +} diff --git a/internal/errors/error_test.go b/internal/errors/error_test.go new file mode 100644 index 00000000..b288d27c --- /dev/null +++ b/internal/errors/error_test.go @@ -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()) +} diff --git a/internal/rpc/rpc_client.go b/internal/rpc/rpc_client.go index d3384ac2..468b9122 100644 --- a/internal/rpc/rpc_client.go +++ b/internal/rpc/rpc_client.go @@ -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() diff --git a/internal/web/actions/default/clusters/clusterutils/cluster_helper.go b/internal/web/actions/default/clusters/clusterutils/cluster_helper.go index a1520313..a73fb104 100644 --- a/internal/web/actions/default/clusters/clusterutils/cluster_helper.go +++ b/internal/web/actions/default/clusters/clusterutils/cluster_helper.go @@ -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) // 左侧菜单 diff --git a/internal/web/actions/default/servers/components/cache/clean.go b/internal/web/actions/default/servers/components/cache/clean.go new file mode 100644 index 00000000..7ced0c35 --- /dev/null +++ b/internal/web/actions/default/servers/components/cache/clean.go @@ -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() +} diff --git a/internal/web/actions/default/servers/components/cache/createPopup.go b/internal/web/actions/default/servers/components/cache/createPopup.go new file mode 100644 index 00000000..e26e10f5 --- /dev/null +++ b/internal/web/actions/default/servers/components/cache/createPopup.go @@ -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() +} diff --git a/internal/web/actions/default/servers/components/cache/delete.go b/internal/web/actions/default/servers/components/cache/delete.go new file mode 100644 index 00000000..ed03b696 --- /dev/null +++ b/internal/web/actions/default/servers/components/cache/delete.go @@ -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() +} diff --git a/internal/web/actions/default/servers/components/cache/index.go b/internal/web/actions/default/servers/components/cache/index.go index 5871f782..4fb286b4 100644 --- a/internal/web/actions/default/servers/components/cache/index.go +++ b/internal/web/actions/default/servers/components/cache/index.go @@ -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() } diff --git a/internal/web/actions/default/servers/components/cache/init.go b/internal/web/actions/default/servers/components/cache/init.go index b98e04f8..042ebf56 100644 --- a/internal/web/actions/default/servers/components/cache/init.go +++ b/internal/web/actions/default/servers/components/cache/init.go @@ -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() }) } diff --git a/internal/web/actions/default/servers/components/cache/policy.go b/internal/web/actions/default/servers/components/cache/policy.go new file mode 100644 index 00000000..3dc4c3ca --- /dev/null +++ b/internal/web/actions/default/servers/components/cache/policy.go @@ -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() +} diff --git a/internal/web/actions/default/servers/components/cache/preheat.go b/internal/web/actions/default/servers/components/cache/preheat.go new file mode 100644 index 00000000..73123fab --- /dev/null +++ b/internal/web/actions/default/servers/components/cache/preheat.go @@ -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() +} diff --git a/internal/web/actions/default/servers/components/cache/purge.go b/internal/web/actions/default/servers/components/cache/purge.go new file mode 100644 index 00000000..fe2030a1 --- /dev/null +++ b/internal/web/actions/default/servers/components/cache/purge.go @@ -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() +} diff --git a/internal/web/actions/default/servers/components/cache/stat.go b/internal/web/actions/default/servers/components/cache/stat.go new file mode 100644 index 00000000..4dfacade --- /dev/null +++ b/internal/web/actions/default/servers/components/cache/stat.go @@ -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() +} diff --git a/internal/web/actions/default/servers/components/cache/test.go b/internal/web/actions/default/servers/components/cache/test.go new file mode 100644 index 00000000..aefc1a64 --- /dev/null +++ b/internal/web/actions/default/servers/components/cache/test.go @@ -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() +} diff --git a/internal/web/actions/default/servers/components/cache/updatePopup.go b/internal/web/actions/default/servers/components/cache/updatePopup.go new file mode 100644 index 00000000..1c7ee465 --- /dev/null +++ b/internal/web/actions/default/servers/components/cache/updatePopup.go @@ -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() +} diff --git a/internal/web/actions/default/servers/components/componentutils/component_helper.go b/internal/web/actions/default/servers/components/componentutils/component_helper.go index 2fe7a902..483d0155 100644 --- a/internal/web/actions/default/servers/components/componentutils/component_helper.go +++ b/internal/web/actions/default/servers/components/componentutils/component_helper.go @@ -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", diff --git a/internal/web/actions/default/servers/components/helper.go b/internal/web/actions/default/servers/components/helper.go index ba3852e1..d0c0f003 100644 --- a/internal/web/actions/default/servers/components/helper.go +++ b/internal/web/actions/default/servers/components/helper.go @@ -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) } diff --git a/internal/web/actions/default/servers/components/index.go b/internal/web/actions/default/servers/components/index.go index fc548342..ffcf9e45 100644 --- a/internal/web/actions/default/servers/components/index.go +++ b/internal/web/actions/default/servers/components/index.go @@ -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() +} diff --git a/internal/web/actions/default/servers/components/init.go b/internal/web/actions/default/servers/components/init.go index b36dd24b..92201799 100644 --- a/internal/web/actions/default/servers/components/init.go +++ b/internal/web/actions/default/servers/components/init.go @@ -13,7 +13,7 @@ func init() { Helper(NewHelper()). Helper(componentutils.NewComponentHelper()). Prefix("/servers/components"). - Get("", new(IndexAction)). + GetPost("", new(IndexAction)). EndAll() }) } diff --git a/internal/web/actions/default/servers/components/ssl/certPopup.go b/internal/web/actions/default/servers/components/ssl/certPopup.go index 88f6fef0..3ecbc855 100644 --- a/internal/web/actions/default/servers/components/ssl/certPopup.go +++ b/internal/web/actions/default/servers/components/ssl/certPopup.go @@ -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 diff --git a/internal/web/actions/default/servers/components/ssl/delete.go b/internal/web/actions/default/servers/components/ssl/delete.go index e9e1d4ab..f2c36508 100644 --- a/internal/web/actions/default/servers/components/ssl/delete.go +++ b/internal/web/actions/default/servers/components/ssl/delete.go @@ -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 diff --git a/internal/web/actions/default/servers/components/ssl/index.go b/internal/web/actions/default/servers/components/ssl/index.go index c6b69bbc..13a32c2a 100644 --- a/internal/web/actions/default/servers/components/ssl/index.go +++ b/internal/web/actions/default/servers/components/ssl/index.go @@ -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, diff --git a/internal/web/actions/default/servers/components/ssl/selectPopup.go b/internal/web/actions/default/servers/components/ssl/selectPopup.go index bc6eb470..67268d08 100644 --- a/internal/web/actions/default/servers/components/ssl/selectPopup.go +++ b/internal/web/actions/default/servers/components/ssl/selectPopup.go @@ -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 diff --git a/internal/web/actions/default/servers/components/ssl/updatePopup.go b/internal/web/actions/default/servers/components/ssl/updatePopup.go index 39a4246e..33288fd6 100644 --- a/internal/web/actions/default/servers/components/ssl/updatePopup.go +++ b/internal/web/actions/default/servers/components/ssl/updatePopup.go @@ -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() +} diff --git a/internal/web/actions/default/servers/helper.go b/internal/web/actions/default/servers/helper.go index da761f6a..e9781c9a 100644 --- a/internal/web/actions/default/servers/helper.go +++ b/internal/web/actions/default/servers/helper.go @@ -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) } diff --git a/internal/web/actions/default/servers/server/settings/cache/index.go b/internal/web/actions/default/servers/server/settings/cache/index.go index ecd31ee0..454d74bf 100644 --- a/internal/web/actions/default/servers/server/settings/cache/index.go +++ b/internal/web/actions/default/servers/server/settings/cache/index.go @@ -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{}) diff --git a/internal/web/actions/default/servers/server/settings/locations/cache/index.go b/internal/web/actions/default/servers/server/settings/locations/cache/index.go index b834f580..122d514a 100644 --- a/internal/web/actions/default/servers/server/settings/locations/cache/index.go +++ b/internal/web/actions/default/servers/server/settings/locations/cache/index.go @@ -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{}) diff --git a/internal/web/actions/default/servers/server/settings/locations/locationutils/location_helper.go b/internal/web/actions/default/servers/server/settings/locations/locationutils/location_helper.go index 78788070..532c23ae 100644 --- a/internal/web/actions/default/servers/server/settings/locations/locationutils/location_helper.go +++ b/internal/web/actions/default/servers/server/settings/locations/locationutils/location_helper.go @@ -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": "访问控制", diff --git a/internal/web/actions/default/servers/serverutils/server_helper.go b/internal/web/actions/default/servers/serverutils/server_helper.go index cbb363cc..596bef5a 100644 --- a/internal/web/actions/default/servers/serverutils/server_helper.go +++ b/internal/web/actions/default/servers/serverutils/server_helper.go @@ -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": "访问控制", diff --git a/web/public/js/components/common/time-duration-box.js b/web/public/js/components/common/time-duration-box.js new file mode 100644 index 00000000..b35e29f3 --- /dev/null +++ b/web/public/js/components/common/time-duration-box.js @@ -0,0 +1,47 @@ +Vue.component("time-duration-box", { + props: ["v-name", "v-value", "v-count", "v-unit"], + data: function () { + let v = this.vValue + if (v == null) { + v = { + count: this.vCount, + unit: this.vUnit + } + } + if (typeof (v["count"]) != "number") { + v["count"] = -1 + } + return { + "size": v, + countString: (v.count >= 0) ? v.count.toString() : "" + } + }, + watch: { + "countString": function (newValue) { + let value = newValue.trim() + if (value.length == 0) { + this.size.count = -1 + return + } + let count = parseInt(value) + if (!isNaN(count)) { + this.size.count = count + } + } + }, + template: `
+ +
+ +
+
+ +
+
` +}) \ No newline at end of file diff --git a/web/public/js/components/server/http-cache-cond-box.js b/web/public/js/components/server/http-cache-cond-box.js new file mode 100644 index 00000000..408ee785 --- /dev/null +++ b/web/public/js/components/server/http-cache-cond-box.js @@ -0,0 +1,50 @@ +Vue.component("http-cache-cond-box", { + template: `
+ + + + + + + + + + + + + + + + + + + + + + + + + +
匹配条件
缓存有效期 + +
状态码列表 + +

允许缓存的HTTP状态码列表。

+
跳过的Cache-Control值 + +

当响应的Cache-Control为这些值时不缓存响应内容,而且不区分大小写。

+
跳过Set-Cookie +
+ + +
+

选中后,当响应的Header中有Set-Cookie时不缓存响应内容。

+
支持请求no-cache刷新 +
+ + +
+

选中后,当请求的Header中含有Pragma: no-cache或Cache-Control: no-cache时,会跳过缓存直接读取源内容。

+
+
` +}) \ No newline at end of file diff --git a/web/public/js/components/server/http-gzip-box.js b/web/public/js/components/server/http-gzip-box.js index cadef2c8..1bf69104 100644 --- a/web/public/js/components/server/http-gzip-box.js +++ b/web/public/js/components/server/http-gzip-box.js @@ -68,8 +68,13 @@ Vue.component("http-gzip-box", {

0表示不限制,内容长度从文件尺寸或Content-Length中获取。

+ + 匹配条件 + + + + - ` }) \ No newline at end of file diff --git a/web/public/js/components/server/http-request-conds-box.js b/web/public/js/components/server/http-request-conds-box.js new file mode 100644 index 00000000..095ac6dd --- /dev/null +++ b/web/public/js/components/server/http-request-conds-box.js @@ -0,0 +1,82 @@ +Vue.component("http-request-conds-box", { + props: ["v-conds"], + data: function () { + let conds = this.vConds + if (conds == null) { + conds = { + isOn: true, + connector: "or", + groups: [] + } + } + return { + conds: conds, + components: window.REQUEST_COND_COMPONENTS + } + }, + methods: { + addGroup: function () { + let that = this + teaweb.popup("/servers/server/settings/conds/addGroupPopup", { + height: "30em", + callback: function (resp) { + that.conds.groups.push(resp.data.group) + } + }) + }, + updateGroup: function (groupIndex, group) { + window.UPDATING_COND_GROUP = group + let that = this + teaweb.popup("/servers/server/settings/conds/addGroupPopup", { + height: "30em", + callback: function (resp) { + Vue.set(that.conds.groups, groupIndex, resp.data.group) + } + }) + }, + removeGroup: function (groupIndex) { + let that = this + teaweb.confirm("确定要删除这一组条件吗?", function () { + that.conds.groups.$remove(groupIndex) + }) + }, + typeName: function (cond) { + let c = this.components.$find(function (k, v) { + return v.type == cond.type + }) + if (c != null) { + return c.name; + } + return cond.param + " " + cond.operator + } + }, + template: `
+ +
+ + + + + +
+ + + {{cond.param}} {{cond.operator}} + {{typeName(cond)}}: + {{cond.value}} + + + {{group.connector}}   + + + +
+
+
+ +
+ +
+
+` +}) \ No newline at end of file diff --git a/web/public/js/components/server/http-request-conds-tbody.js b/web/public/js/components/server/http-request-conds-tbody.js deleted file mode 100644 index beb03a09..00000000 --- a/web/public/js/components/server/http-request-conds-tbody.js +++ /dev/null @@ -1,87 +0,0 @@ -Vue.component("http-request-conds-tbody", { - props: ["v-conds"], - data: function () { - let conds = this.vConds - if (conds == null) { - conds = { - isOn: true, - connector: "or", - groups: [] - } - } - return { - conds: conds, - components: window.REQUEST_COND_COMPONENTS - } - }, - methods: { - addGroup: function () { - let that = this - teaweb.popup("/servers/server/settings/conds/addGroupPopup", { - height: "30em", - callback: function (resp) { - that.conds.groups.push(resp.data.group) - } - }) - }, - updateGroup: function (groupIndex, group) { - window.UPDATING_COND_GROUP = group - let that = this - teaweb.popup("/servers/server/settings/conds/addGroupPopup", { - height: "30em", - callback: function (resp) { - Vue.set(that.conds.groups, groupIndex, resp.data.group) - } - }) - }, - removeGroup: function (groupIndex) { - let that = this - teaweb.confirm("确定要删除这一组条件吗?", function () { - that.conds.groups.$remove(groupIndex) - }) - }, - typeName: function (cond) { - let c = this.components.$find(function (k, v) { - return v.type == cond.type - }) - if (c != null) { - return c.name; - } - return cond.param + " " + cond.operator - } - }, - template: ` - - 匹配条件 - - -
-
- - - - - -
- - - {{cond.param}} {{cond.operator}} - {{typeName(cond)}}: - {{cond.value}} - - - {{group.connector}}   - - - -
-
-
- -
- -
- - - ` -}) \ No newline at end of file diff --git a/web/views/@default/@layout_popup.css b/web/views/@default/@layout_popup.css index 6904e646..ba25b550 100644 --- a/web/views/@default/@layout_popup.css +++ b/web/views/@default/@layout_popup.css @@ -207,10 +207,6 @@ label[for] { label.blue { color: #2185d0 !important; } -td .label.tiny { - padding: 2px; - font-size: 0.9em; -} /** Menu **/ .first-menu .menu.text { margin-top: 0 !important; diff --git a/web/views/@default/@layout_popup.css.map b/web/views/@default/@layout_popup.css.map index e5da5bf4..aea2657c 100644 --- a/web/views/@default/@layout_popup.css.map +++ b/web/views/@default/@layout_popup.css.map @@ -1 +1 @@ -{"version":3,"sources":["@layout_popup.less"],"names":[],"mappings":"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","file":"@layout_popup.css"} \ No newline at end of file +{"version":3,"sources":["@layout_popup.less"],"names":[],"mappings":"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","file":"@layout_popup.css"} \ No newline at end of file diff --git a/web/views/@default/@layout_popup.less b/web/views/@default/@layout_popup.less index 7c9d6c60..f21643b7 100644 --- a/web/views/@default/@layout_popup.less +++ b/web/views/@default/@layout_popup.less @@ -251,8 +251,6 @@ label.blue { } td .label.tiny { - padding: 2px; - font-size: 0.9em; } /** Menu **/ diff --git a/web/views/@default/servers/components/cache/createPopup.html b/web/views/@default/servers/components/cache/createPopup.html new file mode 100644 index 00000000..49b8e7b1 --- /dev/null +++ b/web/views/@default/servers/components/cache/createPopup.html @@ -0,0 +1,74 @@ +{$layout "layout_popup"} + +

创建缓存策略

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
策略名称 *
缓存类型 * + +
缓存目录 * + +

存放文件缓存的目录,通常填写绝对路径。

+
缓存最大容量 + +

允许缓存的最大内容长度,如果为0表示没有限制。

+
最大内容长度 + +

允许缓存的最大内容长度,如果为0表示没有限制。

+
容纳Key数量 + +

可以容纳多少数量的Key,0表示不限制。

+
描述 + +
是否启用 +
+ + +
+
+ +
\ No newline at end of file diff --git a/web/views/@default/servers/components/cache/createPopup.js b/web/views/@default/servers/components/cache/createPopup.js new file mode 100644 index 00000000..cc0adac4 --- /dev/null +++ b/web/views/@default/servers/components/cache/createPopup.js @@ -0,0 +1,5 @@ +Tea.context(function () { + this.success = NotifyPopup + + this.policyType = this.types[0].type +}) \ No newline at end of file diff --git a/web/views/@default/servers/components/cache/index.html b/web/views/@default/servers/components/cache/index.html index fb2dbfb9..9ad0f1eb 100644 --- a/web/views/@default/servers/components/cache/index.html +++ b/web/views/@default/servers/components/cache/index.html @@ -2,5 +2,38 @@ {$template "/left_menu"}
-

此功能暂未开放敬请期待。

+ + 列表 + | + [创建] + + +

暂时还没有缓存策略。

+ + + + + + + + + + + + + + + + + + + +
策略名称策略类型容量引用服务状态操作
{{policy.name}}{{infos[index].typeName}} ({{policy.type}}) + {{policy.capacity.count}}{{policy.capacity.unit.toUpperCase()}} + 不限 + {{infos[index].countServers}} + 详情   修改   删除 +
+ +
\ No newline at end of file diff --git a/web/views/@default/servers/components/cache/index.js b/web/views/@default/servers/components/cache/index.js new file mode 100644 index 00000000..dbd62248 --- /dev/null +++ b/web/views/@default/servers/components/cache/index.js @@ -0,0 +1,37 @@ +Tea.context(function () { + // 创建策略 + this.createPolicy = function () { + teaweb.popup("/servers/components/cache/createPopup", { + height: "27em", + callback: function () { + teaweb.success("保存成功", function () { + window.location.reload() + }) + } + }) + } + + // 修改策略 + this.updatePolicy = function (policyId) { + teaweb.popup("/servers/components/cache/updatePopup?cachePolicyId=" + policyId, { + height: "27em", + callback: function () { + teaweb.success("保存成功", function () { + window.location.reload() + }) + } + }) + } + + // 删除策略 + this.deletePolicy = function (policyId) { + let that = this + teaweb.confirm("确定要删除此缓存策略吗?", function () { + that.$post("/servers/components/cache/delete") + .params({ + cachePolicyId: policyId + }) + .refresh() + }) + } +}) \ No newline at end of file diff --git a/web/views/@default/servers/components/cache/updatePopup.html b/web/views/@default/servers/components/cache/updatePopup.html new file mode 100644 index 00000000..03726cdf --- /dev/null +++ b/web/views/@default/servers/components/cache/updatePopup.html @@ -0,0 +1,76 @@ +{$layout "layout_popup"} + +

修改缓存策略

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
策略名称 *
缓存类型 * + +
缓存目录 * + +

存放文件缓存的目录,通常填写绝对路径。

+
缓存最大容量 + +

允许缓存的最大内容长度,如果为0表示没有限制。

+
最大内容长度 + +

允许缓存的最大内容长度,如果为0表示没有限制。

+
容纳Key数量 + +

可以容纳多少数量的Key,0表示不限制。

+
描述 + +
是否启用 +
+ + +
+
+ +
\ No newline at end of file diff --git a/web/views/@default/servers/components/cache/updatePopup.js b/web/views/@default/servers/components/cache/updatePopup.js new file mode 100644 index 00000000..34fd51e4 --- /dev/null +++ b/web/views/@default/servers/components/cache/updatePopup.js @@ -0,0 +1,5 @@ +Tea.context(function () { + this.success = NotifyPopup + + this.policyType = this.cachePolicy.type +}) \ No newline at end of file diff --git a/web/views/@default/servers/components/index.html b/web/views/@default/servers/components/index.html index fb2dbfb9..bcd368d2 100644 --- a/web/views/@default/servers/components/index.html +++ b/web/views/@default/servers/components/index.html @@ -2,5 +2,24 @@ {$template "/left_menu"}
-

此功能暂未开放敬请期待。

+
+ + + + + + + + + +
HTTP/HTTPS通用设置
是否严格匹配域名 +
+ + +
+

如果选择了严格匹配域名,则没有在Edge里绑定过的域名访问时都会返回404。

+
+ 保存 +
+
\ No newline at end of file diff --git a/web/views/@default/servers/components/index.js b/web/views/@default/servers/components/index.js new file mode 100644 index 00000000..295a9aaf --- /dev/null +++ b/web/views/@default/servers/components/index.js @@ -0,0 +1,3 @@ +Tea.context(function () { + this.success = NotifyReloadSuccess("保存成功") +}) \ No newline at end of file diff --git a/web/views/@default/servers/components/ssl/certPopup.html b/web/views/@default/servers/components/ssl/certPopup.html index 4e9ee5bf..d1fc51d0 100644 --- a/web/views/@default/servers/components/ssl/certPopup.html +++ b/web/views/@default/servers/components/ssl/certPopup.html @@ -8,7 +8,7 @@ 详细说明 - {{info.decription}} + {{info.description}} 证书状态 diff --git a/web/views/@default/servers/components/ssl/index.html b/web/views/@default/servers/components/ssl/index.html index 28c90610..1fcbf0ba 100644 --- a/web/views/@default/servers/components/ssl/index.html +++ b/web/views/@default/servers/components/ssl/index.html @@ -45,7 +45,8 @@ {{certInfos[index].endDay}} {{certInfos[index].countServers}} - 已过期 + 未启用 + 已过期 有效中 diff --git a/web/views/@default/servers/components/ssl/index.js b/web/views/@default/servers/components/ssl/index.js index 2852f907..0bed2e1d 100644 --- a/web/views/@default/servers/components/ssl/index.js +++ b/web/views/@default/servers/components/ssl/index.js @@ -30,4 +30,16 @@ Tea.context(function () { width: "48em" }) } + + // 修改证书 + this.updateCert = function (certId) { + teaweb.popup("/servers/components/ssl/updatePopup?certId=" + certId, { + height: "28em", + callback: function () { + teaweb.success("上传成功", function () { + window.location.reload() + }) + } + }) + } }) \ No newline at end of file diff --git a/web/views/@default/servers/components/ssl/updatePopup.html b/web/views/@default/servers/components/ssl/updatePopup.html new file mode 100644 index 00000000..1a97410e --- /dev/null +++ b/web/views/@default/servers/components/ssl/updatePopup.html @@ -0,0 +1,60 @@ +{$layout "layout_popup"} + +

修改证书

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
证书说明 * + +

可以简单说明证书的用途。

+
证书类型 + +
选择证书文件 + +

内容中通常含有"-----BEGIN CERTIFICATE-----"类似的信息。

+
选择私钥文件 + +

内容中通常含有"-----BEGIN RSA PRIVATE KEY-----"类似的信息。

+
详细说明 + +
是否启用 +
+ + +
+
+ +
\ No newline at end of file diff --git a/web/views/@default/servers/components/ssl/updatePopup.js b/web/views/@default/servers/components/ssl/updatePopup.js new file mode 100644 index 00000000..5e6a55a7 --- /dev/null +++ b/web/views/@default/servers/components/ssl/updatePopup.js @@ -0,0 +1,4 @@ +Tea.context(function () { + this.success = NotifyPopup + this.isCA = this.certConfig.isCA ? 1 : 0 +}) \ No newline at end of file diff --git a/web/views/@default/servers/components/ssl/uploadPopup.html b/web/views/@default/servers/components/ssl/uploadPopup.html index e200ac8d..07baca6f 100644 --- a/web/views/@default/servers/components/ssl/uploadPopup.html +++ b/web/views/@default/servers/components/ssl/uploadPopup.html @@ -24,7 +24,7 @@ 选择证书文件 * -

内容中通常含有"-----BEGIN CERTIFICATE-----"类似的信息。

内容中通常含有"-----BEGIN CERTIFICATE-----"类似的信息。

diff --git a/web/views/@default/servers/index.html b/web/views/@default/servers/index.html index 3dc41209..d3deb3b0 100644 --- a/web/views/@default/servers/index.html +++ b/web/views/@default/servers/index.html @@ -9,7 +9,7 @@ 服务名称 服务类型 部署集群 - 运行节点数 + 运行中节点数 未运行节点数 端口 状态 @@ -24,8 +24,8 @@ [暂无] - -
- {{port.portRange}}({{port.protocol}}) +
+
{{port.portRange}}({{port.protocol}})
diff --git a/web/views/@default/servers/server/index.html b/web/views/@default/servers/server/index.html index 73a1b993..f041f9fd 100644 --- a/web/views/@default/servers/server/index.html +++ b/web/views/@default/servers/server/index.html @@ -1,94 +1,5 @@ {$layout} - {$template "/left_menu"}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
服务名称 - {{server.name}} -
部署的集群 - {{server.cluster.name}} -
服务类型 - {{serverType.name}} -
绑定端口 - - -
- {{port.portRange}}({{port.protocol}}) -
-
绑定域名 -
- {{serverName.type}} {{serverName.name}} -
-
源站地址 -
-
- {{origin.addr.protocol}}://{{origin.addr.host}}:{{origin.addr.portRange}} -
-
-
描述 - - - {{server.description}} -
\ No newline at end of file