mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-24 19:19:15 +08:00
fix: 容器删除使用中对象提示信息优化
This commit is contained in:
parent
9080824a59
commit
7c037b68cd
@ -7,6 +7,8 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||||
"github.com/1Panel-dev/1Panel/backend/buserr"
|
||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/docker"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
@ -80,6 +82,9 @@ func (u *ContainerService) DeleteNetwork(req dto.BatchDelete) error {
|
||||
}
|
||||
for _, id := range req.Names {
|
||||
if err := client.NetworkRemove(context.TODO(), id); err != nil {
|
||||
if strings.Contains(err.Error(), "has active endpoints") {
|
||||
return buserr.WithDetail(constant.ErrInUsed, id, nil)
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ func (u *ContainerService) DeleteVolume(req dto.BatchDelete) error {
|
||||
for _, id := range req.Names {
|
||||
if err := client.VolumeRemove(context.TODO(), id, true); err != nil {
|
||||
if strings.Contains(err.Error(), "volume is in use") {
|
||||
return buserr.New(constant.ErrInUsed)
|
||||
return buserr.WithDetail(constant.ErrInUsed, id, nil)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||||
"github.com/1Panel-dev/1Panel/backend/buserr"
|
||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||
"github.com/1Panel-dev/1Panel/backend/global"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/docker"
|
||||
@ -378,8 +379,14 @@ func (u *ImageService) ImageRemove(req dto.BatchDelete) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, ids := range req.Names {
|
||||
if _, err := client.ImageRemove(context.TODO(), ids, types.ImageRemoveOptions{Force: true, PruneChildren: true}); err != nil {
|
||||
for _, id := range req.Names {
|
||||
if _, err := client.ImageRemove(context.TODO(), id, types.ImageRemoveOptions{Force: true, PruneChildren: true}); err != nil {
|
||||
if strings.Contains(err.Error(), "image is being used") {
|
||||
if strings.Contains(id, "sha256:") {
|
||||
return buserr.New(constant.ErrObjectInUsed)
|
||||
}
|
||||
return buserr.WithDetail(constant.ErrInUsed, id, nil)
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -98,5 +98,6 @@ var (
|
||||
|
||||
//container
|
||||
var (
|
||||
ErrInUsed = "ErrInUsed"
|
||||
ErrInUsed = "ErrInUsed"
|
||||
ErrObjectInUsed = "ErrObjectInUsed"
|
||||
)
|
||||
|
@ -55,4 +55,5 @@ ErrDatabaseIsExist: "The current database already exists. Please enter a new dat
|
||||
ErrTypeOfRedis: "The recovery file type does not match the current persistence mode. Modify the file type and try again"
|
||||
|
||||
#container
|
||||
ErrInUsed: "The deleted object is in use and cannot be deleted"
|
||||
ErrInUsed: "{{ .detail }} is in use and cannot be deleted"
|
||||
ErrObjectInUsed: "This object is in use and cannot be deleted"
|
@ -55,4 +55,5 @@ ErrDatabaseIsExist: "当前数据库已存在,请重新输入"
|
||||
ErrTypeOfRedis: "恢复文件类型与当前持久化方式不符,请修改后重试"
|
||||
|
||||
#container
|
||||
ErrInUsed: "该删除对象正被使用,无法删除"
|
||||
ErrInUsed: "{{ .detail }} 正被使用,无法删除"
|
||||
ErrObjectInUsed: "该对象正被使用,无法删除"
|
@ -49,7 +49,9 @@
|
||||
<ComplexTable :pagination-config="paginationConfig" :data="data" @search="search">
|
||||
<el-table-column :label="$t('logs.resource')" prop="group" fix>
|
||||
<template #default="{ row }">
|
||||
{{ $t('logs.detail.' + row.source) }}
|
||||
<span v-if="row.source">
|
||||
{{ $t('logs.detail.' + row.source) }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('logs.operate')" min-width="150px" prop="detailZH">
|
||||
|
@ -49,7 +49,9 @@
|
||||
<el-table-column prop="version" :label="$t('app.version')" />
|
||||
<el-table-column :label="$t('setting.backupAccount')" min-width="80" prop="from">
|
||||
<template #default="{ row }">
|
||||
{{ $t('setting.' + row.from) }}
|
||||
<span v-if="row.from">
|
||||
{{ $t('setting.' + row.from) }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('commons.table.status')" min-width="80" prop="status">
|
||||
|
Loading…
Reference in New Issue
Block a user