fix: 主机部分问题解决

This commit is contained in:
ssongliu 2023-03-11 17:50:26 +08:00 committed by ssongliu
parent 76a0c38327
commit 9d65d2f4d6
10 changed files with 74 additions and 39 deletions

View File

@ -220,8 +220,12 @@ func (b *BaseApi) UpdateHost(c *gin.Context) {
upMap["port"] = req.Port
upMap["user"] = req.User
upMap["auth_mode"] = req.AuthMode
upMap["password"] = req.Password
upMap["private_key"] = req.PrivateKey
if len(req.Password) != 0 {
upMap["password"] = req.Password
}
if len(req.PrivateKey) != 0 {
upMap["private_key"] = req.PrivateKey
}
upMap["description"] = req.Description
if err := hostService.Update(req.ID, upMap); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)

View File

@ -17,13 +17,18 @@
<span v-if="row.name !== 'default'">{{ row.name }}</span>
<span v-if="row.isDefault">({{ $t('website.default') }})</span>
</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>
</el-table-column>
<el-table-column :label="$t('commons.table.operate')">
<template #default="{ row, $index }">
<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') }}
</el-button>
<el-button link v-if="!row.edit" type="primary" @click="editGroup($index)">
@ -38,10 +43,15 @@
>
{{ $t('commons.button.delete') }}
</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') }}
</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') }}
</el-button>
</div>
@ -58,6 +68,8 @@ import { CreateGroup, DeleteGroup, GetGroupList, UpdateGroup } from '@/api/modul
import Header from '@/components/drawer-header/index.vue';
import { MsgSuccess } from '@/utils/message';
import { Group } from '@/api/interface/group';
import { Rules } from '@/global/form-rules';
import { FormInstance } from 'element-plus';
const open = ref(false);
const type = ref();
@ -67,10 +79,11 @@ const handleClose = () => {
data.value = [];
emit('search');
};
interface DialogProps {
type: string;
}
const groupForm = ref();
const acceptParams = (params: DialogProps): void => {
type.value = params.type;
open.value = true;
@ -93,20 +106,28 @@ const search = () => {
});
};
const saveGroup = (group: Group.GroupInfo, isDefault: boolean) => {
group.type = type.value;
if (group.id == 0) {
CreateGroup(group).then(() => {
MsgSuccess(i18n.global.t('commons.msg.createSuccess'));
search();
});
} else {
group.isDefault = isDefault;
UpdateGroup(group).then(() => {
MsgSuccess(i18n.global.t('commons.msg.updateSuccess'));
search();
});
}
const saveGroup = async (formEl: FormInstance, group: Group.GroupInfo, isEdit: boolean) => {
if (!formEl) return;
await formEl.validate((valid) => {
if (!valid) {
return;
}
group.type = type.value;
if (!isEdit) {
group.isDefault = true;
}
if (group.id == 0) {
CreateGroup(group).then(() => {
MsgSuccess(i18n.global.t('commons.msg.createSuccess'));
search();
});
} else {
UpdateGroup(group).then(() => {
MsgSuccess(i18n.global.t('commons.msg.updateSuccess'));
search();
});
}
});
};
const openCreate = () => {
@ -153,13 +174,5 @@ const editGroup = (index: number) => {
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 });
</script>

View File

@ -45,7 +45,7 @@ const checkUserName = (rule: any, value: any, callback: any) => {
if (value === '' || typeof value === 'undefined' || value == null) {
callback(new Error(i18n.global.t('commons.rule.userName')));
} 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 !== '') {
callback(new Error(i18n.global.t('commons.rule.userName')));
} else {
@ -97,7 +97,7 @@ const checkVolumeName = (rule: any, value: any, callback: any) => {
if (value === '' || typeof value === 'undefined' || value == null) {
callback(new Error(i18n.global.t('commons.rule.volumeName')));
} 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 !== '') {
callback(new Error(i18n.global.t('commons.rule.volumeName')));
} 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) => {
if (value === '' || typeof value === 'undefined' || value == null) {
callback(new Error(i18n.global.t('commons.rule.paramName')));
@ -250,6 +263,7 @@ interface CommonRule {
password: FormItemRule;
email: FormItemRule;
number: FormItemRule;
integerNumber: FormItemRule;
ip: FormItemRule;
port: FormItemRule;
domain: FormItemRule;
@ -339,6 +353,11 @@ export const Rules: CommonRule = {
type: 'number',
message: i18n.global.t('commons.rule.number'),
},
integerNumber: {
required: true,
validator: checkIntegerNumber,
trigger: 'blur',
},
ip: {
validator: checkIp,
required: true,

View File

@ -443,6 +443,7 @@ export default {
mount: 'Mount',
serverPath: 'Server path',
containerDir: 'Container path',
volumeHelper: 'Ensure that the content of the storage volume is correct',
modeRW: 'RW',
modeR: 'R',
mode: 'Mode',

View File

@ -455,6 +455,7 @@ export default {
mount: '挂载卷',
serverPath: '服务器目录',
containerDir: '容器目录',
volumeHelper: '请确认存储卷内容输入正确',
modeRW: '读写',
modeR: '只读',
mode: '权限',
@ -524,6 +525,7 @@ export default {
registrieHelper: '一行一个\n172.16.10.111:8081 \n172.16.10.112:8081',
compose: '编排',
composePathHelper: '容器编排将保存在: {0}',
apps: '应用商店',
local: '本地',
createCompose: '创建编排',

View File

@ -155,9 +155,6 @@ const buttons = [
click: (row: any) => {
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'),

View File

@ -11,7 +11,7 @@
<span v-if="dialogData.rowData!.addr === '127.0.0.1' && dialogData.title === 'edit'">
{{ dialogData.rowData!.addr }}
</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 :label="$t('terminal.user')" prop="user">
<el-input clearable v-model="dialogData.rowData!.user" />
@ -113,8 +113,6 @@ const rules = reactive({
port: [Rules.requiredInput, Rules.port],
user: [Rules.requiredInput],
authMode: [Rules.requiredSelect],
password: [Rules.requiredInput],
privateKey: [Rules.requiredInput],
});
const loadGroups = async () => {

View File

@ -16,7 +16,7 @@
type="warning"
/>
<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">
<span v-if="isLocal">{{ hostInfo.addr }}</span>
</div>

View File

@ -131,7 +131,7 @@ const search = async () => {
await getOperationLogs(params)
.then((res) => {
loading.value = false;
data.value = res.data.items;
data.value = res.data.items || [];
if (globalStore.language === 'zh') {
for (const item of data.value) {
item.detailZH = loadDetail(item.detailZH);

View File

@ -260,6 +260,7 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
.catch(() => {
loading.value = false;
});
return;
}
await editBackup(dialogData.value.rowData)
.then(() => {