mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-28 17:55:56 +08:00
fix: 主机部分问题解决
This commit is contained in:
parent
76a0c38327
commit
9d65d2f4d6
10 changed files with 74 additions and 39 deletions
|
|
@ -220,8 +220,12 @@ func (b *BaseApi) UpdateHost(c *gin.Context) {
|
||||||
upMap["port"] = req.Port
|
upMap["port"] = req.Port
|
||||||
upMap["user"] = req.User
|
upMap["user"] = req.User
|
||||||
upMap["auth_mode"] = req.AuthMode
|
upMap["auth_mode"] = req.AuthMode
|
||||||
|
if len(req.Password) != 0 {
|
||||||
upMap["password"] = req.Password
|
upMap["password"] = req.Password
|
||||||
|
}
|
||||||
|
if len(req.PrivateKey) != 0 {
|
||||||
upMap["private_key"] = req.PrivateKey
|
upMap["private_key"] = req.PrivateKey
|
||||||
|
}
|
||||||
upMap["description"] = req.Description
|
upMap["description"] = req.Description
|
||||||
if err := hostService.Update(req.ID, upMap); err != nil {
|
if err := hostService.Update(req.ID, upMap); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||||
|
|
|
||||||
|
|
@ -17,13 +17,18 @@
|
||||||
<span v-if="row.name !== 'default'">{{ row.name }}</span>
|
<span v-if="row.name !== 'default'">{{ row.name }}</span>
|
||||||
<span v-if="row.isDefault">({{ $t('website.default') }})</span>
|
<span v-if="row.isDefault">({{ $t('website.default') }})</span>
|
||||||
</div>
|
</div>
|
||||||
<el-input v-if="row.edit" v-model="row.name"></el-input>
|
|
||||||
|
<el-form ref="groupForm" v-if="row.edit" :model="row">
|
||||||
|
<el-form-item prop="name" v-if="row.edit" :rules="Rules.name">
|
||||||
|
<el-input v-model="row.name"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column :label="$t('commons.table.operate')">
|
<el-table-column :label="$t('commons.table.operate')">
|
||||||
<template #default="{ row, $index }">
|
<template #default="{ row, $index }">
|
||||||
<div>
|
<div>
|
||||||
<el-button link v-if="row.edit" type="primary" @click="saveGroup(row, false)">
|
<el-button link v-if="row.edit" type="primary" @click="saveGroup(groupForm, row, true)">
|
||||||
{{ $t('commons.button.save') }}
|
{{ $t('commons.button.save') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button link v-if="!row.edit" type="primary" @click="editGroup($index)">
|
<el-button link v-if="!row.edit" type="primary" @click="editGroup($index)">
|
||||||
|
|
@ -38,10 +43,15 @@
|
||||||
>
|
>
|
||||||
{{ $t('commons.button.delete') }}
|
{{ $t('commons.button.delete') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button link v-if="row.edit" type="primary" @click="cancelEdit($index)">
|
<el-button link v-if="row.edit" type="primary" @click="search()">
|
||||||
{{ $t('commons.button.cancel') }}
|
{{ $t('commons.button.cancel') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button link v-if="!row.edit && !row.isDefault" type="primary" @click="saveGroup(row, true)">
|
<el-button
|
||||||
|
link
|
||||||
|
v-if="!row.edit && !row.isDefault"
|
||||||
|
type="primary"
|
||||||
|
@click="saveGroup(groupForm, row, false)"
|
||||||
|
>
|
||||||
{{ $t('website.setDefault') }}
|
{{ $t('website.setDefault') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -58,6 +68,8 @@ import { CreateGroup, DeleteGroup, GetGroupList, UpdateGroup } from '@/api/modul
|
||||||
import Header from '@/components/drawer-header/index.vue';
|
import Header from '@/components/drawer-header/index.vue';
|
||||||
import { MsgSuccess } from '@/utils/message';
|
import { MsgSuccess } from '@/utils/message';
|
||||||
import { Group } from '@/api/interface/group';
|
import { Group } from '@/api/interface/group';
|
||||||
|
import { Rules } from '@/global/form-rules';
|
||||||
|
import { FormInstance } from 'element-plus';
|
||||||
|
|
||||||
const open = ref(false);
|
const open = ref(false);
|
||||||
const type = ref();
|
const type = ref();
|
||||||
|
|
@ -67,10 +79,11 @@ const handleClose = () => {
|
||||||
data.value = [];
|
data.value = [];
|
||||||
emit('search');
|
emit('search');
|
||||||
};
|
};
|
||||||
|
|
||||||
interface DialogProps {
|
interface DialogProps {
|
||||||
type: string;
|
type: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const groupForm = ref();
|
||||||
const acceptParams = (params: DialogProps): void => {
|
const acceptParams = (params: DialogProps): void => {
|
||||||
type.value = params.type;
|
type.value = params.type;
|
||||||
open.value = true;
|
open.value = true;
|
||||||
|
|
@ -93,20 +106,28 @@ const search = () => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const saveGroup = (group: Group.GroupInfo, isDefault: boolean) => {
|
const saveGroup = async (formEl: FormInstance, group: Group.GroupInfo, isEdit: boolean) => {
|
||||||
|
if (!formEl) return;
|
||||||
|
await formEl.validate((valid) => {
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
group.type = type.value;
|
group.type = type.value;
|
||||||
|
if (!isEdit) {
|
||||||
|
group.isDefault = true;
|
||||||
|
}
|
||||||
if (group.id == 0) {
|
if (group.id == 0) {
|
||||||
CreateGroup(group).then(() => {
|
CreateGroup(group).then(() => {
|
||||||
MsgSuccess(i18n.global.t('commons.msg.createSuccess'));
|
MsgSuccess(i18n.global.t('commons.msg.createSuccess'));
|
||||||
search();
|
search();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
group.isDefault = isDefault;
|
|
||||||
UpdateGroup(group).then(() => {
|
UpdateGroup(group).then(() => {
|
||||||
MsgSuccess(i18n.global.t('commons.msg.updateSuccess'));
|
MsgSuccess(i18n.global.t('commons.msg.updateSuccess'));
|
||||||
search();
|
search();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const openCreate = () => {
|
const openCreate = () => {
|
||||||
|
|
@ -153,13 +174,5 @@ const editGroup = (index: number) => {
|
||||||
data.value[index].edit = true;
|
data.value[index].edit = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const cancelEdit = (index: number) => {
|
|
||||||
if (data.value[index].id == 0) {
|
|
||||||
data.value.splice(index, 1);
|
|
||||||
} else {
|
|
||||||
data.value[index].edit = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
defineExpose({ acceptParams });
|
defineExpose({ acceptParams });
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ const checkUserName = (rule: any, value: any, callback: any) => {
|
||||||
if (value === '' || typeof value === 'undefined' || value == null) {
|
if (value === '' || typeof value === 'undefined' || value == null) {
|
||||||
callback(new Error(i18n.global.t('commons.rule.userName')));
|
callback(new Error(i18n.global.t('commons.rule.userName')));
|
||||||
} else {
|
} else {
|
||||||
const reg = /^[a-zA-Z\u4e00-\u9fa5]{1}[a-zA-Z0-9_\u4e00-\u9fa5]{2,30}$/;
|
const reg = /[a-zA-Z0-9_\u4e00-\u9fa5]{3,30}$/;
|
||||||
if (!reg.test(value) && value !== '') {
|
if (!reg.test(value) && value !== '') {
|
||||||
callback(new Error(i18n.global.t('commons.rule.userName')));
|
callback(new Error(i18n.global.t('commons.rule.userName')));
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -97,7 +97,7 @@ const checkVolumeName = (rule: any, value: any, callback: any) => {
|
||||||
if (value === '' || typeof value === 'undefined' || value == null) {
|
if (value === '' || typeof value === 'undefined' || value == null) {
|
||||||
callback(new Error(i18n.global.t('commons.rule.volumeName')));
|
callback(new Error(i18n.global.t('commons.rule.volumeName')));
|
||||||
} else {
|
} else {
|
||||||
const reg = /^[a-zA-Z0-9]{1}[a-z:A-Z0-9_.-]{0,30}$/;
|
const reg = /^[a-zA-Z0-9]{1}[a-z:A-Z0-9_.-]{1,30}$/;
|
||||||
if (!reg.test(value) && value !== '') {
|
if (!reg.test(value) && value !== '') {
|
||||||
callback(new Error(i18n.global.t('commons.rule.volumeName')));
|
callback(new Error(i18n.global.t('commons.rule.volumeName')));
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -159,6 +159,19 @@ const checkDomain = (rule: any, value: any, callback: any) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const checkIntegerNumber = (rule: any, value: any, callback: any) => {
|
||||||
|
if (value === '' || typeof value === 'undefined' || value == null) {
|
||||||
|
callback(new Error(i18n.global.t('commons.rule.integer')));
|
||||||
|
} else {
|
||||||
|
const reg = /^[1-9]\d*$/;
|
||||||
|
if (!reg.test(value) && value !== '') {
|
||||||
|
callback(new Error(i18n.global.t('commons.rule.integer')));
|
||||||
|
} else {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const checkParamCommon = (rule: any, value: any, callback: any) => {
|
const checkParamCommon = (rule: any, value: any, callback: any) => {
|
||||||
if (value === '' || typeof value === 'undefined' || value == null) {
|
if (value === '' || typeof value === 'undefined' || value == null) {
|
||||||
callback(new Error(i18n.global.t('commons.rule.paramName')));
|
callback(new Error(i18n.global.t('commons.rule.paramName')));
|
||||||
|
|
@ -250,6 +263,7 @@ interface CommonRule {
|
||||||
password: FormItemRule;
|
password: FormItemRule;
|
||||||
email: FormItemRule;
|
email: FormItemRule;
|
||||||
number: FormItemRule;
|
number: FormItemRule;
|
||||||
|
integerNumber: FormItemRule;
|
||||||
ip: FormItemRule;
|
ip: FormItemRule;
|
||||||
port: FormItemRule;
|
port: FormItemRule;
|
||||||
domain: FormItemRule;
|
domain: FormItemRule;
|
||||||
|
|
@ -339,6 +353,11 @@ export const Rules: CommonRule = {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
message: i18n.global.t('commons.rule.number'),
|
message: i18n.global.t('commons.rule.number'),
|
||||||
},
|
},
|
||||||
|
integerNumber: {
|
||||||
|
required: true,
|
||||||
|
validator: checkIntegerNumber,
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
ip: {
|
ip: {
|
||||||
validator: checkIp,
|
validator: checkIp,
|
||||||
required: true,
|
required: true,
|
||||||
|
|
|
||||||
|
|
@ -443,6 +443,7 @@ export default {
|
||||||
mount: 'Mount',
|
mount: 'Mount',
|
||||||
serverPath: 'Server path',
|
serverPath: 'Server path',
|
||||||
containerDir: 'Container path',
|
containerDir: 'Container path',
|
||||||
|
volumeHelper: 'Ensure that the content of the storage volume is correct',
|
||||||
modeRW: 'RW',
|
modeRW: 'RW',
|
||||||
modeR: 'R',
|
modeR: 'R',
|
||||||
mode: 'Mode',
|
mode: 'Mode',
|
||||||
|
|
|
||||||
|
|
@ -455,6 +455,7 @@ export default {
|
||||||
mount: '挂载卷',
|
mount: '挂载卷',
|
||||||
serverPath: '服务器目录',
|
serverPath: '服务器目录',
|
||||||
containerDir: '容器目录',
|
containerDir: '容器目录',
|
||||||
|
volumeHelper: '请确认存储卷内容输入正确',
|
||||||
modeRW: '读写',
|
modeRW: '读写',
|
||||||
modeR: '只读',
|
modeR: '只读',
|
||||||
mode: '权限',
|
mode: '权限',
|
||||||
|
|
@ -524,6 +525,7 @@ export default {
|
||||||
registrieHelper: '一行一个,例:\n172.16.10.111:8081 \n172.16.10.112:8081',
|
registrieHelper: '一行一个,例:\n172.16.10.111:8081 \n172.16.10.112:8081',
|
||||||
|
|
||||||
compose: '编排',
|
compose: '编排',
|
||||||
|
composePathHelper: '容器编排将保存在: {0}',
|
||||||
apps: '应用商店',
|
apps: '应用商店',
|
||||||
local: '本地',
|
local: '本地',
|
||||||
createCompose: '创建编排',
|
createCompose: '创建编排',
|
||||||
|
|
|
||||||
|
|
@ -155,9 +155,6 @@ const buttons = [
|
||||||
click: (row: any) => {
|
click: (row: any) => {
|
||||||
dialogGroupChangeRef.value!.acceptParams({ id: row.id, group: row.groupBelong });
|
dialogGroupChangeRef.value!.acceptParams({ id: row.id, group: row.groupBelong });
|
||||||
},
|
},
|
||||||
disabled: (row: any) => {
|
|
||||||
return row.addr === '127.0.0.1';
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: i18n.global.t('commons.button.edit'),
|
label: i18n.global.t('commons.button.edit'),
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
<span v-if="dialogData.rowData!.addr === '127.0.0.1' && dialogData.title === 'edit'">
|
<span v-if="dialogData.rowData!.addr === '127.0.0.1' && dialogData.title === 'edit'">
|
||||||
{{ dialogData.rowData!.addr }}
|
{{ dialogData.rowData!.addr }}
|
||||||
</span>
|
</span>
|
||||||
<el-input v-else clearable v-model="dialogData.rowData!.addr" />
|
<el-input v-else clearable v-model.trim="dialogData.rowData!.addr" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('terminal.user')" prop="user">
|
<el-form-item :label="$t('terminal.user')" prop="user">
|
||||||
<el-input clearable v-model="dialogData.rowData!.user" />
|
<el-input clearable v-model="dialogData.rowData!.user" />
|
||||||
|
|
@ -113,8 +113,6 @@ const rules = reactive({
|
||||||
port: [Rules.requiredInput, Rules.port],
|
port: [Rules.requiredInput, Rules.port],
|
||||||
user: [Rules.requiredInput],
|
user: [Rules.requiredInput],
|
||||||
authMode: [Rules.requiredSelect],
|
authMode: [Rules.requiredSelect],
|
||||||
password: [Rules.requiredInput],
|
|
||||||
privateKey: [Rules.requiredInput],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const loadGroups = async () => {
|
const loadGroups = async () => {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
type="warning"
|
type="warning"
|
||||||
/>
|
/>
|
||||||
<el-form-item :label="$t('terminal.ip')" prop="addr">
|
<el-form-item :label="$t('terminal.ip')" prop="addr">
|
||||||
<el-input v-if="!isLocal" clearable v-model="hostInfo.addr" />
|
<el-input v-if="!isLocal" clearable v-model.trim="hostInfo.addr" />
|
||||||
<div style="margin-left: 12px">
|
<div style="margin-left: 12px">
|
||||||
<span v-if="isLocal">{{ hostInfo.addr }}</span>
|
<span v-if="isLocal">{{ hostInfo.addr }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ const search = async () => {
|
||||||
await getOperationLogs(params)
|
await getOperationLogs(params)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
data.value = res.data.items;
|
data.value = res.data.items || [];
|
||||||
if (globalStore.language === 'zh') {
|
if (globalStore.language === 'zh') {
|
||||||
for (const item of data.value) {
|
for (const item of data.value) {
|
||||||
item.detailZH = loadDetail(item.detailZH);
|
item.detailZH = loadDetail(item.detailZH);
|
||||||
|
|
|
||||||
|
|
@ -260,6 +260,7 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
await editBackup(dialogData.value.rowData)
|
await editBackup(dialogData.value.rowData)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue