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