1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-03-15 10:14:44 +08:00

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) { 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 { if host.ID != 0 {
return nil, constant.ErrRecordExist return nil, constant.ErrRecordExist
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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