diff --git a/internal/rpc/rpc_client.go b/internal/rpc/rpc_client.go index b0f42b27..9a83b34d 100644 --- a/internal/rpc/rpc_client.go +++ b/internal/rpc/rpc_client.go @@ -220,6 +220,10 @@ func (this *RPCClient) HTTPAccessLogRPC() pb.HTTPAccessLogServiceClient { return pb.NewHTTPAccessLogServiceClient(this.pickConn()) } +func (this *RPCClient) HTTPFastcgiRPC() pb.HTTPFastcgiServiceClient { + return pb.NewHTTPFastcgiServiceClient(this.pickConn()) +} + func (this *RPCClient) SSLCertRPC() pb.SSLCertServiceClient { return pb.NewSSLCertServiceClient(this.pickConn()) } diff --git a/internal/web/actions/default/servers/server/settings/fastcgi/createPopup.go b/internal/web/actions/default/servers/server/settings/fastcgi/createPopup.go new file mode 100644 index 00000000..6a2b754f --- /dev/null +++ b/internal/web/actions/default/servers/server/settings/fastcgi/createPopup.go @@ -0,0 +1,96 @@ +// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved. + +package fastcgi + +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/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" + "github.com/iwind/TeaGo/actions" + "net" +) + +type CreatePopupAction struct { + actionutils.ParentAction +} + +func (this *CreatePopupAction) Init() { + this.Nav("", "", "") +} + +func (this *CreatePopupAction) RunGet(params struct{}) { + this.Show() +} + +func (this *CreatePopupAction) RunPost(params struct { + Address string + ParamsJSON []byte + ReadTimeout int64 + PoolSize int32 + PathInfoPattern string + IsOn bool + + Must *actions.Must + CSRF *actionutils.CSRF +}) { + var fastcgiId = int64(0) + defer func() { + if fastcgiId > 0 { + this.CreateLogInfo("创建Fastcgi %d", fastcgiId) + } else { + this.CreateLogInfo("创建Fastcgi") + } + }() + + params.Must. + Field("address", params.Address). + Require("请输入Fastcgi地址") + + _, _, err := net.SplitHostPort(params.Address) + if err != nil { + this.FailField("address", "请输入正确的Fastcgi地址") + } + + readTimeoutJSON, err := json.Marshal(&shared.TimeDuration{ + Count: params.ReadTimeout, + Unit: "second", + }) + if err != nil { + this.ErrorPage(err) + return + } + + createResp, err := this.RPC().HTTPFastcgiRPC().CreateHTTPFastcgi(this.AdminContext(), &pb.CreateHTTPFastcgiRequest{ + IsOn: params.IsOn, + Address: params.Address, + ParamsJSON: params.ParamsJSON, + ReadTimeoutJSON: readTimeoutJSON, + ConnTimeoutJSON: nil, // TODO 将来支持 + PoolSize: params.PoolSize, + PathInfoPattern: params.PathInfoPattern, + }) + if err != nil { + this.ErrorPage(err) + return + } + fastcgiId = createResp.HttpFastcgiId + + configResp, err := this.RPC().HTTPFastcgiRPC().FindEnabledHTTPFastcgiConfig(this.AdminContext(), &pb.FindEnabledHTTPFastcgiConfigRequest{HttpFastcgiId: fastcgiId}) + if err != nil { + this.ErrorPage(err) + return + } + configJSON := configResp.HttpFastcgiJSON + config := &serverconfigs.HTTPFastcgiConfig{} + err = json.Unmarshal(configJSON, config) + if err != nil { + this.ErrorPage(err) + return + } + + this.Data["fastcgi"] = config + + this.Success() +} diff --git a/internal/web/actions/default/servers/server/settings/fastcgi/index.go b/internal/web/actions/default/servers/server/settings/fastcgi/index.go new file mode 100644 index 00000000..46f7db7b --- /dev/null +++ b/internal/web/actions/default/servers/server/settings/fastcgi/index.go @@ -0,0 +1,70 @@ +package fastcgi + +import ( + "encoding/json" + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" + "github.com/iwind/TeaGo/actions" +) + +type IndexAction struct { + actionutils.ParentAction +} + +func (this *IndexAction) Init() { + this.Nav("", "setting", "index") + this.SecondMenu("fastcgi") +} + +func (this *IndexAction) 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["fastcgiRef"] = webConfig.FastcgiRef + this.Data["fastcgiConfigs"] = webConfig.FastcgiList + + this.Show() +} + +func (this *IndexAction) RunPost(params struct { + WebId int64 + FastcgiRefJSON []byte + FastcgiJSON []byte + + Must *actions.Must +}) { + defer this.CreateLogInfo("修改Web %d 的Fastcgi设置", params.WebId) + + // TODO 检查配置 + + fastcgiRef := &serverconfigs.HTTPFastcgiRef{} + err := json.Unmarshal(params.FastcgiRefJSON, fastcgiRef) + if err != nil { + this.ErrorPage(err) + return + } + + fastcgiRefJSON, err := json.Marshal(fastcgiRef) + if err != nil { + this.ErrorPage(err) + return + } + _, err = this.RPC().HTTPWebRPC().UpdateHTTPWebFastcgi(this.AdminContext(), &pb.UpdateHTTPWebFastcgiRequest{ + WebId: params.WebId, + FastcgiJSON: fastcgiRefJSON, + }) + if err != nil { + this.ErrorPage(err) + return + } + + this.Success() +} diff --git a/internal/web/actions/default/servers/server/settings/fastcgi/init.go b/internal/web/actions/default/servers/server/settings/fastcgi/init.go new file mode 100644 index 00000000..6e366bd3 --- /dev/null +++ b/internal/web/actions/default/servers/server/settings/fastcgi/init.go @@ -0,0 +1,21 @@ +package fastcgi + +import ( + "github.com/TeaOSLab/EdgeAdmin/internal/configloaders" + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils" + "github.com/TeaOSLab/EdgeAdmin/internal/web/helpers" + "github.com/iwind/TeaGo" +) + +func init() { + TeaGo.BeforeStart(func(server *TeaGo.Server) { + server. + Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeServer)). + Helper(serverutils.NewServerHelper()). + Prefix("/servers/server/settings/fastcgi"). + GetPost("", new(IndexAction)). + GetPost("/createPopup", new(CreatePopupAction)). + GetPost("/updatePopup", new(UpdatePopupAction)). + EndAll() + }) +} diff --git a/internal/web/actions/default/servers/server/settings/fastcgi/updatePopup.go b/internal/web/actions/default/servers/server/settings/fastcgi/updatePopup.go new file mode 100644 index 00000000..962f3189 --- /dev/null +++ b/internal/web/actions/default/servers/server/settings/fastcgi/updatePopup.go @@ -0,0 +1,106 @@ +// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved. + +package fastcgi + +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/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" + "github.com/iwind/TeaGo/actions" + "net" +) + +type UpdatePopupAction struct { + actionutils.ParentAction +} + +func (this *UpdatePopupAction) Init() { + this.Nav("", "", "") +} + +func (this *UpdatePopupAction) RunGet(params struct { + FastcgiId int64 +}) { + configResp, err := this.RPC().HTTPFastcgiRPC().FindEnabledHTTPFastcgiConfig(this.AdminContext(), &pb.FindEnabledHTTPFastcgiConfigRequest{HttpFastcgiId: params.FastcgiId}) + if err != nil { + this.ErrorPage(err) + return + } + configJSON := configResp.HttpFastcgiJSON + config := &serverconfigs.HTTPFastcgiConfig{} + err = json.Unmarshal(configJSON, config) + if err != nil { + this.ErrorPage(err) + return + } + this.Data["fastcgi"] = config + + this.Show() +} + +func (this *UpdatePopupAction) RunPost(params struct { + FastcgiId int64 + Address string + ParamsJSON []byte + ReadTimeout int64 + PoolSize int32 + PathInfoPattern string + IsOn bool + + Must *actions.Must + CSRF *actionutils.CSRF +}) { + defer this.CreateLogInfo("修改Fastcgi %d", params.FastcgiId) + + params.Must. + Field("address", params.Address). + Require("请输入Fastcgi地址") + + _, _, err := net.SplitHostPort(params.Address) + if err != nil { + this.FailField("address", "请输入正确的Fastcgi地址") + } + + readTimeoutJSON, err := json.Marshal(&shared.TimeDuration{ + Count: params.ReadTimeout, + Unit: "second", + }) + if err != nil { + this.ErrorPage(err) + return + } + + _, err = this.RPC().HTTPFastcgiRPC().UpdateHTTPFastcgi(this.AdminContext(), &pb.UpdateHTTPFastcgiRequest{ + HttpFastcgiId: params.FastcgiId, + IsOn: params.IsOn, + Address: params.Address, + ParamsJSON: params.ParamsJSON, + ReadTimeoutJSON: readTimeoutJSON, + ConnTimeoutJSON: nil, // TODO 将来支持 + PoolSize: params.PoolSize, + PathInfoPattern: params.PathInfoPattern, + }) + if err != nil { + this.ErrorPage(err) + return + } + + configResp, err := this.RPC().HTTPFastcgiRPC().FindEnabledHTTPFastcgiConfig(this.AdminContext(), &pb.FindEnabledHTTPFastcgiConfigRequest{HttpFastcgiId: params.FastcgiId}) + if err != nil { + this.ErrorPage(err) + return + } + configJSON := configResp.HttpFastcgiJSON + config := &serverconfigs.HTTPFastcgiConfig{} + err = json.Unmarshal(configJSON, config) + if err != nil { + this.ErrorPage(err) + return + } + + this.Data["fastcgi"] = config + + this.Success() +} diff --git a/internal/web/actions/default/servers/server/settings/gzip/index.go b/internal/web/actions/default/servers/server/settings/gzip/index.go index 03b743a1..b159f800 100644 --- a/internal/web/actions/default/servers/server/settings/gzip/index.go +++ b/internal/web/actions/default/servers/server/settings/gzip/index.go @@ -40,12 +40,12 @@ func (this *IndexAction) RunGet(params struct { IsOn: true, } if gzipId > 0 { - resp, err := this.RPC().HTTPGzipRPC().FindEnabledHTTPGzipConfig(this.AdminContext(), &pb.FindEnabledGzipConfigRequest{GzipId: gzipId}) + resp, err := this.RPC().HTTPGzipRPC().FindEnabledHTTPGzipConfig(this.AdminContext(), &pb.FindEnabledGzipConfigRequest{HttpGzipId: gzipId}) if err != nil { this.ErrorPage(err) return } - err = json.Unmarshal(resp.GzipJSON, gzipConfig) + err = json.Unmarshal(resp.HttpGzipJSON, gzipConfig) if err != nil { this.ErrorPage(err) return @@ -111,11 +111,11 @@ func (this *IndexAction) RunPost(params struct { if params.GzipId > 0 { _, err := this.RPC().HTTPGzipRPC().UpdateHTTPGzip(this.AdminContext(), &pb.UpdateHTTPGzipRequest{ - GzipId: params.GzipId, - Level: types.Int32(params.Level), - MinLength: minLength, - MaxLength: maxLength, - CondsJSON: params.CondsJSON, + HttpGzipId: params.GzipId, + Level: types.Int32(params.Level), + MinLength: minLength, + MaxLength: maxLength, + CondsJSON: params.CondsJSON, }) if err != nil { this.ErrorPage(err) @@ -132,7 +132,7 @@ func (this *IndexAction) RunPost(params struct { this.ErrorPage(err) return } - gzipRef.GzipId = resp.GzipId + gzipRef.GzipId = resp.HttpGzipId } gzipRefJSON, err := json.Marshal(gzipRef) diff --git a/internal/web/actions/default/servers/server/settings/locations/fastcgi/index.go b/internal/web/actions/default/servers/server/settings/locations/fastcgi/index.go new file mode 100644 index 00000000..4a1e4419 --- /dev/null +++ b/internal/web/actions/default/servers/server/settings/locations/fastcgi/index.go @@ -0,0 +1,69 @@ +package fastcgi + +import ( + "encoding/json" + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" + "github.com/iwind/TeaGo/actions" +) + +type IndexAction struct { + actionutils.ParentAction +} + +func (this *IndexAction) Init() { + +} + +func (this *IndexAction) RunGet(params struct { + LocationId int64 +}) { + webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithLocationId(this.AdminContext(), params.LocationId) + if err != nil { + this.ErrorPage(err) + return + } + + this.Data["webId"] = webConfig.Id + this.Data["fastcgiRef"] = webConfig.FastcgiRef + this.Data["fastcgiConfigs"] = webConfig.FastcgiList + + this.Show() +} + +func (this *IndexAction) RunPost(params struct { + WebId int64 + FastcgiRefJSON []byte + FastcgiJSON []byte + + Must *actions.Must +}) { + defer this.CreateLogInfo("修改Web %d 的Fastcgi设置", params.WebId) + + // TODO 检查配置 + + fastcgiRef := &serverconfigs.HTTPFastcgiRef{} + err := json.Unmarshal(params.FastcgiRefJSON, fastcgiRef) + if err != nil { + this.ErrorPage(err) + return + } + + fastcgiRefJSON, err := json.Marshal(fastcgiRef) + if err != nil { + this.ErrorPage(err) + return + } + _, err = this.RPC().HTTPWebRPC().UpdateHTTPWebFastcgi(this.AdminContext(), &pb.UpdateHTTPWebFastcgiRequest{ + WebId: params.WebId, + FastcgiJSON: fastcgiRefJSON, + }) + if err != nil { + this.ErrorPage(err) + return + } + + this.Success() +} diff --git a/internal/web/actions/default/servers/server/settings/locations/fastcgi/init.go b/internal/web/actions/default/servers/server/settings/locations/fastcgi/init.go new file mode 100644 index 00000000..22246f43 --- /dev/null +++ b/internal/web/actions/default/servers/server/settings/locations/fastcgi/init.go @@ -0,0 +1,22 @@ +package fastcgi + +import ( + "github.com/TeaOSLab/EdgeAdmin/internal/configloaders" + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/locationutils" + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils" + "github.com/TeaOSLab/EdgeAdmin/internal/web/helpers" + "github.com/iwind/TeaGo" +) + +func init() { + TeaGo.BeforeStart(func(server *TeaGo.Server) { + server. + Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeServer)). + Helper(locationutils.NewLocationHelper()). + Helper(serverutils.NewServerHelper()). + Data("tinyMenuItem", "fastcgi"). + Prefix("/servers/server/settings/locations/fastcgi"). + GetPost("", new(IndexAction)). + EndAll() + }) +} diff --git a/internal/web/actions/default/servers/server/settings/locations/gzip/index.go b/internal/web/actions/default/servers/server/settings/locations/gzip/index.go index b45b48c4..4d148f92 100644 --- a/internal/web/actions/default/servers/server/settings/locations/gzip/index.go +++ b/internal/web/actions/default/servers/server/settings/locations/gzip/index.go @@ -39,12 +39,12 @@ func (this *IndexAction) RunGet(params struct { IsOn: true, } if gzipId > 0 { - resp, err := this.RPC().HTTPGzipRPC().FindEnabledHTTPGzipConfig(this.AdminContext(), &pb.FindEnabledGzipConfigRequest{GzipId: gzipId}) + resp, err := this.RPC().HTTPGzipRPC().FindEnabledHTTPGzipConfig(this.AdminContext(), &pb.FindEnabledGzipConfigRequest{HttpGzipId: gzipId}) if err != nil { this.ErrorPage(err) return } - err = json.Unmarshal(resp.GzipJSON, gzipConfig) + err = json.Unmarshal(resp.HttpGzipJSON, gzipConfig) if err != nil { this.ErrorPage(err) return @@ -109,10 +109,10 @@ func (this *IndexAction) RunPost(params struct { if params.GzipId > 0 { _, err := this.RPC().HTTPGzipRPC().UpdateHTTPGzip(this.AdminContext(), &pb.UpdateHTTPGzipRequest{ - GzipId: params.GzipId, - Level: types.Int32(params.Level), - MinLength: minLength, - MaxLength: maxLength, + HttpGzipId: params.GzipId, + Level: types.Int32(params.Level), + MinLength: minLength, + MaxLength: maxLength, }) if err != nil { this.ErrorPage(err) @@ -128,7 +128,7 @@ func (this *IndexAction) RunPost(params struct { this.ErrorPage(err) return } - gzipId := resp.GzipId + gzipId := resp.HttpGzipId gzipRef.GzipId = gzipId } diff --git a/internal/web/actions/default/servers/server/settings/locations/index.go b/internal/web/actions/default/servers/server/settings/locations/index.go index 5646134e..59c2a26b 100644 --- a/internal/web/actions/default/servers/server/settings/locations/index.go +++ b/internal/web/actions/default/servers/server/settings/locations/index.go @@ -1,8 +1,12 @@ package locations import ( + "encoding/json" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" + "github.com/iwind/TeaGo/maps" + "strings" ) type IndexAction struct { @@ -24,11 +28,36 @@ func (this *IndexAction) RunGet(params struct { } this.Data["webId"] = webConfig.Id + locationMaps := []maps.Map{} if webConfig.Locations != nil { - this.Data["locations"] = webConfig.Locations - } else { - this.Data["locations"] = []interface{}{} + for _, location := range webConfig.Locations { + err := location.ExtractPattern() + if err != nil { + continue + } + jsonData, err := json.Marshal(location) + if err != nil { + this.ErrorPage(err) + return + } + m := maps.Map{} + err = json.Unmarshal(jsonData, &m) + if err != nil { + this.ErrorPage(err) + return + } + pieces := strings.Split(location.Pattern, " ") + if len(pieces) == 2 { + m["pattern"] = pieces[1] + m["patternTypeName"] = serverconfigs.FindLocationPatternTypeName(location.PatternType()) + } else { + m["pattern"] = location.Pattern + m["patternTypeName"] = serverconfigs.FindLocationPatternTypeName(serverconfigs.HTTPLocationPatternTypePrefix) + } + locationMaps = append(locationMaps, m) + } } + this.Data["locations"] = locationMaps this.Show() } 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 4e8469e1..d2cde37d 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 @@ -149,6 +149,12 @@ func (this *LocationHelper) createMenus(serverIdString string, locationIdString "isActive": secondMenuItem == "websocket", "isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.WebsocketRef != nil && locationConfig.Web.WebsocketRef.IsPrior, }) + menuItems = append(menuItems, maps.Map{ + "name": "Fastcgi", + "url": "/servers/server/settings/locations/fastcgi?serverId=" + serverIdString + "&locationId=" + locationIdString, + "isActive": secondMenuItem == "fastcgi", + "isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.FastcgiRef != nil && locationConfig.Web.FastcgiRef.IsPrior, + }) return menuItems } diff --git a/internal/web/actions/default/servers/serverutils/server_helper.go b/internal/web/actions/default/servers/serverutils/server_helper.go index 93cd98d9..ed6f31eb 100644 --- a/internal/web/actions/default/servers/serverutils/server_helper.go +++ b/internal/web/actions/default/servers/serverutils/server_helper.go @@ -311,6 +311,12 @@ func (this *ServerHelper) createSettingsMenu(secondMenuItem string, serverIdStri "isActive": secondMenuItem == "websocket", "isOn": serverConfig.Web != nil && serverConfig.Web.WebsocketRef != nil && serverConfig.Web.WebsocketRef.IsOn, }) + menuItems = append(menuItems, maps.Map{ + "name": "Fastcgi", + "url": "/servers/server/settings/fastcgi?serverId=" + serverIdString, + "isActive": secondMenuItem == "fastcgi", + "isOn": serverConfig.Web != nil && serverConfig.Web.FastcgiRef != nil && serverConfig.Web.FastcgiRef.IsOn, + }) } else if serverConfig.IsTCPFamily() { menuItems = append(menuItems, maps.Map{ "name": "TCP", diff --git a/internal/web/import.go b/internal/web/import.go index fdcb58b1..a47ff5b4 100644 --- a/internal/web/import.go +++ b/internal/web/import.go @@ -48,6 +48,7 @@ import ( _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/charset" _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/conds" _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/dns" + _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/fastcgi" _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/gzip" _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/headers" _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/http" @@ -57,6 +58,7 @@ import ( _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/accessLog" _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/cache" _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/charset" + _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/fastcgi" _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/gzip" _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/headers" _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/http" diff --git a/web/public/js/components/server/http-fastcgi-box.js b/web/public/js/components/server/http-fastcgi-box.js new file mode 100644 index 00000000..58bac798 --- /dev/null +++ b/web/public/js/components/server/http-fastcgi-box.js @@ -0,0 +1,90 @@ +Vue.component("http-fastcgi-box", { + props: ["v-fastcgi-ref", "v-fastcgi-configs", "v-is-location"], + data: function () { + let fastcgiRef = this.vFastcgiRef + if (fastcgiRef == null) { + fastcgiRef = { + isPrior: false, + isOn: false, + fastcgiIds: [] + } + } + let fastcgiConfigs = this.vFastcgiConfigs + if (fastcgiConfigs == null) { + fastcgiConfigs = [] + } else { + fastcgiRef.fastcgiIds = fastcgiConfigs.map(function (v) { + return v.id + }) + } + + return { + fastcgiRef: fastcgiRef, + fastcgiConfigs: fastcgiConfigs, + advancedVisible: false + } + }, + methods: { + isOn: function () { + return (!this.vIsLocation || this.fastcgiRef.isPrior) && this.fastcgiRef.isOn + }, + createFastcgi: function () { + let that = this + teaweb.popup("/servers/server/settings/fastcgi/createPopup", { + height: "26em", + callback: function (resp) { + teaweb.success("添加成功", function () { + that.fastcgiConfigs.push(resp.data.fastcgi) + that.fastcgiRef.fastcgiIds.push(resp.data.fastcgi.id) + }) + } + }) + }, + updateFastcgi: function (fastcgiId, index) { + let that = this + teaweb.popup("/servers/server/settings/fastcgi/updatePopup?fastcgiId=" + fastcgiId, { + callback: function (resp) { + teaweb.success("修改成功", function () { + Vue.set(that.fastcgiConfigs, index, resp.data.fastcgi) + }) + } + }) + }, + removeFastcgi: function (index) { + this.fastcgiRef.fastcgiIds.$remove(index) + this.fastcgiConfigs.$remove(index) + } + }, + template: `
` +}) \ No newline at end of file diff --git a/web/public/js/components/server/http-header-policy-box.js b/web/public/js/components/server/http-header-policy-box.js index d3e32bf1..0dd945dc 100644 --- a/web/public/js/components/server/http-header-policy-box.js +++ b/web/public/js/components/server/http-header-policy-box.js @@ -138,7 +138,7 @@ Vue.component("http-header-policy-box", {暂时还没有Header。
-| 名称 | @@ -179,8 +179,9 @@ Vue.component("http-header-policy-box", {||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 名称 | diff --git a/web/views/@default/servers/addPortPopup.html b/web/views/@default/servers/addPortPopup.html index 982ec0fa..8e3695da 100644 --- a/web/views/@default/servers/addPortPopup.html +++ b/web/views/@default/servers/addPortPopup.html @@ -7,8 +7,8 @@|
|---|---|
| 网络协议 | - | 端口 * | 
 				
-				 可以是一个数字端口(通常不超过65535),也可以是"地址:端口"的方式。 +可以是一个数字端口(通常不超过65535),也可以是"地址:端口"的方式。 + HTTP常用端口为80。 + HTTPS常用端口为443。 +  | 
 		
 	
{{error}}