fix: 修复非运行状态容器删除失败的问题

This commit is contained in:
ssongliu 2022-12-02 11:34:08 +08:00
parent 9f5cc07e9f
commit 9fcd3c78e1
5 changed files with 23 additions and 8 deletions

View file

@ -188,7 +188,7 @@ func (u *ContainerService) ContainerOperation(req dto.ContainerOperation) error
case constant.ContainerOpRename:
err = client.ContainerRename(ctx, req.ContainerID, req.NewName)
case constant.ContainerOpRemove:
err = client.ContainerRemove(ctx, req.ContainerID, types.ContainerRemoveOptions{RemoveVolumes: true, RemoveLinks: true, Force: true})
err = client.ContainerRemove(ctx, req.ContainerID, types.ContainerRemoveOptions{RemoveVolumes: true, Force: true})
}
return err
}

View file

@ -102,6 +102,7 @@ export namespace Container {
export interface NetworkInfo {
id: string;
name: string;
isSystem: boolean;
labels: Array<string>;
driver: string;
ipamDriver: string;

View file

@ -7,9 +7,11 @@
</template>
<div>
<span style="font-size: 12px">{{ operationInfo }}</span>
<el-input v-model="submitInput"></el-input>
<span style="font-size: 12px">{{ $t('commons.msg.operateConfirm') }}</span>
<span style="font-size: 12px; color: red; font-weight: 500">'{{ submitInputInfo }}'</span>
<div style="margin-top: 10px">
<span style="font-size: 12px">{{ $t('commons.msg.operateConfirm') }}</span>
<span style="font-size: 12px; color: red; font-weight: 500">'{{ submitInputInfo }}'</span>
</div>
<el-input style="margin-top: 10px" v-model="submitInput"></el-input>
</div>
<template #footer>
<span class="dialog-footer">

View file

@ -11,10 +11,11 @@
{{ $t('commons.button.delete') }}
</el-button>
</template>
<el-table-column type="selection" fix />
<el-table-column type="selection" :selectable="selectable" fix />
<el-table-column :label="$t('commons.table.name')" show-overflow-tooltip min-width="80" prop="name" fix>
<template #default="{ row }">
<el-link @click="onInspect(row.id)" type="primary">{{ row.name }}</el-link>
<el-tag effect="dark" round v-if="row.isSystem" style="margin-left: 5px">system</el-tag>
</template>
</el-table-column>
<el-table-column :label="$t('container.driver')" show-overflow-tooltip min-width="40" prop="driver" />
@ -81,6 +82,10 @@ const onCreate = async () => {
dialogCreateRef.value!.acceptParams();
};
function selectable(row) {
return !row.isSystem;
}
const search = async () => {
const params = {
page: paginationConfig.page,
@ -89,6 +94,9 @@ const search = async () => {
await searchNetwork(params).then((res) => {
if (res.data) {
data.value = res.data.items;
for (const item of data.value) {
item.isSystem = isSystem(item.name);
}
}
paginationConfig.total = res.data.total;
});
@ -117,12 +125,19 @@ const onInspect = async (id: string) => {
codemirror.value!.acceptParams(param);
};
function isSystem(val: string) {
return val === 'bridge' || val === '1panel' || val === 'none' || val === 'host';
}
const buttons = [
{
label: i18n.global.t('commons.button.delete'),
click: (row: Container.NetworkInfo) => {
batchDelete(row);
},
disabled: (row: any) => {
return row.isSystem;
},
},
];

View file

@ -66,9 +66,6 @@
<div class="login-border"></div>
<div class="login-welcome">{{ $t('commons.login.codeInput') }}</div>
<div class="login-form">
<el-form-item>
<span style="font-size: 14px">Secret: {{ mfaLoginForm.secret }}</span>
</el-form-item>
<el-form-item>
<el-input
size="default"