mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-24 02:59:16 +08:00
feat: 修改部分监控接口 (#6033)
This commit is contained in:
parent
9f4d9a3f00
commit
370463366b
@ -35,6 +35,7 @@ var (
|
||||
fileService = service.NewIFileService()
|
||||
sshService = service.NewISSHService()
|
||||
firewallService = service.NewIFirewallService()
|
||||
monitorService = service.NewIMonitorService()
|
||||
|
||||
deviceService = service.NewIDeviceService()
|
||||
fail2banService = service.NewIFail2BanService()
|
||||
|
@ -2,21 +2,17 @@ package v1
|
||||
|
||||
import (
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/agent/app/api/v1/helper"
|
||||
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||
"github.com/1Panel-dev/1Panel/agent/app/model"
|
||||
"github.com/1Panel-dev/1Panel/agent/constant"
|
||||
"github.com/1Panel-dev/1Panel/agent/global"
|
||||
"github.com/1Panel-dev/1Panel/agent/utils/common"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/shirou/gopsutil/v3/disk"
|
||||
"github.com/shirou/gopsutil/v3/net"
|
||||
)
|
||||
|
||||
// @Tags Monitor
|
||||
// @Summary Load monitor datas
|
||||
// @Summary Load monitor data
|
||||
// @Description 获取监控数据
|
||||
// @Param request body dto.MonitorSearch true "request"
|
||||
// @Success 200
|
||||
@ -28,82 +24,60 @@ func (b *BaseApi) LoadMonitor(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
loc, _ := time.LoadLocation(common.LoadTimeZone())
|
||||
req.StartTime = req.StartTime.In(loc)
|
||||
req.EndTime = req.EndTime.In(loc)
|
||||
|
||||
var backdatas []dto.MonitorData
|
||||
if req.Param == "all" || req.Param == "cpu" || req.Param == "memory" || req.Param == "load" {
|
||||
var bases []model.MonitorBase
|
||||
if err := global.MonitorDB.
|
||||
Where("created_at > ? AND created_at < ?", req.StartTime, req.EndTime).
|
||||
Find(&bases).Error; err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
}
|
||||
|
||||
var itemData dto.MonitorData
|
||||
itemData.Param = "base"
|
||||
for _, base := range bases {
|
||||
itemData.Date = append(itemData.Date, base.CreatedAt)
|
||||
itemData.Value = append(itemData.Value, base)
|
||||
}
|
||||
backdatas = append(backdatas, itemData)
|
||||
data, err := monitorService.LoadMonitorData(req)
|
||||
if err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
}
|
||||
if req.Param == "all" || req.Param == "io" {
|
||||
var bases []model.MonitorIO
|
||||
if err := global.MonitorDB.
|
||||
Where("created_at > ? AND created_at < ?", req.StartTime, req.EndTime).
|
||||
Find(&bases).Error; err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
}
|
||||
|
||||
var itemData dto.MonitorData
|
||||
itemData.Param = "io"
|
||||
for _, base := range bases {
|
||||
itemData.Date = append(itemData.Date, base.CreatedAt)
|
||||
itemData.Value = append(itemData.Value, base)
|
||||
}
|
||||
backdatas = append(backdatas, itemData)
|
||||
}
|
||||
if req.Param == "all" || req.Param == "network" {
|
||||
var bases []model.MonitorNetwork
|
||||
if err := global.MonitorDB.
|
||||
Where("name = ? AND created_at > ? AND created_at < ?", req.Info, req.StartTime, req.EndTime).
|
||||
Find(&bases).Error; err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
}
|
||||
|
||||
var itemData dto.MonitorData
|
||||
itemData.Param = "network"
|
||||
for _, base := range bases {
|
||||
itemData.Date = append(itemData.Date, base.CreatedAt)
|
||||
itemData.Value = append(itemData.Value, base)
|
||||
}
|
||||
backdatas = append(backdatas, itemData)
|
||||
}
|
||||
helper.SuccessWithData(c, backdatas)
|
||||
helper.SuccessWithData(c, data)
|
||||
}
|
||||
|
||||
// @Tags Monitor
|
||||
// @Summary Clean monitor datas
|
||||
// @Summary Clean monitor data
|
||||
// @Description 清空监控数据
|
||||
// @Success 200
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /hosts/monitor/clean [post]
|
||||
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"清空监控数据","formatEN":"clean monitor datas"}
|
||||
func (b *BaseApi) CleanMonitor(c *gin.Context) {
|
||||
if err := global.MonitorDB.Exec("DELETE FROM monitor_bases").Error; err != nil {
|
||||
if err := monitorService.CleanData(); err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
}
|
||||
if err := global.MonitorDB.Exec("DELETE FROM monitor_ios").Error; err != nil {
|
||||
|
||||
helper.SuccessWithData(c, nil)
|
||||
}
|
||||
|
||||
// @Tags Monitor
|
||||
// @Summary Load monitor setting
|
||||
// @Description 获取默认监控设置
|
||||
// @Success 200
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /hosts/monitor/setting [get]
|
||||
func (b *BaseApi) LoadMonitorSetting(c *gin.Context) {
|
||||
setting, err := monitorService.LoadSetting()
|
||||
if err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
}
|
||||
if err := global.MonitorDB.Exec("DELETE FROM monitor_networks").Error; err != nil {
|
||||
|
||||
helper.SuccessWithData(c, setting)
|
||||
}
|
||||
|
||||
// @Tags Monitor
|
||||
// @Summary Update monitor setting
|
||||
// @Description 更新默认监控设置
|
||||
// @Param request body dto.MonitorSettingUpdate true "request"
|
||||
// @Success 200
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /hosts/monitor/setting/update [post]
|
||||
// @x-panel-log {"bodyKeys":["key", "value"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改默认监控网卡 [name]-[value]","formatEN":"update default monitor [name]-[value]"}
|
||||
func (b *BaseApi) UpdateMonitorSetting(c *gin.Context) {
|
||||
var req dto.MonitorSettingUpdate
|
||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||
return
|
||||
}
|
||||
if err := monitorService.UpdateSetting(req.Key, req.Value); err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
}
|
||||
|
@ -73,3 +73,15 @@ type TreeChild struct {
|
||||
ID uint `json:"id"`
|
||||
Label string `json:"label"`
|
||||
}
|
||||
|
||||
type MonitorSetting struct {
|
||||
MonitorStatus string `json:"monitorStatus"`
|
||||
MonitorStoreDays string `json:"monitorStoreDays"`
|
||||
MonitorInterval string `json:"monitorInterval"`
|
||||
DefaultNetwork string `json:"defaultNetwork"`
|
||||
}
|
||||
|
||||
type MonitorSettingUpdate struct {
|
||||
Key string `json:"key" validate:"required,oneof=MonitorStatus MonitorStoreDays MonitorInterval DefaultNetwork"`
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ type ICommonRepo interface {
|
||||
WithLikeName(name string) DBOption
|
||||
WithIdsIn(ids []uint) DBOption
|
||||
WithByDate(startTime, endTime time.Time) DBOption
|
||||
WithByCreatedAt(startTime, endTime time.Time) DBOption
|
||||
WithByStartDate(startTime time.Time) DBOption
|
||||
WithByStatus(status string) DBOption
|
||||
WithByFrom(from string) DBOption
|
||||
@ -51,6 +52,12 @@ func (c *CommonRepo) WithByDate(startTime, endTime time.Time) DBOption {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *CommonRepo) WithByCreatedAt(startTime, endTime time.Time) DBOption {
|
||||
return func(g *gorm.DB) *gorm.DB {
|
||||
return g.Where("created_at > ? AND created_at < ?", startTime, endTime)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *CommonRepo) WithByStartDate(startTime time.Time) DBOption {
|
||||
return func(g *gorm.DB) *gorm.DB {
|
||||
return g.Where("start_time < ?", startTime)
|
||||
|
74
agent/app/repo/monitor.go
Normal file
74
agent/app/repo/monitor.go
Normal file
@ -0,0 +1,74 @@
|
||||
package repo
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/agent/app/model"
|
||||
"github.com/1Panel-dev/1Panel/agent/global"
|
||||
)
|
||||
|
||||
type MonitorRepo struct{}
|
||||
|
||||
type IMonitorRepo interface {
|
||||
GetBase(opts ...DBOption) ([]model.MonitorBase, error)
|
||||
GetIO(opts ...DBOption) ([]model.MonitorIO, error)
|
||||
GetNetwork(opts ...DBOption) ([]model.MonitorNetwork, error)
|
||||
|
||||
CreateMonitorBase(model model.MonitorBase) error
|
||||
BatchCreateMonitorIO(ioList []model.MonitorIO) error
|
||||
BatchCreateMonitorNet(ioList []model.MonitorNetwork) error
|
||||
DelMonitorBase(timeForDelete time.Time) error
|
||||
DelMonitorIO(timeForDelete time.Time) error
|
||||
DelMonitorNet(timeForDelete time.Time) error
|
||||
}
|
||||
|
||||
func NewIMonitorRepo() IMonitorRepo {
|
||||
return &MonitorRepo{}
|
||||
}
|
||||
|
||||
func (u *MonitorRepo) GetBase(opts ...DBOption) ([]model.MonitorBase, error) {
|
||||
var data []model.MonitorBase
|
||||
db := global.DB
|
||||
for _, opt := range opts {
|
||||
db = opt(db)
|
||||
}
|
||||
err := db.Find(&data).Error
|
||||
return data, err
|
||||
}
|
||||
func (u *MonitorRepo) GetIO(opts ...DBOption) ([]model.MonitorIO, error) {
|
||||
var data []model.MonitorIO
|
||||
db := global.DB
|
||||
for _, opt := range opts {
|
||||
db = opt(db)
|
||||
}
|
||||
err := db.First(&data).Error
|
||||
return data, err
|
||||
}
|
||||
func (u *MonitorRepo) GetNetwork(opts ...DBOption) ([]model.MonitorNetwork, error) {
|
||||
var data []model.MonitorNetwork
|
||||
db := global.DB
|
||||
for _, opt := range opts {
|
||||
db = opt(db)
|
||||
}
|
||||
err := db.First(&data).Error
|
||||
return data, err
|
||||
}
|
||||
|
||||
func (u *MonitorRepo) CreateMonitorBase(model model.MonitorBase) error {
|
||||
return global.MonitorDB.Create(&model).Error
|
||||
}
|
||||
func (u *MonitorRepo) BatchCreateMonitorIO(ioList []model.MonitorIO) error {
|
||||
return global.MonitorDB.CreateInBatches(ioList, len(ioList)).Error
|
||||
}
|
||||
func (u *MonitorRepo) BatchCreateMonitorNet(ioList []model.MonitorNetwork) error {
|
||||
return global.MonitorDB.CreateInBatches(ioList, len(ioList)).Error
|
||||
}
|
||||
func (u *MonitorRepo) DelMonitorBase(timeForDelete time.Time) error {
|
||||
return global.MonitorDB.Where("created_at < ?", timeForDelete).Delete(&model.MonitorBase{}).Error
|
||||
}
|
||||
func (u *MonitorRepo) DelMonitorIO(timeForDelete time.Time) error {
|
||||
return global.MonitorDB.Where("created_at < ?", timeForDelete).Delete(&model.MonitorIO{}).Error
|
||||
}
|
||||
func (u *MonitorRepo) DelMonitorNet(timeForDelete time.Time) error {
|
||||
return global.MonitorDB.Where("created_at < ?", timeForDelete).Delete(&model.MonitorNetwork{}).Error
|
||||
}
|
@ -26,6 +26,7 @@ var (
|
||||
commandRepo = repo.NewICommandRepo()
|
||||
ftpRepo = repo.NewIFtpRepo()
|
||||
clamRepo = repo.NewIClamRepo()
|
||||
monitorRepo = repo.NewIMonitorRepo()
|
||||
|
||||
settingRepo = repo.NewISettingRepo()
|
||||
backupRepo = repo.NewIBackupRepo()
|
||||
|
@ -2,12 +2,16 @@ package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||
"github.com/1Panel-dev/1Panel/agent/app/model"
|
||||
"github.com/1Panel-dev/1Panel/agent/constant"
|
||||
"github.com/1Panel-dev/1Panel/agent/global"
|
||||
"github.com/1Panel-dev/1Panel/agent/utils/common"
|
||||
"github.com/robfig/cron/v3"
|
||||
"github.com/shirou/gopsutil/v3/cpu"
|
||||
"github.com/shirou/gopsutil/v3/disk"
|
||||
@ -25,6 +29,10 @@ var monitorCancel context.CancelFunc
|
||||
|
||||
type IMonitorService interface {
|
||||
Run()
|
||||
LoadMonitorData(req dto.MonitorSearch) ([]dto.MonitorData, error)
|
||||
LoadSetting() (*dto.MonitorSetting, error)
|
||||
UpdateSetting(key, value string) error
|
||||
CleanData() error
|
||||
|
||||
saveIODataToDB(ctx context.Context, interval float64)
|
||||
saveNetDataToDB(ctx context.Context, interval float64)
|
||||
@ -37,6 +45,94 @@ func NewIMonitorService() IMonitorService {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MonitorService) LoadMonitorData(req dto.MonitorSearch) ([]dto.MonitorData, error) {
|
||||
loc, _ := time.LoadLocation(common.LoadTimeZone())
|
||||
req.StartTime = req.StartTime.In(loc)
|
||||
req.EndTime = req.EndTime.In(loc)
|
||||
|
||||
var data []dto.MonitorData
|
||||
if req.Param == "all" || req.Param == "cpu" || req.Param == "memory" || req.Param == "load" {
|
||||
bases, err := monitorRepo.GetBase(commonRepo.WithByCreatedAt(req.StartTime, req.EndTime))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var itemData dto.MonitorData
|
||||
itemData.Param = "base"
|
||||
for _, base := range bases {
|
||||
itemData.Date = append(itemData.Date, base.CreatedAt)
|
||||
itemData.Value = append(itemData.Value, base)
|
||||
}
|
||||
data = append(data, itemData)
|
||||
}
|
||||
if req.Param == "all" || req.Param == "io" {
|
||||
bases, err := monitorRepo.GetIO(commonRepo.WithByCreatedAt(req.StartTime, req.EndTime))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var itemData dto.MonitorData
|
||||
itemData.Param = "io"
|
||||
for _, base := range bases {
|
||||
itemData.Date = append(itemData.Date, base.CreatedAt)
|
||||
itemData.Value = append(itemData.Value, base)
|
||||
}
|
||||
data = append(data, itemData)
|
||||
}
|
||||
if req.Param == "all" || req.Param == "network" {
|
||||
bases, err := monitorRepo.GetIO(commonRepo.WithByName(req.Info), commonRepo.WithByCreatedAt(req.StartTime, req.EndTime))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var itemData dto.MonitorData
|
||||
itemData.Param = "network"
|
||||
for _, base := range bases {
|
||||
itemData.Date = append(itemData.Date, base.CreatedAt)
|
||||
itemData.Value = append(itemData.Value, base)
|
||||
}
|
||||
data = append(data, itemData)
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (m *MonitorService) LoadSetting() (*dto.MonitorSetting, error) {
|
||||
setting, err := settingRepo.GetList()
|
||||
if err != nil {
|
||||
return nil, constant.ErrRecordNotFound
|
||||
}
|
||||
settingMap := make(map[string]string)
|
||||
for _, set := range setting {
|
||||
settingMap[set.Key] = set.Value
|
||||
}
|
||||
var info dto.MonitorSetting
|
||||
arr, err := json.Marshal(settingMap)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := json.Unmarshal(arr, &info); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &info, err
|
||||
}
|
||||
|
||||
func (m *MonitorService) UpdateSetting(key, value string) error {
|
||||
return settingRepo.Update(key, value)
|
||||
}
|
||||
|
||||
func (m *MonitorService) CleanData() error {
|
||||
if err := global.MonitorDB.Exec("DELETE FROM monitor_bases").Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if err := global.MonitorDB.Exec("DELETE FROM monitor_ios").Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if err := global.MonitorDB.Exec("DELETE FROM monitor_networks").Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MonitorService) Run() {
|
||||
var itemModel model.MonitorBase
|
||||
totalPercent, _ := cpu.Percent(3*time.Second, false)
|
||||
|
@ -6,8 +6,6 @@ import (
|
||||
|
||||
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||
"github.com/1Panel-dev/1Panel/agent/constant"
|
||||
"github.com/1Panel-dev/1Panel/agent/global"
|
||||
"github.com/robfig/cron/v3"
|
||||
)
|
||||
|
||||
type SettingService struct{}
|
||||
@ -45,31 +43,6 @@ func (u *SettingService) GetSettingInfo() (*dto.SettingInfo, error) {
|
||||
|
||||
func (u *SettingService) Update(key, value string) error {
|
||||
switch key {
|
||||
case "MonitorStatus":
|
||||
if value == "enable" && global.MonitorCronID == 0 {
|
||||
interval, err := settingRepo.Get(settingRepo.WithByKey("MonitorInterval"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := StartMonitor(false, interval.Value); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if value == "disable" && global.MonitorCronID != 0 {
|
||||
monitorCancel()
|
||||
global.Cron.Remove(cron.EntryID(global.MonitorCronID))
|
||||
global.MonitorCronID = 0
|
||||
}
|
||||
case "MonitorInterval":
|
||||
status, err := settingRepo.Get(settingRepo.WithByKey("MonitorStatus"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if status.Value == "enable" && global.MonitorCronID != 0 {
|
||||
if err := StartMonitor(true, value); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
case "AppStoreLastModified":
|
||||
exist, _ := settingRepo.Get(settingRepo.WithByKey("AppStoreLastModified"))
|
||||
if exist.ID == 0 {
|
||||
|
@ -145,9 +145,6 @@ var InitSetting = &gormigrate.Migration{
|
||||
return err
|
||||
}
|
||||
|
||||
if err := tx.Create(&model.Setting{Key: "DefaultNetwork", Value: "all"}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if err := tx.Create(&model.Setting{Key: "LastCleanTime", Value: ""}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
@ -158,6 +155,9 @@ var InitSetting = &gormigrate.Migration{
|
||||
return err
|
||||
}
|
||||
|
||||
if err := tx.Create(&model.Setting{Key: "DefaultNetwork", Value: "all"}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if err := tx.Create(&model.Setting{Key: "MonitorStatus", Value: "enable"}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -6,11 +6,16 @@ import (
|
||||
|
||||
"github.com/1Panel-dev/1Panel/agent/app/api/v1/helper"
|
||||
"github.com/1Panel-dev/1Panel/agent/constant"
|
||||
"github.com/1Panel-dev/1Panel/agent/global"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Certificate() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
if global.CurrentNode == "127.0.0.1" || len(global.CurrentNode) == 0 {
|
||||
c.Next()
|
||||
return
|
||||
}
|
||||
if !c.Request.TLS.HandshakeComplete || len(c.Request.TLS.PeerCertificates) == 0 {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, errors.New("no such tls peer certificates"))
|
||||
return
|
||||
|
@ -36,6 +36,8 @@ func (s *HostRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
hostRouter.POST("/monitor/clean", baseApi.CleanMonitor)
|
||||
hostRouter.GET("/monitor/netoptions", baseApi.GetNetworkOptions)
|
||||
hostRouter.GET("/monitor/iooptions", baseApi.GetIOOptions)
|
||||
hostRouter.GET("/monitor/setting", baseApi.LoadMonitorSetting)
|
||||
hostRouter.POST("/monitor/setting/update", baseApi.UpdateMonitorSetting)
|
||||
|
||||
hostRouter.GET("/ssh/conf", baseApi.LoadSSHConf)
|
||||
hostRouter.POST("/ssh/search", baseApi.GetSSHInfo)
|
||||
|
@ -44,7 +44,7 @@ func Start() {
|
||||
server := &http.Server{
|
||||
Handler: rootRouter,
|
||||
}
|
||||
if global.CurrentNode == "127.0.0.1" {
|
||||
if len(global.CurrentNode) == 0 || global.CurrentNode == "127.0.0.1" {
|
||||
_ = os.Remove("/tmp/agent.sock")
|
||||
listener, err := net.Listen("unix", "/tmp/agent.sock")
|
||||
if err != nil {
|
||||
|
@ -271,16 +271,6 @@ func (b *BaseApi) HandlePasswordExpired(c *gin.Context) {
|
||||
helper.SuccessWithData(c, nil)
|
||||
}
|
||||
|
||||
// @Tags System Setting
|
||||
// @Summary Load local backup dir
|
||||
// @Description 获取安装根目录
|
||||
// @Success 200 {string} path
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /settings/basedir [get]
|
||||
func (b *BaseApi) LoadBaseDir(c *gin.Context) {
|
||||
helper.SuccessWithData(c, global.CONF.System.DataDir)
|
||||
}
|
||||
|
||||
// @Tags System Setting
|
||||
// @Summary Load mfa info
|
||||
// @Description 获取 mfa 信息
|
||||
|
@ -30,6 +30,5 @@ func (s *SettingRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
settingRouter.POST("/upgrade", baseApi.Upgrade)
|
||||
settingRouter.POST("/upgrade/notes", baseApi.GetNotesByVersion)
|
||||
settingRouter.GET("/upgrade", baseApi.GetUpgradeInfo)
|
||||
settingRouter.GET("/basedir", baseApi.LoadBaseDir)
|
||||
}
|
||||
}
|
||||
|
@ -128,6 +128,12 @@ export namespace Host {
|
||||
rules: Array<RulePort>;
|
||||
}
|
||||
|
||||
export interface MonitorSetting {
|
||||
defaultNetwork: string;
|
||||
monitorStatus: string;
|
||||
monitorStoreDays: string;
|
||||
monitorInterval: string;
|
||||
}
|
||||
export interface MonitorData {
|
||||
param: string;
|
||||
date: Array<Date>;
|
||||
|
@ -130,6 +130,12 @@ export const getIOOptions = () => {
|
||||
export const cleanMonitors = () => {
|
||||
return http.post(`/hosts/monitor/clean`, {});
|
||||
};
|
||||
export const loadMonitorSetting = () => {
|
||||
return http.get<Host.MonitorSetting>(`/hosts/monitor/setting`, {});
|
||||
};
|
||||
export const updateMonitorSetting = (key: string, value: string) => {
|
||||
return http.post(`/hosts/monitor/setting/update`, { key: key, value: value });
|
||||
};
|
||||
|
||||
// ssh
|
||||
export const getSSHInfo = () => {
|
||||
|
@ -6,25 +6,29 @@ import { Backup } from '../interface/backup';
|
||||
import { Setting } from '../interface/setting';
|
||||
import { TimeoutEnum } from '@/enums/http-enum';
|
||||
|
||||
// license
|
||||
export const UploadFileData = (params: FormData) => {
|
||||
return http.upload('/licenses/upload', params);
|
||||
};
|
||||
|
||||
export const getLicense = () => {
|
||||
return http.get<Setting.License>(`/licenses/get`);
|
||||
};
|
||||
export const getLicenseStatus = () => {
|
||||
return http.get<Setting.LicenseStatus>(`/licenses/get/status`);
|
||||
};
|
||||
|
||||
export const syncLicense = () => {
|
||||
return http.post(`/licenses/sync`);
|
||||
};
|
||||
|
||||
export const unbindLicense = () => {
|
||||
return http.post(`/licenses/unbind`);
|
||||
};
|
||||
|
||||
// agent
|
||||
export const loadBaseDir = () => {
|
||||
return http.get<string>(`/settings/basedir`);
|
||||
};
|
||||
|
||||
// core
|
||||
export const getSettingInfo = () => {
|
||||
return http.post<Setting.SettingInfo>(`/core/settings/search`);
|
||||
};
|
||||
@ -33,11 +37,11 @@ export const getSystemAvailable = () => {
|
||||
};
|
||||
|
||||
export const updateSetting = (param: Setting.SettingUpdate) => {
|
||||
return http.post(`/settings/update`, param);
|
||||
return http.post(`/core/settings/update`, param);
|
||||
};
|
||||
|
||||
export const updateMenu = (param: Setting.SettingUpdate) => {
|
||||
return http.post(`/settings/menu/update`, param);
|
||||
return http.post(`/core/settings/menu/update`, param);
|
||||
};
|
||||
|
||||
export const updateProxy = (params: Setting.ProxyUpdate) => {
|
||||
@ -46,60 +50,49 @@ export const updateProxy = (params: Setting.ProxyUpdate) => {
|
||||
request.proxyPasswd = Base64.encode(request.proxyPasswd);
|
||||
}
|
||||
request.proxyType = request.proxyType === 'close' ? '' : request.proxyType;
|
||||
return http.post(`/settings/proxy/update`, request);
|
||||
return http.post(`/core/settings/proxy/update`, request);
|
||||
};
|
||||
|
||||
export const updatePassword = (param: Setting.PasswordUpdate) => {
|
||||
return http.post(`/settings/password/update`, param);
|
||||
return http.post(`/core/settings/password/update`, param);
|
||||
};
|
||||
|
||||
export const loadInterfaceAddr = () => {
|
||||
return http.get(`/settings/interface`);
|
||||
return http.get(`/core/settings/interface`);
|
||||
};
|
||||
|
||||
export const updateBindInfo = (ipv6: string, bindAddress: string) => {
|
||||
return http.post(`/settings/bind/update`, { ipv6: ipv6, bindAddress: bindAddress });
|
||||
return http.post(`/core/settings/bind/update`, { ipv6: ipv6, bindAddress: bindAddress });
|
||||
};
|
||||
|
||||
export const updatePort = (param: Setting.PortUpdate) => {
|
||||
return http.post(`/settings/port/update`, param);
|
||||
return http.post(`/core/settings/port/update`, param);
|
||||
};
|
||||
|
||||
export const updateSSL = (param: Setting.SSLUpdate) => {
|
||||
return http.post(`/settings/ssl/update`, param);
|
||||
return http.post(`/core/settings/ssl/update`, param);
|
||||
};
|
||||
export const loadSSLInfo = () => {
|
||||
return http.get<Setting.SSLInfo>(`/settings/ssl/info`);
|
||||
return http.get<Setting.SSLInfo>(`/core/settings/ssl/info`);
|
||||
};
|
||||
export const downloadSSL = () => {
|
||||
return http.download<any>(`settings/ssl/download`);
|
||||
return http.download<any>(`/core/settings/ssl/download`);
|
||||
};
|
||||
|
||||
export const handleExpired = (param: Setting.PasswordUpdate) => {
|
||||
return http.post(`/settings/expired/handle`, param);
|
||||
};
|
||||
|
||||
export const loadTimeZone = () => {
|
||||
return http.get<Array<string>>(`/settings/time/option`);
|
||||
};
|
||||
export const syncTime = (ntpSite: string) => {
|
||||
return http.post<string>(`/settings/time/sync`, { ntpSite: ntpSite });
|
||||
return http.post(`/core/settings/expired/handle`, param);
|
||||
};
|
||||
|
||||
export const loadMFA = (param: Setting.MFARequest) => {
|
||||
return http.post<Setting.MFAInfo>(`/settings/mfa`, param);
|
||||
return http.post<Setting.MFAInfo>(`/core/settings/mfa`, param);
|
||||
};
|
||||
|
||||
export const loadDaemonJsonPath = () => {
|
||||
return http.get<string>(`/settings/daemonjson`, {});
|
||||
return http.get<string>(`/core/settings/daemonjson`, {});
|
||||
};
|
||||
|
||||
export const bindMFA = (param: Setting.MFABind) => {
|
||||
return http.post(`/settings/mfa/bind`, param);
|
||||
};
|
||||
|
||||
export const loadBaseDir = () => {
|
||||
return http.get<string>(`/settings/basedir`);
|
||||
return http.post(`/core/settings/mfa/bind`, param);
|
||||
};
|
||||
|
||||
// backup
|
||||
|
@ -932,6 +932,8 @@ const message = {
|
||||
globalFilter: 'Global Filter',
|
||||
enableMonitor: 'Enable',
|
||||
storeDays: 'Expiration days',
|
||||
defaultNetwork: 'Default Network Adapter',
|
||||
defaultNetworkHelper: 'Network adapter option displayed in the default monitoring and overview interface',
|
||||
cleanMonitor: 'Clearing monitoring records',
|
||||
|
||||
avgLoad: 'Average load',
|
||||
@ -1381,7 +1383,6 @@ const message = {
|
||||
proxyPasswdKeep: 'Remember Password',
|
||||
systemIPWarning: 'The server address is not currently set. Please set it in the control panel first!',
|
||||
systemIPWarning1: 'The current server address is set to {0}, and quick redirection is not possible!',
|
||||
defaultNetwork: 'Network Card',
|
||||
syncTime: 'Server Time',
|
||||
timeZone: 'Time Zone',
|
||||
timeZoneChangeHelper: 'Changing the time zone requires restarting the service. Do you want to continue?',
|
||||
|
@ -887,6 +887,8 @@ const message = {
|
||||
globalFilter: '全局過濾',
|
||||
enableMonitor: '監控狀態',
|
||||
storeDays: '保存天數',
|
||||
defaultNetwork: '預設網卡',
|
||||
defaultNetworkHelper: '預設監控和概覽介面顯示的網卡選項',
|
||||
cleanMonitor: '清空監控記錄',
|
||||
|
||||
avgLoad: '平均負載',
|
||||
@ -1307,7 +1309,6 @@ const message = {
|
||||
proxyPasswdKeep: '記住密碼',
|
||||
systemIPWarning: '當前未設置服務器地址,請先在面板設置中設置!',
|
||||
systemIPWarning1: '當前服務器地址設置為 {0},無法快速跳轉!',
|
||||
defaultNetwork: '默認網卡',
|
||||
changePassword: '密碼修改',
|
||||
oldPassword: '原密碼',
|
||||
newPassword: '新密碼',
|
||||
|
@ -888,6 +888,8 @@ const message = {
|
||||
globalFilter: '全局过滤',
|
||||
enableMonitor: '监控状态',
|
||||
storeDays: '保存天数',
|
||||
defaultNetwork: '默认网卡',
|
||||
defaultNetworkHelper: '默认监控和概览界面显示的网卡选项',
|
||||
cleanMonitor: '清空监控记录',
|
||||
|
||||
avgLoad: '平均负载',
|
||||
@ -1309,7 +1311,6 @@ const message = {
|
||||
proxyPasswdKeep: '记住密码',
|
||||
systemIPWarning: '当前未设置服务器地址,请先在面板设置中设置!',
|
||||
systemIPWarning1: '当前服务器地址设置为 {0},无法快速跳转!',
|
||||
defaultNetwork: '默认网卡',
|
||||
changePassword: '密码修改',
|
||||
oldPassword: '原密码',
|
||||
newPassword: '新密码',
|
||||
|
@ -136,7 +136,6 @@ const loadNodes = async () => {
|
||||
nodes.value = [];
|
||||
return;
|
||||
}
|
||||
console.log('dqwdqwd');
|
||||
nodes.value = res.data;
|
||||
return;
|
||||
}
|
||||
|
@ -47,7 +47,6 @@ const loadDataFromDB = async () => {
|
||||
const res = await getSettingInfo();
|
||||
document.title = res.data.panelName;
|
||||
globalStore.entrance = res.data.securityEntrance;
|
||||
globalStore.setDefaultNetwork(res.data.defaultNetwork);
|
||||
globalStore.setOpenMenuTabs(res.data.menuTabs === 'enable');
|
||||
};
|
||||
|
||||
|
@ -149,27 +149,24 @@
|
||||
<div :class="mobile ? 'flx-wrap' : 'flx-justify-between'">
|
||||
<div>
|
||||
<span class="title">{{ $t('monitor.network') }} IO:</span>
|
||||
<el-popover placement="bottom" :width="200" trigger="click">
|
||||
<el-select @change="search('network')" v-model="networkChoose">
|
||||
<template #prefix>{{ $t('monitor.networkCard') }}</template>
|
||||
<div v-for="item in netOptions" :key="item">
|
||||
<el-option
|
||||
v-if="item === 'all'"
|
||||
:label="$t('commons.table.all')"
|
||||
:value="item"
|
||||
/>
|
||||
<el-option v-else :label="item" :value="item" />
|
||||
</div>
|
||||
</el-select>
|
||||
<template #reference>
|
||||
<span class="networkOption" v-if="networkChoose === 'all'">
|
||||
{{ $t('commons.table.all') }}
|
||||
</span>
|
||||
<span v-else class="networkOption">
|
||||
{{ networkChoose }}
|
||||
</span>
|
||||
<el-dropdown max-height="300px" @command="onChangeNetwork">
|
||||
<span class="networkOption">
|
||||
{{ networkChoose === 'all' ? $t('commons.table.all') : networkChoose }}
|
||||
<el-icon>
|
||||
<arrow-down />
|
||||
</el-icon>
|
||||
</span>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<div v-for="item in netOptions" :key="item">
|
||||
<el-dropdown-item v-if="item === 'all'" command="all">
|
||||
{{ $t('commons.table.all') }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item v-else :command="item">{{ item }}</el-dropdown-item>
|
||||
</div>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-popover>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
<el-date-picker
|
||||
@change="search('network')"
|
||||
@ -249,6 +246,11 @@ const searchGlobal = () => {
|
||||
search('network');
|
||||
};
|
||||
|
||||
const onChangeNetwork = (command: string) => {
|
||||
networkChoose.value = command;
|
||||
search('network');
|
||||
};
|
||||
|
||||
const search = async (param: string) => {
|
||||
searchInfo.param = param;
|
||||
switch (param) {
|
||||
|
@ -21,7 +21,7 @@ import i18n from '@/lang';
|
||||
import { MsgSuccess } from '@/utils/message';
|
||||
import { FormInstance } from 'element-plus';
|
||||
import { Rules } from '@/global/form-rules';
|
||||
import { updateSetting } from '@/api/modules/setting';
|
||||
import { updateMonitorSetting } from '@/api/modules/host';
|
||||
|
||||
const emit = defineEmits<{ (e: 'search'): void }>();
|
||||
|
||||
@ -47,7 +47,7 @@ const onSave = async (formEl: FormInstance | undefined) => {
|
||||
formEl.validate(async (valid) => {
|
||||
if (!valid) return;
|
||||
loading.value = true;
|
||||
await updateSetting({ key: 'MonitorStoreDays', value: form.monitorStoreDays + '' })
|
||||
await updateMonitorSetting('MonitorStoreDays', form.monitorStoreDays + '')
|
||||
.then(() => {
|
||||
loading.value = false;
|
||||
handleClose();
|
||||
|
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<DrawerPro v-model="drawerVisible" :header="$t('setting.defaultNetwork')" :back="handleClose" size="small">
|
||||
<DrawerPro v-model="drawerVisible" :header="$t('monitor.defaultNetwork')" :back="handleClose" size="small">
|
||||
<el-form ref="formRef" label-position="top" :model="form" @submit.prevent v-loading="loading">
|
||||
<el-form-item :label="$t('setting.defaultNetwork')" prop="defaultNetwork" :rules="Rules.requiredSelect">
|
||||
<el-form-item :label="$t('monitor.defaultNetwork')" prop="defaultNetwork" :rules="Rules.requiredSelect">
|
||||
<el-select v-model="form.defaultNetwork" filterable>
|
||||
<el-option
|
||||
v-for="item in netOptions"
|
||||
@ -26,10 +26,9 @@
|
||||
import { reactive, ref } from 'vue';
|
||||
import i18n from '@/lang';
|
||||
import { MsgSuccess } from '@/utils/message';
|
||||
import { updateSetting } from '@/api/modules/setting';
|
||||
import { FormInstance } from 'element-plus';
|
||||
import { Rules } from '@/global/form-rules';
|
||||
import { getNetworkOptions } from '@/api/modules/host';
|
||||
import { getNetworkOptions, updateMonitorSetting } from '@/api/modules/host';
|
||||
import { GlobalStore } from '@/store';
|
||||
const globalStore = GlobalStore();
|
||||
|
||||
@ -63,7 +62,7 @@ const onSave = async (formEl: FormInstance | undefined) => {
|
||||
if (!formEl) return;
|
||||
formEl.validate(async (valid) => {
|
||||
if (!valid) return;
|
||||
await updateSetting({ key: 'DefaultNetwork', value: form.defaultNetwork })
|
||||
await updateMonitorSetting('DefaultNetwork', form.defaultNetwork)
|
||||
.then(async () => {
|
||||
globalStore.setDefaultNetwork(form.defaultNetwork);
|
||||
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
@ -34,6 +34,16 @@
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('monitor.defaultNetwork')">
|
||||
<el-input disabled v-model="form.defaultNetwork">
|
||||
<template #append>
|
||||
<el-button @click="onChangeNetwork" icon="Setting">
|
||||
{{ $t('commons.button.set') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
<span class="input-help">{{ $t('monitor.defaultNetworkHelper') }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="onClean()" icon="Delete">{{ $t('monitor.cleanMonitor') }}</el-button>
|
||||
</el-form-item>
|
||||
@ -45,17 +55,18 @@
|
||||
|
||||
<Interval ref="intervalRef" @search="search" />
|
||||
<StoreDays ref="daysRef" @search="search" />
|
||||
<Network ref="networkRef" @search="search()" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, reactive, ref } from 'vue';
|
||||
import { ElMessageBox, FormInstance } from 'element-plus';
|
||||
import { cleanMonitors } from '@/api/modules/host';
|
||||
import { getSettingInfo, getSystemAvailable, updateSetting } from '@/api/modules/setting';
|
||||
import { cleanMonitors, loadMonitorSetting, updateMonitorSetting } from '@/api/modules/host';
|
||||
import MonitorRouter from '@/views/host/monitor/index.vue';
|
||||
import Interval from '@/views/host/monitor/setting/interval/index.vue';
|
||||
import StoreDays from '@/views/host/monitor/setting/days/index.vue';
|
||||
import Network from '@/views/host/monitor/setting/default-network/index.vue';
|
||||
import i18n from '@/lang';
|
||||
import { MsgSuccess } from '@/utils/message';
|
||||
|
||||
@ -64,26 +75,25 @@ const form = reactive({
|
||||
monitorStatus: 'disable',
|
||||
monitorStoreDays: 30,
|
||||
monitorInterval: 1,
|
||||
defaultNetwork: '',
|
||||
});
|
||||
const panelFormRef = ref<FormInstance>();
|
||||
|
||||
const intervalRef = ref();
|
||||
const daysRef = ref();
|
||||
const networkRef = ref();
|
||||
|
||||
const search = async () => {
|
||||
const res = await getSettingInfo();
|
||||
const res = await loadMonitorSetting();
|
||||
form.monitorStatus = res.data.monitorStatus;
|
||||
form.monitorInterval = Number(res.data.monitorInterval);
|
||||
form.monitorStoreDays = Number(res.data.monitorStoreDays);
|
||||
form.defaultNetwork = res.data.defaultNetwork;
|
||||
};
|
||||
|
||||
const onSaveStatus = async () => {
|
||||
let param = {
|
||||
key: 'MonitorStatus',
|
||||
value: form.monitorStatus,
|
||||
};
|
||||
loading.value = true;
|
||||
await updateSetting(param)
|
||||
await updateMonitorSetting('MonitorStatus', form.monitorStatus)
|
||||
.then(() => {
|
||||
loading.value = false;
|
||||
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
||||
@ -99,6 +109,9 @@ const onChangeStoreDays = () => {
|
||||
const onChangeInterval = () => {
|
||||
intervalRef.value.acceptParams({ monitorInterval: form.monitorInterval });
|
||||
};
|
||||
const onChangeNetwork = () => {
|
||||
networkRef.value.acceptParams({ defaultNetwork: form.defaultNetwork });
|
||||
};
|
||||
|
||||
const onClean = async () => {
|
||||
ElMessageBox.confirm(i18n.global.t('commons.msg.clean'), i18n.global.t('monitor.cleanMonitor'), {
|
||||
@ -120,6 +133,5 @@ const onClean = async () => {
|
||||
|
||||
onMounted(() => {
|
||||
search();
|
||||
getSystemAvailable();
|
||||
});
|
||||
</script>
|
||||
|
@ -25,7 +25,7 @@ import i18n from '@/lang';
|
||||
import { MsgSuccess } from '@/utils/message';
|
||||
import { FormInstance } from 'element-plus';
|
||||
import { Rules, checkNumberRange } from '@/global/form-rules';
|
||||
import { updateSetting } from '@/api/modules/setting';
|
||||
import { updateMonitorSetting } from '@/api/modules/host';
|
||||
|
||||
const emit = defineEmits<{ (e: 'search'): void }>();
|
||||
|
||||
@ -51,7 +51,7 @@ const onSave = async (formEl: FormInstance | undefined) => {
|
||||
formEl.validate(async (valid) => {
|
||||
if (!valid) return;
|
||||
loading.value = true;
|
||||
await updateSetting({ key: 'MonitorInterval', value: form.monitorInterval + '' })
|
||||
await updateMonitorSetting('MonitorInterval', form.monitorInterval + '')
|
||||
.then(() => {
|
||||
loading.value = false;
|
||||
handleClose();
|
||||
|
@ -361,7 +361,6 @@ const loadDataFromDB = async () => {
|
||||
i18n.locale.value = res.data.language;
|
||||
i18n.warnHtmlMessage = false;
|
||||
globalStore.entrance = res.data.securityEntrance;
|
||||
globalStore.setDefaultNetwork(res.data.defaultNetwork);
|
||||
globalStore.setOpenMenuTabs(res.data.menuTabs === 'enable');
|
||||
globalStore.updateLanguage(res.data.language);
|
||||
globalStore.setThemeConfig({ ...themeConfig.value, theme: res.data.theme, panelName: res.data.panelName });
|
||||
|
@ -89,33 +89,6 @@
|
||||
</span>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="$t('setting.defaultNetwork')">
|
||||
<el-input disabled v-model="form.defaultNetworkVal">
|
||||
<template #append>
|
||||
<el-button v-show="!show" @click="onChangeNetwork" icon="Setting">
|
||||
{{ $t('commons.button.set') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="$t('setting.systemIP')" prop="systemIP">
|
||||
<el-input disabled v-if="form.systemIP" v-model="form.systemIP">
|
||||
<template #append>
|
||||
<el-button @click="onChangeSystemIP" icon="Setting">
|
||||
{{ $t('commons.button.set') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
<el-input disabled v-if="!form.systemIP" v-model="unset">
|
||||
<template #append>
|
||||
<el-button @click="onChangeSystemIP" icon="Setting">
|
||||
{{ $t('commons.button.set') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="$t('setting.proxy')" prop="proxyShow">
|
||||
<el-input disabled v-model="form.proxyShow">
|
||||
<template #append>
|
||||
@ -159,10 +132,8 @@
|
||||
<Password ref="passwordRef" />
|
||||
<UserName ref="userNameRef" />
|
||||
<PanelName ref="panelNameRef" @search="search()" />
|
||||
<SystemIP ref="systemIPRef" @search="search()" />
|
||||
<Proxy ref="proxyRef" @search="search()" />
|
||||
<Timeout ref="timeoutRef" @search="search()" />
|
||||
<Network ref="networkRef" @search="search()" />
|
||||
<HideMenu ref="hideMenuRef" @search="search()" />
|
||||
</div>
|
||||
</template>
|
||||
@ -179,9 +150,7 @@ import Password from '@/views/setting/panel/password/index.vue';
|
||||
import UserName from '@/views/setting/panel/username/index.vue';
|
||||
import Timeout from '@/views/setting/panel/timeout/index.vue';
|
||||
import PanelName from '@/views/setting/panel/name/index.vue';
|
||||
import SystemIP from '@/views/setting/panel/systemip/index.vue';
|
||||
import Proxy from '@/views/setting/panel/proxy/index.vue';
|
||||
import Network from '@/views/setting/panel/default-network/index.vue';
|
||||
import HideMenu from '@/views/setting/panel/hidemenu/index.vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { getXpackSetting, updateXpackSettingByKey } from '@/utils/xpack';
|
||||
@ -197,19 +166,12 @@ const { switchTheme } = useTheme();
|
||||
const form = reactive({
|
||||
userName: '',
|
||||
password: '',
|
||||
email: '',
|
||||
sessionTimeout: 0,
|
||||
localTime: '',
|
||||
timeZone: '',
|
||||
ntpSite: '',
|
||||
panelName: '',
|
||||
systemIP: '',
|
||||
theme: '',
|
||||
menuTabs: '',
|
||||
language: '',
|
||||
complexityVerification: '',
|
||||
defaultNetwork: '',
|
||||
defaultNetworkVal: '',
|
||||
developerMode: '',
|
||||
|
||||
proxyShow: '',
|
||||
@ -229,10 +191,8 @@ const show = ref();
|
||||
const userNameRef = ref();
|
||||
const passwordRef = ref();
|
||||
const panelNameRef = ref();
|
||||
const systemIPRef = ref();
|
||||
const proxyRef = ref();
|
||||
const timeoutRef = ref();
|
||||
const networkRef = ref();
|
||||
const hideMenuRef = ref();
|
||||
const unset = ref(i18n.t('setting.unSetting'));
|
||||
|
||||
@ -250,16 +210,10 @@ const search = async () => {
|
||||
form.userName = res.data.userName;
|
||||
form.password = '******';
|
||||
form.sessionTimeout = Number(res.data.sessionTimeout);
|
||||
form.localTime = res.data.localTime;
|
||||
form.timeZone = res.data.timeZone;
|
||||
form.ntpSite = res.data.ntpSite;
|
||||
form.panelName = res.data.panelName;
|
||||
form.systemIP = res.data.systemIP;
|
||||
form.menuTabs = res.data.menuTabs;
|
||||
form.language = res.data.language;
|
||||
form.complexityVerification = res.data.complexityVerification;
|
||||
form.defaultNetwork = res.data.defaultNetwork;
|
||||
form.defaultNetworkVal = res.data.defaultNetwork === 'all' ? i18n.t('commons.table.all') : res.data.defaultNetwork;
|
||||
form.proHideMenus = res.data.xpackHideMenu;
|
||||
form.hideMenuList = res.data.xpackHideMenu;
|
||||
form.developerMode = res.data.developerMode;
|
||||
@ -322,9 +276,6 @@ const onChangeTitle = () => {
|
||||
const onChangeTimeout = () => {
|
||||
timeoutRef.value.acceptParams({ sessionTimeout: form.sessionTimeout });
|
||||
};
|
||||
const onChangeSystemIP = () => {
|
||||
systemIPRef.value.acceptParams({ systemIP: form.systemIP });
|
||||
};
|
||||
const onChangeProxy = () => {
|
||||
proxyRef.value.acceptParams({
|
||||
url: form.proxyUrl,
|
||||
@ -335,9 +286,6 @@ const onChangeProxy = () => {
|
||||
passwdKeep: form.proxyPasswdKeep,
|
||||
});
|
||||
};
|
||||
const onChangeNetwork = () => {
|
||||
networkRef.value.acceptParams({ defaultNetwork: form.defaultNetwork });
|
||||
};
|
||||
|
||||
const onChangeHideMenus = () => {
|
||||
hideMenuRef.value.acceptParams({ menuList: form.hideMenuList });
|
||||
|
Loading…
Reference in New Issue
Block a user