mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-18 14:50:26 +08:00
证书列表区分管理员和用户证书
This commit is contained in:
@@ -19,13 +19,19 @@ func (this *IndexAction) Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *IndexAction) RunGet(params struct {
|
func (this *IndexAction) RunGet(params struct {
|
||||||
UserId int64
|
UserId int64
|
||||||
Type string
|
Type string // [empty] | ca | 7days | ...
|
||||||
Keyword string
|
Keyword string
|
||||||
|
UserType string
|
||||||
}) {
|
}) {
|
||||||
this.Data["type"] = params.Type
|
this.Data["type"] = params.Type
|
||||||
this.Data["keyword"] = params.Keyword
|
this.Data["keyword"] = params.Keyword
|
||||||
|
|
||||||
|
if params.UserId > 0 {
|
||||||
|
params.UserType = "user"
|
||||||
|
}
|
||||||
|
this.Data["userType"] = params.UserType
|
||||||
|
|
||||||
// 当前用户
|
// 当前用户
|
||||||
this.Data["searchingUserId"] = params.UserId
|
this.Data["searchingUserId"] = params.UserId
|
||||||
var userMap = maps.Map{
|
var userMap = maps.Map{
|
||||||
@@ -57,12 +63,15 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
var count7Days int64
|
var count7Days int64
|
||||||
var count30Days int64
|
var count30Days int64
|
||||||
|
|
||||||
|
var userOnly = params.UserType == "user" || params.UserId > 0
|
||||||
|
|
||||||
// 计算数量
|
// 计算数量
|
||||||
{
|
{
|
||||||
// all
|
// all
|
||||||
resp, err := this.RPC().SSLCertRPC().CountSSLCerts(this.AdminContext(), &pb.CountSSLCertRequest{
|
resp, err := this.RPC().SSLCertRPC().CountSSLCerts(this.AdminContext(), &pb.CountSSLCertRequest{
|
||||||
UserId: params.UserId,
|
UserId: params.UserId,
|
||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
|
UserOnly: userOnly,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
@@ -72,9 +81,10 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
|
|
||||||
// CA
|
// CA
|
||||||
resp, err = this.RPC().SSLCertRPC().CountSSLCerts(this.AdminContext(), &pb.CountSSLCertRequest{
|
resp, err = this.RPC().SSLCertRPC().CountSSLCerts(this.AdminContext(), &pb.CountSSLCertRequest{
|
||||||
UserId: params.UserId,
|
UserId: params.UserId,
|
||||||
IsCA: true,
|
IsCA: true,
|
||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
|
UserOnly: userOnly,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
@@ -87,6 +97,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
UserId: params.UserId,
|
UserId: params.UserId,
|
||||||
IsAvailable: true,
|
IsAvailable: true,
|
||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
|
UserOnly: userOnly,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
@@ -99,6 +110,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
UserId: params.UserId,
|
UserId: params.UserId,
|
||||||
IsExpired: true,
|
IsExpired: true,
|
||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
|
UserOnly: userOnly,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
@@ -111,6 +123,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
UserId: params.UserId,
|
UserId: params.UserId,
|
||||||
ExpiringDays: 7,
|
ExpiringDays: 7,
|
||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
|
UserOnly: userOnly,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
@@ -123,6 +136,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
UserId: params.UserId,
|
UserId: params.UserId,
|
||||||
ExpiringDays: 30,
|
ExpiringDays: 30,
|
||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
|
UserOnly: userOnly,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
@@ -146,19 +160,21 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
case "":
|
case "":
|
||||||
page = this.NewPage(countAll)
|
page = this.NewPage(countAll)
|
||||||
listResp, err = this.RPC().SSLCertRPC().ListSSLCerts(this.AdminContext(), &pb.ListSSLCertsRequest{
|
listResp, err = this.RPC().SSLCertRPC().ListSSLCerts(this.AdminContext(), &pb.ListSSLCertsRequest{
|
||||||
UserId: params.UserId,
|
UserId: params.UserId,
|
||||||
Offset: page.Offset,
|
Offset: page.Offset,
|
||||||
Size: page.Size,
|
Size: page.Size,
|
||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
|
UserOnly: userOnly,
|
||||||
})
|
})
|
||||||
case "ca":
|
case "ca":
|
||||||
page = this.NewPage(countCA)
|
page = this.NewPage(countCA)
|
||||||
listResp, err = this.RPC().SSLCertRPC().ListSSLCerts(this.AdminContext(), &pb.ListSSLCertsRequest{
|
listResp, err = this.RPC().SSLCertRPC().ListSSLCerts(this.AdminContext(), &pb.ListSSLCertsRequest{
|
||||||
UserId: params.UserId,
|
UserId: params.UserId,
|
||||||
IsCA: true,
|
IsCA: true,
|
||||||
Offset: page.Offset,
|
Offset: page.Offset,
|
||||||
Size: page.Size,
|
Size: page.Size,
|
||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
|
UserOnly: userOnly,
|
||||||
})
|
})
|
||||||
case "available":
|
case "available":
|
||||||
page = this.NewPage(countAvailable)
|
page = this.NewPage(countAvailable)
|
||||||
@@ -168,6 +184,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
Offset: page.Offset,
|
Offset: page.Offset,
|
||||||
Size: page.Size,
|
Size: page.Size,
|
||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
|
UserOnly: userOnly,
|
||||||
})
|
})
|
||||||
case "expired":
|
case "expired":
|
||||||
page = this.NewPage(countExpired)
|
page = this.NewPage(countExpired)
|
||||||
@@ -177,6 +194,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
Offset: page.Offset,
|
Offset: page.Offset,
|
||||||
Size: page.Size,
|
Size: page.Size,
|
||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
|
UserOnly: userOnly,
|
||||||
})
|
})
|
||||||
case "7days":
|
case "7days":
|
||||||
page = this.NewPage(count7Days)
|
page = this.NewPage(count7Days)
|
||||||
@@ -195,14 +213,16 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
Offset: page.Offset,
|
Offset: page.Offset,
|
||||||
Size: page.Size,
|
Size: page.Size,
|
||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
|
UserOnly: userOnly,
|
||||||
})
|
})
|
||||||
default:
|
default:
|
||||||
page = this.NewPage(countAll)
|
page = this.NewPage(countAll)
|
||||||
listResp, err = this.RPC().SSLCertRPC().ListSSLCerts(this.AdminContext(), &pb.ListSSLCertsRequest{
|
listResp, err = this.RPC().SSLCertRPC().ListSSLCerts(this.AdminContext(), &pb.ListSSLCertsRequest{
|
||||||
UserId: params.UserId,
|
UserId: params.UserId,
|
||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
Offset: page.Offset,
|
UserOnly: userOnly,
|
||||||
Size: page.Size,
|
Offset: page.Offset,
|
||||||
|
Size: page.Size,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -221,6 +241,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
var certMaps = []maps.Map{}
|
var certMaps = []maps.Map{}
|
||||||
var nowTime = time.Now().Unix()
|
var nowTime = time.Now().Unix()
|
||||||
for _, certConfig := range certConfigs {
|
for _, certConfig := range certConfigs {
|
||||||
|
// count servers
|
||||||
countServersResp, err := this.RPC().ServerRPC().CountAllEnabledServersWithSSLCertId(this.AdminContext(), &pb.CountAllEnabledServersWithSSLCertIdRequest{
|
countServersResp, err := this.RPC().ServerRPC().CountAllEnabledServersWithSSLCertId(this.AdminContext(), &pb.CountAllEnabledServersWithSSLCertIdRequest{
|
||||||
SslCertId: certConfig.Id,
|
SslCertId: certConfig.Id,
|
||||||
})
|
})
|
||||||
@@ -229,6 +250,23 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// user
|
||||||
|
userResp, err := this.RPC().SSLCertRPC().FindSSLCertUser(this.AdminContext(), &pb.FindSSLCertUserRequest{SslCertId: certConfig.Id})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var certUserMap = maps.Map{
|
||||||
|
"id": 0,
|
||||||
|
}
|
||||||
|
if userResp.User != nil {
|
||||||
|
certUserMap = maps.Map{
|
||||||
|
"id": userResp.User.Id,
|
||||||
|
"username": userResp.User.Username,
|
||||||
|
"fullname": userResp.User.Fullname,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
certMaps = append(certMaps, maps.Map{
|
certMaps = append(certMaps, maps.Map{
|
||||||
"isOn": certConfig.IsOn,
|
"isOn": certConfig.IsOn,
|
||||||
"beginDay": timeutil.FormatTime("Y-m-d", certConfig.TimeBeginAt),
|
"beginDay": timeutil.FormatTime("Y-m-d", certConfig.TimeBeginAt),
|
||||||
@@ -236,6 +274,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
"isExpired": nowTime > certConfig.TimeEndAt,
|
"isExpired": nowTime > certConfig.TimeEndAt,
|
||||||
"isAvailable": nowTime <= certConfig.TimeEndAt,
|
"isAvailable": nowTime <= certConfig.TimeEndAt,
|
||||||
"countServers": countServersResp.Count,
|
"countServers": countServersResp.Count,
|
||||||
|
"user": certUserMap,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.Data["certInfos"] = certMaps
|
this.Data["certInfos"] = certMaps
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
|
|
||||||
<div class="right-box without-tabbar">
|
<div class="right-box without-tabbar">
|
||||||
<second-menu>
|
<second-menu>
|
||||||
<menu-item :href="'/servers/certs?keyword=' + keyword + '&userId=' + searchingUserId" :active="type == ''">所有证书({{countAll}})</menu-item>
|
<menu-item :href="'/servers/certs?userType=' + userType + '&keyword=' + keyword + '&userId=' + searchingUserId" :active="type == ''">所有证书({{countAll}})</menu-item>
|
||||||
<menu-item :href="'/servers/certs?type=ca&keyword=' + keyword + '&userId=' + searchingUserId" :active="type == 'ca'">CA证书({{countCA}})</menu-item>
|
<menu-item :href="'/servers/certs?userType=' + userType + '&type=ca&keyword=' + keyword + '&userId=' + searchingUserId" :active="type == 'ca'">CA证书({{countCA}})</menu-item>
|
||||||
<menu-item :href="'/servers/certs?type=available&keyword=' + keyword + '&userId=' + searchingUserId" :active="type == 'available'">有效证书({{countAvailable}})</menu-item>
|
<menu-item :href="'/servers/certs?userType=' + userType + '&type=available&keyword=' + keyword + '&userId=' + searchingUserId" :active="type == 'available'">有效证书({{countAvailable}})</menu-item>
|
||||||
<menu-item :href="'/servers/certs?type=expired&keyword=' + keyword + '&userId=' + searchingUserId" :active="type == 'expired'">过期证书<span :class="{red: countExpired > 0}">({{countExpired}})</span></menu-item>
|
<menu-item :href="'/servers/certs?userType=' + userType + '&type=expired&keyword=' + keyword + '&userId=' + searchingUserId" :active="type == 'expired'">过期证书<span :class="{red: countExpired > 0}">({{countExpired}})</span></menu-item>
|
||||||
<menu-item :href="'/servers/certs?type=7days&keyword=' + keyword + '&userId=' + searchingUserId" :active="type == '7days'">7天内过期<span :class="{red: count7Days > 0}">({{count7Days}})</span></menu-item>
|
<menu-item :href="'/servers/certs?userType=' + userType + '&type=7days&keyword=' + keyword + '&userId=' + searchingUserId" :active="type == '7days'">7天内过期<span :class="{red: count7Days > 0}">({{count7Days}})</span></menu-item>
|
||||||
<menu-item :href="'/servers/certs?type=30days&keyword=' + keyword + '&userId=' + searchingUserId" :active="type == '30days'">30天内过期({{count30Days}})</menu-item>
|
<menu-item :href="'/servers/certs?userType=' + userType + '&type=30days&keyword=' + keyword + '&userId=' + searchingUserId" :active="type == '30days'">30天内过期({{count30Days}})</menu-item>
|
||||||
<span class="item disabled">|</span>
|
<span class="item disabled">|</span>
|
||||||
<a href="" class="item" @click.prevent="uploadCert">[上传证书]</a>
|
<a href="" class="item" @click.prevent="uploadCert">[上传证书]</a>
|
||||||
<a href="" class="item" @click.prevent="uploadBatch">[批量上传]</a>
|
<a href="" class="item" @click.prevent="uploadBatch">[批量上传]</a>
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
<form class="ui form">
|
<form class="ui form">
|
||||||
<input type="hidden" name="type" :value="type"/>
|
<input type="hidden" name="type" :value="type"/>
|
||||||
|
<input type="hidden" name="userType" :value="userType"/>
|
||||||
<div class="ui fields inline">
|
<div class="ui fields inline">
|
||||||
<div class="ui field">
|
<div class="ui field">
|
||||||
<input type="text" name="keyword" placeholder="域名、说明等关键词" style="width:12em" v-model="keyword"/>
|
<input type="text" name="keyword" placeholder="域名、说明等关键词" style="width:12em" v-model="keyword"/>
|
||||||
@@ -26,17 +27,23 @@
|
|||||||
<div class="ui field">
|
<div class="ui field">
|
||||||
<button type="submit" class="ui button">搜索</button>
|
<button type="submit" class="ui button">搜索</button>
|
||||||
|
|
||||||
<a :href="Tea.url('.', { 'type':type })" v-if="keyword.length > 0 || searchingUserId > 0">[清除条件]</a>
|
<a :href="Tea.url('.', { 'userType':userType, 'type':type })" v-if="keyword.length > 0 || searchingUserId > 0">[清除条件]</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div v-if="searchingUserId == 0">
|
<div v-if="searchingUserId == 0">
|
||||||
<div class="ui divider"></div>
|
<div class="ui menu text basic tiny blue" style="margin-bottom:0">
|
||||||
<p class="comment" style="padding-top: 0">默认只显示管理员所属的证书,用户所属证书请在上面表单中选择对应用户后搜索。</p>
|
<a :href="'/servers/certs?userType=&type=' + type + '&keyword=' + keyword + '&userId=' + searchingUserId" class="item" :class="{active: userType == ''}">管理员证书</a>
|
||||||
|
<a :href="'/servers/certs?userType=user&type=' + type + '&keyword=' + keyword + '&userId=' + searchingUserId" class="item" :class="{active: userType == 'user'}">用户证书</a>
|
||||||
|
</div>
|
||||||
|
<div class="ui divider" style="margin-top:0"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="comment" v-if="certs.length == 0"><span v-if="searchingUserId > 0">当前用户下</span>暂时还没有相关的证书。</p>
|
<p class="comment" v-if="certs.length == 0"><span v-if="searchingUserId > 0">当前用户下</span>暂时还没有相关的证书。</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<table class="ui table selectable celled" v-if="certs.length > 0">
|
<table class="ui table selectable celled" v-if="certs.length > 0">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -72,7 +79,7 @@
|
|||||||
<td>{{certInfos[index].endDay}}</td>
|
<td>{{certInfos[index].endDay}}</td>
|
||||||
<td class="center">{{certInfos[index].countServers}}</td>
|
<td class="center">{{certInfos[index].countServers}}</td>
|
||||||
<td>
|
<td>
|
||||||
<span v-if="user != null && user.id > 0"><user-link :v-user="user"></user-link></span>
|
<span v-if="certInfos[index].user != null && certInfos[index].user.id > 0"><user-link :v-user="certInfos[index].user"></user-link></span>
|
||||||
<span v-else class="disabled">管理员</span>
|
<span v-else class="disabled">管理员</span>
|
||||||
</td>
|
</td>
|
||||||
<td nowrap="" class="center">
|
<td nowrap="" class="center">
|
||||||
|
|||||||
Reference in New Issue
Block a user