提供管理界面的HTTP/HTTPS修改功能

This commit is contained in:
GoEdgeLab
2020-10-15 16:41:32 +08:00
parent 9c9fbcd45d
commit c5b48bd3f8
34 changed files with 596 additions and 73 deletions

View File

@@ -4,7 +4,6 @@ import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
"time"
)
// 检查变更的集群列表
@@ -19,47 +18,20 @@ func (this *CheckChangeAction) Init() {
func (this *CheckChangeAction) RunPost(params struct {
IsNotifying bool
}) {
timeout := time.NewTimer(55 * time.Second) // 比客户端提前结束,避免在客户端产生一个请求错误
this.Data["clusters"] = []interface{}{}
Loop:
for {
select {
case <-this.Request.Context().Done():
break Loop
case <-timeout.C:
break Loop
default:
// 继续
}
resp, err := this.RPC().NodeClusterRPC().FindAllChangedNodeClusters(this.AdminContext(), &pb.FindAllChangedNodeClustersRequest{})
if err != nil {
this.ErrorPage(err)
return
}
result := []maps.Map{}
for _, cluster := range resp.Clusters {
result = append(result, maps.Map{
"id": cluster.Id,
"name": cluster.Name,
})
}
// 从提醒到提醒消失
if len(result) == 0 && params.IsNotifying {
break
}
this.Data["clusters"] = result
if len(result) > 0 {
break
}
time.Sleep(1 * time.Second)
resp, err := this.RPC().NodeClusterRPC().FindAllChangedNodeClusters(this.AdminContext(), &pb.FindAllChangedNodeClustersRequest{})
if err != nil {
this.ErrorPage(err)
return
}
result := []maps.Map{}
for _, cluster := range resp.Clusters {
result = append(result, maps.Map{
"id": cluster.Id,
"name": cluster.Name,
})
}
this.Data["clusters"] = result
this.Success()
}