fix: 解决主机添加连接失败的问题

This commit is contained in:
ssongliu 2023-02-23 17:31:46 +08:00 committed by ssongliu
parent f6cdfdc17b
commit a618118792
10 changed files with 60 additions and 42 deletions

View File

@ -92,7 +92,7 @@ func (u *HostService) SearchForTree(search dto.SearchForTree) ([]dto.HostTree, e
}
func (u *HostService) Create(req dto.HostOperate) (*dto.HostInfo, error) {
host, _ := hostRepo.Get(commonRepo.WithByName(req.Name))
host, _ := hostRepo.Get(hostRepo.WithByAddr(req.Addr))
if host.ID != 0 {
return nil, constant.ErrRecordExist
}

View File

@ -215,7 +215,7 @@ var AddTableWebsite = &gormigrate.Migration{
return err
}
item := &model.WebsiteGroup{
Name: "默认分组",
Name: "默认",
Default: true,
}
if err := tx.Create(item).Error; err != nil {

View File

@ -235,10 +235,8 @@ export default {
kubepiInfo: 'Modern open source Kubernetes panel',
goInstall: 'Go install',
allNetworkCard: 'All',
networkCard: 'NetworkCard',
disk: 'Disk',
allDisk: 'All',
},
tabs: {
more: 'More',
@ -742,6 +740,7 @@ export default {
sessionTimeoutHelper:
'If you do not operate the panel for more than {0} seconds, the panel automatically logs out',
syncTime: 'Server time',
second: ' S',
changePassword: 'Password change',
oldPassword: 'Original password',
newPassword: 'New password',
@ -811,7 +810,7 @@ export default {
upgrade: 'Upgrade',
upgrading: 'Please wait while the upgrade is underway...',
upgradeHelper: 'The upgrade requires a service restart. Do you want to continue?',
noUpgrade: 'This is the latest version. You do not need to update it',
noUpgrade: 'It is currently the latest version',
newVersion: 'Latest version',
upgradeCheck: 'Check for updates',
upgradeNotes: 'Release note',
@ -837,7 +836,7 @@ export default {
about: 'About',
project: 'Project Address',
issue: 'Feedback',
chat: 'Community Discussion',
doc: 'Official document',
star: 'Star',
description: '1Panel, A modern open source Linux panel.',
},
@ -1052,7 +1051,6 @@ export default {
data: 'data',
ever: 'permanent',
nextYear: 'One year later',
allGroup: 'All Groups',
noLog: 'There are currently no logs...',
defaultServer: 'Default Site',
noDefaulServer: 'Not set',

View File

@ -247,8 +247,6 @@ export default {
networkCard: '网卡',
disk: '磁盘',
allNetworkCard: '所有网卡',
allDisk: '所有磁盘',
},
tabs: {
more: '更多',
@ -613,7 +611,7 @@ export default {
connTestOk: '连接信息可用',
connTestFailed: '连接不可用请检查连接信息',
hostList: '主机信息',
createConn: '建连接',
createConn: '建连接',
createGroup: '创建分组',
expand: '全部展开',
fold: '全部收缩',
@ -748,6 +746,7 @@ export default {
sessionTimeoutError: '最小超时时间为 300 ',
sessionTimeoutHelper: '如果用户超过 {0} 秒未操作面板面板将自动退出登录',
syncTime: '服务器时间',
second: ' ',
changePassword: '密码修改',
oldPassword: '原密码',
newPassword: '新密码',
@ -798,7 +797,7 @@ export default {
upgrade: '升级',
upgrading: '正在升级中请稍候...',
upgradeHelper: '升级操作需要重启服务是否继续',
noUpgrade: '当前已是最新版本无需更新',
noUpgrade: '当前已是最新版本',
newVersion: '最新版本',
upgradeCheck: '检查更新',
upgradeNotes: '更新内容',
@ -842,7 +841,7 @@ export default {
about: '关于',
project: '项目地址',
issue: '问题反馈',
chat: '参与讨论',
doc: '官方文档',
star: '点亮 Star',
description: '1Panel一款现代化的开源 Linux 面板',
},
@ -1056,7 +1055,6 @@ export default {
data: '数据',
ever: '永久',
nextYear: '一年后',
allGroup: '所有分组',
noLog: '当前没有日志...',
defaultServer: '默认站点',
noDefaulServer: '未设置',

View File

@ -173,7 +173,7 @@ const search = async () => {
loading.value = false;
data.value = res.data.items || [];
for (const item of data.value) {
if (item.targetDir !== '-') {
if (item.targetDir !== '-' || item.targetDir !== '') {
item.targetDir = i18n.global.t('setting.' + item.targetDir);
}
}
@ -191,6 +191,7 @@ const onOpenDialog = async (
title: string,
rowData: Partial<Cronjob.CronjobInfo> = {
specType: 'perMonth',
type: 'shell',
week: 1,
day: 3,
hour: 1,

View File

@ -4,7 +4,7 @@
<el-card>
<div>
<el-tag style="float: left" effect="dark" type="success">
{{ dialogData.rowData.name }}-{{ $t('cronjob.' + dialogData.rowData.type) }}
{{ $t('cronjob.' + dialogData.rowData.type) }} - {{ dialogData.rowData.name }}
</el-tag>
<el-tag v-if="dialogData.rowData.status === 'Enable'" round class="status-content" type="success">
{{ $t('commons.status.running') }}
@ -75,7 +75,7 @@
</div>
<LayoutContent :title="$t('cronjob.record')" :reload="true">
<template #search v-if="hasRecords">
<template #search>
<el-row :gutter="20">
<el-col :span="8">
<el-date-picker
@ -321,7 +321,7 @@ const acceptParams = async (params: DialogProps): Promise<void> => {
pageSize: searchInfo.pageSize,
cronjobID: dialogData.value.rowData!.id,
startTime: new Date(new Date().setHours(0, 0, 0, 0)),
endTime: new Date(),
endTime: new Date(new Date().setHours(23, 59, 59, 0)),
status: searchInfo.status,
};
const res = await searchRecords(itemSearch);
@ -343,7 +343,7 @@ const shortcuts = [
{
text: i18n.global.t('monitor.today'),
value: () => {
const end = new Date();
const end = new Date(new Date().setHours(23, 59, 59, 999));
const start = new Date(new Date().setHours(0, 0, 0, 0));
return [start, end];
},
@ -361,7 +361,7 @@ const shortcuts = [
text: i18n.global.t('monitor.lastNDay', [3]),
value: () => {
const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 3);
const end = new Date();
const end = new Date(new Date().setHours(23, 59, 59, 999));
return [start, end];
},
},
@ -369,7 +369,7 @@ const shortcuts = [
text: i18n.global.t('monitor.lastNDay', [7]),
value: () => {
const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 7);
const end = new Date();
const end = new Date(new Date().setHours(23, 59, 59, 999));
return [start, end];
},
},
@ -377,7 +377,7 @@ const shortcuts = [
text: i18n.global.t('monitor.lastNDay', [30]),
value: () => {
const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 30);
const end = new Date();
const end = new Date(new Date().setHours(23, 59, 59, 999));
return [start, end];
},
},
@ -391,14 +391,17 @@ const weekOptions = [
{ label: i18n.global.t('cronjob.saturday'), value: 6 },
{ label: i18n.global.t('cronjob.sunday'), value: 7 },
];
const timeRangeLoad = ref<[Date, Date]>([new Date(new Date().setHours(0, 0, 0, 0)), new Date()]);
const timeRangeLoad = ref<[Date, Date]>([
new Date(new Date().setHours(0, 0, 0, 0)),
new Date(new Date().setHours(23, 59, 59, 999)),
]);
const searchInfo = reactive({
page: 1,
pageSize: 8,
recordTotal: 0,
cronjobID: 0,
startTime: new Date(new Date().setHours(0, 0, 0, 0)),
endTime: new Date(),
endTime: new Date(new Date().setHours(23, 59, 59, 999)),
status: '',
});

View File

@ -71,7 +71,7 @@
<el-option
v-for="item in netOptions"
:key="item"
:label="item == 'all' ? $t('home.allNetworkCard') : item"
:label="item == 'all' ? $t('commons.table.all') : item"
:value="item"
/>
</el-select>
@ -85,7 +85,7 @@
<el-option
v-for="item in ioOptions"
:key="item"
:label="item == 'all' ? $t('home.allDisk') : item"
:label="item == 'all' ? $t('commons.table.all') : item"
:value="item"
/>
</el-select>

View File

@ -95,7 +95,7 @@ let hostInfo = reactive<Host.HostOperate>({
});
const rules = reactive({
addr: [Rules.requiredInput],
addr: [Rules.ip],
port: [Rules.requiredInput, Rules.port],
user: [Rules.requiredInput],
authMode: [Rules.requiredSelect],
@ -108,6 +108,16 @@ interface DialogProps {
isLocal: boolean;
}
const acceptParams = (props: DialogProps) => {
hostInfo.addr = '';
hostInfo.name = '';
hostInfo.groupBelong = 'default';
hostInfo.addr = '';
hostInfo.port = 22;
hostInfo.user = '';
hostInfo.authMode = 'password';
hostInfo.password = '';
hostInfo.privateKey = '';
hostInfo.description = '';
isLocal.value = props.isLocal;
if (props.isLocal) {
hostInfo.addr = '127.0.0.1';
@ -144,7 +154,7 @@ const submitAddHost = (formEl: FormInstance | undefined, ops: string) => {
if (res.data.name.length !== 0) {
title = res.data.name + '-' + title;
}
emit('on-conn-terminal', title, res.data.id, res.data.addr, '');
emit('on-conn-terminal', title, res.data.id, false);
emit('load-host-tree');
}
});

View File

@ -42,12 +42,7 @@
<div>
<el-select v-model="quickCmd" clearable filterable @change="quickInput" style="width: 25%">
<template #prefix>{{ $t('terminal.quickCommand') }}</template>
<el-option
v-for="cmd in commandList"
:key="cmd.id"
:label="cmd.name + ' [ ' + cmd.command + ' ] '"
:value="cmd.command"
/>
<el-option v-for="cmd in commandList" :key="cmd.id" :label="cmd.name" :value="cmd.command" />
</el-select>
<el-input v-model="batchVal" @keyup.enter="batchInput" style="width: 75%">
<template #prepend>
@ -64,13 +59,16 @@
icon="Plus"
></el-button>
<el-popover ref="popoverRef" width="250px" trigger="hover" virtual-triggering persistent>
<el-button-group style="width: 100%">
<el-button @click="onNewSsh">New ssh</el-button>
<el-button @click="onNewLocal">New tab</el-button>
</el-button-group>
<el-input clearable style="margin-top: 5px" v-model="hostfilterInfo">
<template #append><el-button icon="search" /></template>
</el-input>
<el-button link type="primary" @click="onNewSsh">{{ $t('terminal.createConn') }}</el-button>
<div class="search-button" style="float: none">
<el-input
v-model="hostfilterInfo"
style="margin-top: 5px"
clearable
suffix-icon="Search"
:placeholder="$t('commons.button.search')"
></el-input>
</div>
<el-tree
ref="treeRef"
:expand-on-click-node="false"
@ -277,7 +275,7 @@ const onClickConn = (node: Node, data: Tree) => {
if (node.level === 1) {
return;
}
onConnTerminal(node.label, data.id);
onConnTerminal(node.label, data.id, false);
};
const onReconnect = async (item: any) => {
@ -307,16 +305,19 @@ const onConnTerminal = async (title: string, wsID: number, isLocal?: boolean) =>
}
}
}
console.log('走到了这里');
terminalTabs.value.push({
index: tabIndex,
title: title,
wsID: wsID,
status: res.data ? 'online' : 'closed',
});
console.log(terminalTabs.value);
terminalValue.value = tabIndex;
if (!res.data && isLocal) {
dialogRef.value!.acceptParams({ isLocal: true });
}
console.log(terminalValue.value);
nextTick(() => {
ctx.refs[`t-${terminalValue.value}`] &&
ctx.refs[`t-${terminalValue.value}`][0].acceptParams({
@ -382,4 +383,11 @@ defineExpose({
.el-tabs--top.el-tabs--card > .el-tabs__header .el-tabs__item:last-child {
padding-right: 0px;
}
.el-input__wrapper {
border-radius: 50px;
}
.el-input-group__prepend {
border-top-left-radius: 50px;
border-bottom-left-radius: 50px;
}
</style>

View File

@ -49,7 +49,7 @@
<div :class="{ mask: nginxStatus != 'Running' }">
<el-select v-model="req.websiteGroupId" @change="search()">
<template #prefix>{{ $t('website.group') }}</template>
<el-option :label="$t('website.allGroup')" :value="0"></el-option>
<el-option :label="$t('commons.table.all')" :value="0"></el-option>
<el-option
v-for="(group, index) in groups"
:key="index"