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

@ -4,11 +4,12 @@ import "time"
type PageContainer struct {
PageInfo
Name string `json:"name"`
State string `json:"state" validate:"required,oneof=all created running paused restarting removing exited dead"`
OrderBy string `json:"orderBy"`
Order string `json:"order"`
Filters string `json:"filters"`
Name string `json:"name"`
State string `json:"state" validate:"required,oneof=all created running paused restarting removing exited dead"`
OrderBy string `json:"orderBy"`
Order string `json:"order"`
Filters string `json:"filters"`
ExcludeAppStore bool `json:"excludeAppStore"`
}
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.Add("label", req.Filters)
}
list, err = client.ContainerList(context.Background(), options)
containers, err := client.ContainerList(context.Background(), options)
if err != nil {
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 {
length, count := len(list), 0
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?',
sockPathErr: 'Please select or enter the correct Docker sock file path',
related: 'Related resources',
includeAppstore: 'Show app store container',
},
cronjob: {
create: 'Create Cronjob',

View File

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

View File

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

View File

@ -6,6 +6,15 @@
<span>{{ $t('container.startIn') }}</span>
</el-card>
<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>
<el-row>
<el-col :xs="24" :sm="16" :md="16" :lg="16" :xl="16">
@ -347,6 +356,7 @@ const searchState = ref('all');
const dialogUpgradeRef = ref();
const dialogPortJumpRef = ref();
const opRef = ref();
const includeAppStore = ref(true);
const dockerStatus = ref('Running');
const loadStatus = async () => {
@ -410,6 +420,7 @@ const search = async (column?: any) => {
filters: filterItem,
orderBy: paginationConfig.orderBy,
order: paginationConfig.order,
excludeAppStore: !includeAppStore.value,
};
loading.value = true;
loadStats();