fix: 修改监控相关接口 (#4427)

This commit is contained in:
ssongliu 2024-04-08 16:52:07 +08:00 committed by GitHub
parent e69fd3b388
commit 4f2a340212
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 473 additions and 163 deletions

View File

@ -15,6 +15,13 @@ import (
"github.com/shirou/gopsutil/v3/net" "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) { func (b *BaseApi) LoadMonitor(c *gin.Context) {
var req dto.MonitorSearch var req dto.MonitorSearch
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
@ -80,6 +87,30 @@ func (b *BaseApi) LoadMonitor(c *gin.Context) {
helper.SuccessWithData(c, backdatas) 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) { func (b *BaseApi) GetNetworkOptions(c *gin.Context) {
netStat, _ := net.IOCounters(true) netStat, _ := net.IOCounters(true)
var options []string var options []string

View File

@ -60,6 +60,28 @@ func (b *BaseApi) UpdateSetting(c *gin.Context) {
helper.SuccessWithData(c, nil) 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 // @Tags System Setting
// @Summary Update system password // @Summary Update system password
// @Description 更新系统登录密码 // @Description 更新系统登录密码
@ -227,30 +249,6 @@ func (b *BaseApi) LoadBaseDir(c *gin.Context) {
helper.SuccessWithData(c, global.CONF.System.DataDir) 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 // @Tags System Setting
// @Summary Load mfa info // @Summary Load mfa info
// @Description 获取 mfa 信息 // @Description 获取 mfa 信息

View File

@ -6,7 +6,6 @@ func commonGroups() []CommonRouter {
&DashboardRouter{}, &DashboardRouter{},
&HostRouter{}, &HostRouter{},
&ContainerRouter{}, &ContainerRouter{},
&MonitorRouter{},
&LogRouter{}, &LogRouter{},
&FileRouter{}, &FileRouter{},
&ToolboxRouter{}, &ToolboxRouter{},

View File

@ -35,6 +35,11 @@ func (s *HostRouter) InitRouter(Router *gin.RouterGroup) {
hostRouter.POST("/firewall/update/addr", baseApi.UpdateAddrRule) hostRouter.POST("/firewall/update/addr", baseApi.UpdateAddrRule)
hostRouter.POST("/firewall/update/description", baseApi.UpdateFirewallDescription) 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.GET("/ssh/conf", baseApi.LoadSSHConf)
hostRouter.POST("/ssh/search", baseApi.GetSSHInfo) hostRouter.POST("/ssh/search", baseApi.GetSSHInfo)
hostRouter.POST("/ssh/update", baseApi.UpdateSSH) hostRouter.POST("/ssh/update", baseApi.UpdateSSH)

View File

@ -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)
}
}

View File

@ -23,13 +23,13 @@ func (s *SettingRouter) InitRouter(Router *gin.RouterGroup) {
settingRouter.GET("/search/available", baseApi.GetSystemAvailable) settingRouter.GET("/search/available", baseApi.GetSystemAvailable)
settingRouter.POST("/update", baseApi.UpdateSetting) settingRouter.POST("/update", baseApi.UpdateSetting)
settingRouter.GET("/interface", baseApi.LoadInterfaceAddr) settingRouter.GET("/interface", baseApi.LoadInterfaceAddr)
settingRouter.POST("/menu/update", baseApi.UpdateMenu)
settingRouter.POST("/bind/update", baseApi.UpdateBindInfo) settingRouter.POST("/bind/update", baseApi.UpdateBindInfo)
settingRouter.POST("/port/update", baseApi.UpdatePort) settingRouter.POST("/port/update", baseApi.UpdatePort)
settingRouter.POST("/ssl/update", baseApi.UpdateSSL) settingRouter.POST("/ssl/update", baseApi.UpdateSSL)
settingRouter.GET("/ssl/info", baseApi.LoadFromCert) settingRouter.GET("/ssl/info", baseApi.LoadFromCert)
settingRouter.POST("/ssl/download", baseApi.DownloadSSL) settingRouter.POST("/ssl/download", baseApi.DownloadSSL)
settingRouter.POST("/password/update", baseApi.UpdatePassword) settingRouter.POST("/password/update", baseApi.UpdatePassword)
settingRouter.POST("/monitor/clean", baseApi.CleanMonitor)
settingRouter.POST("/mfa", baseApi.LoadMFA) settingRouter.POST("/mfa", baseApi.LoadMFA)
settingRouter.POST("/mfa/bind", baseApi.MFABind) settingRouter.POST("/mfa/bind", baseApi.MFABind)

View File

@ -1,5 +1,5 @@
// Package docs GENERATED BY SWAG; DO NOT EDIT // Code generated by swaggo/swag. DO NOT EDIT.
// This file was generated by swaggo/swag
package docs package docs
import "github.com/swaggo/swag" 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": { "/hosts/search": {
"post": { "post": {
"security": [ "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": { "/settings/mfa": {
"post": { "post": {
"security": [ "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": { "/settings/password/update": {
"post": { "post": {
"security": [ "security": [
@ -14814,6 +14884,9 @@ const docTemplate = `{
"backupAccounts": { "backupAccounts": {
"type": "string" "type": "string"
}, },
"command": {
"type": "string"
},
"containerName": { "containerName": {
"type": "string" "type": "string"
}, },
@ -14885,6 +14958,9 @@ const docTemplate = `{
"backupAccounts": { "backupAccounts": {
"type": "string" "type": "string"
}, },
"command": {
"type": "string"
},
"containerName": { "containerName": {
"type": "string" "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": { "dto.MysqlDBCreate": {
"type": "object", "type": "object",
"required": [ "required": [
@ -17728,6 +17832,9 @@ const docTemplate = `{
}, },
"weChatVars": { "weChatVars": {
"type": "string" "type": "string"
},
"xpackHideMenu": {
"type": "string"
} }
} }
}, },
@ -17974,6 +18081,9 @@ const docTemplate = `{
}, },
"sourceDir": { "sourceDir": {
"type": "string" "type": "string"
},
"type": {
"type": "string"
} }
} }
}, },

View File

@ -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": { "/hosts/search": {
"post": { "post": {
"security": [ "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": { "/settings/mfa": {
"post": { "post": {
"security": [ "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": { "/settings/password/update": {
"post": { "post": {
"security": [ "security": [
@ -14807,6 +14877,9 @@
"backupAccounts": { "backupAccounts": {
"type": "string" "type": "string"
}, },
"command": {
"type": "string"
},
"containerName": { "containerName": {
"type": "string" "type": "string"
}, },
@ -14878,6 +14951,9 @@
"backupAccounts": { "backupAccounts": {
"type": "string" "type": "string"
}, },
"command": {
"type": "string"
},
"containerName": { "containerName": {
"type": "string" "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": { "dto.MysqlDBCreate": {
"type": "object", "type": "object",
"required": [ "required": [
@ -17721,6 +17825,9 @@
}, },
"weChatVars": { "weChatVars": {
"type": "string" "type": "string"
},
"xpackHideMenu": {
"type": "string"
} }
} }
}, },
@ -17967,6 +18074,9 @@
}, },
"sourceDir": { "sourceDir": {
"type": "string" "type": "string"
},
"type": {
"type": "string"
} }
} }
}, },

View File

@ -584,6 +584,8 @@ definitions:
type: string type: string
backupAccounts: backupAccounts:
type: string type: string
command:
type: string
containerName: containerName:
type: string type: string
dbName: dbName:
@ -632,6 +634,8 @@ definitions:
type: string type: string
backupAccounts: backupAccounts:
type: string type: string
command:
type: string
containerName: containerName:
type: string type: string
dbName: dbName:
@ -1528,6 +1532,26 @@ definitions:
- interval - interval
- secret - secret
type: object 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: dto.MysqlDBCreate:
properties: properties:
database: database:
@ -2556,6 +2580,8 @@ definitions:
type: string type: string
weChatVars: weChatVars:
type: string type: string
xpackHideMenu:
type: string
type: object type: object
dto.SettingUpdate: dto.SettingUpdate:
properties: properties:
@ -2717,6 +2743,8 @@ definitions:
type: string type: string
sourceDir: sourceDir:
type: string type: string
type:
type: string
type: object type: object
files.FileInfo: files.FileInfo:
properties: properties:
@ -10098,6 +10126,41 @@ paths:
summary: Create group summary: Create group
tags: tags:
- Firewall - 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: /hosts/search:
post: post:
consumes: consumes:
@ -11244,6 +11307,32 @@ paths:
summary: Load system address summary: Load system address
tags: tags:
- System Setting - 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: /settings/mfa:
post: post:
consumes: consumes:
@ -11292,23 +11381,6 @@ paths:
formatEN: bind mfa formatEN: bind mfa
formatZH: mfa 绑定 formatZH: mfa 绑定
paramKeys: [] 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: /settings/password/update:
post: post:
consumes: consumes:

View File

@ -116,6 +116,18 @@ export namespace Host {
rules: Array<RulePort>; 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 { export interface SSHInfo {
autoStart: boolean; autoStart: boolean;
status: string; status: string;

View File

@ -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;
}
}

View File

@ -101,6 +101,20 @@ export const batchOperateRule = (params: Host.BatchRule) => {
return http.post(`/hosts/firewall/batch`, params, TimeoutEnum.T_60S); 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 // ssh
export const getSSHInfo = () => { export const getSSHInfo = () => {
return http.post<Host.SSHInfo>(`/hosts/ssh/search`); return http.post<Host.SSHInfo>(`/hosts/ssh/search`);

View File

@ -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`);
};

View File

@ -29,6 +29,10 @@ export const updateSetting = (param: Setting.SettingUpdate) => {
return http.post(`/settings/update`, param); 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) => { export const updatePassword = (param: Setting.PasswordUpdate) => {
return http.post(`/settings/password/update`, param); 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 }); return http.post<string>(`/settings/time/sync`, { ntpSite: ntpSite });
}; };
export const cleanMonitors = () => {
return http.post(`/settings/monitor/clean`, {});
};
export const loadMFA = (param: Setting.MFARequest) => { export const loadMFA = (param: Setting.MFARequest) => {
return http.post<Setting.MFAInfo>(`/settings/mfa`, param); return http.post<Setting.MFAInfo>(`/settings/mfa`, param);
}; };

View File

@ -24,7 +24,7 @@ const settingRouter = {
hidden: true, hidden: true,
meta: { meta: {
requiresAuth: true, requiresAuth: true,
activeMenu: 'Setting', activeMenu: '/settings',
}, },
}, },
{ {

View File

@ -250,7 +250,7 @@ import { Dashboard } from '@/api/interface/dashboard';
import { dateFormatForSecond, computeSize } from '@/utils/util'; import { dateFormatForSecond, computeSize } from '@/utils/util';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { loadBaseInfo, loadCurrentInfo } from '@/api/modules/dashboard'; 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 { getSettingInfo, loadUpgradeInfo } from '@/api/modules/setting';
import { GlobalStore } from '@/store'; import { GlobalStore } from '@/store';
const router = useRouter(); const router = useRouter();

View File

@ -202,13 +202,13 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, onMounted, computed } from 'vue'; import { ref, reactive, onMounted, computed } from 'vue';
import { loadMonitor, getNetworkOptions } from '@/api/modules/monitor'; import { loadMonitor, getNetworkOptions } from '@/api/modules/host';
import { Monitor } from '@/api/interface/monitor';
import { computeSizeFromKBs, dateFormatWithoutYear } from '@/utils/util'; import { computeSizeFromKBs, dateFormatWithoutYear } from '@/utils/util';
import i18n from '@/lang'; import i18n from '@/lang';
import MonitorRouter from '@/views/host/monitor/index.vue'; import MonitorRouter from '@/views/host/monitor/index.vue';
import { GlobalStore } from '@/store'; import { GlobalStore } from '@/store';
import { shortcuts } from '@/utils/shortcuts'; import { shortcuts } from '@/utils/shortcuts';
import { Host } from '@/api/interface/host';
const globalStore = GlobalStore(); const globalStore = GlobalStore();
@ -229,7 +229,7 @@ const netOptions = ref();
const chartsOption = ref({ loadLoadChart: null, loadCPUChart: null, loadMemoryChart: null, loadNetworkChart: null }); const chartsOption = ref({ loadLoadChart: null, loadCPUChart: null, loadMemoryChart: null, loadNetworkChart: null });
const searchTime = ref(); const searchTime = ref();
const searchInfo = reactive<Monitor.MonitorSearch>({ const searchInfo = reactive<Host.MonitorSearch>({
param: '', param: '',
info: '', info: '',
startTime: new Date(new Date().setHours(0, 0, 0, 0)), startTime: new Date(new Date().setHours(0, 0, 0, 0)),
@ -372,7 +372,7 @@ const loadNetworkOptions = async () => {
search('all'); search('all');
}; };
function initLoadCharts(item: Monitor.MonitorData) { function initLoadCharts(item: Host.MonitorData) {
let itemLoadDate = item.date.length === 0 ? loadEmptyDate(timeRangeLoad.value) : item.date; let itemLoadDate = item.date.length === 0 ? loadEmptyDate(timeRangeLoad.value) : item.date;
let loadDate = itemLoadDate.map(function (item: any) { let loadDate = itemLoadDate.map(function (item: any) {
return dateFormatWithoutYear(item); 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 itemIODate = item.date?.length === 0 ? loadEmptyDate(timeRangeIO.value) : item.date;
let ioDate = itemIODate.map(function (item: any) { let ioDate = itemIODate.map(function (item: any) {
return dateFormatWithoutYear(item); return dateFormatWithoutYear(item);

View File

@ -15,7 +15,7 @@
<el-col :span="22"> <el-col :span="22">
<el-form-item <el-form-item
:label="$t('monitor.storeDays')" :label="$t('monitor.storeDays')"
:rules="[Rules.integerNumber, checkNumberRange(1, 365)]" :rules="[Rules.integerNumber]"
prop="monitorStoreDays" prop="monitorStoreDays"
> >
<el-input clearable v-model.number="form.monitorStoreDays" /> <el-input clearable v-model.number="form.monitorStoreDays" />
@ -39,7 +39,7 @@ import { reactive, ref } from 'vue';
import i18n from '@/lang'; import i18n from '@/lang';
import { MsgSuccess } from '@/utils/message'; import { MsgSuccess } from '@/utils/message';
import { FormInstance } from 'element-plus'; 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 { updateSetting } from '@/api/modules/setting';
import DrawerHeader from '@/components/drawer-header/index.vue'; import DrawerHeader from '@/components/drawer-header/index.vue';

View File

@ -51,7 +51,8 @@
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, reactive, ref } from 'vue'; import { onMounted, reactive, ref } from 'vue';
import { ElMessageBox, FormInstance } from 'element-plus'; 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 MonitorRouter from '@/views/host/monitor/index.vue';
import Interval from '@/views/host/monitor/setting/interval/index.vue'; import Interval from '@/views/host/monitor/setting/interval/index.vue';
import StoreDays from '@/views/host/monitor/setting/days/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'), cancelButtonText: i18n.global.t('commons.button.cancel'),
type: 'info', type: 'info',
}).then(async () => { }).then(async () => {
await cleanMonitors(); loading.value = true;
await cleanMonitors()
.then(() => {
loading.value = false;
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
})
.catch(() => {
loading.value = false;
});
}); });
}; };

View File

@ -43,7 +43,7 @@ import { updateSetting } from '@/api/modules/setting';
import { FormInstance } from 'element-plus'; import { FormInstance } from 'element-plus';
import { Rules } from '@/global/form-rules'; import { Rules } from '@/global/form-rules';
import DrawerHeader from '@/components/drawer-header/index.vue'; import DrawerHeader from '@/components/drawer-header/index.vue';
import { getNetworkOptions } from '@/api/modules/monitor'; import { getNetworkOptions } from '@/api/modules/host';
import { GlobalStore } from '@/store'; import { GlobalStore } from '@/store';
const globalStore = GlobalStore(); const globalStore = GlobalStore();