diff --git a/internal/web/actions/default/api/node/init.go b/internal/web/actions/default/api/node/init.go
index f485d5d4..a0b585d8 100644
--- a/internal/web/actions/default/api/node/init.go
+++ b/internal/web/actions/default/api/node/init.go
@@ -23,6 +23,7 @@ func init() {
Get("", new(IndexAction)).
GetPost("/update", new(UpdateAction)).
Get("/install", new(InstallAction)).
+ Get("/logs", new(LogsAction)).
EndAll()
})
diff --git a/internal/web/actions/default/api/node/logs.go b/internal/web/actions/default/api/node/logs.go
new file mode 100644
index 00000000..d10126be
--- /dev/null
+++ b/internal/web/actions/default/api/node/logs.go
@@ -0,0 +1,71 @@
+package node
+
+import (
+ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
+ "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
+ "github.com/iwind/TeaGo/maps"
+ timeutil "github.com/iwind/TeaGo/utils/time"
+)
+
+type LogsAction struct {
+ actionutils.ParentAction
+}
+
+func (this *LogsAction) Init() {
+ this.Nav("", "node", "log")
+ this.SecondMenu("nodes")
+}
+
+func (this *LogsAction) RunGet(params struct {
+ NodeId int64
+}) {
+ apiNodeResp, err := this.RPC().APINodeRPC().FindEnabledAPINode(this.AdminContext(), &pb.FindEnabledAPINodeRequest{NodeId: params.NodeId})
+ if err != nil {
+ this.ErrorPage(err)
+ return
+ }
+ apiNode := apiNodeResp.Node
+ if apiNode == nil {
+ this.NotFound("apiNode", params.NodeId)
+ return
+ }
+
+ this.Data["node"] = maps.Map{
+ "id": apiNode.Id,
+ "name": apiNode.Name,
+ }
+
+ countResp, err := this.RPC().NodeLogRPC().CountNodeLogs(this.AdminContext(), &pb.CountNodeLogsRequest{
+ Role: "api",
+ NodeId: params.NodeId,
+ })
+ if err != nil {
+ this.ErrorPage(err)
+ return
+ }
+ count := countResp.Count
+ page := this.NewPage(count, 20)
+
+ logsResp, err := this.RPC().NodeLogRPC().ListNodeLogs(this.AdminContext(), &pb.ListNodeLogsRequest{
+ NodeId: params.NodeId,
+ Role: "api",
+ Offset: page.Offset,
+ Size: page.Size,
+ })
+
+ logs := []maps.Map{}
+ for _, log := range logsResp.NodeLogs {
+ logs = append(logs, maps.Map{
+ "tag": log.Tag,
+ "description": log.Description,
+ "createdTime": timeutil.FormatTime("Y-m-d H:i:s", log.CreatedAt),
+ "level": log.Level,
+ "isToday": timeutil.FormatTime("Y-m-d", log.CreatedAt) == timeutil.Format("Y-m-d"),
+ })
+ }
+ this.Data["logs"] = logs
+
+ this.Data["page"] = page.AsHTML()
+
+ this.Show()
+}
diff --git a/internal/web/actions/default/users/features.go b/internal/web/actions/default/users/features.go
new file mode 100644
index 00000000..f35a99ce
--- /dev/null
+++ b/internal/web/actions/default/users/features.go
@@ -0,0 +1,78 @@
+package users
+
+import (
+ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
+ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/users/userutils"
+ "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
+ "github.com/iwind/TeaGo/actions"
+ "github.com/iwind/TeaGo/lists"
+ "github.com/iwind/TeaGo/maps"
+)
+
+type FeaturesAction struct {
+ actionutils.ParentAction
+}
+
+func (this *FeaturesAction) Init() {
+ this.Nav("", "", "feature")
+}
+
+func (this *FeaturesAction) RunGet(params struct {
+ UserId int64
+}) {
+ err := userutils.InitUser(this.Parent(), params.UserId)
+ if err != nil {
+ this.ErrorPage(err)
+ return
+ }
+
+ featuresResp, err := this.RPC().UserRPC().FindAllUserFeatureDefinitions(this.AdminContext(), &pb.FindAllUserFeatureDefinitionsRequest{})
+ if err != nil {
+ this.ErrorPage(err)
+ return
+ }
+ allFeatures := featuresResp.Features
+
+ userFeaturesResp, err := this.RPC().UserRPC().FindUserFeatures(this.AdminContext(), &pb.FindUserFeaturesRequest{UserId: params.UserId})
+ if err != nil {
+ this.ErrorPage(err)
+ return
+ }
+ userFeatureCodes := []string{}
+ for _, userFeature := range userFeaturesResp.Features {
+ userFeatureCodes = append(userFeatureCodes, userFeature.Code)
+ }
+
+ featureMaps := []maps.Map{}
+ for _, feature := range allFeatures {
+ featureMaps = append(featureMaps, maps.Map{
+ "name": feature.Name,
+ "code": feature.Code,
+ "description": feature.Description,
+ "isChecked": lists.ContainsString(userFeatureCodes, feature.Code),
+ })
+ }
+ this.Data["features"] = featureMaps
+
+ this.Show()
+}
+
+func (this *FeaturesAction) RunPost(params struct {
+ UserId int64
+ Codes []string
+
+ Must *actions.Must
+ CSRF *actionutils.CSRF
+}) {
+ defer this.CreateLogInfo("设置用户 %d 的功能列表", params.UserId)
+
+ _, err := this.RPC().UserRPC().UpdateUserFeatures(this.AdminContext(), &pb.UpdateUserFeaturesRequest{
+ UserId: params.UserId,
+ FeatureCodes: params.Codes,
+ })
+ if err != nil {
+ this.ErrorPage(err)
+ return
+ }
+ this.Success()
+}
diff --git a/internal/web/actions/default/users/init.go b/internal/web/actions/default/users/init.go
index 53a4a83e..3776f131 100644
--- a/internal/web/actions/default/users/init.go
+++ b/internal/web/actions/default/users/init.go
@@ -17,6 +17,7 @@ func init() {
Get("/user", new(UserAction)).
GetPost("/update", new(UpdateAction)).
Post("/delete", new(DeleteAction)).
+ GetPost("/features", new(FeaturesAction)).
EndAll()
})
}
diff --git a/web/views/@default/api/node/@menu.html b/web/views/@default/api/node/@menu.html
index 297c8d5e..20f96759 100644
--- a/web/views/@default/api/node/@menu.html
+++ b/web/views/@default/api/node/@menu.html
@@ -2,6 +2,7 @@
暂时还没有日志。
+ +
+ [{{log.createdTime}}][{{log.createdTime}}][{{log.tag}}]{{log.description}}
+ |
+