mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 20:40:26 +08:00
服务列表增加筛选
This commit is contained in:
@@ -16,8 +16,17 @@ func (this *IndexAction) Init() {
|
||||
this.Nav("", "server", "index")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct{}) {
|
||||
countResp, err := this.RPC().ServerRPC().CountAllEnabledServers(this.AdminContext(), &pb.CountAllEnabledServersRequest{})
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
GroupId int64
|
||||
Keyword string
|
||||
}) {
|
||||
this.Data["groupId"] = params.GroupId
|
||||
this.Data["keyword"] = params.Keyword
|
||||
|
||||
countResp, err := this.RPC().ServerRPC().CountAllEnabledServersMatch(this.AdminContext(), &pb.CountAllEnabledServersMatchRequest{
|
||||
GroupId: params.GroupId,
|
||||
Keyword: params.Keyword,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
@@ -27,9 +36,11 @@ func (this *IndexAction) RunGet(params struct{}) {
|
||||
this.Data["page"] = page.AsHTML()
|
||||
|
||||
// 服务列表
|
||||
serversResp, err := this.RPC().ServerRPC().ListEnabledServers(this.AdminContext(), &pb.ListEnabledServersRequest{
|
||||
serversResp, err := this.RPC().ServerRPC().ListEnabledServersMatch(this.AdminContext(), &pb.ListEnabledServersMatchRequest{
|
||||
Offset: page.Offset,
|
||||
Size: page.Size,
|
||||
GroupId: params.GroupId,
|
||||
Keyword: params.Keyword,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
@@ -106,6 +117,16 @@ func (this *IndexAction) RunGet(params struct{}) {
|
||||
}
|
||||
}
|
||||
|
||||
// 域名列表
|
||||
serverNames := []*serverconfigs.ServerNameConfig{}
|
||||
if len(server.ServerNamesJON) > 0 {
|
||||
err = json.Unmarshal(server.ServerNamesJON, &serverNames)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
serverMaps = append(serverMaps, maps.Map{
|
||||
"id": server.Id,
|
||||
"isOn": server.IsOn,
|
||||
@@ -117,9 +138,25 @@ func (this *IndexAction) RunGet(params struct{}) {
|
||||
"ports": portMaps,
|
||||
"serverTypeName": serverconfigs.FindServerType(server.Type).GetString("name"),
|
||||
"groups": groupMaps,
|
||||
"serverNames": serverNames,
|
||||
})
|
||||
}
|
||||
this.Data["servers"] = serverMaps
|
||||
|
||||
// 分组
|
||||
groupsResp, err := this.RPC().ServerGroupRPC().FindAllEnabledServerGroups(this.AdminContext(), &pb.FindAllEnabledServerGroupsRequest{})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
groupMaps := []maps.Map{}
|
||||
for _, group := range groupsResp.Groups {
|
||||
groupMaps = append(groupMaps, maps.Map{
|
||||
"id": group.Id,
|
||||
"name": group.Name,
|
||||
})
|
||||
}
|
||||
this.Data["groups"] = groupMaps
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
@@ -8,3 +8,8 @@ Vue.component("label-on", {
|
||||
Vue.component("code-label", {
|
||||
template: `<span class="ui label basic tiny" style="padding: 3px;margin-left:2px;margin-right:2px"><slot></slot></span>`
|
||||
})
|
||||
|
||||
// tiny标签
|
||||
Vue.component("tiny-label", {
|
||||
template: `<span class="ui label tiny" style="margin-bottom: 0.5em"><slot></slot></span>`
|
||||
})
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
{$template "menu"}
|
||||
|
||||
<form class="ui form segment" action="/clusters/cluster">
|
||||
<form class="ui form" action="/clusters/cluster">
|
||||
<input type="hidden" name="clusterId" :value="clusterId"/>
|
||||
<div class="ui fields inline">
|
||||
<div class="ui field" v-if="groups.length > 0">
|
||||
<div class="ui field" v-if="groups.length > 0" style="padding-right: 0">
|
||||
所属分组:
|
||||
</div>
|
||||
<div class="ui field" v-if="groups.length > 0">
|
||||
@@ -14,7 +14,7 @@
|
||||
<option v-for="group in groups" :value="group.id">{{group.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="ui field">
|
||||
<div class="ui field" style="padding-right: 0">
|
||||
安装状态:
|
||||
</div>
|
||||
<div class="ui field">
|
||||
@@ -24,7 +24,7 @@
|
||||
<option value="2">未安装</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="ui field">
|
||||
<div class="ui field" style="padding-right: 0">
|
||||
在线状态:
|
||||
</div>
|
||||
<div class="ui field">
|
||||
|
||||
@@ -1,6 +1,27 @@
|
||||
{$layout}
|
||||
{$template "menu"}
|
||||
|
||||
<form class="ui form" action="/servers">
|
||||
<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="groups.length > 0">
|
||||
<select class="ui dropdown" name="groupId" v-model="groupId">
|
||||
<option value="0">[全部]</option>
|
||||
<option v-for="group in groups" :value="group.id">{{group.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="ui field">
|
||||
<input type="text" name="keyword" style="width:10em" placeholder="关键词" v-model="keyword"/>
|
||||
</div>
|
||||
<div class="ui field">
|
||||
<button type="submit" class="ui button">搜索</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<p class="ui message" v-if="servers.length == 0">暂时还没有服务。</p>
|
||||
|
||||
<table class="ui table selectable" v-if="servers.length > 0">
|
||||
@@ -8,29 +29,37 @@
|
||||
<tr>
|
||||
<th>服务名称</th>
|
||||
<th>所属分组</th>
|
||||
<th>服务类型</th>
|
||||
<th>部署集群</th>
|
||||
<th>域名</th>
|
||||
<th>端口</th>
|
||||
<th class="two wide">状态</th>
|
||||
<th class="two op">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr v-for="server in servers">
|
||||
<td>{{server.name}}</td>
|
||||
<td>{{server.name}}
|
||||
<div style="margin-top:0.2em">
|
||||
<tiny-label>{{server.serverTypeName}}</tiny-label>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div v-if="server.groups.length > 0">
|
||||
<div v-for="group in server.groups">
|
||||
<span class="ui label tiny" style="margin-bottom:0.5em">{{group.name}}</span>
|
||||
<tiny-label>{{group.name}}</tiny-label>
|
||||
</div>
|
||||
</div>
|
||||
<span class="disabled" v-else>-</span>
|
||||
</td>
|
||||
<td>{{server.serverTypeName}}</td>
|
||||
<td>{{server.cluster.name}}</td>
|
||||
<td>
|
||||
<div v-for="serverName in server.serverNames">
|
||||
<tiny-label>{{serverName.name}}</tiny-label>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<span v-if="server.ports.length == 0">-</span>
|
||||
<div v-for="port in server.ports">
|
||||
<div class="ui label tiny" style="margin-bottom:0.5em">{{port.portRange}}<span class="small">({{port.protocol}})</span></div>
|
||||
<tiny-label>{{port.portRange}}<span class="small">({{port.protocol}})</span></tiny-label>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
Reference in New Issue
Block a user