mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-31 14:08:06 +08:00
fix: 增加工具箱获取超时时间 (#3328)
This commit is contained in:
parent
f91831a5ea
commit
55c71df906
@ -14,7 +14,7 @@ import (
|
||||
// @Description 获取设备基础信息
|
||||
// @Success 200 {object} dto.DeviceBaseInfo
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /toolbox/device/base [get]
|
||||
// @Router /toolbox/device/base [post]
|
||||
func (b *BaseApi) LoadDeviceBaseInfo(c *gin.Context) {
|
||||
data, err := deviceService.LoadBaseInfo()
|
||||
if err != nil {
|
||||
|
@ -55,10 +55,15 @@ func (u *DeviceService) LoadBaseInfo() (dto.DeviceBaseInfo, error) {
|
||||
baseInfo.Hosts = loadHosts()
|
||||
baseInfo.Hostname = loadHostname()
|
||||
baseInfo.User = loadUser()
|
||||
ntp, _ := settingRepo.Get(settingRepo.WithByKey("NtpSite"))
|
||||
baseInfo.Ntp = ntp.Value
|
||||
ntp, err := settingRepo.Get(settingRepo.WithByKey("NtpSite"))
|
||||
if err == nil {
|
||||
baseInfo.Ntp = ntp.Value
|
||||
}
|
||||
|
||||
swapInfo, _ := mem.SwapMemory()
|
||||
swapInfo, err := mem.SwapMemory()
|
||||
if err != nil {
|
||||
return baseInfo, err
|
||||
}
|
||||
baseInfo.SwapMemoryTotal = swapInfo.Total
|
||||
baseInfo.SwapMemoryAvailable = swapInfo.Free
|
||||
baseInfo.SwapMemoryUsed = swapInfo.Used
|
||||
@ -375,7 +380,7 @@ func loadUser() string {
|
||||
|
||||
func loadSwap() []dto.SwapHelper {
|
||||
var data []dto.SwapHelper
|
||||
std, err := cmd.Execf("%s swapon --show --summary", cmd.SudoHandleCmd())
|
||||
std, err := cmd.Execf("%s swapon --summary", cmd.SudoHandleCmd())
|
||||
if err != nil {
|
||||
return data
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ func (s *ToolboxRouter) InitToolboxRouter(Router *gin.RouterGroup) {
|
||||
Use(middleware.PasswordExpired())
|
||||
baseApi := v1.ApiGroupApp.BaseApi
|
||||
{
|
||||
toolboxRouter.GET("/device/base", baseApi.LoadDeviceBaseInfo)
|
||||
toolboxRouter.POST("/device/base", baseApi.LoadDeviceBaseInfo)
|
||||
toolboxRouter.GET("/device/zone/options", baseApi.LoadTimeOption)
|
||||
toolboxRouter.POST("/device/update/conf", baseApi.UpdateDeviceConf)
|
||||
toolboxRouter.POST("/device/update/host", baseApi.UpdateDeviceHost)
|
||||
|
@ -10102,7 +10102,7 @@ const docTemplate = `{
|
||||
}
|
||||
},
|
||||
"/toolbox/device/base": {
|
||||
"get": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
|
@ -10095,7 +10095,7 @@
|
||||
}
|
||||
},
|
||||
"/toolbox/device/base": {
|
||||
"get": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
|
@ -11190,7 +11190,7 @@ paths:
|
||||
formatZH: 清理系统垃圾文件
|
||||
paramKeys: []
|
||||
/toolbox/device/base:
|
||||
get:
|
||||
post:
|
||||
description: 获取设备基础信息
|
||||
responses:
|
||||
"200":
|
||||
|
@ -6,16 +6,16 @@ import { TimeoutEnum } from '@/enums/http-enum';
|
||||
|
||||
// device
|
||||
export const getDeviceBase = () => {
|
||||
return http.get<Toolbox.DeviceBaseInfo>(`/toolbox/device/base`);
|
||||
return http.post<Toolbox.DeviceBaseInfo>(`/toolbox/device/base`, {}, TimeoutEnum.T_60S);
|
||||
};
|
||||
export const loadTimeZoneOptions = () => {
|
||||
return http.get<Array<string>>(`/toolbox/device/zone/options`);
|
||||
};
|
||||
export const updateDevice = (key: string, value: string) => {
|
||||
return http.post(`/toolbox/device/update/conf`, { key: key, value: value });
|
||||
return http.post(`/toolbox/device/update/conf`, { key: key, value: value }, TimeoutEnum.T_60S);
|
||||
};
|
||||
export const updateDeviceHost = (param: Array<Toolbox.TimeZoneOptions>) => {
|
||||
return http.post(`/toolbox/device/update/host`, param);
|
||||
return http.post(`/toolbox/device/update/host`, param, TimeoutEnum.T_60S);
|
||||
};
|
||||
export const updateDevicePasswd = (user: string, passwd: string) => {
|
||||
return http.post(`/toolbox/device/update/passwd`, { user: user, passwd: Base64.encode(passwd) });
|
||||
|
@ -69,7 +69,7 @@
|
||||
{{ $t('home.free') }}: {{ formatNumber(currentInfo.swapMemoryAvailable / 1024 / 1024) }} MB
|
||||
</el-tag>
|
||||
<el-tag class="tagClass">
|
||||
{{ $t('home.percent') }}: {{ formatNumber(currentInfo.swapMemoryUsedPercent * 100) }}%
|
||||
{{ $t('home.percent') }}: {{ formatNumber(currentInfo.swapMemoryUsedPercent) }}%
|
||||
</el-tag>
|
||||
</div>
|
||||
<template #reference>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<DrawerHeader header="DNS" :back="handleClose" />
|
||||
</template>
|
||||
|
||||
<el-row type="flex" justify="center">
|
||||
<el-row type="flex" justify="center" v-loading="loading">
|
||||
<el-col :span="22">
|
||||
<el-alert
|
||||
:title="$t('toolbox.device.dnsAlert')"
|
||||
@ -24,7 +24,6 @@
|
||||
label-position="top"
|
||||
@submit.prevent
|
||||
:model="form"
|
||||
v-loading="loading"
|
||||
>
|
||||
<el-form-item label="DNS" prop="dns">
|
||||
<el-input
|
||||
|
@ -5,7 +5,7 @@
|
||||
<DrawerHeader :header="$t('toolbox.device.hostname')" :back="handleClose" />
|
||||
</template>
|
||||
|
||||
<el-row type="flex" justify="center">
|
||||
<el-row type="flex" justify="center" v-loading="loading">
|
||||
<el-col :span="22">
|
||||
<el-alert
|
||||
:title="$t('toolbox.device.hostnameHelper')"
|
||||
@ -13,7 +13,7 @@
|
||||
:closable="false"
|
||||
type="warning"
|
||||
/>
|
||||
<el-form ref="formRef" label-position="top" :model="form" @submit.prevent v-loading="loading">
|
||||
<el-form ref="formRef" label-position="top" :model="form" @submit.prevent>
|
||||
<el-form-item
|
||||
:label="$t('toolbox.device.hostname')"
|
||||
prop="hostname"
|
||||
@ -76,6 +76,7 @@ const onSaveHostame = async (formEl: FormInstance | undefined) => {
|
||||
type: 'info',
|
||||
},
|
||||
).then(async () => {
|
||||
loading.value = true;
|
||||
await updateDevice('Hostname', form.hostname)
|
||||
.then(async () => {
|
||||
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
||||
|
@ -5,7 +5,7 @@
|
||||
<DrawerHeader header="Hosts" :back="handleClose" />
|
||||
</template>
|
||||
|
||||
<el-row type="flex" justify="center">
|
||||
<el-row type="flex" justify="center" v-loading="loading">
|
||||
<el-col :span="22">
|
||||
<el-radio-group v-model="confShowType" @change="changeMode">
|
||||
<el-radio-button label="base">{{ $t('database.baseConf') }}</el-radio-button>
|
||||
|
@ -1,11 +1,11 @@
|
||||
<template>
|
||||
<div v-loading="loading">
|
||||
<div>
|
||||
<el-drawer v-model="passwordVisible" :destroy-on-close="true" :close-on-click-modal="false" size="30%">
|
||||
<template #header>
|
||||
<DrawerHeader :header="$t('setting.changePassword')" :back="handleClose" />
|
||||
</template>
|
||||
|
||||
<el-row type="flex" justify="center">
|
||||
<el-row type="flex" justify="center" v-loading="loading">
|
||||
<el-col :span="22">
|
||||
<el-form ref="formRef" label-position="top" :model="form" :rules="passRules">
|
||||
<el-alert
|
||||
|
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div v-loading="loading">
|
||||
<div>
|
||||
<el-drawer v-model="drawerVisible" :destroy-on-close="true" :close-on-click-modal="false" size="50%">
|
||||
<template #header>
|
||||
<DrawerHeader header="Swap" :back="handleClose" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user