mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-01-06 15:14:29 +08:00
fix: Fix the issue of abnormal refresh after container creation/editing (#10657)
This commit is contained in:
parent
1c16a0a69f
commit
fb24a699e6
8 changed files with 34 additions and 41 deletions
|
|
@ -71,7 +71,6 @@ type ResourceLimit struct {
|
|||
|
||||
type ContainerOperate struct {
|
||||
TaskID string `json:"taskID"`
|
||||
ContainerID string `json:"containerID"`
|
||||
ForcePull bool `json:"forcePull"`
|
||||
Name string `json:"name" validate:"required"`
|
||||
Image string `json:"image" validate:"required"`
|
||||
|
|
|
|||
|
|
@ -640,7 +640,6 @@ func (u *ContainerService) ContainerInfo(req dto.OperationWithName) (*dto.Contai
|
|||
}
|
||||
|
||||
var data dto.ContainerOperate
|
||||
data.ContainerID = oldContainer.ID
|
||||
data.Name = strings.ReplaceAll(oldContainer.Name, "/", "")
|
||||
data.Image = oldContainer.Config.Image
|
||||
if oldContainer.NetworkSettings != nil {
|
||||
|
|
@ -702,11 +701,7 @@ func (u *ContainerService) ContainerUpdate(req dto.ContainerOperate) error {
|
|||
}
|
||||
defer client.Close()
|
||||
ctx := context.Background()
|
||||
newContainer, _ := client.ContainerInspect(ctx, req.Name)
|
||||
if newContainer.ContainerJSONBase != nil && newContainer.ID != req.ContainerID {
|
||||
return buserr.New("ErrContainerName")
|
||||
}
|
||||
oldContainer, err := client.ContainerInspect(ctx, req.ContainerID)
|
||||
oldContainer, err := client.ContainerInspect(ctx, req.Name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -730,7 +725,7 @@ func (u *ContainerService) ContainerUpdate(req dto.ContainerOperate) error {
|
|||
}, nil)
|
||||
|
||||
taskItem.AddSubTask(i18n.GetWithName("ContainerCreate", req.Name), func(t *task.Task) error {
|
||||
err := client.ContainerRemove(ctx, req.ContainerID, container.RemoveOptions{Force: true})
|
||||
err := client.ContainerRemove(ctx, req.Name, container.RemoveOptions{Force: true})
|
||||
taskItem.LogWithStatus(i18n.GetWithName("ContainerRemoveOld", req.Name), err)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ export namespace Container {
|
|||
}
|
||||
export interface ContainerHelper {
|
||||
taskID: string;
|
||||
containerID: string;
|
||||
name: string;
|
||||
image: string;
|
||||
imageInput: boolean;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@ const isCollapse = computed((): boolean => menuStore.isCollapse);
|
|||
|
||||
let routerMenus = computed((): RouteRecordRaw[] => {
|
||||
const aa = menuStore.menuList.filter((route) => route.meta && !route.meta.hideInSidebar) as RouteRecordRaw[];
|
||||
console.log(aa);
|
||||
return aa;
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -594,8 +594,8 @@ function loadMemValue(t: number) {
|
|||
return Number((t / Math.pow(num, 3)).toFixed(2));
|
||||
}
|
||||
|
||||
const onContainerOperate = async (containerID: string) => {
|
||||
routerToNameWithQuery('ContainerCreate', { containerID: containerID });
|
||||
const onContainerOperate = async (container: string) => {
|
||||
routerToNameWithQuery('ContainerCreate', { name: container });
|
||||
};
|
||||
|
||||
const dialogMonitorRef = ref();
|
||||
|
|
@ -701,7 +701,7 @@ const buttons = [
|
|||
{
|
||||
label: i18n.global.t('commons.button.edit'),
|
||||
click: (row: Container.ContainerInfo) => {
|
||||
onContainerOperate(row.containerID);
|
||||
onContainerOperate(row.name);
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
</el-button>
|
||||
<el-form-item class="mt-5" :label="$t('commons.table.name')" prop="name">
|
||||
<el-input
|
||||
:disabled="isFromApp(form)"
|
||||
:disabled="!isCreate"
|
||||
class="mini-form-item"
|
||||
clearable
|
||||
v-model.trim="form.name"
|
||||
|
|
@ -378,8 +378,8 @@ import {
|
|||
updateContainer,
|
||||
loadResourceLimit,
|
||||
listNetwork,
|
||||
searchContainer,
|
||||
loadContainerInfo,
|
||||
searchContainer,
|
||||
} from '@/api/modules/container';
|
||||
import { Container } from '@/api/interface/container';
|
||||
import { MsgError } from '@/utils/message';
|
||||
|
|
@ -387,7 +387,7 @@ import TaskLog from '@/components/log/task/index.vue';
|
|||
import { checkIpV4V6, checkPort, newUUID } from '@/utils/util';
|
||||
import router from '@/routers';
|
||||
import TerminalDialog from '@/views/host/file-management/terminal/index.vue';
|
||||
import { routerToName } from '@/utils/router';
|
||||
import { routerToName, routerToNameWithQuery } from '@/utils/router';
|
||||
|
||||
const loading = ref(false);
|
||||
const isCreate = ref();
|
||||
|
|
@ -395,7 +395,6 @@ const confirmRef = ref();
|
|||
const volumeRef = ref();
|
||||
const form = reactive<Container.ContainerHelper>({
|
||||
taskID: '',
|
||||
containerID: '',
|
||||
name: '',
|
||||
image: '',
|
||||
imageInput: false,
|
||||
|
|
@ -431,7 +430,7 @@ const form = reactive<Container.ContainerHelper>({
|
|||
const search = async () => {
|
||||
if (!isCreate.value) {
|
||||
loading.value = true;
|
||||
await loadContainerInfo(form.containerID)
|
||||
await loadContainerInfo(form.name)
|
||||
.then((res) => {
|
||||
loading.value = false;
|
||||
form.name = res.data.name;
|
||||
|
|
@ -520,6 +519,7 @@ const goBack = () => {
|
|||
};
|
||||
const closeTask = () => {
|
||||
taskLogRef.value.handleClose();
|
||||
checkExist();
|
||||
};
|
||||
const dialogTerminalRef = ref();
|
||||
const toTerminal = () => {
|
||||
|
|
@ -621,7 +621,6 @@ const submit = async () => {
|
|||
openTaskLog(form.taskID);
|
||||
})
|
||||
.catch(() => {
|
||||
updateContainerID();
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
|
|
@ -631,24 +630,6 @@ const openTaskLog = (taskID: string) => {
|
|||
taskLogRef.value.openWithTaskID(taskID);
|
||||
};
|
||||
|
||||
const updateContainerID = async () => {
|
||||
let params = {
|
||||
page: 1,
|
||||
pageSize: 1,
|
||||
state: 'all',
|
||||
name: form.name,
|
||||
filters: '',
|
||||
orderBy: 'createdAt',
|
||||
order: 'null',
|
||||
};
|
||||
await searchContainer(params).then((res) => {
|
||||
if (res.data.items?.length === 1) {
|
||||
form.containerID = res.data.items[0].containerID;
|
||||
return;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const checkPortValid = () => {
|
||||
if (form.exposedPorts.length === 0) {
|
||||
return true;
|
||||
|
|
@ -727,10 +708,31 @@ const splitStringIgnoringQuotes = (input) => {
|
|||
return result;
|
||||
};
|
||||
|
||||
const checkExist = async () => {
|
||||
let params = {
|
||||
page: 1,
|
||||
pageSize: 1,
|
||||
state: 'all',
|
||||
name: form.name,
|
||||
filters: '',
|
||||
orderBy: 'createdAt',
|
||||
order: 'null',
|
||||
};
|
||||
await searchContainer(params).then((res) => {
|
||||
if (res.data.items?.length === 1) {
|
||||
isCreate.value = false;
|
||||
routerToNameWithQuery('ContainerCreate', { name: form.name, t: Date.now() });
|
||||
return;
|
||||
} else {
|
||||
isCreate.value = true;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
if (router.currentRoute.value.query.containerID) {
|
||||
if (router.currentRoute.value.query.name) {
|
||||
isCreate.value = false;
|
||||
form.containerID = String(router.currentRoute.value.query.containerID);
|
||||
form.name = String(router.currentRoute.value.query.name);
|
||||
} else {
|
||||
isCreate.value = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
>
|
||||
<template #content>
|
||||
<el-alert :closable="false" :title="$t('terminal.localConnJump')" type="info" />
|
||||
<Terminal class="mt-2" style="height: calc(100vh - 160px)" ref="terminalRef"></Terminal>
|
||||
<Terminal class="mt-2" style="height: calc(100vh - 170px)" ref="terminalRef"></Terminal>
|
||||
<div>
|
||||
<el-cascader
|
||||
v-model="quickCmd"
|
||||
|
|
|
|||
|
|
@ -478,7 +478,6 @@ const acceptParams = async (props: OperateRrops) => {
|
|||
searchAppList(null);
|
||||
}
|
||||
} else {
|
||||
console.log(props);
|
||||
searchAppList(props.appID);
|
||||
getRuntime(props.id);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue