记录和显示最近常用的服务

This commit is contained in:
刘祥超
2021-05-03 15:15:31 +08:00
parent 19a2af8bfa
commit c2ebf81e6c
7 changed files with 70 additions and 4 deletions

View File

@@ -38,7 +38,7 @@ func (this *IndexAction) RunGet(params struct {
// 常用的节点 // 常用的节点
latestClusterMaps := []maps.Map{} latestClusterMaps := []maps.Map{}
if !isSearching { if !isSearching {
clustersResp, err := this.RPC().NodeClusterRPC().FindLatestNodeClusters(this.AdminContext(), &pb.FindLatestNodeClustersRequest{Size: 4}) clustersResp, err := this.RPC().NodeClusterRPC().FindLatestNodeClusters(this.AdminContext(), &pb.FindLatestNodeClustersRequest{Size: 6})
if err != nil { if err != nil {
this.ErrorPage(err) this.ErrorPage(err)
return return

View File

@@ -30,10 +30,29 @@ func (this *IndexAction) RunGet(params struct {
this.Data["auditingFlag"] = params.AuditingFlag this.Data["auditingFlag"] = params.AuditingFlag
this.Data["checkDNS"] = params.CheckDNS this.Data["checkDNS"] = params.CheckDNS
isSearching := params.AuditingFlag == 1 || params.ClusterId > 0 || params.GroupId > 0 || len(params.Keyword) > 0
if params.AuditingFlag > 0 { if params.AuditingFlag > 0 {
this.Data["firstMenuItem"] = "auditing" this.Data["firstMenuItem"] = "auditing"
} }
// 常用的服务
latestServerMaps := []maps.Map{}
if !isSearching {
serversResp, err := this.RPC().ServerRPC().FindLatestServers(this.AdminContext(), &pb.FindLatestServersRequest{Size: 6})
if err != nil {
this.ErrorPage(err)
return
}
for _, server := range serversResp.Servers {
latestServerMaps = append(latestServerMaps, maps.Map{
"id": server.Id,
"name": server.Name,
})
}
}
this.Data["latestServers"] = latestServerMaps
// 审核中的数量 // 审核中的数量
countAuditingResp, err := this.RPC().ServerRPC().CountAllEnabledServersMatch(this.AdminContext(), &pb.CountAllEnabledServersMatchRequest{ countAuditingResp, err := this.RPC().ServerRPC().CountAllEnabledServersMatch(this.AdminContext(), &pb.CountAllEnabledServersMatchRequest{
AuditingFlag: 1, AuditingFlag: 1,

View File

@@ -24,6 +24,16 @@ func (this *IndexAction) RunGet(params struct {
this.Data["serverId"] = params.ServerId this.Data["serverId"] = params.ServerId
this.Data["requestId"] = params.RequestId this.Data["requestId"] = params.RequestId
// 记录最近使用
_, err := this.RPC().LatestItemRPC().IncreaseLatestItem(this.AdminContext(), &pb.IncreaseLatestItemRequest{
ItemType: "server",
ItemId: params.ServerId,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Show() this.Show()
} }

View File

@@ -10,7 +10,7 @@ import (
"github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/maps"
) )
// 服务基本信息设置 // IndexAction 服务基本信息设置
type IndexAction struct { type IndexAction struct {
actionutils.ParentAction actionutils.ParentAction
} }
@@ -102,10 +102,20 @@ func (this *IndexAction) RunGet(params struct {
typeName := serverType.GetString("name") typeName := serverType.GetString("name")
this.Data["typeName"] = typeName this.Data["typeName"] = typeName
// 记录最近使用
_, err = this.RPC().LatestItemRPC().IncreaseLatestItem(this.AdminContext(), &pb.IncreaseLatestItemRequest{
ItemType: "server",
ItemId: params.ServerId,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Show() this.Show()
} }
// 保存 // RunPost 保存
func (this *IndexAction) RunPost(params struct { func (this *IndexAction) RunPost(params struct {
ServerId int64 ServerId int64
Name string Name string

View File

@@ -146,5 +146,15 @@ func (this *IndexAction) RunGet(params struct {
this.Data["provinceStats"] = provinceStatMaps this.Data["provinceStats"] = provinceStatMaps
this.Data["cityStats"] = cityStatMaps this.Data["cityStats"] = cityStatMaps
// 记录最近使用
_, err = this.RPC().LatestItemRPC().IncreaseLatestItem(this.AdminContext(), &pb.IncreaseLatestItemRequest{
ItemType: "server",
ItemId: params.ServerId,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Show() this.Show()
} }

View File

@@ -25,6 +25,9 @@
<div class="ui field"> <div class="ui field">
<button type="submit" class="ui button">搜索</button> <button type="submit" class="ui button">搜索</button>
</div> </div>
<div class="ui field" v-if="latestServers.length > 0">
<a href="" @click.prevent="showLatest()">常用<i class="icon angle" :class="{down: !latestVisible, up: latestVisible}"></i> </a>
</div>
</div> </div>
</div> </div>
<div class="item right"> <div class="item right">
@@ -33,6 +36,11 @@
</div> </div>
</form> </form>
<!-- 常用服务 -->
<div class="ui segment" v-if="latestVisible">
常用服务:<span v-for="server in latestServers"><a :href="'/servers/server?serverId=' + server.id">{{server.name}}</a> &nbsp; </span>
</div>
<p class="ui message" v-if="servers.length == 0">暂时还没有服务。</p> <p class="ui message" v-if="servers.length == 0">暂时还没有服务。</p>
<table class="ui table selectable celled" v-if="servers.length > 0"> <table class="ui table selectable celled" v-if="servers.length > 0">

View File

@@ -37,4 +37,13 @@ Tea.context(function () {
}) })
}) })
} }
});
/**
* 最近使用
*/
this.latestVisible = false
this.showLatest = function () {
this.latestVisible = !this.latestVisible
}
})