mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-04 04:54:32 +08:00
SSH认证可搜索
This commit is contained in:
@@ -15,8 +15,14 @@ func (this *IndexAction) Init() {
|
|||||||
this.Nav("", "grant", "index")
|
this.Nav("", "grant", "index")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *IndexAction) RunGet(params struct{}) {
|
func (this *IndexAction) RunGet(params struct {
|
||||||
countResp, err := this.RPC().NodeGrantRPC().CountAllEnabledNodeGrants(this.AdminContext(), &pb.CountAllEnabledNodeGrantsRequest{})
|
Keyword string
|
||||||
|
}) {
|
||||||
|
this.Data["keyword"] = params.Keyword
|
||||||
|
|
||||||
|
countResp, err := this.RPC().NodeGrantRPC().CountAllEnabledNodeGrants(this.AdminContext(), &pb.CountAllEnabledNodeGrantsRequest{
|
||||||
|
Keyword: params.Keyword,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
@@ -25,8 +31,9 @@ func (this *IndexAction) RunGet(params struct{}) {
|
|||||||
this.Data["page"] = page.AsHTML()
|
this.Data["page"] = page.AsHTML()
|
||||||
|
|
||||||
grantsResp, err := this.RPC().NodeGrantRPC().ListEnabledNodeGrants(this.AdminContext(), &pb.ListEnabledNodeGrantsRequest{
|
grantsResp, err := this.RPC().NodeGrantRPC().ListEnabledNodeGrants(this.AdminContext(), &pb.ListEnabledNodeGrantsRequest{
|
||||||
Offset: page.Offset,
|
Keyword: params.Keyword,
|
||||||
Size: page.Size,
|
Offset: page.Offset,
|
||||||
|
Size: page.Size,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
@@ -57,6 +64,7 @@ func (this *IndexAction) RunGet(params struct{}) {
|
|||||||
"type": grant.Method,
|
"type": grant.Method,
|
||||||
"name": grantutils.FindGrantMethodName(grant.Method),
|
"name": grantutils.FindGrantMethodName(grant.Method),
|
||||||
},
|
},
|
||||||
|
"username": grant.Username,
|
||||||
"countClusters": countClusters,
|
"countClusters": countClusters,
|
||||||
"countNodes": countNodes,
|
"countNodes": countNodes,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -27,10 +27,12 @@ func (this *SelectPopupAction) RunGet(params struct{}) {
|
|||||||
grantMaps := []maps.Map{}
|
grantMaps := []maps.Map{}
|
||||||
for _, grant := range grants {
|
for _, grant := range grants {
|
||||||
grantMaps = append(grantMaps, maps.Map{
|
grantMaps = append(grantMaps, maps.Map{
|
||||||
"id": grant.Id,
|
"id": grant.Id,
|
||||||
"name": grant.Name,
|
"name": grant.Name,
|
||||||
"method": grant.Method,
|
"method": grant.Method,
|
||||||
"methodName": grantutils.FindGrantMethodName(grant.Method),
|
"methodName": grantutils.FindGrantMethodName(grant.Method),
|
||||||
|
"username": grant.Username,
|
||||||
|
"description": grant.Description,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.Data["grants"] = grantMaps
|
this.Data["grants"] = grantMaps
|
||||||
|
|||||||
@@ -1,6 +1,21 @@
|
|||||||
{$layout}
|
{$layout}
|
||||||
{$template "menu"}
|
{$template "menu"}
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 搜索表单 -->
|
||||||
|
<form class="ui form" method="get" action="/clusters/grants">
|
||||||
|
<div class="margin"></div>
|
||||||
|
<div class="ui fields inline">
|
||||||
|
<div class="ui field">
|
||||||
|
<input type="text" name="keyword" placeholder="名称、用户名等..." v-model="keyword"/>
|
||||||
|
</div>
|
||||||
|
<div class="ui field">
|
||||||
|
<button class="ui button" type="submit">搜索</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<!-- SSH认证列表 -->
|
||||||
<div class="ui message" v-if="grants.length == 0">暂时还没有认证信息。</div>
|
<div class="ui message" v-if="grants.length == 0">暂时还没有认证信息。</div>
|
||||||
|
|
||||||
<table class="ui table selectable celled" v-if="grants.length > 0">
|
<table class="ui table selectable celled" v-if="grants.length > 0">
|
||||||
@@ -8,6 +23,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>名称</th>
|
<th>名称</th>
|
||||||
<th>类型</th>
|
<th>类型</th>
|
||||||
|
<th>用户名</th>
|
||||||
<th class="center width5">集群数</th>
|
<th class="center width5">集群数</th>
|
||||||
<th class="center width5">节点数</th>
|
<th class="center width5">节点数</th>
|
||||||
<th class="two op">操作</th>
|
<th class="two op">操作</th>
|
||||||
@@ -18,6 +34,10 @@
|
|||||||
<td>
|
<td>
|
||||||
<span class="ui label tiny basic">{{grant.method.name}}</span>
|
<span class="ui label tiny basic">{{grant.method.name}}</span>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<span v-if="grant.username.length > 0">{{grant.username}}</span>
|
||||||
|
<span v-else class="disabled">-</span>
|
||||||
|
</td>
|
||||||
<td class="center">
|
<td class="center">
|
||||||
<span v-if="grant.countClusters > 0">{{grant.countClusters}}</span>
|
<span v-if="grant.countClusters > 0">{{grant.countClusters}}</span>
|
||||||
<span v-else class="disabled">0</span>
|
<span v-else class="disabled">0</span>
|
||||||
|
|||||||
@@ -2,11 +2,19 @@
|
|||||||
|
|
||||||
<h3>选择认证</h3>
|
<h3>选择认证</h3>
|
||||||
|
|
||||||
<table class="ui table definition">
|
<form class="ui form">
|
||||||
|
<div class="ui fields inline">
|
||||||
|
<div class="ui field">
|
||||||
|
<input type="text" placeholder="搜索名称、用户名等" v-model="keyword"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<table class="ui table">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<span v-if="grants.length == 0">暂时还没有可用的认证。</span>
|
<span v-if="grants.length == 0">暂时还没有可用的认证。</span>
|
||||||
<a class="ui label small basic" v-for="grant in grants" :class="{blue:grantId == grant.id}" @click.prevent="selectGrant(grant)" style="margin-bottom:0.5em">{{grant.name}} <span class="small">({{grant.methodName}})</span></a>
|
<a class="ui label small basic" v-for="grant in grants" :class="{blue:grantId == grant.id}" @click.prevent="selectGrant(grant)" style="margin-bottom:0.5em">{{grant.name}} <span class="small">({{grant.methodName}})</span><span v-if="grant.username.length > 0" class="small">({{grant.username}})</span></a>
|
||||||
<p class="comment">请点击选中某个认证。</p>
|
<p class="comment">请点击选中某个认证。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
Tea.context(function () {
|
Tea.context(function () {
|
||||||
this.grantId = 0;
|
this.grantId = 0
|
||||||
|
this.keyword = ""
|
||||||
|
let allGrants = this.grants.$copy()
|
||||||
|
|
||||||
this.selectGrant = function (grant) {
|
this.selectGrant = function (grant) {
|
||||||
NotifyPopup({
|
NotifyPopup({
|
||||||
@@ -8,5 +10,20 @@ Tea.context(function () {
|
|||||||
grant: grant
|
grant: grant
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
};
|
}
|
||||||
});
|
|
||||||
|
this.$delay(function () {
|
||||||
|
let that = this
|
||||||
|
this.$watch("keyword", function (keyword) {
|
||||||
|
if (keyword.length > 0) {
|
||||||
|
that.grants = allGrants.$findAll(function (k, grant) {
|
||||||
|
return teaweb.match(grant.name, keyword)
|
||||||
|
|| teaweb.match(grant.description, keyword)
|
||||||
|
|| teaweb.match(grant.username, keyword)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
that.grants = allGrants
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user