增加一部分操作日志

This commit is contained in:
GoEdgeLab
2020-11-10 21:37:48 +08:00
parent d088e88e58
commit 35f728515e
61 changed files with 273 additions and 22 deletions

View File

@@ -1,6 +1,7 @@
package cache
import (
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/nodeutils"
"github.com/TeaOSLab/EdgeCommon/pkg/messageconfigs"
@@ -88,5 +89,8 @@ func (this *CleanAction) RunPost(params struct {
this.Data["isAllOk"] = isAllOk
this.Data["results"] = results
// 创建日志
this.CreateLog(oplogs.LevelInfo, "清除缓存,缓存策略:%d", params.CachePolicyId)
this.Success()
}

View File

@@ -2,6 +2,7 @@ package cache
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
@@ -63,7 +64,7 @@ func (this *CreatePopupAction) RunPost(params struct {
this.ErrorPage(err)
return
}
_, err = this.RPC().HTTPCachePolicyRPC().CreateHTTPCachePolicy(this.AdminContext(), &pb.CreateHTTPCachePolicyRequest{
createResp, err := this.RPC().HTTPCachePolicyRPC().CreateHTTPCachePolicy(this.AdminContext(), &pb.CreateHTTPCachePolicyRequest{
IsOn: params.IsOn,
Name: params.Name,
Description: params.Description,
@@ -78,5 +79,8 @@ func (this *CreatePopupAction) RunPost(params struct {
return
}
// 创建日志
this.CreateLog(oplogs.LevelInfo, "创建缓存策略:%d", createResp.CachePolicyId)
this.Success()
}

View File

@@ -1,6 +1,7 @@
package cache
import (
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
)
@@ -28,5 +29,8 @@ func (this *DeleteAction) RunPost(params struct {
return
}
// 创建日志
this.CreateLog(oplogs.LevelInfo, "删除缓存策略:%d", params.CachePolicyId)
this.Success()
}

View File

@@ -1,6 +1,7 @@
package cache
import (
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/nodeutils"
"github.com/TeaOSLab/EdgeCommon/pkg/messageconfigs"
@@ -108,5 +109,8 @@ func (this *PreheatAction) RunPost(params struct {
this.Data["isAllOk"] = isAllOk
this.Data["results"] = results
// 创建日志
this.CreateLog(oplogs.LevelInfo, "预热缓存,缓存策略:%d", params.CachePolicyId)
this.Success()
}

View File

@@ -1,6 +1,7 @@
package cache
import (
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/nodeutils"
"github.com/TeaOSLab/EdgeCommon/pkg/messageconfigs"
@@ -107,5 +108,8 @@ func (this *PurgeAction) RunPost(params struct {
this.Data["isAllOk"] = isAllOk
this.Data["results"] = results
// 创建日志
this.CreateLog(oplogs.LevelInfo, "删除缓存,缓存策略:%d", params.CachePolicyId)
this.Success()
}

View File

@@ -1,6 +1,7 @@
package cache
import (
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/nodeutils"
"github.com/TeaOSLab/EdgeCommon/pkg/messageconfigs"
@@ -88,5 +89,8 @@ func (this *StatAction) RunPost(params struct {
this.Data["isAllOk"] = isAllOk
this.Data["results"] = results
// 创建日志
this.CreateLog(oplogs.LevelInfo, "统计缓存,缓存策略:%d", params.CachePolicyId)
this.Success()
}

View File

@@ -1,6 +1,7 @@
package cache
import (
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/nodeutils"
"github.com/TeaOSLab/EdgeCommon/pkg/messageconfigs"
@@ -56,5 +57,8 @@ func (this *TestReadAction) RunPost(params struct {
this.Data["isAllOk"] = isAllOk
this.Data["results"] = results
// 创建日志
this.CreateLog(oplogs.LevelInfo, "测试读取,缓存策略:%d", params.CachePolicyId)
this.Success()
}

View File

@@ -1,6 +1,7 @@
package cache
import (
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/nodeutils"
"github.com/TeaOSLab/EdgeCommon/pkg/messageconfigs"
@@ -59,5 +60,8 @@ func (this *TestWriteAction) RunPost(params struct {
this.Data["isAllOk"] = isAllOk
this.Data["results"] = results
// 创建日志
this.CreateLog(oplogs.LevelInfo, "测试写入,缓存策略:%d", params.CachePolicyId)
this.Success()
}

View File

@@ -2,6 +2,7 @@ package cache
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
@@ -104,5 +105,8 @@ func (this *UpdateAction) RunPost(params struct {
return
}
// 创建日志
this.CreateLog(oplogs.LevelInfo, "修改缓存策略:%d", params.CachePolicyId)
this.Success()
}

View File

@@ -1,6 +1,7 @@
package groups
import (
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
@@ -19,7 +20,7 @@ func (this *CreatePopupAction) RunGet(params struct{}) {
this.Show()
}
func (this *CreatePopupAction) RunPost(params struct{
func (this *CreatePopupAction) RunPost(params struct {
Name string
Must *actions.Must
@@ -28,7 +29,7 @@ func (this *CreatePopupAction) RunPost(params struct{
Field("name", params.Name).
Require("请输入分组名称")
createResp, err := this.RPC().ServerGroupRPC().CreateServerGroup(this.AdminContext(), &pb.CreateServerGroupRequest{
Name: params.Name,
Name: params.Name,
})
if err != nil {
this.ErrorPage(err)
@@ -40,5 +41,8 @@ func (this *CreatePopupAction) RunPost(params struct{
"name": params.Name,
}
// 创建日志
this.CreateLog(oplogs.LevelInfo, "创建代理服务分组 %d", createResp.GroupId)
this.Success()
}

View File

@@ -1,6 +1,7 @@
package groups
import (
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
)
@@ -12,6 +13,9 @@ type DeleteAction struct {
func (this *DeleteAction) RunPost(params struct {
GroupId int64
}) {
// 创建日志
this.CreateLog(oplogs.LevelInfo, "删除代理服务分组 %d", params.GroupId)
// 检查是否正在使用
countResp, err := this.RPC().ServerRPC().CountAllEnabledServersWithGroupId(this.AdminContext(), &pb.CountAllEnabledServersWithGroupIdRequest{GroupId: params.GroupId})
if err != nil {

View File

@@ -1,6 +1,7 @@
package groups
import (
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
)
@@ -12,6 +13,9 @@ type SortAction struct {
func (this *SortAction) RunPost(params struct {
GroupIds []int64
}) {
// 创建日志
this.CreateLog(oplogs.LevelInfo, "修改代理分组排序")
_, err := this.RPC().ServerGroupRPC().UpdateServerGroupOrders(this.AdminContext(), &pb.UpdateServerGroupOrdersRequest{GroupIds: params.GroupIds})
if err != nil {
this.ErrorPage(err)

View File

@@ -1,6 +1,7 @@
package groups
import (
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
@@ -43,6 +44,9 @@ func (this *UpdatePopupAction) RunPost(params struct {
Must *actions.Must
}) {
// 创建日志
this.CreateLog(oplogs.LevelInfo, "修改代理服务分组 %d", params.GroupId)
params.Must.
Field("name", params.Name).
Require("请输入分组名称")

View File

@@ -2,6 +2,7 @@ package components
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
@@ -45,6 +46,9 @@ func (this *IndexAction) RunPost(params struct {
GlobalConfigJSON []byte
Must *actions.Must
}) {
// 创建日志
this.CreateLog(oplogs.LevelInfo, "保存代理服务全局配置")
if len(params.GlobalConfigJSON) == 0 {
this.Fail("错误的配置信息,请刷新当前页面后重试")
}

View File

@@ -1,6 +1,7 @@
package iplibrary
import (
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
)
@@ -12,6 +13,9 @@ type DeleteAction struct {
func (this *DeleteAction) RunPost(params struct {
LibraryId int64
}) {
// 创建日志
this.CreateLog(oplogs.LevelInfo, "删除IP库 %d", params.LibraryId)
_, err := this.RPC().IPLibraryRPC().DeleteIPLibrary(this.AdminContext(), &pb.DeleteIPLibraryRequest{IpLibraryId: params.LibraryId})
if err != nil {
this.ErrorPage(err)

View File

@@ -1,6 +1,7 @@
package iplibrary
import (
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
@@ -93,7 +94,7 @@ func (this *UploadPopupAction) RunPost(params struct {
}
// 保存
_, err = this.RPC().IPLibraryRPC().CreateIPLibrary(this.AdminContext(), &pb.CreateIPLibraryRequest{
createResp, err := this.RPC().IPLibraryRPC().CreateIPLibrary(this.AdminContext(), &pb.CreateIPLibraryRequest{
Type: params.Type,
FileId: fileId,
})
@@ -102,5 +103,8 @@ func (this *UploadPopupAction) RunPost(params struct {
return
}
// 创建日志
this.CreateLog(oplogs.LevelInfo, "上传IP库 %d", createResp.IpLibraryId)
this.Success()
}

View File

@@ -1,6 +1,7 @@
package ssl
import (
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
)
@@ -12,6 +13,9 @@ type DeleteAction struct {
func (this *DeleteAction) RunPost(params struct {
CertId int64
}) {
// 创建日志
this.CreateLog(oplogs.LevelInfo, "删除SSL证书 %d", params.CertId)
// 是否正在被使用
countResp, err := this.RPC().ServerRPC().CountAllEnabledServersWithSSLCertId(this.AdminContext(), &pb.CountAllEnabledServersWithSSLCertIdRequest{CertId: params.CertId})
if err != nil {

View File

@@ -2,6 +2,7 @@ package ssl
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs"
@@ -54,6 +55,9 @@ func (this *UpdatePopupAction) RunPost(params struct {
Must *actions.Must
}) {
// 创建日志
this.CreateLog(oplogs.LevelInfo, "修改SSL证书 %d", params.CertId)
// 查询Cert
certConfigResp, err := this.RPC().SSLCertRPC().FindEnabledSSLCertConfig(this.AdminContext(), &pb.FindEnabledSSLCertConfigRequest{CertId: params.CertId})
if err != nil {

View File

@@ -2,6 +2,7 @@ package ssl
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs"
@@ -113,5 +114,8 @@ func (this *UploadPopupAction) RunPost(params struct {
CertId: certId,
}
// 创建日志
this.CreateLog(oplogs.LevelInfo, "上传SSL证书 %d", certId)
this.Success()
}