mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-03-01 03:24:14 +08:00
fix: Fix the issue of the container creation not popping up the task box (#7989)
This commit is contained in:
parent
79b8d17887
commit
d64ed8c718
@ -804,10 +804,7 @@ func (u *ContainerService) StreamLogs(ctx *gin.Context, params dto.StreamLog) {
|
|||||||
select {
|
select {
|
||||||
case msg, ok := <-messageChan:
|
case msg, ok := <-messageChan:
|
||||||
if !ok {
|
if !ok {
|
||||||
if msg == "" {
|
return msg == ""
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
_, err := fmt.Fprintf(w, "data: %v\n\n", msg)
|
_, err := fmt.Fprintf(w, "data: %v\n\n", msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1495,12 +1492,12 @@ func loadContainerPortForInfo(itemPorts []types.Port) []dto.PortHelper {
|
|||||||
var exposedPorts []dto.PortHelper
|
var exposedPorts []dto.PortHelper
|
||||||
samePortMap := make(map[string]dto.PortHelper)
|
samePortMap := make(map[string]dto.PortHelper)
|
||||||
ports := transPortToStr(itemPorts)
|
ports := transPortToStr(itemPorts)
|
||||||
var itemPort dto.PortHelper
|
|
||||||
for _, item := range ports {
|
for _, item := range ports {
|
||||||
itemStr := strings.Split(item, "->")
|
itemStr := strings.Split(item, "->")
|
||||||
if len(itemStr) < 2 {
|
if len(itemStr) < 2 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
var itemPort dto.PortHelper
|
||||||
lastIndex := strings.LastIndex(itemStr[0], ":")
|
lastIndex := strings.LastIndex(itemStr[0], ":")
|
||||||
if lastIndex == -1 {
|
if lastIndex == -1 {
|
||||||
itemPort.HostPort = itemStr[0]
|
itemPort.HostPort = itemStr[0]
|
||||||
|
@ -49,6 +49,7 @@ export namespace Container {
|
|||||||
memory: number;
|
memory: number;
|
||||||
}
|
}
|
||||||
export interface ContainerHelper {
|
export interface ContainerHelper {
|
||||||
|
taskID: string;
|
||||||
containerID: string;
|
containerID: string;
|
||||||
name: string;
|
name: string;
|
||||||
image: string;
|
image: string;
|
||||||
|
@ -75,10 +75,10 @@
|
|||||||
</el-button>
|
</el-button>
|
||||||
<el-button-group>
|
<el-button-group>
|
||||||
<el-button :disabled="checkStatus('start', null)" @click="onOperate('start', null)">
|
<el-button :disabled="checkStatus('start', null)" @click="onOperate('start', null)">
|
||||||
{{ $t('app.start') }}
|
{{ $t('commons.operate.start') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button :disabled="checkStatus('stop', null)" @click="onOperate('stop', null)">
|
<el-button :disabled="checkStatus('stop', null)" @click="onOperate('stop', null)">
|
||||||
{{ $t('app.stop') }}
|
{{ $t('commons.operate.stop') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button :disabled="checkStatus('restart', null)" @click="onOperate('restart', null)">
|
<el-button :disabled="checkStatus('restart', null)" @click="onOperate('restart', null)">
|
||||||
{{ $t('commons.button.restart') }}
|
{{ $t('commons.button.restart') }}
|
||||||
@ -158,13 +158,13 @@
|
|||||||
:disabled="checkStatus('start', row)"
|
:disabled="checkStatus('start', row)"
|
||||||
@click="onOperate('start', row)"
|
@click="onOperate('start', row)"
|
||||||
>
|
>
|
||||||
{{ $t('app.start') }}
|
{{ $t('commons.operate.start') }}
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
<el-dropdown-item
|
<el-dropdown-item
|
||||||
:disabled="checkStatus('stop', row)"
|
:disabled="checkStatus('stop', row)"
|
||||||
@click="onOperate('stop', row)"
|
@click="onOperate('stop', row)"
|
||||||
>
|
>
|
||||||
{{ $t('app.stop') }}
|
{{ $t('commons.operate.stop') }}
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
<el-dropdown-item
|
<el-dropdown-item
|
||||||
:disabled="checkStatus('restart', row)"
|
:disabled="checkStatus('restart', row)"
|
||||||
|
@ -196,7 +196,7 @@
|
|||||||
<el-tab-pane :label="$t('container.mount')">
|
<el-tab-pane :label="$t('container.mount')">
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-table v-if="form.volumes.length !== 0" :data="form.volumes">
|
<el-table v-if="form.volumes.length !== 0" :data="form.volumes">
|
||||||
<el-table-column :label="$t('container.server')" min-width="120">
|
<el-table-column :label="$t('container.server')" min-width="150">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-radio-group v-model="row.type">
|
<el-radio-group v-model="row.type">
|
||||||
<el-radio-button value="volume">
|
<el-radio-button value="volume">
|
||||||
@ -234,7 +234,7 @@
|
|||||||
<el-input v-else v-model="row.sourceDir" />
|
<el-input v-else v-model="row.sourceDir" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column :label="$t('container.mode')" min-width="120">
|
<el-table-column :label="$t('container.mode')" min-width="130">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-radio-group v-model="row.mode">
|
<el-radio-group v-model="row.mode">
|
||||||
<el-radio value="rw">{{ $t('container.modeRW') }}</el-radio>
|
<el-radio value="rw">{{ $t('container.modeRW') }}</el-radio>
|
||||||
@ -425,6 +425,7 @@
|
|||||||
</LayoutContent>
|
</LayoutContent>
|
||||||
<Command ref="commandRef" />
|
<Command ref="commandRef" />
|
||||||
<Confirm ref="confirmRef" @submit="submit" />
|
<Confirm ref="confirmRef" @submit="submit" />
|
||||||
|
<TaskLog ref="taskLogRef" width="70%" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -446,14 +447,16 @@ import {
|
|||||||
loadContainerInfo,
|
loadContainerInfo,
|
||||||
} from '@/api/modules/container';
|
} from '@/api/modules/container';
|
||||||
import { Container } from '@/api/interface/container';
|
import { Container } from '@/api/interface/container';
|
||||||
import { MsgError, MsgSuccess } from '@/utils/message';
|
import { MsgError } from '@/utils/message';
|
||||||
import { checkIpV4V6, checkPort } from '@/utils/util';
|
import TaskLog from '@/components/task-log/index.vue';
|
||||||
|
import { checkIpV4V6, checkPort, newUUID } from '@/utils/util';
|
||||||
import router from '@/routers';
|
import router from '@/routers';
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const isCreate = ref();
|
const isCreate = ref();
|
||||||
const confirmRef = ref();
|
const confirmRef = ref();
|
||||||
const form = reactive<Container.ContainerHelper>({
|
const form = reactive<Container.ContainerHelper>({
|
||||||
|
taskID: '',
|
||||||
containerID: '',
|
containerID: '',
|
||||||
name: '',
|
name: '',
|
||||||
image: '',
|
image: '',
|
||||||
@ -557,6 +560,7 @@ const search = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const commandRef = ref();
|
const commandRef = ref();
|
||||||
|
const taskLogRef = ref();
|
||||||
const images = ref();
|
const images = ref();
|
||||||
const volumes = ref();
|
const volumes = ref();
|
||||||
const networks = ref();
|
const networks = ref();
|
||||||
@ -654,6 +658,7 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
|
|||||||
};
|
};
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
form.cmd = [];
|
form.cmd = [];
|
||||||
|
form.taskID = newUUID();
|
||||||
if (form.cmdStr) {
|
if (form.cmdStr) {
|
||||||
let itemCmd = splitStringIgnoringQuotes(form.cmdStr);
|
let itemCmd = splitStringIgnoringQuotes(form.cmdStr);
|
||||||
for (const item of itemCmd) {
|
for (const item of itemCmd) {
|
||||||
@ -682,8 +687,7 @@ const submit = async () => {
|
|||||||
await createContainer(form)
|
await createContainer(form)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
openTaskLog(form.taskID);
|
||||||
goBack();
|
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
@ -692,8 +696,7 @@ const submit = async () => {
|
|||||||
await updateContainer(form)
|
await updateContainer(form)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
openTaskLog(form.taskID);
|
||||||
goBack();
|
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
updateContainerID();
|
updateContainerID();
|
||||||
@ -702,6 +705,10 @@ const submit = async () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const openTaskLog = (taskID: string) => {
|
||||||
|
taskLogRef.value.openWithTaskID(taskID);
|
||||||
|
};
|
||||||
|
|
||||||
const updateContainerID = async () => {
|
const updateContainerID = async () => {
|
||||||
let params = {
|
let params = {
|
||||||
page: 1,
|
page: 1,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user