mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-23 18:49:21 +08:00
fix: 修改监控相关接口 (#4427)
This commit is contained in:
parent
e69fd3b388
commit
4f2a340212
@ -15,6 +15,13 @@ import (
|
||||
"github.com/shirou/gopsutil/v3/net"
|
||||
)
|
||||
|
||||
// @Tags Monitor
|
||||
// @Summary Load monitor datas
|
||||
// @Description 获取监控数据
|
||||
// @Param request body dto.MonitorSearch true "request"
|
||||
// @Success 200
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /hosts/monitor/search [post]
|
||||
func (b *BaseApi) LoadMonitor(c *gin.Context) {
|
||||
var req dto.MonitorSearch
|
||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||
@ -80,6 +87,30 @@ func (b *BaseApi) LoadMonitor(c *gin.Context) {
|
||||
helper.SuccessWithData(c, backdatas)
|
||||
}
|
||||
|
||||
// @Tags Monitor
|
||||
// @Summary Clean monitor datas
|
||||
// @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.DB.Exec("DELETE FROM monitor_bases").Error; err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
}
|
||||
if err := global.DB.Exec("DELETE FROM monitor_ios").Error; err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
}
|
||||
if err := global.DB.Exec("DELETE FROM monitor_networks").Error; err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
}
|
||||
|
||||
helper.SuccessWithData(c, nil)
|
||||
}
|
||||
|
||||
func (b *BaseApi) GetNetworkOptions(c *gin.Context) {
|
||||
netStat, _ := net.IOCounters(true)
|
||||
var options []string
|
||||
|
@ -60,6 +60,28 @@ func (b *BaseApi) UpdateSetting(c *gin.Context) {
|
||||
helper.SuccessWithData(c, nil)
|
||||
}
|
||||
|
||||
// @Tags System Setting
|
||||
// @Summary Update system setting
|
||||
// @Description 更新系统菜单配置
|
||||
// @Accept json
|
||||
// @Param request body dto.SettingUpdate true "request"
|
||||
// @Success 200
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /settings/menu/update [post]
|
||||
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改系统高级功能菜单隐藏设置","formatEN":"modify system advanced function menu hidden settings."}
|
||||
func (b *BaseApi) UpdateMenu(c *gin.Context) {
|
||||
var req dto.SettingUpdate
|
||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if err := settingService.Update(req.Key, req.Value); err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
}
|
||||
helper.SuccessWithData(c, nil)
|
||||
}
|
||||
|
||||
// @Tags System Setting
|
||||
// @Summary Update system password
|
||||
// @Description 更新系统登录密码
|
||||
@ -227,30 +249,6 @@ func (b *BaseApi) LoadBaseDir(c *gin.Context) {
|
||||
helper.SuccessWithData(c, global.CONF.System.DataDir)
|
||||
}
|
||||
|
||||
// @Tags System Setting
|
||||
// @Summary Clean monitor datas
|
||||
// @Description 清空监控数据
|
||||
// @Success 200
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /settings/monitor/clean [post]
|
||||
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"清空监控数据","formatEN":"clean monitor datas"}
|
||||
func (b *BaseApi) CleanMonitor(c *gin.Context) {
|
||||
if err := global.DB.Exec("DELETE FROM monitor_bases").Error; err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
}
|
||||
if err := global.DB.Exec("DELETE FROM monitor_ios").Error; err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
}
|
||||
if err := global.DB.Exec("DELETE FROM monitor_networks").Error; err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
}
|
||||
|
||||
helper.SuccessWithData(c, nil)
|
||||
}
|
||||
|
||||
// @Tags System Setting
|
||||
// @Summary Load mfa info
|
||||
// @Description 获取 mfa 信息
|
||||
|
@ -6,7 +6,6 @@ func commonGroups() []CommonRouter {
|
||||
&DashboardRouter{},
|
||||
&HostRouter{},
|
||||
&ContainerRouter{},
|
||||
&MonitorRouter{},
|
||||
&LogRouter{},
|
||||
&FileRouter{},
|
||||
&ToolboxRouter{},
|
||||
|
@ -35,6 +35,11 @@ func (s *HostRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
hostRouter.POST("/firewall/update/addr", baseApi.UpdateAddrRule)
|
||||
hostRouter.POST("/firewall/update/description", baseApi.UpdateFirewallDescription)
|
||||
|
||||
hostRouter.POST("/monitor/search", baseApi.LoadMonitor)
|
||||
hostRouter.POST("/monitor/clean", baseApi.CleanMonitor)
|
||||
hostRouter.GET("/monitor/netoptions", baseApi.GetNetworkOptions)
|
||||
hostRouter.GET("/monitor/iooptions", baseApi.GetIOOptions)
|
||||
|
||||
hostRouter.GET("/ssh/conf", baseApi.LoadSSHConf)
|
||||
hostRouter.POST("/ssh/search", baseApi.GetSSHInfo)
|
||||
hostRouter.POST("/ssh/update", baseApi.UpdateSSH)
|
||||
|
@ -1,23 +0,0 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
v1 "github.com/1Panel-dev/1Panel/backend/app/api/v1"
|
||||
"github.com/1Panel-dev/1Panel/backend/middleware"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type MonitorRouter struct{}
|
||||
|
||||
func (s *MonitorRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
monitorRouter := Router.Group("monitors").
|
||||
Use(middleware.JwtAuth()).
|
||||
Use(middleware.SessionAuth()).
|
||||
Use(middleware.PasswordExpired())
|
||||
baseApi := v1.ApiGroupApp.BaseApi
|
||||
{
|
||||
monitorRouter.POST("/search", baseApi.LoadMonitor)
|
||||
monitorRouter.GET("/netoptions", baseApi.GetNetworkOptions)
|
||||
monitorRouter.GET("/iooptions", baseApi.GetIOOptions)
|
||||
}
|
||||
}
|
@ -23,13 +23,13 @@ func (s *SettingRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
settingRouter.GET("/search/available", baseApi.GetSystemAvailable)
|
||||
settingRouter.POST("/update", baseApi.UpdateSetting)
|
||||
settingRouter.GET("/interface", baseApi.LoadInterfaceAddr)
|
||||
settingRouter.POST("/menu/update", baseApi.UpdateMenu)
|
||||
settingRouter.POST("/bind/update", baseApi.UpdateBindInfo)
|
||||
settingRouter.POST("/port/update", baseApi.UpdatePort)
|
||||
settingRouter.POST("/ssl/update", baseApi.UpdateSSL)
|
||||
settingRouter.GET("/ssl/info", baseApi.LoadFromCert)
|
||||
settingRouter.POST("/ssl/download", baseApi.DownloadSSL)
|
||||
settingRouter.POST("/password/update", baseApi.UpdatePassword)
|
||||
settingRouter.POST("/monitor/clean", baseApi.CleanMonitor)
|
||||
settingRouter.POST("/mfa", baseApi.LoadMFA)
|
||||
settingRouter.POST("/mfa/bind", baseApi.MFABind)
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Package docs GENERATED BY SWAG; DO NOT EDIT
|
||||
// This file was generated by swaggo/swag
|
||||
// Code generated by swaggo/swag. DO NOT EDIT.
|
||||
|
||||
package docs
|
||||
|
||||
import "github.com/swaggo/swag"
|
||||
@ -8097,6 +8097,62 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/hosts/monitor/clean": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "清空监控数据",
|
||||
"tags": [
|
||||
"Monitor"
|
||||
],
|
||||
"summary": "Clean monitor datas",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
"BeforeFunctions": [],
|
||||
"bodyKeys": [],
|
||||
"formatEN": "clean monitor datas",
|
||||
"formatZH": "清空监控数据",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"/hosts/monitor/search": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "获取监控数据",
|
||||
"tags": [
|
||||
"Monitor"
|
||||
],
|
||||
"summary": "Load monitor datas",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "request",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.MonitorSearch"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/hosts/search": {
|
||||
"post": {
|
||||
"security": [
|
||||
@ -9923,6 +9979,46 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/menu/update": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "更新系统菜单配置",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"System Setting"
|
||||
],
|
||||
"summary": "Update system setting",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "request",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.SettingUpdate"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
"BeforeFunctions": [],
|
||||
"bodyKeys": [],
|
||||
"formatEN": "modify system advanced function menu hidden settings.",
|
||||
"formatZH": "修改系统高级功能菜单隐藏设置",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/mfa": {
|
||||
"post": {
|
||||
"security": [
|
||||
@ -9999,32 +10095,6 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/monitor/clean": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "清空监控数据",
|
||||
"tags": [
|
||||
"System Setting"
|
||||
],
|
||||
"summary": "Clean monitor datas",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
"BeforeFunctions": [],
|
||||
"bodyKeys": [],
|
||||
"formatEN": "clean monitor datas",
|
||||
"formatZH": "清空监控数据",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/password/update": {
|
||||
"post": {
|
||||
"security": [
|
||||
@ -14814,6 +14884,9 @@ const docTemplate = `{
|
||||
"backupAccounts": {
|
||||
"type": "string"
|
||||
},
|
||||
"command": {
|
||||
"type": "string"
|
||||
},
|
||||
"containerName": {
|
||||
"type": "string"
|
||||
},
|
||||
@ -14885,6 +14958,9 @@ const docTemplate = `{
|
||||
"backupAccounts": {
|
||||
"type": "string"
|
||||
},
|
||||
"command": {
|
||||
"type": "string"
|
||||
},
|
||||
"containerName": {
|
||||
"type": "string"
|
||||
},
|
||||
@ -16208,6 +16284,34 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.MonitorSearch": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"param"
|
||||
],
|
||||
"properties": {
|
||||
"endTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"info": {
|
||||
"type": "string"
|
||||
},
|
||||
"param": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"all",
|
||||
"cpu",
|
||||
"memory",
|
||||
"load",
|
||||
"io",
|
||||
"network"
|
||||
]
|
||||
},
|
||||
"startTime": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.MysqlDBCreate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
@ -17728,6 +17832,9 @@ const docTemplate = `{
|
||||
},
|
||||
"weChatVars": {
|
||||
"type": "string"
|
||||
},
|
||||
"xpackHideMenu": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -17974,6 +18081,9 @@ const docTemplate = `{
|
||||
},
|
||||
"sourceDir": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -8090,6 +8090,62 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/hosts/monitor/clean": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "清空监控数据",
|
||||
"tags": [
|
||||
"Monitor"
|
||||
],
|
||||
"summary": "Clean monitor datas",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
"BeforeFunctions": [],
|
||||
"bodyKeys": [],
|
||||
"formatEN": "clean monitor datas",
|
||||
"formatZH": "清空监控数据",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"/hosts/monitor/search": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "获取监控数据",
|
||||
"tags": [
|
||||
"Monitor"
|
||||
],
|
||||
"summary": "Load monitor datas",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "request",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.MonitorSearch"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/hosts/search": {
|
||||
"post": {
|
||||
"security": [
|
||||
@ -9916,6 +9972,46 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/menu/update": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "更新系统菜单配置",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"System Setting"
|
||||
],
|
||||
"summary": "Update system setting",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "request",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.SettingUpdate"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
"BeforeFunctions": [],
|
||||
"bodyKeys": [],
|
||||
"formatEN": "modify system advanced function menu hidden settings.",
|
||||
"formatZH": "修改系统高级功能菜单隐藏设置",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/mfa": {
|
||||
"post": {
|
||||
"security": [
|
||||
@ -9992,32 +10088,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/monitor/clean": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "清空监控数据",
|
||||
"tags": [
|
||||
"System Setting"
|
||||
],
|
||||
"summary": "Clean monitor datas",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
"BeforeFunctions": [],
|
||||
"bodyKeys": [],
|
||||
"formatEN": "clean monitor datas",
|
||||
"formatZH": "清空监控数据",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/password/update": {
|
||||
"post": {
|
||||
"security": [
|
||||
@ -14807,6 +14877,9 @@
|
||||
"backupAccounts": {
|
||||
"type": "string"
|
||||
},
|
||||
"command": {
|
||||
"type": "string"
|
||||
},
|
||||
"containerName": {
|
||||
"type": "string"
|
||||
},
|
||||
@ -14878,6 +14951,9 @@
|
||||
"backupAccounts": {
|
||||
"type": "string"
|
||||
},
|
||||
"command": {
|
||||
"type": "string"
|
||||
},
|
||||
"containerName": {
|
||||
"type": "string"
|
||||
},
|
||||
@ -16201,6 +16277,34 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.MonitorSearch": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"param"
|
||||
],
|
||||
"properties": {
|
||||
"endTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"info": {
|
||||
"type": "string"
|
||||
},
|
||||
"param": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"all",
|
||||
"cpu",
|
||||
"memory",
|
||||
"load",
|
||||
"io",
|
||||
"network"
|
||||
]
|
||||
},
|
||||
"startTime": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.MysqlDBCreate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
@ -17721,6 +17825,9 @@
|
||||
},
|
||||
"weChatVars": {
|
||||
"type": "string"
|
||||
},
|
||||
"xpackHideMenu": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -17967,6 +18074,9 @@
|
||||
},
|
||||
"sourceDir": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -584,6 +584,8 @@ definitions:
|
||||
type: string
|
||||
backupAccounts:
|
||||
type: string
|
||||
command:
|
||||
type: string
|
||||
containerName:
|
||||
type: string
|
||||
dbName:
|
||||
@ -632,6 +634,8 @@ definitions:
|
||||
type: string
|
||||
backupAccounts:
|
||||
type: string
|
||||
command:
|
||||
type: string
|
||||
containerName:
|
||||
type: string
|
||||
dbName:
|
||||
@ -1528,6 +1532,26 @@ definitions:
|
||||
- interval
|
||||
- secret
|
||||
type: object
|
||||
dto.MonitorSearch:
|
||||
properties:
|
||||
endTime:
|
||||
type: string
|
||||
info:
|
||||
type: string
|
||||
param:
|
||||
enum:
|
||||
- all
|
||||
- cpu
|
||||
- memory
|
||||
- load
|
||||
- io
|
||||
- network
|
||||
type: string
|
||||
startTime:
|
||||
type: string
|
||||
required:
|
||||
- param
|
||||
type: object
|
||||
dto.MysqlDBCreate:
|
||||
properties:
|
||||
database:
|
||||
@ -2556,6 +2580,8 @@ definitions:
|
||||
type: string
|
||||
weChatVars:
|
||||
type: string
|
||||
xpackHideMenu:
|
||||
type: string
|
||||
type: object
|
||||
dto.SettingUpdate:
|
||||
properties:
|
||||
@ -2717,6 +2743,8 @@ definitions:
|
||||
type: string
|
||||
sourceDir:
|
||||
type: string
|
||||
type:
|
||||
type: string
|
||||
type: object
|
||||
files.FileInfo:
|
||||
properties:
|
||||
@ -10098,6 +10126,41 @@ paths:
|
||||
summary: Create group
|
||||
tags:
|
||||
- Firewall
|
||||
/hosts/monitor/clean:
|
||||
post:
|
||||
description: 清空监控数据
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
summary: Clean monitor datas
|
||||
tags:
|
||||
- Monitor
|
||||
x-panel-log:
|
||||
BeforeFunctions: []
|
||||
bodyKeys: []
|
||||
formatEN: clean monitor datas
|
||||
formatZH: 清空监控数据
|
||||
paramKeys: []
|
||||
/hosts/monitor/search:
|
||||
post:
|
||||
description: 获取监控数据
|
||||
parameters:
|
||||
- description: request
|
||||
in: body
|
||||
name: request
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/dto.MonitorSearch'
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
summary: Load monitor datas
|
||||
tags:
|
||||
- Monitor
|
||||
/hosts/search:
|
||||
post:
|
||||
consumes:
|
||||
@ -11244,6 +11307,32 @@ paths:
|
||||
summary: Load system address
|
||||
tags:
|
||||
- System Setting
|
||||
/settings/menu/update:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 更新系统菜单配置
|
||||
parameters:
|
||||
- description: request
|
||||
in: body
|
||||
name: request
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/dto.SettingUpdate'
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
summary: Update system setting
|
||||
tags:
|
||||
- System Setting
|
||||
x-panel-log:
|
||||
BeforeFunctions: []
|
||||
bodyKeys: []
|
||||
formatEN: modify system advanced function menu hidden settings.
|
||||
formatZH: 修改系统高级功能菜单隐藏设置
|
||||
paramKeys: []
|
||||
/settings/mfa:
|
||||
post:
|
||||
consumes:
|
||||
@ -11292,23 +11381,6 @@ paths:
|
||||
formatEN: bind mfa
|
||||
formatZH: mfa 绑定
|
||||
paramKeys: []
|
||||
/settings/monitor/clean:
|
||||
post:
|
||||
description: 清空监控数据
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
summary: Clean monitor datas
|
||||
tags:
|
||||
- System Setting
|
||||
x-panel-log:
|
||||
BeforeFunctions: []
|
||||
bodyKeys: []
|
||||
formatEN: clean monitor datas
|
||||
formatZH: 清空监控数据
|
||||
paramKeys: []
|
||||
/settings/password/update:
|
||||
post:
|
||||
consumes:
|
||||
|
@ -116,6 +116,18 @@ export namespace Host {
|
||||
rules: Array<RulePort>;
|
||||
}
|
||||
|
||||
export interface MonitorData {
|
||||
param: string;
|
||||
date: Array<Date>;
|
||||
value: Array<any>;
|
||||
}
|
||||
export interface MonitorSearch {
|
||||
param: string;
|
||||
info: string;
|
||||
startTime: Date;
|
||||
endTime: Date;
|
||||
}
|
||||
|
||||
export interface SSHInfo {
|
||||
autoStart: boolean;
|
||||
status: string;
|
||||
|
@ -1,13 +0,0 @@
|
||||
export namespace Monitor {
|
||||
export interface MonitorData {
|
||||
param: string;
|
||||
date: Array<Date>;
|
||||
value: Array<any>;
|
||||
}
|
||||
export interface MonitorSearch {
|
||||
param: string;
|
||||
info: string;
|
||||
startTime: Date;
|
||||
endTime: Date;
|
||||
}
|
||||
}
|
@ -101,6 +101,20 @@ export const batchOperateRule = (params: Host.BatchRule) => {
|
||||
return http.post(`/hosts/firewall/batch`, params, TimeoutEnum.T_60S);
|
||||
};
|
||||
|
||||
// monitors
|
||||
export const loadMonitor = (param: Host.MonitorSearch) => {
|
||||
return http.post<Array<Host.MonitorData>>(`/hosts/monitor/search`, param);
|
||||
};
|
||||
export const getNetworkOptions = () => {
|
||||
return http.get<Array<string>>(`/hosts/monitor/netoptions`);
|
||||
};
|
||||
export const getIOOptions = () => {
|
||||
return http.get<Array<string>>(`/hosts/monitor/iooptions`);
|
||||
};
|
||||
export const cleanMonitors = () => {
|
||||
return http.post(`/hosts/monitor/clean`, {});
|
||||
};
|
||||
|
||||
// ssh
|
||||
export const getSSHInfo = () => {
|
||||
return http.post<Host.SSHInfo>(`/hosts/ssh/search`);
|
||||
|
@ -1,14 +0,0 @@
|
||||
import http from '@/api';
|
||||
import { Monitor } from '../interface/monitor';
|
||||
|
||||
export const loadMonitor = (param: Monitor.MonitorSearch) => {
|
||||
return http.post<Array<Monitor.MonitorData>>(`/monitors/search`, param);
|
||||
};
|
||||
|
||||
export const getNetworkOptions = () => {
|
||||
return http.get<Array<string>>(`/monitors/netoptions`);
|
||||
};
|
||||
|
||||
export const getIOOptions = () => {
|
||||
return http.get<Array<string>>(`/monitors/iooptions`);
|
||||
};
|
@ -29,6 +29,10 @@ export const updateSetting = (param: Setting.SettingUpdate) => {
|
||||
return http.post(`/settings/update`, param);
|
||||
};
|
||||
|
||||
export const updateMenu = (param: Setting.SettingUpdate) => {
|
||||
return http.post(`/settings/menu/update`, param);
|
||||
};
|
||||
|
||||
export const updatePassword = (param: Setting.PasswordUpdate) => {
|
||||
return http.post(`/settings/password/update`, param);
|
||||
};
|
||||
@ -66,10 +70,6 @@ export const syncTime = (ntpSite: string) => {
|
||||
return http.post<string>(`/settings/time/sync`, { ntpSite: ntpSite });
|
||||
};
|
||||
|
||||
export const cleanMonitors = () => {
|
||||
return http.post(`/settings/monitor/clean`, {});
|
||||
};
|
||||
|
||||
export const loadMFA = (param: Setting.MFARequest) => {
|
||||
return http.post<Setting.MFAInfo>(`/settings/mfa`, param);
|
||||
};
|
||||
|
@ -24,7 +24,7 @@ const settingRouter = {
|
||||
hidden: true,
|
||||
meta: {
|
||||
requiresAuth: true,
|
||||
activeMenu: 'Setting',
|
||||
activeMenu: '/settings',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -250,7 +250,7 @@ import { Dashboard } from '@/api/interface/dashboard';
|
||||
import { dateFormatForSecond, computeSize } from '@/utils/util';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { loadBaseInfo, loadCurrentInfo } from '@/api/modules/dashboard';
|
||||
import { getIOOptions, getNetworkOptions } from '@/api/modules/monitor';
|
||||
import { getIOOptions, getNetworkOptions } from '@/api/modules/host';
|
||||
import { getSettingInfo, loadUpgradeInfo } from '@/api/modules/setting';
|
||||
import { GlobalStore } from '@/store';
|
||||
const router = useRouter();
|
||||
|
@ -202,13 +202,13 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed } from 'vue';
|
||||
import { loadMonitor, getNetworkOptions } from '@/api/modules/monitor';
|
||||
import { Monitor } from '@/api/interface/monitor';
|
||||
import { loadMonitor, getNetworkOptions } from '@/api/modules/host';
|
||||
import { computeSizeFromKBs, dateFormatWithoutYear } from '@/utils/util';
|
||||
import i18n from '@/lang';
|
||||
import MonitorRouter from '@/views/host/monitor/index.vue';
|
||||
import { GlobalStore } from '@/store';
|
||||
import { shortcuts } from '@/utils/shortcuts';
|
||||
import { Host } from '@/api/interface/host';
|
||||
|
||||
const globalStore = GlobalStore();
|
||||
|
||||
@ -229,7 +229,7 @@ const netOptions = ref();
|
||||
const chartsOption = ref({ loadLoadChart: null, loadCPUChart: null, loadMemoryChart: null, loadNetworkChart: null });
|
||||
|
||||
const searchTime = ref();
|
||||
const searchInfo = reactive<Monitor.MonitorSearch>({
|
||||
const searchInfo = reactive<Host.MonitorSearch>({
|
||||
param: '',
|
||||
info: '',
|
||||
startTime: new Date(new Date().setHours(0, 0, 0, 0)),
|
||||
@ -372,7 +372,7 @@ const loadNetworkOptions = async () => {
|
||||
search('all');
|
||||
};
|
||||
|
||||
function initLoadCharts(item: Monitor.MonitorData) {
|
||||
function initLoadCharts(item: Host.MonitorData) {
|
||||
let itemLoadDate = item.date.length === 0 ? loadEmptyDate(timeRangeLoad.value) : item.date;
|
||||
let loadDate = itemLoadDate.map(function (item: any) {
|
||||
return dateFormatWithoutYear(item);
|
||||
@ -428,7 +428,7 @@ function initLoadCharts(item: Monitor.MonitorData) {
|
||||
};
|
||||
}
|
||||
|
||||
function initIOCharts(item: Monitor.MonitorData) {
|
||||
function initIOCharts(item: Host.MonitorData) {
|
||||
let itemIODate = item.date?.length === 0 ? loadEmptyDate(timeRangeIO.value) : item.date;
|
||||
let ioDate = itemIODate.map(function (item: any) {
|
||||
return dateFormatWithoutYear(item);
|
||||
|
@ -15,7 +15,7 @@
|
||||
<el-col :span="22">
|
||||
<el-form-item
|
||||
:label="$t('monitor.storeDays')"
|
||||
:rules="[Rules.integerNumber, checkNumberRange(1, 365)]"
|
||||
:rules="[Rules.integerNumber]"
|
||||
prop="monitorStoreDays"
|
||||
>
|
||||
<el-input clearable v-model.number="form.monitorStoreDays" />
|
||||
@ -39,7 +39,7 @@ import { reactive, ref } from 'vue';
|
||||
import i18n from '@/lang';
|
||||
import { MsgSuccess } from '@/utils/message';
|
||||
import { FormInstance } from 'element-plus';
|
||||
import { Rules, checkNumberRange } from '@/global/form-rules';
|
||||
import { Rules } from '@/global/form-rules';
|
||||
import { updateSetting } from '@/api/modules/setting';
|
||||
import DrawerHeader from '@/components/drawer-header/index.vue';
|
||||
|
||||
|
@ -51,7 +51,8 @@
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, reactive, ref } from 'vue';
|
||||
import { ElMessageBox, FormInstance } from 'element-plus';
|
||||
import { cleanMonitors, getSettingInfo, getSystemAvailable, updateSetting } from '@/api/modules/setting';
|
||||
import { cleanMonitors } from '@/api/modules/host';
|
||||
import { getSettingInfo, getSystemAvailable, updateSetting } from '@/api/modules/setting';
|
||||
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';
|
||||
@ -105,7 +106,15 @@ const onClean = async () => {
|
||||
cancelButtonText: i18n.global.t('commons.button.cancel'),
|
||||
type: 'info',
|
||||
}).then(async () => {
|
||||
await cleanMonitors();
|
||||
loading.value = true;
|
||||
await cleanMonitors()
|
||||
.then(() => {
|
||||
loading.value = false;
|
||||
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
||||
})
|
||||
.catch(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -43,7 +43,7 @@ import { updateSetting } from '@/api/modules/setting';
|
||||
import { FormInstance } from 'element-plus';
|
||||
import { Rules } from '@/global/form-rules';
|
||||
import DrawerHeader from '@/components/drawer-header/index.vue';
|
||||
import { getNetworkOptions } from '@/api/modules/monitor';
|
||||
import { getNetworkOptions } from '@/api/modules/host';
|
||||
import { GlobalStore } from '@/store';
|
||||
const globalStore = GlobalStore();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user