From d20c20cb333b7987fb09ce3d87652df5f1d43a5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Mon, 9 Oct 2023 16:18:27 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B3=E8=AF=B7=E8=AF=81=E4=B9=A6=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=88=97=E8=A1=A8=E5=8C=BA=E5=88=86=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E5=92=8C=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../default/servers/certs/acme/index.go | 59 +++++++++++++++---- .../@default/servers/certs/acme/index.html | 23 +++++--- 2 files changed, 62 insertions(+), 20 deletions(-) diff --git a/internal/web/actions/default/servers/certs/acme/index.go b/internal/web/actions/default/servers/certs/acme/index.go index 769144a8..a54ca2dd 100644 --- a/internal/web/actions/default/servers/certs/acme/index.go +++ b/internal/web/actions/default/servers/certs/acme/index.go @@ -17,12 +17,16 @@ func (this *IndexAction) Init() { } func (this *IndexAction) RunGet(params struct { - UserId int64 - Type string - Keyword string + UserId int64 + Type string + Keyword string + UserType string }) { this.Data["type"] = params.Type this.Data["keyword"] = params.Keyword + this.Data["userType"] = params.UserType + + var userOnly = params.UserId > 0 || params.UserType == "user" // 当前用户 this.Data["searchingUserId"] = params.UserId @@ -58,8 +62,9 @@ func (this *IndexAction) RunGet(params struct { { // all resp, err := this.RPC().ACMETaskRPC().CountAllEnabledACMETasks(this.AdminContext(), &pb.CountAllEnabledACMETasksRequest{ - UserId: params.UserId, - Keyword: params.Keyword, + UserId: params.UserId, + Keyword: params.Keyword, + UserOnly: userOnly, }) if err != nil { this.ErrorPage(err) @@ -72,6 +77,7 @@ func (this *IndexAction) RunGet(params struct { UserId: params.UserId, IsAvailable: true, Keyword: params.Keyword, + UserOnly: userOnly, }) if err != nil { this.ErrorPage(err) @@ -84,6 +90,7 @@ func (this *IndexAction) RunGet(params struct { UserId: params.UserId, IsExpired: true, Keyword: params.Keyword, + UserOnly: userOnly, }) if err != nil { this.ErrorPage(err) @@ -96,6 +103,7 @@ func (this *IndexAction) RunGet(params struct { UserId: params.UserId, ExpiringDays: 7, Keyword: params.Keyword, + UserOnly: userOnly, }) if err != nil { this.ErrorPage(err) @@ -108,6 +116,7 @@ func (this *IndexAction) RunGet(params struct { UserId: params.UserId, ExpiringDays: 30, Keyword: params.Keyword, + UserOnly: userOnly, }) if err != nil { this.ErrorPage(err) @@ -130,10 +139,11 @@ func (this *IndexAction) RunGet(params struct { case "": page = this.NewPage(countAll) tasksResp, err = this.RPC().ACMETaskRPC().ListEnabledACMETasks(this.AdminContext(), &pb.ListEnabledACMETasksRequest{ - UserId: params.UserId, - Offset: page.Offset, - Size: page.Size, - Keyword: params.Keyword, + UserId: params.UserId, + Offset: page.Offset, + Size: page.Size, + Keyword: params.Keyword, + UserOnly: userOnly, }) case "available": page = this.NewPage(countAvailable) @@ -143,6 +153,7 @@ func (this *IndexAction) RunGet(params struct { Offset: page.Offset, Size: page.Size, Keyword: params.Keyword, + UserOnly: userOnly, }) case "expired": page = this.NewPage(countExpired) @@ -152,6 +163,7 @@ func (this *IndexAction) RunGet(params struct { Offset: page.Offset, Size: page.Size, Keyword: params.Keyword, + UserOnly: userOnly, }) case "7days": page = this.NewPage(count7Days) @@ -161,6 +173,7 @@ func (this *IndexAction) RunGet(params struct { Offset: page.Offset, Size: page.Size, Keyword: params.Keyword, + UserOnly: userOnly, }) case "30days": page = this.NewPage(count30Days) @@ -170,14 +183,16 @@ func (this *IndexAction) RunGet(params struct { Offset: page.Offset, Size: page.Size, Keyword: params.Keyword, + UserOnly: userOnly, }) default: page = this.NewPage(countAll) tasksResp, err = this.RPC().ACMETaskRPC().ListEnabledACMETasks(this.AdminContext(), &pb.ListEnabledACMETasksRequest{ - UserId: params.UserId, - Keyword: params.Keyword, - Offset: page.Offset, - Size: page.Size, + UserId: params.UserId, + Keyword: params.Keyword, + UserOnly: userOnly, + Offset: page.Offset, + Size: page.Size, }) } if err != nil { @@ -242,6 +257,23 @@ func (this *IndexAction) RunGet(params struct { } } + // user + userResp, err := this.RPC().ACMETaskRPC().FindACMETaskUser(this.AdminContext(), &pb.FindACMETaskUserRequest{AcmeTaskId: task.Id}) + if err != nil { + this.ErrorPage(err) + return + } + var taskUserMap = maps.Map{ + "id": 0, + } + if userResp.User != nil { + taskUserMap = maps.Map{ + "id": userResp.User.Id, + "username": userResp.User.Username, + "fullname": userResp.User.Fullname, + } + } + taskMaps = append(taskMaps, maps.Map{ "id": task.Id, "authType": task.AuthType, @@ -257,6 +289,7 @@ func (this *IndexAction) RunGet(params struct { "autoRenew": task.AutoRenew, "cert": certMap, "log": logMap, + "user": taskUserMap, }) } this.Data["tasks"] = taskMaps diff --git a/web/views/@default/servers/certs/acme/index.html b/web/views/@default/servers/certs/acme/index.html index 76a91d73..8a2a0f38 100644 --- a/web/views/@default/servers/certs/acme/index.html +++ b/web/views/@default/servers/certs/acme/index.html @@ -5,14 +5,15 @@ {$template "menu"} - 所有任务({{countAll}}) - 有效证书({{countAvailable}}) - 过期证书({{countExpired}}) - 7天内过期({{count7Days}}) - 30天内过期({{count30Days}}) + 所有任务({{countAll}}) + 有效证书({{countAvailable}}) + 过期证书({{countExpired}}) + 7天内过期({{count7Days}}) + 30天内过期({{count30Days}})
+
@@ -24,11 +25,19 @@
+
+ +
+
+

当前用户下暂时还没有证书申请任务。

有任务在执行中,可能需要的时间较长,请耐心等待。
@@ -84,7 +93,7 @@ - - + 管理员