优化API节点详情页

This commit is contained in:
GoEdgeLab
2021-07-06 15:31:09 +08:00
parent 6ac860c18e
commit b86453408c
3 changed files with 12 additions and 6 deletions

View File

@@ -32,6 +32,7 @@ func (this *IndexAction) RunGet(params struct {
} }
// 监听地址 // 监听地址
var hasHTTPS = false
httpConfig := &serverconfigs.HTTPProtocolConfig{} httpConfig := &serverconfigs.HTTPProtocolConfig{}
if len(node.HttpJSON) > 0 { if len(node.HttpJSON) > 0 {
err = json.Unmarshal(node.HttpJSON, httpConfig) err = json.Unmarshal(node.HttpJSON, httpConfig)
@@ -47,6 +48,7 @@ func (this *IndexAction) RunGet(params struct {
this.ErrorPage(err) this.ErrorPage(err)
return return
} }
hasHTTPS = len(httpsConfig.Listen) > 0
} }
// 监听地址 // 监听地址
@@ -56,7 +58,6 @@ func (this *IndexAction) RunGet(params struct {
// 证书信息 // 证书信息
certs := []*sslconfigs.SSLCertConfig{} certs := []*sslconfigs.SSLCertConfig{}
sslPolicyId := int64(0)
if httpsConfig.SSLPolicyRef != nil && httpsConfig.SSLPolicyRef.SSLPolicyId > 0 { if httpsConfig.SSLPolicyRef != nil && httpsConfig.SSLPolicyRef.SSLPolicyId > 0 {
sslPolicyConfigResp, err := this.RPC().SSLPolicyRPC().FindEnabledSSLPolicyConfig(this.AdminContext(), &pb.FindEnabledSSLPolicyConfigRequest{SslPolicyId: httpsConfig.SSLPolicyRef.SSLPolicyId}) sslPolicyConfigResp, err := this.RPC().SSLPolicyRPC().FindEnabledSSLPolicyConfig(this.AdminContext(), &pb.FindEnabledSSLPolicyConfigRequest{SslPolicyId: httpsConfig.SSLPolicyRef.SSLPolicyId})
if err != nil { if err != nil {
@@ -65,8 +66,6 @@ func (this *IndexAction) RunGet(params struct {
} }
sslPolicyConfigJSON := sslPolicyConfigResp.SslPolicyJSON sslPolicyConfigJSON := sslPolicyConfigResp.SslPolicyJSON
if len(sslPolicyConfigJSON) > 0 { if len(sslPolicyConfigJSON) > 0 {
sslPolicyId = httpsConfig.SSLPolicyRef.SSLPolicyId
sslPolicy := &sslconfigs.SSLPolicy{} sslPolicy := &sslconfigs.SSLPolicy{}
err = json.Unmarshal(sslPolicyConfigJSON, sslPolicy) err = json.Unmarshal(sslPolicyConfigJSON, sslPolicy)
if err != nil { if err != nil {
@@ -112,6 +111,10 @@ func (this *IndexAction) RunGet(params struct {
if httpsConfig.IsOn && len(httpsConfig.Listen) > 0 { if httpsConfig.IsOn && len(httpsConfig.Listen) > 0 {
restAccessAddrs = append(restAccessAddrs, httpsConfig.Listen...) restAccessAddrs = append(restAccessAddrs, httpsConfig.Listen...)
} }
if !hasHTTPS {
hasHTTPS = len(httpsConfig.Listen) > 0
}
} }
} }
@@ -124,7 +127,7 @@ func (this *IndexAction) RunGet(params struct {
"accessAddrs": accessAddrs, "accessAddrs": accessAddrs,
"restIsOn": node.RestIsOn, "restIsOn": node.RestIsOn,
"restAccessAddrs": restAccessAddrs, "restAccessAddrs": restAccessAddrs,
"hasHTTPS": sslPolicyId > 0, "hasHTTPS": hasHTTPS,
"certs": certs, "certs": certs,
} }

View File

@@ -127,7 +127,7 @@ func (this *UpdateAction) RunGet(params struct {
this.Show() this.Show()
} }
// 保存基础设置 // RunPost 保存基础设置
func (this *UpdateAction) RunPost(params struct { func (this *UpdateAction) RunPost(params struct {
NodeId int64 NodeId int64
Name string Name string

View File

@@ -24,7 +24,10 @@
<tr v-if="node.hasHTTPS"> <tr v-if="node.hasHTTPS">
<td>HTTPS证书</td> <td>HTTPS证书</td>
<td> <td>
<ssl-certs-view :v-certs="node.certs"></ssl-certs-view> <div v-if="node.certs != null && node.certs.length > 0">
<ssl-certs-view :v-certs="node.certs"></ssl-certs-view>
</div>
<span v-else class="red">还没有设置证书可能会导致HTTPS相关服务不可用。</span>
</td> </td>
</tr> </tr>
<tr> <tr>