fix: 解决容器存储卷创建时间加载错误的问题 (#3169)

Refs #3147
pull/3171/head
ssongliu 2023-12-04 17:20:10 +08:00 committed by GitHub
parent a09fd97b10
commit 86d5a68cd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 7 deletions

View File

@ -9,6 +9,7 @@ import (
"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/common"
"github.com/1Panel-dev/1Panel/backend/utils/docker"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/volume"
@ -51,15 +52,20 @@ func (u *ContainerService) PageVolume(req dto.SearchWithPage) (int64, interface{
records = list.Volumes[start:end]
}
nyc, _ := time.LoadLocation(common.LoadTimeZone())
for _, item := range records {
tag := make([]string, 0)
for _, val := range item.Labels {
tag = append(tag, val)
}
if len(item.CreatedAt) > 19 {
item.CreatedAt = item.CreatedAt[0:19]
var createTime time.Time
if strings.Contains(item.CreatedAt, "Z") {
createTime, _ = time.ParseInLocation("2006-01-02T15:04:05Z", item.CreatedAt, nyc)
} else if strings.Contains(item.CreatedAt, "+") {
createTime, _ = time.ParseInLocation("2006-01-02T15:04:05+08:00", item.CreatedAt, nyc)
} else {
createTime, _ = time.ParseInLocation("2006-01-02T15:04:05", item.CreatedAt, nyc)
}
createTime, _ := time.Parse("2006-01-02T15:04:05", item.CreatedAt)
data = append(data, dto.Volume{
CreatedAt: createTime,
Name: item.Name,

View File

@ -332,7 +332,7 @@ func (f *FileService) ReadLogByLine(req request.FileReadByLineReq) (*response.Fi
logFilePath = ssl.GetLogPath()
case constant.TypeSystem:
fileName := ""
if req.Name == time.Now().Format("2006-01-02") {
if len(req.Name) == 0 || req.Name == time.Now().Format("2006-01-02") {
fileName = "1Panel.log"
} else {
fileName = "1Panel-" + req.Name + ".log"

View File

@ -391,7 +391,7 @@ func (u *ImageService) ImageRemove(req dto.BatchDelete) error {
}
for _, id := range req.Names {
if _, err := client.ImageRemove(context.TODO(), id, types.ImageRemoveOptions{Force: req.Force, PruneChildren: true}); err != nil {
if strings.Contains(err.Error(), "image is being used") {
if strings.Contains(err.Error(), "image is being used") || strings.Contains(err.Error(), "is using") {
if strings.Contains(id, "sha256:") {
return buserr.New(constant.ErrObjectInUsed)
}

View File

@ -95,7 +95,7 @@ const globalStore = GlobalStore();
const terminalSocket = ref<WebSocket>();
const logSearch = reactive({
isWatch: false,
isWatch: true,
container: '',
containerID: '',
mode: 'all',
@ -197,7 +197,7 @@ const acceptParams = (props: DialogProps): void => {
logSearch.containerID = props.containerID;
logSearch.tail = 100;
logSearch.mode = 'all';
logSearch.isWatch = false;
logSearch.isWatch = true;
logSearch.container = props.container;
searchLogs();