feat: 容器列表增加关联资源展示 (#3465)

Refs https://github.com/1Panel-dev/1Panel/issues/659
pull/3469/head
zhengkunwang 11 months ago committed by GitHub
parent aaafeb039e
commit 9716e3754e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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 {

@ -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 {

@ -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',

@ -728,6 +728,7 @@ const message = {
sockPathHelper1: '/var/run/docker-x.sock',
sockPathMsg: ' Socket Docker ',
sockPathErr: ' Docker sock ',
related: '',
},
cronjob: {
create: '',

@ -729,6 +729,7 @@ const message = {
sockPathHelper1: '/var/run/docker.sock',
sockPathMsg: ' Socket Docker ',
sockPathErr: ' Docker sock ',
related: '',
},
cronjob: {
create: '',

@ -76,15 +76,16 @@
@sort-change="search"
@search="search"
:row-style="{ height: '65px' }"
style="width: 100%"
>
<el-table-column type="selection" fix />
<el-table-column type="selection" />
<el-table-column
:label="$t('commons.table.name')"
:width="mobile ? 300 : 'auto'"
min-width="80"
:width="mobile ? 300 : '200'"
min-width="100"
prop="name"
sortable
fix
:fixed="mobile ? 'false' : 'left'"
>
<template #default="{ row }">
<Tooltip @click="onInspect(row.containerID)" :text="row.name" />
@ -93,15 +94,15 @@
<el-table-column
:label="$t('container.image')"
show-overflow-tooltip
min-width="80"
min-width="150"
prop="imageName"
/>
<el-table-column :label="$t('commons.table.status')" min-width="70" prop="state" sortable fix>
<el-table-column :label="$t('commons.table.status')" min-width="100" prop="state" sortable>
<template #default="{ row }">
<Status :key="row.state" :status="row.state"></Status>
</template>
</el-table-column>
<el-table-column :label="$t('container.source')" show-overflow-tooltip min-width="80" fix>
<el-table-column :label="$t('container.source')" show-overflow-tooltip min-width="100">
<template #default="{ row }">
<div v-if="row.hasLoad">
<div class="source-font">CPU: {{ row.cpuPercent.toFixed(2) }}%</div>
@ -174,17 +175,56 @@
</div>
</template>
</el-table-column>
<el-table-column :label="$t('container.ip')" :width="mobile ? 80 : 'auto'" min-width="70" fix>
<el-table-column :label="$t('container.ip')" :width="mobile ? 80 : 'auto'" min-width="100" fix>
<template #default="{ row }">
<div v-if="row.network">
<div v-for="(item, index) in row.network" :key="index">{{ item }}</div>
</div>
</template>
</el-table-column>
<el-table-column :label="$t('container.related')" min-width="200">
<template #default="{ row }">
<el-tooltip
v-if="row.appName != ''"
:hide-after="20"
:content="row.appName"
placement="top"
>
<el-button
icon="Position"
type="primary"
plain
size="small"
@click="router.push({ name: 'AppInstalled' })"
>
{{ $t('app.app') }}: {{ row.appName }} [{{ row.appInstallName }}]
</el-button>
</el-tooltip>
<el-tooltip
v-if="row.websites != null"
:hide-after="20"
:content="row.websites.join(',')"
placement="top"
class="mt-1"
>
<el-button
icon="Position"
type="primary"
plain
size="small"
@click="router.push({ name: 'Website' })"
>
{{ $t('website.website') }}:
{{ row.websites.join(',') }}
</el-button>
</el-tooltip>
</template>
</el-table-column>
<el-table-column
:label="$t('commons.table.port')"
:width="mobile ? 260 : 'auto'"
min-width="130"
min-width="200"
prop="ports"
fix
>
@ -225,7 +265,7 @@
</el-table-column>
<el-table-column
:label="$t('container.upTime')"
min-width="80"
min-width="200"
show-overflow-tooltip
prop="runTime"
fix
@ -235,7 +275,7 @@
:ellipsis="2"
:buttons="buttons"
:label="$t('commons.table.operate')"
fix
fixed="right"
/>
</ComplexTable>
</template>

Loading…
Cancel
Save