mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 12:20:28 +08:00
[网站服务]列表中增加审核筛选和标识
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
@@ -19,15 +18,36 @@ func (this *IndexAction) Init() {
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
GroupId int64
|
||||
Keyword string
|
||||
ClusterId int64
|
||||
GroupId int64
|
||||
Keyword string
|
||||
AuditingFlag int32
|
||||
}) {
|
||||
this.Data["clusterId"] = params.ClusterId
|
||||
this.Data["groupId"] = params.GroupId
|
||||
this.Data["keyword"] = params.Keyword
|
||||
this.Data["auditingFlag"] = params.AuditingFlag
|
||||
|
||||
if params.AuditingFlag > 0 {
|
||||
this.Data["firstMenuItem"] = "auditing"
|
||||
}
|
||||
|
||||
// 审核中的数量
|
||||
countAuditingResp, err := this.RPC().ServerRPC().CountAllEnabledServersMatch(this.AdminContext(), &pb.CountAllEnabledServersMatchRequest{
|
||||
AuditingFlag: 1,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
this.Data["countAuditing"] = countAuditingResp.Count
|
||||
|
||||
// 全部数量
|
||||
countResp, err := this.RPC().ServerRPC().CountAllEnabledServersMatch(this.AdminContext(), &pb.CountAllEnabledServersMatchRequest{
|
||||
GroupId: params.GroupId,
|
||||
Keyword: params.Keyword,
|
||||
ClusterId: params.ClusterId,
|
||||
GroupId: params.GroupId,
|
||||
Keyword: params.Keyword,
|
||||
AuditingFlag: params.AuditingFlag,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
@@ -39,10 +59,12 @@ func (this *IndexAction) RunGet(params struct {
|
||||
|
||||
// 服务列表
|
||||
serversResp, err := this.RPC().ServerRPC().ListEnabledServersMatch(this.AdminContext(), &pb.ListEnabledServersMatchRequest{
|
||||
Offset: page.Offset,
|
||||
Size: page.Size,
|
||||
GroupId: params.GroupId,
|
||||
Keyword: params.Keyword,
|
||||
Offset: page.Offset,
|
||||
Size: page.Size,
|
||||
ClusterId: params.ClusterId,
|
||||
GroupId: params.GroupId,
|
||||
Keyword: params.Keyword,
|
||||
AuditingFlag: params.AuditingFlag,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
@@ -121,6 +143,9 @@ func (this *IndexAction) RunGet(params struct {
|
||||
|
||||
// 域名列表
|
||||
serverNames := []*serverconfigs.ServerNameConfig{}
|
||||
if server.IsAuditing {
|
||||
server.ServerNamesJSON = server.AuditingServerNamesJSON
|
||||
}
|
||||
if len(server.ServerNamesJSON) > 0 {
|
||||
err = json.Unmarshal(server.ServerNamesJSON, &serverNames)
|
||||
if err != nil {
|
||||
@@ -159,11 +184,27 @@ func (this *IndexAction) RunGet(params struct {
|
||||
"groups": groupMaps,
|
||||
"serverNames": serverNames,
|
||||
"countServerNames": countServerNames,
|
||||
"isAuditing": server.IsAuditing,
|
||||
"user": userMap,
|
||||
})
|
||||
}
|
||||
this.Data["servers"] = serverMaps
|
||||
|
||||
// 集群
|
||||
clustersResp, err := this.RPC().NodeClusterRPC().FindAllEnabledNodeClusters(this.AdminContext(), &pb.FindAllEnabledNodeClustersRequest{})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
clusterMaps := []maps.Map{}
|
||||
for _, cluster := range clustersResp.NodeClusters {
|
||||
clusterMaps = append(clusterMaps, maps.Map{
|
||||
"id": cluster.Id,
|
||||
"name": cluster.Name,
|
||||
})
|
||||
}
|
||||
this.Data["clusters"] = clusterMaps
|
||||
|
||||
// 分组
|
||||
groupsResp, err := this.RPC().ServerGroupRPC().FindAllEnabledServerGroups(this.AdminContext(), &pb.FindAllEnabledServerGroupsRequest{})
|
||||
if err != nil {
|
||||
@@ -172,16 +213,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
}
|
||||
groupMaps := []maps.Map{}
|
||||
for _, group := range groupsResp.Groups {
|
||||
countResp, err := this.RPC().ServerRPC().CountAllEnabledServersWithGroupId(this.AdminContext(), &pb.CountAllEnabledServersWithGroupIdRequest{GroupId: group.Id})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
groupName := group.Name
|
||||
if countResp.Count > 0 {
|
||||
groupName += "(" + strconv.FormatInt(countResp.Count, 10) + ")"
|
||||
}
|
||||
groupMaps = append(groupMaps, maps.Map{
|
||||
"id": group.Id,
|
||||
"name": groupName,
|
||||
|
||||
@@ -58,8 +58,8 @@ func (this *IndexAction) RunPost(params struct {
|
||||
}
|
||||
|
||||
_, err = this.RPC().ServerRPC().UpdateServerNames(this.AdminContext(), &pb.UpdateServerNamesRequest{
|
||||
ServerId: params.ServerId,
|
||||
Config: []byte(params.ServerNames),
|
||||
ServerId: params.ServerId,
|
||||
ServerNamesJSON: []byte(params.ServerNames),
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
@@ -23,6 +23,9 @@ func (this *ServerNamesPopupAction) RunGet(params struct {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
if serverNamesResp.IsAuditing {
|
||||
serverNamesResp.ServerNamesJSON = serverNamesResp.AuditingServerNamesJSON
|
||||
}
|
||||
serverNames := []*serverconfigs.ServerNameConfig{}
|
||||
if len(serverNamesResp.ServerNamesJSON) > 0 {
|
||||
err = json.Unmarshal(serverNamesResp.ServerNamesJSON, &serverNames)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<first-menu>
|
||||
<menu-item href="/servers" code="index">服务列表</menu-item>
|
||||
<menu-item href="/servers?auditingFlag=1" code="auditing">审核中<span :class="{red: countAuditing > 0}">({{countAuditing}})</span></menu-item>
|
||||
<menu-item href="/servers/create" code="create">创建服务</menu-item>
|
||||
</first-menu>
|
||||
@@ -2,14 +2,18 @@
|
||||
{$template "menu"}
|
||||
|
||||
<form method="get" class="ui form" action="/servers">
|
||||
<input type="hidden" name="auditingFlag" :value="auditingFlag"/>
|
||||
<div class="ui margin"></div>
|
||||
<div class="ui fields inline">
|
||||
<div class="ui field" v-if="groups.length > 0" style="padding-right:0">
|
||||
所属分组:
|
||||
</div>
|
||||
<div class="ui field" v-if="clusters.length > 0">
|
||||
<select class="ui dropdown auto-width" name="clusterId" v-model="clusterId">
|
||||
<option value="0">[选择集群]</option>
|
||||
<option v-for="cluster in clusters" :value="cluster.id">{{cluster.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="ui field" v-if="groups.length > 0">
|
||||
<select class="ui dropdown" name="groupId" v-model="groupId">
|
||||
<option value="0">[全部]</option>
|
||||
<select class="ui dropdown auto-width" name="groupId" v-model="groupId">
|
||||
<option value="0">[选择分组]</option>
|
||||
<option v-for="group in groups" :value="group.id">{{group.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
@@ -54,6 +58,10 @@
|
||||
<span v-if="server.countServerNames > 1">等{{server.countServerNames}}个域名 <popup-icon :href="'/servers/serverNamesPopup?serverId=' + server.id" height="20em"></popup-icon></span>
|
||||
</span>
|
||||
<span v-else class="disabled">-</span>
|
||||
|
||||
<div v-if="server.isAuditing" style="margin-top: 0.5em">
|
||||
<span class="ui label basic tiny red">审核中</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<span v-if="server.ports.length == 0">-</span>
|
||||
|
||||
Reference in New Issue
Block a user