mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-16 13:40:24 +08:00
证书列表可以使用用户筛选
This commit is contained in:
@@ -19,12 +19,37 @@ func (this *IndexAction) Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *IndexAction) RunGet(params struct {
|
func (this *IndexAction) RunGet(params struct {
|
||||||
|
UserId int64
|
||||||
Type string
|
Type string
|
||||||
Keyword string
|
Keyword string
|
||||||
}) {
|
}) {
|
||||||
this.Data["type"] = params.Type
|
this.Data["type"] = params.Type
|
||||||
this.Data["keyword"] = params.Keyword
|
this.Data["keyword"] = params.Keyword
|
||||||
|
|
||||||
|
// 当前用户
|
||||||
|
this.Data["searchingUserId"] = params.UserId
|
||||||
|
var userMap = maps.Map{
|
||||||
|
"id": 0,
|
||||||
|
"username": "",
|
||||||
|
"fullname": "",
|
||||||
|
}
|
||||||
|
if params.UserId > 0 {
|
||||||
|
userResp, err := this.RPC().UserRPC().FindEnabledUser(this.AdminContext(), &pb.FindEnabledUserRequest{UserId: params.UserId})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var user = userResp.User
|
||||||
|
if user != nil {
|
||||||
|
userMap = maps.Map{
|
||||||
|
"id": user.Id,
|
||||||
|
"username": user.Username,
|
||||||
|
"fullname": user.Fullname,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.Data["user"] = userMap
|
||||||
|
|
||||||
var countAll = int64(0)
|
var countAll = int64(0)
|
||||||
var countCA = int64(0)
|
var countCA = int64(0)
|
||||||
var countAvailable = int64(0)
|
var countAvailable = int64(0)
|
||||||
@@ -36,6 +61,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
{
|
{
|
||||||
// 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,
|
||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -46,6 +72,7 @@ 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,
|
||||||
IsCA: true,
|
IsCA: true,
|
||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
})
|
})
|
||||||
@@ -57,6 +84,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
|
|
||||||
// available
|
// available
|
||||||
resp, err = this.RPC().SSLCertRPC().CountSSLCerts(this.AdminContext(), &pb.CountSSLCertRequest{
|
resp, err = this.RPC().SSLCertRPC().CountSSLCerts(this.AdminContext(), &pb.CountSSLCertRequest{
|
||||||
|
UserId: params.UserId,
|
||||||
IsAvailable: true,
|
IsAvailable: true,
|
||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
})
|
})
|
||||||
@@ -68,6 +96,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
|
|
||||||
// expired
|
// expired
|
||||||
resp, err = this.RPC().SSLCertRPC().CountSSLCerts(this.AdminContext(), &pb.CountSSLCertRequest{
|
resp, err = this.RPC().SSLCertRPC().CountSSLCerts(this.AdminContext(), &pb.CountSSLCertRequest{
|
||||||
|
UserId: params.UserId,
|
||||||
IsExpired: true,
|
IsExpired: true,
|
||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
})
|
})
|
||||||
@@ -79,6 +108,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
|
|
||||||
// expire in 7 days
|
// expire in 7 days
|
||||||
resp, err = this.RPC().SSLCertRPC().CountSSLCerts(this.AdminContext(), &pb.CountSSLCertRequest{
|
resp, err = this.RPC().SSLCertRPC().CountSSLCerts(this.AdminContext(), &pb.CountSSLCertRequest{
|
||||||
|
UserId: params.UserId,
|
||||||
ExpiringDays: 7,
|
ExpiringDays: 7,
|
||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
})
|
})
|
||||||
@@ -90,6 +120,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
|
|
||||||
// expire in 30 days
|
// expire in 30 days
|
||||||
resp, err = this.RPC().SSLCertRPC().CountSSLCerts(this.AdminContext(), &pb.CountSSLCertRequest{
|
resp, err = this.RPC().SSLCertRPC().CountSSLCerts(this.AdminContext(), &pb.CountSSLCertRequest{
|
||||||
|
UserId: params.UserId,
|
||||||
ExpiringDays: 30,
|
ExpiringDays: 30,
|
||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
})
|
})
|
||||||
@@ -115,28 +146,60 @@ 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,
|
||||||
Offset: page.Offset,
|
Offset: page.Offset,
|
||||||
Size: page.Size,
|
Size: page.Size,
|
||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
})
|
})
|
||||||
case "ca":
|
case "ca":
|
||||||
page = this.NewPage(countCA)
|
page = this.NewPage(countCA)
|
||||||
listResp, err = this.RPC().SSLCertRPC().ListSSLCerts(this.AdminContext(), &pb.ListSSLCertsRequest{IsCA: true, Offset: page.Offset, Size: page.Size, Keyword: params.Keyword})
|
listResp, err = this.RPC().SSLCertRPC().ListSSLCerts(this.AdminContext(), &pb.ListSSLCertsRequest{
|
||||||
|
UserId: params.UserId,
|
||||||
|
IsCA: true,
|
||||||
|
Offset: page.Offset,
|
||||||
|
Size: page.Size,
|
||||||
|
Keyword: params.Keyword,
|
||||||
|
})
|
||||||
case "available":
|
case "available":
|
||||||
page = this.NewPage(countAvailable)
|
page = this.NewPage(countAvailable)
|
||||||
listResp, err = this.RPC().SSLCertRPC().ListSSLCerts(this.AdminContext(), &pb.ListSSLCertsRequest{IsAvailable: true, Offset: page.Offset, Size: page.Size, Keyword: params.Keyword})
|
listResp, err = this.RPC().SSLCertRPC().ListSSLCerts(this.AdminContext(), &pb.ListSSLCertsRequest{
|
||||||
|
UserId: params.UserId,
|
||||||
|
IsAvailable: true,
|
||||||
|
Offset: page.Offset,
|
||||||
|
Size: page.Size,
|
||||||
|
Keyword: params.Keyword,
|
||||||
|
})
|
||||||
case "expired":
|
case "expired":
|
||||||
page = this.NewPage(countExpired)
|
page = this.NewPage(countExpired)
|
||||||
listResp, err = this.RPC().SSLCertRPC().ListSSLCerts(this.AdminContext(), &pb.ListSSLCertsRequest{IsExpired: true, Offset: page.Offset, Size: page.Size, Keyword: params.Keyword})
|
listResp, err = this.RPC().SSLCertRPC().ListSSLCerts(this.AdminContext(), &pb.ListSSLCertsRequest{
|
||||||
|
UserId: params.UserId,
|
||||||
|
IsExpired: true,
|
||||||
|
Offset: page.Offset,
|
||||||
|
Size: page.Size,
|
||||||
|
Keyword: params.Keyword,
|
||||||
|
})
|
||||||
case "7days":
|
case "7days":
|
||||||
page = this.NewPage(count7Days)
|
page = this.NewPage(count7Days)
|
||||||
listResp, err = this.RPC().SSLCertRPC().ListSSLCerts(this.AdminContext(), &pb.ListSSLCertsRequest{ExpiringDays: 7, Offset: page.Offset, Size: page.Size, Keyword: params.Keyword})
|
listResp, err = this.RPC().SSLCertRPC().ListSSLCerts(this.AdminContext(), &pb.ListSSLCertsRequest{
|
||||||
|
UserId: params.UserId,
|
||||||
|
ExpiringDays: 7,
|
||||||
|
Offset: page.Offset,
|
||||||
|
Size: page.Size,
|
||||||
|
Keyword: params.Keyword,
|
||||||
|
})
|
||||||
case "30days":
|
case "30days":
|
||||||
page = this.NewPage(count30Days)
|
page = this.NewPage(count30Days)
|
||||||
listResp, err = this.RPC().SSLCertRPC().ListSSLCerts(this.AdminContext(), &pb.ListSSLCertsRequest{ExpiringDays: 30, Offset: page.Offset, Size: page.Size, Keyword: params.Keyword})
|
listResp, err = this.RPC().SSLCertRPC().ListSSLCerts(this.AdminContext(), &pb.ListSSLCertsRequest{
|
||||||
|
UserId: params.UserId,
|
||||||
|
ExpiringDays: 30,
|
||||||
|
Offset: page.Offset,
|
||||||
|
Size: page.Size,
|
||||||
|
Keyword: params.Keyword,
|
||||||
|
})
|
||||||
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,
|
||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
Offset: page.Offset,
|
Offset: page.Offset,
|
||||||
Size: page.Size,
|
Size: page.Size,
|
||||||
@@ -158,7 +221,9 @@ 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 {
|
||||||
countServersResp, err := this.RPC().ServerRPC().CountAllEnabledServersWithSSLCertId(this.AdminContext(), &pb.CountAllEnabledServersWithSSLCertIdRequest{SslCertId: certConfig.Id})
|
countServersResp, err := this.RPC().ServerRPC().CountAllEnabledServersWithSSLCertId(this.AdminContext(), &pb.CountAllEnabledServersWithSSLCertIdRequest{
|
||||||
|
SslCertId: certConfig.Id,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
选择申请方式
|
选择申请方式
|
||||||
</div>
|
</div>
|
||||||
<div class="ui step" :class="{active:step == 'user'}">
|
<div class="ui step" :class="{active:step == 'user'}">
|
||||||
选择用户
|
选择ACME用户
|
||||||
</div>
|
</div>
|
||||||
<div class="ui step" :class="{active:step == 'dns'}">
|
<div class="ui step" :class="{active:step == 'dns'}">
|
||||||
填写域名信息
|
填写域名信息
|
||||||
|
|||||||
@@ -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" :active="type == ''">所有证书({{countAll}})</menu-item>
|
<menu-item :href="'/servers/certs?keyword=' + keyword + '&userId=' + searchingUserId" :active="type == ''">所有证书({{countAll}})</menu-item>
|
||||||
<menu-item :href="'/servers/certs?type=ca&keyword=' + keyword" :active="type == 'ca'">CA证书({{countCA}})</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?type=available&keyword=' + keyword" :active="type == 'available'">有效证书({{countAvailable}})</menu-item>
|
<menu-item :href="'/servers/certs?type=available&keyword=' + keyword + '&userId=' + searchingUserId" :active="type == 'available'">有效证书({{countAvailable}})</menu-item>
|
||||||
<menu-item :href="'/servers/certs?type=expired&keyword=' + keyword" :active="type == 'expired'">过期证书<span :class="{red: countExpired > 0}">({{countExpired}})</span></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?type=7days&keyword=' + keyword" :active="type == '7days'">7天内过期<span :class="{red: count7Days > 0}">({{count7Days}})</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?type=30days&keyword=' + keyword" :active="type == '30days'">30天内过期({{count30Days}})</menu-item>
|
<menu-item :href="'/servers/certs?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>
|
||||||
@@ -18,17 +18,20 @@
|
|||||||
<input type="hidden" name="type" :value="type"/>
|
<input type="hidden" name="type" :value="type"/>
|
||||||
<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:10em" v-model="keyword"/>
|
<input type="text" name="keyword" placeholder="域名、说明等关键词" style="width:12em" v-model="keyword"/>
|
||||||
|
</div>
|
||||||
|
<div class="ui field">
|
||||||
|
<user-selector :v-user-id="searchingUserId"></user-selector>
|
||||||
</div>
|
</div>
|
||||||
<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">[清除条件]</a>
|
<a :href="Tea.url('.', { 'type':type })" v-if="keyword.length > 0 || searchingUserId > 0">[清除条件]</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<p class="comment" v-if="certs.length == 0">暂时还没有相关的证书。</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>
|
||||||
@@ -38,6 +41,7 @@
|
|||||||
<th>生效日期</th>
|
<th>生效日期</th>
|
||||||
<th>过期日期</th>
|
<th>过期日期</th>
|
||||||
<th class="center">引用服务</th>
|
<th class="center">引用服务</th>
|
||||||
|
<th>所属用户</th>
|
||||||
<th class="center">状态</th>
|
<th class="center">状态</th>
|
||||||
<th class="three op">操作</th>
|
<th class="three op">操作</th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -62,6 +66,10 @@
|
|||||||
<td>{{certInfos[index].beginDay}}</td>
|
<td>{{certInfos[index].beginDay}}</td>
|
||||||
<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>
|
||||||
|
<span v-if="user != null && user.id > 0"><user-link :v-user="user"></user-link></span>
|
||||||
|
<span v-else class="disabled">管理员</span>
|
||||||
|
</td>
|
||||||
<td nowrap="" class="center">
|
<td nowrap="" class="center">
|
||||||
<span class="ui label red tiny basic" v-if="!certInfos[index].isOn">未启用</span>
|
<span class="ui label red tiny basic" v-if="!certInfos[index].isOn">未启用</span>
|
||||||
<span class="ui label red tiny basic" v-else-if="certInfos[index].isExpired">已过期</span>
|
<span class="ui label red tiny basic" v-else-if="certInfos[index].isExpired">已过期</span>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
Tea.context(function () {
|
Tea.context(function () {
|
||||||
// 上传证书
|
// 上传证书
|
||||||
this.uploadCert = function () {
|
this.uploadCert = function () {
|
||||||
teaweb.popup("/servers/certs/uploadPopup", {
|
teaweb.popup("/servers/certs/uploadPopup?userId=" + this.searchingUserId, {
|
||||||
height: "30em",
|
height: "30em",
|
||||||
callback: function () {
|
callback: function () {
|
||||||
teaweb.success("上传成功", function () {
|
teaweb.success("上传成功", function () {
|
||||||
@@ -13,7 +13,7 @@ Tea.context(function () {
|
|||||||
|
|
||||||
// 批量上传证书
|
// 批量上传证书
|
||||||
this.uploadBatch = function () {
|
this.uploadBatch = function () {
|
||||||
teaweb.popup("/servers/certs/uploadBatchPopup", {
|
teaweb.popup("/servers/certs/uploadBatchPopup?userId=" + this.searchingUserId, {
|
||||||
callback: function () {
|
callback: function () {
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
<!-- 证书列表 -->
|
<!-- 证书列表 -->
|
||||||
<p class="comment" v-if="certs.length == 0">
|
<p class="comment" v-if="certs.length == 0">
|
||||||
暂时还没有<span v-if="searchingType == 'match'">跟所添加域名匹配的</span>相关证书<span v-if="searchingUserId > 0">,<a href="" @click.prevent="searchNoneUserCerts">[尝试搜索未指定用户证书]</a></span>。
|
<span v-if="searchingUserId > 0">当前用户下</span>暂时还没有<span v-if="searchingType == 'match'">跟所添加域名匹配的</span>相关证书<span v-if="searchingUserId > 0">,<a href="" @click.prevent="searchNoneUserCerts">[尝试搜索管理员上传和申请的证书]</a></span>。
|
||||||
</p>
|
</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>
|
||||||
|
|||||||
Reference in New Issue
Block a user