From 9716e3754e91f50f10db972a617a6568ca357543 Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Wed, 27 Dec 2023 22:38:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=B9=E5=99=A8=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=85=B3=E8=81=94=E8=B5=84=E6=BA=90=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=20(#3465)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs https://github.com/1Panel-dev/1Panel/issues/659 --- backend/app/dto/container.go | 4 ++ backend/app/service/container.go | 12 +++- frontend/src/lang/modules/en.ts | 1 + frontend/src/lang/modules/tw.ts | 1 + frontend/src/lang/modules/zh.ts | 1 + .../src/views/container/container/index.vue | 62 +++++++++++++++---- 6 files changed, 69 insertions(+), 12 deletions(-) diff --git a/backend/app/dto/container.go b/backend/app/dto/container.go index 66f55f498..5ed8280c3 100644 --- a/backend/app/dto/container.go +++ b/backend/app/dto/container.go @@ -30,6 +30,10 @@ type ContainerInfo struct { IsFromApp bool `json:"isFromApp"` IsFromCompose bool `json:"isFromCompose"` + + AppName string `json:"appName"` + AppInstallName string `json:"appInstallName"` + Websites []string `json:"websites"` } type ResourceLimit struct { diff --git a/backend/app/service/container.go b/backend/app/service/container.go index f17e67cbd..9796ae822 100644 --- a/backend/app/service/container.go +++ b/backend/app/service/container.go @@ -162,7 +162,7 @@ func (u *ContainerService) Page(req dto.PageContainer) (int64, interface{}, erro } ports := loadContainerPort(item.Ports) - backDatas[i] = dto.ContainerInfo{ + info := dto.ContainerInfo{ ContainerID: item.ID, CreateTime: time.Unix(item.Created, 0).Format("2006-01-02 15:04:05"), Name: item.Names[0][1:], @@ -174,6 +174,16 @@ func (u *ContainerService) Page(req dto.PageContainer) (int64, interface{}, erro IsFromApp: IsFromApp, IsFromCompose: IsFromCompose, } + install, _ := appInstallRepo.GetFirst(appInstallRepo.WithContainerName(info.Name)) + if install.ID > 0 { + info.AppInstallName = install.Name + info.AppName = install.App.Name + websites, _ := websiteRepo.GetBy(websiteRepo.WithAppInstallId(install.ID)) + for _, website := range websites { + info.Websites = append(info.Websites, website.PrimaryDomain) + } + } + backDatas[i] = info if item.NetworkSettings != nil && len(item.NetworkSettings.Networks) > 0 { networks := make([]string, 0, len(item.NetworkSettings.Networks)) for key := range item.NetworkSettings.Networks { diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 0cc732196..5acb1cfed 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -757,6 +757,7 @@ const message = { sockPathMsg: 'Saving the Socket Path setting may result in Docker service being unavailable. Do you want to continue?', sockPathErr: 'Please select or enter the correct Docker sock file path', + related: 'Related resources', }, cronjob: { create: 'Create Cronjob', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index ff6a8e9c7..3c2ecec7a 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -728,6 +728,7 @@ const message = { sockPathHelper1: '默認路徑:/var/run/docker-x.sock', sockPathMsg: '保存設定 Socket 路徑可能導致 Docker 服務不可用,是否繼續?', sockPathErr: '請選擇或輸入正確的 Docker sock 文件路徑', + related: '相關資源', }, cronjob: { create: '創建計劃任務', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 5963c8cba..f1442c4eb 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -729,6 +729,7 @@ const message = { sockPathHelper1: '默认路径:/var/run/docker.sock', sockPathMsg: '保存设置 Socket 路径可能导致 Docker 服务不可用,是否继续?', sockPathErr: '请选择或输入正确的 Docker sock 文件路径', + related: '关联资源', }, cronjob: { create: '创建计划任务', diff --git a/frontend/src/views/container/container/index.vue b/frontend/src/views/container/container/index.vue index 9955aa8ae..c054872d6 100644 --- a/frontend/src/views/container/container/index.vue +++ b/frontend/src/views/container/container/index.vue @@ -76,15 +76,16 @@ @sort-change="search" @search="search" :row-style="{ height: '65px' }" + style="width: 100%" > - + @@ -93,15 +94,15 @@ - + - + CPU: {{ row.cpuPercent.toFixed(2) }}% @@ -174,17 +175,56 @@ - + {{ item }} + + + + + {{ $t('app.app') }}: {{ row.appName }} [{{ row.appInstallName }}] + + + + + + {{ $t('website.website') }}: + {{ row.websites.join(',') }} + + + + @@ -225,7 +265,7 @@