mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 20:40:26 +08:00
70 lines
1.4 KiB
Go
70 lines
1.4 KiB
Go
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
|
|
CanChange bool
|
|
|
|
Must *actions.Must
|
|
CSRF *actionutils.CSRF
|
|
}) {
|
|
defer this.CreateLogInfo("修改日志相关配置")
|
|
|
|
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
|
|
}
|
|
if config.CanChange {
|
|
config.CanDelete = params.CanDelete
|
|
config.CanClean = params.CanClean
|
|
config.Days = params.Days
|
|
}
|
|
config.Capacity = capacity
|
|
config.CanChange = params.CanChange
|
|
err = configloaders.UpdateLogConfig(config)
|
|
if err != nil {
|
|
this.ErrorPage(err)
|
|
return
|
|
}
|
|
|
|
this.Success()
|
|
}
|