1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-19 16:29:17 +08:00

feat: 容器列表增加过滤应用商店容器功能 (#3469)

This commit is contained in:
zhengkunwang 2023-12-28 11:44:11 +08:00 committed by GitHub
parent 9716e3754e
commit 14e2ced3da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 6 deletions

View File

@ -9,6 +9,7 @@ type PageContainer struct {
OrderBy string `json:"orderBy"` OrderBy string `json:"orderBy"`
Order string `json:"order"` Order string `json:"order"`
Filters string `json:"filters"` Filters string `json:"filters"`
ExcludeAppStore bool `json:"excludeAppStore"`
} }
type InspectReq struct { type InspectReq struct {

View File

@ -89,10 +89,21 @@ func (u *ContainerService) Page(req dto.PageContainer) (int64, interface{}, erro
options.Filters = filters.NewArgs() options.Filters = filters.NewArgs()
options.Filters.Add("label", req.Filters) options.Filters.Add("label", req.Filters)
} }
list, err = client.ContainerList(context.Background(), options) containers, err := client.ContainerList(context.Background(), options)
if err != nil { if err != nil {
return 0, nil, err return 0, nil, err
} }
if req.ExcludeAppStore {
for _, item := range containers {
if created, ok := item.Labels[composeCreatedBy]; ok && created == "Apps" {
continue
}
list = append(list, item)
}
} else {
list = containers
}
if len(req.Name) != 0 { if len(req.Name) != 0 {
length, count := len(list), 0 length, count := len(list), 0
for count < length { for count < length {

View File

@ -758,6 +758,7 @@ const message = {
'Saving the Socket Path setting may result in Docker service being unavailable. Do you want to continue?', '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', sockPathErr: 'Please select or enter the correct Docker sock file path',
related: 'Related resources', related: 'Related resources',
includeAppstore: 'Show app store container',
}, },
cronjob: { cronjob: {
create: 'Create Cronjob', create: 'Create Cronjob',

View File

@ -729,6 +729,7 @@ const message = {
sockPathMsg: '保存設定 Socket 路徑可能導致 Docker 服務不可用是否繼續', sockPathMsg: '保存設定 Socket 路徑可能導致 Docker 服務不可用是否繼續',
sockPathErr: '請選擇或輸入正確的 Docker sock 文件路徑', sockPathErr: '請選擇或輸入正確的 Docker sock 文件路徑',
related: '相關資源', related: '相關資源',
includeAppstore: '顯示應用程式商店容器',
}, },
cronjob: { cronjob: {
create: '創建計劃任務', create: '創建計劃任務',

View File

@ -730,6 +730,7 @@ const message = {
sockPathMsg: '保存设置 Socket 路径可能导致 Docker 服务不可用是否继续', sockPathMsg: '保存设置 Socket 路径可能导致 Docker 服务不可用是否继续',
sockPathErr: '请选择或输入正确的 Docker sock 文件路径', sockPathErr: '请选择或输入正确的 Docker sock 文件路径',
related: '关联资源', related: '关联资源',
includeAppstore: '显示应用商店容器',
}, },
cronjob: { cronjob: {
create: '创建计划任务', create: '创建计划任务',

View File

@ -6,6 +6,15 @@
<span>{{ $t('container.startIn') }}</span> <span>{{ $t('container.startIn') }}</span>
</el-card> </el-card>
<LayoutContent :title="$t('container.container')" :class="{ mask: dockerStatus != 'Running' }"> <LayoutContent :title="$t('container.container')" :class="{ mask: dockerStatus != 'Running' }">
<template #rightButton>
<div class="flex justify-end">
<div class="mr-10">
<el-checkbox v-model="includeAppStore" @change="search()">
{{ $t('container.includeAppstore') }}
</el-checkbox>
</div>
</div>
</template>
<template #toolbar> <template #toolbar>
<el-row> <el-row>
<el-col :xs="24" :sm="16" :md="16" :lg="16" :xl="16"> <el-col :xs="24" :sm="16" :md="16" :lg="16" :xl="16">
@ -347,6 +356,7 @@ const searchState = ref('all');
const dialogUpgradeRef = ref(); const dialogUpgradeRef = ref();
const dialogPortJumpRef = ref(); const dialogPortJumpRef = ref();
const opRef = ref(); const opRef = ref();
const includeAppStore = ref(true);
const dockerStatus = ref('Running'); const dockerStatus = ref('Running');
const loadStatus = async () => { const loadStatus = async () => {
@ -410,6 +420,7 @@ const search = async (column?: any) => {
filters: filterItem, filters: filterItem,
orderBy: paginationConfig.orderBy, orderBy: paginationConfig.orderBy,
order: paginationConfig.order, order: paginationConfig.order,
excludeAppStore: !includeAppStore.value,
}; };
loading.value = true; loading.value = true;
loadStats(); loadStats();