fix 容器终端、容器日志无法正常使用

This commit is contained in:
bwcx_jzy 2024-01-14 17:27:12 +08:00
parent f9d1274e86
commit 08363a4a47
No known key found for this signature in database
GPG Key ID: 5E48E9372088B9E5
6 changed files with 157 additions and 139 deletions

View File

@ -6,6 +6,7 @@
1. 【server】修复 docker TLS 证书无法查看全部、证书无法编辑(新版遗漏)
2. 【server】优化 docker 资产监控支持自定义配置 cron `jpom.assets.docker.monitor-cron`
3. 【server】修复 容器终端、容器日志无法正常使用
------

View File

@ -191,6 +191,9 @@ export default {
return
}
const tempArray = (Array.isArray(data) ? data : [data])
.flatMap((item) => {
return item.split('\r\n')
})
.map((item) => {
return {
text: ansiparse(item)

View File

@ -8,7 +8,7 @@
$emit('cancelBtnClick')
}
"
width="60vw"
width="80vw"
title="重建容器"
:maskClosable="false"
:footer-style="{ textAlign: 'right' }"
@ -48,160 +48,168 @@
<a-form-item label="端口">
<a-form-item-rest>
<a-row v-for="(item, index) in temp.exposedPorts" :key="index">
<a-col :span="21">
<a-space>
<a-input-group>
<a-row>
<a-col :span="8">
<a-input addon-before="IP" placeholder="宿主机ip" v-model:value="item.ip"> </a-input>
</a-col>
<a-col :span="6" :offset="1">
<a-input addon-before="端口" placeholder="端口" v-model:value="item.publicPort"> </a-input>
</a-col>
<a-col :span="8" :offset="1">
<a-input
addon-before="容器"
:disabled="item.disabled"
v-model:value="item.port"
placeholder="容器端口"
>
<template v-slot:addonAfter>
<a-select :disabled="item.disabled" v-model:value="item.scheme" placeholder="端口协议">
<a-select-option value="tcp">tcp</a-select-option>
<a-select-option value="udp">udp</a-select-option>
<a-select-option value="sctp">sctp</a-select-option>
</a-select>
</template>
</a-input>
</a-col>
</a-row>
</a-input-group>
</a-space>
</a-col>
<a-col :span="2" :offset="1">
<a-space>
<MinusCircleOutlined
v-if="temp.exposedPorts && temp.exposedPorts.length > 1"
@click="
() => {
temp.exposedPorts.splice(index, 1)
}
"
/>
<a-space direction="vertical" style="width: 100%">
<a-row v-for="(item, index) in temp.exposedPorts" :key="index">
<a-col :span="21">
<a-space>
<a-input-group>
<a-row>
<a-col :span="8">
<a-input addon-before="IP" placeholder="宿主机ip" v-model:value="item.ip"> </a-input>
</a-col>
<a-col :span="6" :offset="1">
<a-input addon-before="端口" placeholder="端口" v-model:value="item.publicPort"> </a-input>
</a-col>
<a-col :span="8" :offset="1">
<a-input
addon-before="容器"
:disabled="item.disabled"
v-model:value="item.port"
placeholder="容器端口"
>
<template v-slot:addonAfter>
<a-select :disabled="item.disabled" v-model:value="item.scheme" placeholder="端口协议">
<a-select-option value="tcp">tcp</a-select-option>
<a-select-option value="udp">udp</a-select-option>
<a-select-option value="sctp">sctp</a-select-option>
</a-select>
</template>
</a-input>
</a-col>
</a-row>
</a-input-group>
</a-space>
</a-col>
<a-col :span="2" :offset="1">
<a-space>
<MinusCircleOutlined
v-if="temp.exposedPorts && temp.exposedPorts.length > 1"
@click="
() => {
temp.exposedPorts.splice(index, 1)
}
"
/>
<PlusSquareOutlined
@click="
() => {
temp.exposedPorts.push({
scheme: 'tcp',
ip: '0.0.0.0'
})
}
"
/>
</a-space>
</a-col>
</a-row>
<PlusSquareOutlined
@click="
() => {
temp.exposedPorts.push({
scheme: 'tcp',
ip: '0.0.0.0'
})
}
"
/>
</a-space>
</a-col>
</a-row>
</a-space>
</a-form-item-rest>
</a-form-item>
<a-form-item label="挂载卷">
<a-form-item-rest>
<a-row v-for="(item, index) in temp.volumes" :key="index">
<a-col :span="10">
<a-input addon-before="宿主" v-model:value="item.host" placeholder="宿主机目录" />
</a-col>
<a-col :span="10" :offset="1">
<a-input
addon-before="容器"
:disabled="item.disabled"
v-model:value="item.container"
placeholder="容器目录"
/>
</a-col>
<a-col :span="2" :offset="1">
<a-space>
<MinusCircleOutlined
v-if="temp.volumes && temp.volumes.length > 1"
@click="
() => {
temp.volumes.splice(index, 1)
}
"
<a-space direction="vertical" style="width: 100%">
<a-row v-for="(item, index) in temp.volumes" :key="index">
<a-col :span="10">
<a-input addon-before="宿主" v-model:value="item.host" placeholder="宿主机目录" />
</a-col>
<a-col :span="10" :offset="1">
<a-input
addon-before="容器"
:disabled="item.disabled"
v-model:value="item.container"
placeholder="容器目录"
/>
</a-col>
<a-col :span="2" :offset="1">
<a-space>
<MinusCircleOutlined
v-if="temp.volumes && temp.volumes.length > 1"
@click="
() => {
temp.volumes.splice(index, 1)
}
"
/>
<PlusSquareOutlined
@click="
() => {
temp.volumes.push({})
}
"
/>
</a-space>
</a-col>
</a-row>
<PlusSquareOutlined
@click="
() => {
temp.volumes.push({})
}
"
/>
</a-space>
</a-col>
</a-row>
</a-space>
</a-form-item-rest>
</a-form-item>
<a-form-item label="环境变量">
<a-form-item-rest>
<a-row v-for="(item, index) in temp.env" :key="index">
<a-col :span="10">
<a-input v-model:value="item.key" placeholder="变量名" />
</a-col>
<a-col :span="10" :offset="1">
<a-input v-model:value="item.value" placeholder="变量值" />
</a-col>
<a-col :span="2" :offset="1">
<a-space>
<MinusCircleOutlined
v-if="temp.env && temp.env.length > 1"
@click="
() => {
temp.env.splice(index, 1)
}
"
/>
<a-space direction="vertical" style="width: 100%">
<a-row v-for="(item, index) in temp.env" :key="index">
<a-col :span="10">
<a-input v-model:value="item.key" placeholder="变量名" />
</a-col>
<a-col :span="10" :offset="1">
<a-input v-model:value="item.value" placeholder="变量值" />
</a-col>
<a-col :span="2" :offset="1">
<a-space>
<MinusCircleOutlined
v-if="temp.env && temp.env.length > 1"
@click="
() => {
temp.env.splice(index, 1)
}
"
/>
<PlusSquareOutlined
@click="
() => {
temp.env.push({})
}
"
/>
</a-space>
</a-col>
</a-row>
<PlusSquareOutlined
@click="
() => {
temp.env.push({})
}
"
/>
</a-space>
</a-col>
</a-row>
</a-space>
</a-form-item-rest>
</a-form-item>
<a-form-item label="命令">
<a-form-item-rest>
<a-row v-for="(item, index) in temp.commands" :key="index">
<a-col :span="20">
<a-input addon-before="命令值" v-model:value="item.value" placeholder="填写运行命令" />
</a-col>
<a-space direction="vertical" style="width: 100%">
<a-row v-for="(item, index) in temp.commands" :key="index">
<a-col :span="20">
<a-input addon-before="命令值" v-model:value="item.value" placeholder="填写运行命令" />
</a-col>
<a-col :span="2" :offset="1">
<a-space>
<MinusCircleOutlined
v-if="temp.commands && temp.commands.length > 1"
@click="
() => {
temp.commands.splice(index, 1)
}
"
/>
<PlusSquareOutlined
@click="
() => {
temp.commands.push({})
}
"
/>
</a-space>
</a-col>
</a-row>
<a-col :span="2" :offset="1">
<a-space>
<MinusCircleOutlined
v-if="temp.commands && temp.commands.length > 1"
@click="
() => {
temp.commands.splice(index, 1)
}
"
/>
<PlusSquareOutlined
@click="
() => {
temp.commands.push({})
}
"
/>
</a-space>
</a-col>
</a-row>
</a-space>
</a-form-item-rest>
</a-form-item>
<a-form-item label="hostname" name="hostname">

View File

@ -44,6 +44,7 @@ import { mapState } from 'pinia'
import { getWebSocketUrl } from '@/api/config'
import { dockerContainerDownloaLog } from '@/api/docker-api'
import { useUserStore } from '@/stores/user'
import { useAppStore } from '@/stores/app'
import LogView2 from '@/components/logView'
export default {
@ -77,7 +78,8 @@ export default {
}
},
computed: {
...mapState(useUserStore, ['getLongTermToken', 'getWorkspaceId']),
...mapState(useUserStore, ['getLongTermToken']),
...mapState(useAppStore, ['getWorkspaceId']),
socketUrl() {
return getWebSocketUrl(
'/socket/docker_log',

View File

@ -125,9 +125,11 @@
>
<a-form ref="editForm" :rules="rules" :model="temp" :label-col="{ span: 4 }" :wrapper-col="{ span: 18 }">
<a-form-item label="服务名称" name="name">
<template #help><span v-if="!temp.serviceId">创建后不支持修改</span></template>
<a-input v-model:value="temp.name" :disabled="temp.serviceId ? true : false" placeholder="服务名称" />
</a-form-item>
<a-form-item label="运行模式" name="mode">
<template #help><span v-if="!temp.serviceId">创建后不支持修改</span></template>
<a-radio-group name="mode" v-model:value="temp.mode" :disabled="temp.serviceId ? true : false">
<a-radio value="REPLICATED">副本</a-radio>
<a-radio value="GLOBAL">独立 </a-radio>

View File

@ -7,6 +7,7 @@ import { mapState } from 'pinia'
import { getWebSocketUrl } from '@/api/config'
import terminal from '@/components/terminal'
import { useUserStore } from '@/stores/user'
import { useAppStore } from '@/stores/app'
// https://blog.csdn.net/qq_41840688/article/details/108636267
export default {
@ -30,7 +31,8 @@ export default {
return {}
},
computed: {
...mapState(useUserStore, ['getLongTermToken', 'getWorkspaceId']),
...mapState(useUserStore, ['getLongTermToken']),
...mapState(useAppStore, ['getWorkspaceId']),
socketUrl() {
return getWebSocketUrl(
'/socket/docker_cli',