mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-06 23:00:25 +08:00
[日志审计]增加删除、清理和别的一些设置
This commit is contained in:
5
internal/configloaders/locker.go
Normal file
5
internal/configloaders/locker.go
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package configloaders
|
||||||
|
|
||||||
|
import "sync"
|
||||||
|
|
||||||
|
var locker sync.Mutex
|
||||||
83
internal/configloaders/log_config.go
Normal file
83
internal/configloaders/log_config.go
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
package configloaders
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
|
||||||
|
"github.com/iwind/TeaGo/logs"
|
||||||
|
"reflect"
|
||||||
|
)
|
||||||
|
|
||||||
|
var sharedLogConfig *systemconfigs.LogConfig = nil
|
||||||
|
|
||||||
|
const (
|
||||||
|
LogSettingName = "adminLogConfig"
|
||||||
|
)
|
||||||
|
|
||||||
|
func LoadLogConfig() (*systemconfigs.LogConfig, error) {
|
||||||
|
locker.Lock()
|
||||||
|
defer locker.Unlock()
|
||||||
|
|
||||||
|
config, err := loadLogConfig()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
v := reflect.Indirect(reflect.ValueOf(config)).Interface().(systemconfigs.LogConfig)
|
||||||
|
return &v, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func UpdateLogConfig(logConfig *systemconfigs.LogConfig) error {
|
||||||
|
locker.Lock()
|
||||||
|
defer locker.Unlock()
|
||||||
|
|
||||||
|
var rpcClient, err = rpc.SharedRPC()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
valueJSON, err := json.Marshal(logConfig)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = rpcClient.SysSettingRPC().UpdateSysSetting(rpcClient.Context(0), &pb.UpdateSysSettingRequest{
|
||||||
|
Code: LogSettingName,
|
||||||
|
ValueJSON: valueJSON,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
sharedLogConfig = logConfig
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadLogConfig() (*systemconfigs.LogConfig, error) {
|
||||||
|
if sharedLogConfig != nil {
|
||||||
|
return sharedLogConfig, nil
|
||||||
|
}
|
||||||
|
var rpcClient, err = rpc.SharedRPC()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
resp, err := rpcClient.SysSettingRPC().ReadSysSetting(rpcClient.Context(0), &pb.ReadSysSettingRequest{
|
||||||
|
Code: LogSettingName,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(resp.ValueJSON) == 0 {
|
||||||
|
sharedLogConfig = systemconfigs.DefaultLogConfig()
|
||||||
|
return sharedLogConfig, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
config := &systemconfigs.LogConfig{}
|
||||||
|
err = json.Unmarshal(resp.ValueJSON, config)
|
||||||
|
if err != nil {
|
||||||
|
logs.Println("[LOG_MANAGER]" + err.Error())
|
||||||
|
sharedLogConfig = systemconfigs.DefaultLogConfig()
|
||||||
|
return sharedLogConfig, nil
|
||||||
|
}
|
||||||
|
sharedLogConfig = config
|
||||||
|
return sharedLogConfig, nil
|
||||||
|
}
|
||||||
@@ -1,17 +1,15 @@
|
|||||||
package securitymanager
|
package configloaders
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/events"
|
"github.com/TeaOSLab/EdgeAdmin/internal/events"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
|
||||||
"github.com/iwind/TeaGo/logs"
|
"github.com/iwind/TeaGo/logs"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sync"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var locker sync.Mutex
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SecuritySettingName = "adminSecurityConfig"
|
SecuritySettingName = "adminSecurityConfig"
|
||||||
|
|
||||||
@@ -20,16 +18,9 @@ const (
|
|||||||
FrameSameOrigin = "SAMEORIGIN"
|
FrameSameOrigin = "SAMEORIGIN"
|
||||||
)
|
)
|
||||||
|
|
||||||
var sharedSecurityConfig *SecurityConfig = nil
|
var sharedSecurityConfig *systemconfigs.SecurityConfig = nil
|
||||||
|
|
||||||
type SecurityConfig struct {
|
func LoadSecurityConfig() (*systemconfigs.SecurityConfig, error) {
|
||||||
Frame string `json:"frame"`
|
|
||||||
AllowCountryIds []int64 `json:"allowCountryIds"`
|
|
||||||
AllowProvinceIds []int64 `json:"allowProvinceIds"`
|
|
||||||
AllowLocal bool `json:"allowLocal"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func LoadSecurityConfig() (*SecurityConfig, error) {
|
|
||||||
locker.Lock()
|
locker.Lock()
|
||||||
defer locker.Unlock()
|
defer locker.Unlock()
|
||||||
|
|
||||||
@@ -38,11 +29,11 @@ func LoadSecurityConfig() (*SecurityConfig, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
v := reflect.Indirect(reflect.ValueOf(config)).Interface().(SecurityConfig)
|
v := reflect.Indirect(reflect.ValueOf(config)).Interface().(systemconfigs.SecurityConfig)
|
||||||
return &v, nil
|
return &v, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateSecurityConfig(securityConfig *SecurityConfig) error {
|
func UpdateSecurityConfig(securityConfig *systemconfigs.SecurityConfig) error {
|
||||||
locker.Lock()
|
locker.Lock()
|
||||||
defer locker.Unlock()
|
defer locker.Unlock()
|
||||||
|
|
||||||
@@ -69,7 +60,7 @@ func UpdateSecurityConfig(securityConfig *SecurityConfig) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadSecurityConfig() (*SecurityConfig, error) {
|
func loadSecurityConfig() (*systemconfigs.SecurityConfig, error) {
|
||||||
if sharedSecurityConfig != nil {
|
if sharedSecurityConfig != nil {
|
||||||
return sharedSecurityConfig, nil
|
return sharedSecurityConfig, nil
|
||||||
}
|
}
|
||||||
@@ -88,7 +79,7 @@ func loadSecurityConfig() (*SecurityConfig, error) {
|
|||||||
return sharedSecurityConfig, nil
|
return sharedSecurityConfig, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
config := &SecurityConfig{}
|
config := &systemconfigs.SecurityConfig{}
|
||||||
err = json.Unmarshal(resp.ValueJSON, config)
|
err = json.Unmarshal(resp.ValueJSON, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logs.Println("[SECURITY_MANAGER]" + err.Error())
|
logs.Println("[SECURITY_MANAGER]" + err.Error())
|
||||||
@@ -99,8 +90,8 @@ func loadSecurityConfig() (*SecurityConfig, error) {
|
|||||||
return sharedSecurityConfig, nil
|
return sharedSecurityConfig, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultSecurityConfig() *SecurityConfig {
|
func defaultSecurityConfig() *systemconfigs.SecurityConfig {
|
||||||
return &SecurityConfig{
|
return &systemconfigs.SecurityConfig{
|
||||||
Frame: FrameSameOrigin,
|
Frame: FrameSameOrigin,
|
||||||
AllowLocal: true,
|
AllowLocal: true,
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package securitymanager
|
package configloaders
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "github.com/iwind/TeaGo/bootstrap"
|
_ "github.com/iwind/TeaGo/bootstrap"
|
||||||
@@ -1,30 +1,21 @@
|
|||||||
package uimanager
|
package configloaders
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
|
||||||
"github.com/iwind/TeaGo/logs"
|
"github.com/iwind/TeaGo/logs"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sync"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var sharedUIConfig *UIConfig = nil
|
var sharedUIConfig *systemconfigs.UIConfig = nil
|
||||||
var locker sync.Mutex
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
UISettingName = "adminUIConfig"
|
UISettingName = "adminUIConfig"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UIConfig struct {
|
func LoadUIConfig() (*systemconfigs.UIConfig, error) {
|
||||||
ProductName string `json:"productName"` // 产品名
|
|
||||||
AdminSystemName string `json:"adminSystemName"` // 管理员系统名称
|
|
||||||
ShowOpenSourceInfo bool `json:"showOpenSourceInfo"` // 是否显示开源信息
|
|
||||||
ShowVersion bool `json:"showVersion"` // 是否显示版本号
|
|
||||||
Version string `json:"version"` // 显示的版本号
|
|
||||||
}
|
|
||||||
|
|
||||||
func LoadUIConfig() (*UIConfig, error) {
|
|
||||||
locker.Lock()
|
locker.Lock()
|
||||||
defer locker.Unlock()
|
defer locker.Unlock()
|
||||||
|
|
||||||
@@ -33,11 +24,11 @@ func LoadUIConfig() (*UIConfig, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
v := reflect.Indirect(reflect.ValueOf(config)).Interface().(UIConfig)
|
v := reflect.Indirect(reflect.ValueOf(config)).Interface().(systemconfigs.UIConfig)
|
||||||
return &v, nil
|
return &v, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateUIConfig(uiConfig *UIConfig) error {
|
func UpdateUIConfig(uiConfig *systemconfigs.UIConfig) error {
|
||||||
locker.Lock()
|
locker.Lock()
|
||||||
defer locker.Unlock()
|
defer locker.Unlock()
|
||||||
|
|
||||||
@@ -61,7 +52,7 @@ func UpdateUIConfig(uiConfig *UIConfig) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadUIConfig() (*UIConfig, error) {
|
func loadUIConfig() (*systemconfigs.UIConfig, error) {
|
||||||
if sharedUIConfig != nil {
|
if sharedUIConfig != nil {
|
||||||
return sharedUIConfig, nil
|
return sharedUIConfig, nil
|
||||||
}
|
}
|
||||||
@@ -80,7 +71,7 @@ func loadUIConfig() (*UIConfig, error) {
|
|||||||
return sharedUIConfig, nil
|
return sharedUIConfig, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
config := &UIConfig{}
|
config := &systemconfigs.UIConfig{}
|
||||||
err = json.Unmarshal(resp.ValueJSON, config)
|
err = json.Unmarshal(resp.ValueJSON, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logs.Println("[UI_MANAGER]" + err.Error())
|
logs.Println("[UI_MANAGER]" + err.Error())
|
||||||
@@ -91,8 +82,8 @@ func loadUIConfig() (*UIConfig, error) {
|
|||||||
return sharedUIConfig, nil
|
return sharedUIConfig, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultUIConfig() *UIConfig {
|
func defaultUIConfig() *systemconfigs.UIConfig {
|
||||||
return &UIConfig{
|
return &systemconfigs.UIConfig{
|
||||||
ProductName: "GoEdge",
|
ProductName: "GoEdge",
|
||||||
AdminSystemName: "GoEdge管理员系统",
|
AdminSystemName: "GoEdge管理员系统",
|
||||||
ShowOpenSourceInfo: true,
|
ShowOpenSourceInfo: true,
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package uimanager
|
package configloaders
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "github.com/iwind/TeaGo/bootstrap"
|
_ "github.com/iwind/TeaGo/bootstrap"
|
||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestLoadSecurityConfig(t *testing.T) {
|
func TestLoadUIConfig(t *testing.T) {
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
before := time.Now()
|
before := time.Now()
|
||||||
config, err := LoadUIConfig()
|
config, err := LoadUIConfig()
|
||||||
@@ -2,11 +2,11 @@ package index
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||||
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
|
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/setup"
|
"github.com/TeaOSLab/EdgeAdmin/internal/setup"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/uimanager"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||||
@@ -50,7 +50,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
this.Data["token"] = stringutil.Md5(TokenSalt+timestamp) + timestamp
|
this.Data["token"] = stringutil.Md5(TokenSalt+timestamp) + timestamp
|
||||||
this.Data["from"] = params.From
|
this.Data["from"] = params.From
|
||||||
|
|
||||||
config, err := uimanager.LoadUIConfig()
|
config, err := configloaders.LoadUIConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
|
|||||||
100
internal/web/actions/default/log/clean.go
Normal file
100
internal/web/actions/default/log/clean.go
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
package log
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
"github.com/iwind/TeaGo/actions"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CleanAction struct {
|
||||||
|
actionutils.ParentAction
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *CleanAction) Init() {
|
||||||
|
this.Nav("", "", "clean")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *CleanAction) RunGet(params struct{}) {
|
||||||
|
// 读取配置
|
||||||
|
config, err := configloaders.LoadLogConfig()
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !config.CanClean {
|
||||||
|
this.WriteString("已设置不能清理")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.Data["logConfig"] = config
|
||||||
|
|
||||||
|
sizeResp, err := this.RPC().LogRPC().SumLogsSize(this.AdminContext(), &pb.SumLogsSizeRequest{})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
sizeHuman := ""
|
||||||
|
if sizeResp.SizeBytes < 1024 {
|
||||||
|
sizeHuman = numberutils.FormatInt64(sizeResp.SizeBytes) + "字节"
|
||||||
|
} else if sizeResp.SizeBytes < 1024*1024 {
|
||||||
|
sizeHuman = fmt.Sprintf("%.2fK", float64(sizeResp.SizeBytes)/1024)
|
||||||
|
} else if sizeResp.SizeBytes < 1024*1024*1024 {
|
||||||
|
sizeHuman = fmt.Sprintf("%.2fM", float64(sizeResp.SizeBytes)/1024/1024)
|
||||||
|
} else {
|
||||||
|
sizeHuman = fmt.Sprintf("%.2fG", float64(sizeResp.SizeBytes)/1024/1024/1024)
|
||||||
|
}
|
||||||
|
this.Data["size"] = sizeHuman
|
||||||
|
|
||||||
|
this.Show()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *CleanAction) RunPost(params struct {
|
||||||
|
Type string
|
||||||
|
Days int32
|
||||||
|
|
||||||
|
Must *actions.Must
|
||||||
|
CSRF *actionutils.CSRF
|
||||||
|
}) {
|
||||||
|
// 读取配置
|
||||||
|
config, err := configloaders.LoadLogConfig()
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !config.CanClean {
|
||||||
|
this.WriteString("已设置不能清理")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
switch params.Type {
|
||||||
|
case "all":
|
||||||
|
defer this.CreateLogInfo("清除全部日志")
|
||||||
|
|
||||||
|
_, err := this.RPC().LogRPC().CleanLogsPermanently(this.AdminContext(), &pb.CleanLogsPermanentlyRequest{
|
||||||
|
Days: 0,
|
||||||
|
ClearAll: true,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
case "days":
|
||||||
|
defer this.CreateLogInfo("清除 %d 以前的日志", params.Days)
|
||||||
|
|
||||||
|
_, err := this.RPC().LogRPC().CleanLogsPermanently(this.AdminContext(), &pb.CleanLogsPermanentlyRequest{
|
||||||
|
Days: params.Days,
|
||||||
|
ClearAll: false,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
this.Fail("不支持的清理方式 '" + params.Type + "'")
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Success()
|
||||||
|
}
|
||||||
37
internal/web/actions/default/log/delete.go
Normal file
37
internal/web/actions/default/log/delete.go
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
package log
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DeleteAction struct {
|
||||||
|
actionutils.ParentAction
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *DeleteAction) RunPost(params struct {
|
||||||
|
LogId int64
|
||||||
|
}) {
|
||||||
|
// 读取配置
|
||||||
|
config, err := configloaders.LoadLogConfig()
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !config.CanDelete {
|
||||||
|
this.Fail("已设置不能删除")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 记录日志
|
||||||
|
defer this.CreateLogInfo("删除单个操作日志 %d", params.LogId)
|
||||||
|
|
||||||
|
// 执行删除
|
||||||
|
_, err = this.RPC().LogRPC().DeleteLogPermanently(this.AdminContext(), &pb.DeleteLogPermanentlyRequest{LogId: params.LogId})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Success()
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package log
|
package log
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/iwind/TeaGo/lists"
|
"github.com/iwind/TeaGo/lists"
|
||||||
@@ -14,7 +15,7 @@ type IndexAction struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *IndexAction) Init() {
|
func (this *IndexAction) Init() {
|
||||||
this.Nav("log", "log", "")
|
this.Nav("log", "log", "list")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *IndexAction) RunGet(params struct {
|
func (this *IndexAction) RunGet(params struct {
|
||||||
@@ -22,6 +23,14 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
DayTo string
|
DayTo string
|
||||||
Keyword string
|
Keyword string
|
||||||
}) {
|
}) {
|
||||||
|
// 读取配置
|
||||||
|
config, err := configloaders.LoadLogConfig()
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.Data["logConfig"] = config
|
||||||
|
|
||||||
this.Data["dayFrom"] = params.DayFrom
|
this.Data["dayFrom"] = params.DayFrom
|
||||||
this.Data["dayTo"] = params.DayTo
|
this.Data["dayTo"] = params.DayTo
|
||||||
this.Data["keyword"] = params.Keyword
|
this.Data["keyword"] = params.Keyword
|
||||||
@@ -76,6 +85,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logMaps = append(logMaps, maps.Map{
|
logMaps = append(logMaps, maps.Map{
|
||||||
|
"id": log.Id,
|
||||||
"description": log.Description,
|
"description": log.Description,
|
||||||
"userName": log.UserName,
|
"userName": log.UserName,
|
||||||
"createdTime": timeutil.FormatTime("Y-m-d H:i:s", log.CreatedAt),
|
"createdTime": timeutil.FormatTime("Y-m-d H:i:s", log.CreatedAt),
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ func init() {
|
|||||||
Prefix("/log").
|
Prefix("/log").
|
||||||
Get("", new(IndexAction)).
|
Get("", new(IndexAction)).
|
||||||
Get("/exportExcel", new(ExportExcelAction)).
|
Get("/exportExcel", new(ExportExcelAction)).
|
||||||
|
Post("/delete", new(DeleteAction)).
|
||||||
|
GetPost("/clean", new(CleanAction)).
|
||||||
|
GetPost("/settings", new(SettingsAction)).
|
||||||
|
|
||||||
EndAll()
|
EndAll()
|
||||||
})
|
})
|
||||||
|
|||||||
63
internal/web/actions/default/log/settings.go
Normal file
63
internal/web/actions/default/log/settings.go
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
package log
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||||
|
"github.com/iwind/TeaGo/actions"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SettingsAction struct {
|
||||||
|
actionutils.ParentAction
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *SettingsAction) Init() {
|
||||||
|
this.Nav("", "", "setting")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *SettingsAction) RunGet(params struct{}) {
|
||||||
|
config, err := configloaders.LoadLogConfig()
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Data["logConfig"] = config
|
||||||
|
|
||||||
|
this.Show()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *SettingsAction) RunPost(params struct {
|
||||||
|
CanDelete bool
|
||||||
|
CanClean bool
|
||||||
|
CapacityJSON []byte
|
||||||
|
Days int
|
||||||
|
|
||||||
|
Must *actions.Must
|
||||||
|
CSRF *actionutils.CSRF
|
||||||
|
}) {
|
||||||
|
capacity := &shared.SizeCapacity{}
|
||||||
|
err := json.Unmarshal(params.CapacityJSON, capacity)
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
config, err := configloaders.LoadLogConfig()
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
config.CanDelete = params.CanDelete
|
||||||
|
config.CanClean = params.CanClean
|
||||||
|
config.Days = params.Days
|
||||||
|
config.Capacity = capacity
|
||||||
|
err = configloaders.UpdateLogConfig(config)
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Success()
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ package security
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/securitymanager"
|
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
@@ -18,7 +18,7 @@ func (this *IndexAction) Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *IndexAction) RunGet(params struct{}) {
|
func (this *IndexAction) RunGet(params struct{}) {
|
||||||
config, err := securitymanager.LoadSecurityConfig()
|
config, err := configloaders.LoadSecurityConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
@@ -75,7 +75,7 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
}) {
|
}) {
|
||||||
defer this.CreateLogInfo("修改管理界面安全设置")
|
defer this.CreateLogInfo("修改管理界面安全设置")
|
||||||
|
|
||||||
config, err := securitymanager.LoadSecurityConfig()
|
config, err := configloaders.LoadSecurityConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
@@ -109,7 +109,7 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
// 允许本地
|
// 允许本地
|
||||||
config.AllowLocal = params.AllowLocal
|
config.AllowLocal = params.AllowLocal
|
||||||
|
|
||||||
err = securitymanager.UpdateSecurityConfig(config)
|
err = configloaders.UpdateSecurityConfig(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/uimanager"
|
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
)
|
)
|
||||||
@@ -15,7 +15,7 @@ func (this *IndexAction) Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *IndexAction) RunGet(params struct{}) {
|
func (this *IndexAction) RunGet(params struct{}) {
|
||||||
config, err := uimanager.LoadUIConfig()
|
config, err := configloaders.LoadUIConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
@@ -41,7 +41,7 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
Field("adminSystemName", params.AdminSystemName).
|
Field("adminSystemName", params.AdminSystemName).
|
||||||
Require("请输入管理员系统名称")
|
Require("请输入管理员系统名称")
|
||||||
|
|
||||||
config, err := uimanager.LoadUIConfig()
|
config, err := configloaders.LoadUIConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
@@ -51,7 +51,7 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
config.ShowOpenSourceInfo = params.ShowOpenSourceInfo
|
config.ShowOpenSourceInfo = params.ShowOpenSourceInfo
|
||||||
config.ShowVersion = params.ShowVersion
|
config.ShowVersion = params.ShowVersion
|
||||||
config.Version = params.Version
|
config.Version = params.Version
|
||||||
err = uimanager.UpdateUIConfig(config)
|
err = configloaders.UpdateUIConfig(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
package helpers
|
package helpers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||||
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
|
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
|
||||||
nodes "github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
nodes "github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/securitymanager"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/setup"
|
"github.com/TeaOSLab/EdgeAdmin/internal/setup"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/uimanager"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
@@ -28,7 +27,7 @@ func (this *UserMustAuth) BeforeAction(actionPtr actions.ActionWrapper, paramNam
|
|||||||
var action = actionPtr.Object()
|
var action = actionPtr.Object()
|
||||||
|
|
||||||
// 安全相关
|
// 安全相关
|
||||||
securityConfig, _ := securitymanager.LoadSecurityConfig()
|
securityConfig, _ := configloaders.LoadSecurityConfig()
|
||||||
if securityConfig == nil {
|
if securityConfig == nil {
|
||||||
action.AddHeader("X-Frame-Options", "SAMEORIGIN")
|
action.AddHeader("X-Frame-Options", "SAMEORIGIN")
|
||||||
} else if len(securityConfig.Frame) > 0 {
|
} else if len(securityConfig.Frame) > 0 {
|
||||||
@@ -84,7 +83,7 @@ func (this *UserMustAuth) BeforeAction(actionPtr actions.ActionWrapper, paramNam
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
config, err := uimanager.LoadUIConfig()
|
config, err := configloaders.LoadUIConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
action.WriteString(err.Error())
|
action.WriteString(err.Error())
|
||||||
return false
|
return false
|
||||||
@@ -206,16 +205,16 @@ func (this *UserMustAuth) modules() []maps.Map {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"code": "log",
|
||||||
|
"name": "日志审计",
|
||||||
|
"icon": "history",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"code": "settings",
|
"code": "settings",
|
||||||
"name": "系统设置",
|
"name": "系统设置",
|
||||||
"icon": "setting",
|
"icon": "setting",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"code": "log",
|
|
||||||
"name": "操作日志",
|
|
||||||
"icon": "history",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package helpers
|
package helpers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/securitymanager"
|
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -16,7 +16,7 @@ func (this *UserShouldAuth) BeforeAction(actionPtr actions.ActionWrapper, paramN
|
|||||||
|
|
||||||
// 安全相关
|
// 安全相关
|
||||||
action := this.action
|
action := this.action
|
||||||
securityConfig, _ := securitymanager.LoadSecurityConfig()
|
securityConfig, _ := configloaders.LoadSecurityConfig()
|
||||||
if securityConfig == nil {
|
if securityConfig == nil {
|
||||||
action.AddHeader("X-Frame-Options", "SAMEORIGIN")
|
action.AddHeader("X-Frame-Options", "SAMEORIGIN")
|
||||||
} else if len(securityConfig.Frame) > 0 {
|
} else if len(securityConfig.Frame) > 0 {
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package helpers
|
|||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/events"
|
"github.com/TeaOSLab/EdgeAdmin/internal/events"
|
||||||
nodes "github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
nodes "github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/securitymanager"
|
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
|
||||||
"github.com/iwind/TeaGo/lists"
|
"github.com/iwind/TeaGo/lists"
|
||||||
"github.com/iwind/TeaGo/logs"
|
"github.com/iwind/TeaGo/logs"
|
||||||
"net"
|
"net"
|
||||||
@@ -23,7 +23,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 检查用户IP并支持缓存
|
// 检查用户IP并支持缓存
|
||||||
func checkIP(config *securitymanager.SecurityConfig, ipAddr string) bool {
|
func checkIP(config *systemconfigs.SecurityConfig, ipAddr string) bool {
|
||||||
ipCacheLocker.Lock()
|
ipCacheLocker.Lock()
|
||||||
ipCache, ok := ipCacheMap[ipAddr]
|
ipCache, ok := ipCacheMap[ipAddr]
|
||||||
if ok && ipCache {
|
if ok && ipCache {
|
||||||
@@ -46,7 +46,7 @@ func checkIP(config *securitymanager.SecurityConfig, ipAddr string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 检查用户IP
|
// 检查用户IP
|
||||||
func checkIPWithoutCache(config *securitymanager.SecurityConfig, ipAddr string) bool {
|
func checkIPWithoutCache(config *systemconfigs.SecurityConfig, ipAddr string) bool {
|
||||||
if config == nil {
|
if config == nil {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
Vue.component("size-capacity-box", {
|
Vue.component("size-capacity-box", {
|
||||||
props: ["v-name", "v-value", "v-count", "v-unit"],
|
props: ["v-name", "v-value", "v-count", "v-unit", "size", "maxlength"],
|
||||||
data: function () {
|
data: function () {
|
||||||
let v = this.vValue
|
let v = this.vValue
|
||||||
if (v == null) {
|
if (v == null) {
|
||||||
@@ -11,38 +11,51 @@ Vue.component("size-capacity-box", {
|
|||||||
if (typeof (v["count"]) != "number") {
|
if (typeof (v["count"]) != "number") {
|
||||||
v["count"] = -1
|
v["count"] = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let vSize = this.size
|
||||||
|
if (vSize == null) {
|
||||||
|
vSize = 6
|
||||||
|
}
|
||||||
|
|
||||||
|
let vMaxlength = this.maxlength
|
||||||
|
if (vMaxlength == null) {
|
||||||
|
vMaxlength = 10
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
size: v,
|
capacity: v,
|
||||||
countString: (v.count >= 0) ? v.count.toString() : ""
|
countString: (v.count >= 0) ? v.count.toString() : "",
|
||||||
|
vSize: vSize,
|
||||||
|
vMaxlength: vMaxlength
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
"countString": function (newValue) {
|
"countString": function (newValue) {
|
||||||
let value = newValue.trim()
|
let value = newValue.trim()
|
||||||
if (value.length == 0) {
|
if (value.length == 0) {
|
||||||
this.size.count = -1
|
this.capacity.count = -1
|
||||||
this.change()
|
this.change()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let count = parseInt(value)
|
let count = parseInt(value)
|
||||||
if (!isNaN(count)) {
|
if (!isNaN(count)) {
|
||||||
this.size.count = count
|
this.capacity.count = count
|
||||||
}
|
}
|
||||||
this.change()
|
this.change()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
change: function () {
|
change: function () {
|
||||||
this.$emit("change", this.size)
|
this.$emit("change", this.capacity)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
template: `<div class="ui fields inline">
|
template: `<div class="ui fields inline">
|
||||||
<input type="hidden" :name="vName" :value="JSON.stringify(size)"/>
|
<input type="hidden" :name="vName" :value="JSON.stringify(capacity)"/>
|
||||||
<div class="ui field">
|
<div class="ui field">
|
||||||
<input type="text" v-model="countString" maxlength="11" size="11"/>
|
<input type="text" v-model="countString" :maxlength="vMaxlength" :size="vSize"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui field">
|
<div class="ui field">
|
||||||
<select class="ui dropdown" v-model="size.unit" @change="change">
|
<select class="ui dropdown" v-model="capacity.unit" @change="change">
|
||||||
<option value="byte">字节</option>
|
<option value="byte">字节</option>
|
||||||
<option value="kb">KB</option>
|
<option value="kb">KB</option>
|
||||||
<option value="mb">MB</option>
|
<option value="mb">MB</option>
|
||||||
|
|||||||
5
web/views/@default/log/@menu.html
Normal file
5
web/views/@default/log/@menu.html
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<first-menu>
|
||||||
|
<menu-item href="/log" code="list">查询</menu-item>
|
||||||
|
<menu-item href="/log/clean" code="clean" v-if="logConfig.canClean">清理</menu-item>
|
||||||
|
<menu-item href="/log/settings" code="setting">设置</menu-item>
|
||||||
|
</first-menu>
|
||||||
31
web/views/@default/log/clean.html
Normal file
31
web/views/@default/log/clean.html
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{$layout}
|
||||||
|
{$template "menu"}
|
||||||
|
|
||||||
|
<form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
|
||||||
|
<csrf-token></csrf-token>
|
||||||
|
|
||||||
|
<table class="ui table definition selectable">
|
||||||
|
<!--<tr>
|
||||||
|
<td>当前用量</td>
|
||||||
|
<td>{{size}}</td>
|
||||||
|
</tr>-->
|
||||||
|
<tr>
|
||||||
|
<td class="title" :class="{'color-border':cleanType == 'days'}">清理方式</td>
|
||||||
|
<td>
|
||||||
|
<radio name="type" v-model="cleanType" :v-value="'all'">全部清除</radio>
|
||||||
|
<radio name="type" v-model="cleanType" :v-value="'days'">按天数清除</radio>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr v-show="cleanType == 'days'">
|
||||||
|
<td :class="{'color-border':cleanType == 'days'}">天数</td>
|
||||||
|
<td>
|
||||||
|
<div class="ui input right labeled">
|
||||||
|
<input type="text" name="days" v-model="days" style="width:5em" maxlength="3"/>
|
||||||
|
<span class="ui label">天以外</span>
|
||||||
|
</div>
|
||||||
|
<p class="comment">表示清除此天数以外的日志数据。</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<submit-btn></submit-btn>
|
||||||
|
</form>
|
||||||
6
web/views/@default/log/clean.js
Normal file
6
web/views/@default/log/clean.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
Tea.context(function () {
|
||||||
|
this.cleanType = "all"
|
||||||
|
this.days = 30
|
||||||
|
|
||||||
|
this.success = NotifyReloadSuccess("清理完成")
|
||||||
|
})
|
||||||
8
web/views/@default/log/index.css
Normal file
8
web/views/@default/log/index.css
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
.log-row {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.log-row .buttons {
|
||||||
|
position: absolute;
|
||||||
|
right: 1em;
|
||||||
|
}
|
||||||
|
/*# sourceMappingURL=index.css.map */
|
||||||
1
web/views/@default/log/index.css.map
Normal file
1
web/views/@default/log/index.css.map
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"sources":["index.less"],"names":[],"mappings":"AAAA;EACC,kBAAA;;AADD,QAGC;EACC,kBAAA;EACA,UAAA","file":"index.css"}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
{$layout}
|
{$layout}
|
||||||
|
{$template "menu"}
|
||||||
|
|
||||||
{$var "header"}
|
{$var "header"}
|
||||||
<!-- datepicker -->
|
<!-- datepicker -->
|
||||||
@@ -9,7 +10,6 @@
|
|||||||
<link rel="stylesheet" href="/js/pikaday.triangle.css"/>
|
<link rel="stylesheet" href="/js/pikaday.triangle.css"/>
|
||||||
{$end}
|
{$end}
|
||||||
|
|
||||||
|
|
||||||
<div class="margin"></div>
|
<div class="margin"></div>
|
||||||
|
|
||||||
<form method="get" action="/log" class="ui form" autocomplete="off">
|
<form method="get" action="/log" class="ui form" autocomplete="off">
|
||||||
@@ -42,9 +42,11 @@
|
|||||||
|
|
||||||
<table class="ui table selectable" v-for="log in logs">
|
<table class="ui table selectable" v-for="log in logs">
|
||||||
<tr :class="{error: log.level == 'error', warning: log.level == 'warn'}">
|
<tr :class="{error: log.level == 'error', warning: log.level == 'warn'}">
|
||||||
<td>{{log.createdTime}} <span class="grey"> <span
|
<td class="log-row">{{log.createdTime}} <span class="grey"> <span
|
||||||
v-if="log.userName.length > 0">| {{log.userName}}</span> | {{log.ip}}<span
|
v-if="log.userName.length > 0">| {{log.userName}}</span> | {{log.ip}}<span
|
||||||
v-if="log.region.length > 0"> | {{log.region}}</span> <a href="" @click.prevent="showMore(log)" title="显示更多">...</a> <span v-if="log.moreVisible">{{log.action}}</span></span></td>
|
v-if="log.region.length > 0"> | {{log.region}}</span> <a href="" @click.prevent="showMore(log)" title="显示更多">...</a> <span v-if="log.moreVisible">{{log.action}}</span></span>
|
||||||
|
<span class="buttons"><a v-if="logConfig.canDelete" href="" title="删除" @click.prevent="deleteLog(log.id)"><i class="icon remove small"></i></a> </span>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr :class="{error: log.level == 'error', warning: log.level == 'warn'}">
|
<tr :class="{error: log.level == 'error', warning: log.level == 'warn'}">
|
||||||
<td>{{log.description}}</td>
|
<td>{{log.description}}</td>
|
||||||
|
|||||||
@@ -18,4 +18,15 @@ Tea.context(function () {
|
|||||||
window.location = "/log/exportExcel?dayFrom=" + that.dayFrom + "&dayTo=" + that.dayTo + "&keyword=" + that.keyword
|
window.location = "/log/exportExcel?dayFrom=" + that.dayFrom + "&dayTo=" + that.dayTo + "&keyword=" + that.keyword
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.deleteLog = function (logId) {
|
||||||
|
let that = this
|
||||||
|
teaweb.confirm("确定要删除此日志吗?", function () {
|
||||||
|
that.$post(".delete")
|
||||||
|
.params({
|
||||||
|
logId: logId
|
||||||
|
})
|
||||||
|
.refresh()
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
8
web/views/@default/log/index.less
Normal file
8
web/views/@default/log/index.less
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
.log-row {
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
.buttons {
|
||||||
|
position: absolute;
|
||||||
|
right: 1em;
|
||||||
|
}
|
||||||
|
}
|
||||||
37
web/views/@default/log/settings.html
Normal file
37
web/views/@default/log/settings.html
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
{$layout}
|
||||||
|
{$template "menu"}
|
||||||
|
|
||||||
|
<form method="post" class="ui form" data-tea-success="success" data-tea-action="$">
|
||||||
|
<csrf-token></csrf-token>
|
||||||
|
|
||||||
|
<table class="ui table definition selectable">
|
||||||
|
<tr>
|
||||||
|
<td class="title">是否可以手动删除日志</td>
|
||||||
|
<td>
|
||||||
|
<checkbox name="canDelete" v-model="logConfig.canDelete"></checkbox>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>是否可以手动清理</td>
|
||||||
|
<td>
|
||||||
|
<checkbox name="canClean" v-model="logConfig.canClean"></checkbox>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>日志保留天数</td>
|
||||||
|
<td>
|
||||||
|
<input type="text" name="days" v-model="logConfig.days" style="width:5em" maxlength="3"/>
|
||||||
|
<p class="comment">超过此天数的日志将会被自动清理,0表示不自动清理。</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>最大容量限制</td>
|
||||||
|
<td>
|
||||||
|
<size-capacity-box :v-name="'capacityJSON'" :v-value="logConfig.capacity"></size-capacity-box>
|
||||||
|
<p class="comment">超出此容量限制后将会发送提醒。</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<submit-btn></submit-btn>
|
||||||
|
</form>
|
||||||
3
web/views/@default/log/settings.js
Normal file
3
web/views/@default/log/settings.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
Tea.context(function () {
|
||||||
|
this.success = NotifyReloadSuccess("保存成功")
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user