Skip to content

Commit 7792601

Browse files
feat: Website list supports filtering by type. (#8414)
Refs #6409
1 parent 52ec3b9 commit 7792601

6 files changed

Lines changed: 49 additions & 26 deletions

File tree

agent/app/dto/request/website.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type WebsiteSearch struct {
1010
OrderBy string `json:"orderBy" validate:"required,oneof=primary_domain type status createdAt expire_date created_at"`
1111
Order string `json:"order" validate:"required,oneof=null ascending descending"`
1212
WebsiteGroupID uint `json:"websiteGroupId"`
13+
Type string `json:"type"`
1314
}
1415

1516
type WebsiteCreate struct {

agent/app/repo/website.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ type IWebsiteRepo interface {
1818
WithDomainLike(domain string) DBOption
1919
WithRuntimeID(runtimeID uint) DBOption
2020
WithParentID(websiteID uint) DBOption
21+
WithType(websiteType string) DBOption
2122

2223
Page(page, size int, opts ...DBOption) (int64, []model.Website, error)
2324
List(opts ...DBOption) ([]model.Website, error)
@@ -93,6 +94,12 @@ func (w *WebsiteRepo) WithDefaultServer() DBOption {
9394
}
9495
}
9596

97+
func (w *WebsiteRepo) WithType(websiteType string) DBOption {
98+
return func(db *gorm.DB) *gorm.DB {
99+
return db.Where("type = ?", websiteType)
100+
}
101+
}
102+
96103
func (w *WebsiteRepo) Page(page, size int, opts ...DBOption) (int64, []model.Website, error) {
97104
var websites []model.Website
98105
db := getDb(opts...).Model(&model.Website{})

agent/app/service/website.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ func (w WebsiteService) PageWebsite(req request.WebsiteSearch) (int64, []respons
150150
if req.WebsiteGroupID != 0 {
151151
opts = append(opts, websiteRepo.WithGroupID(req.WebsiteGroupID))
152152
}
153+
if req.Type != "" {
154+
opts = append(opts, websiteRepo.WithType(req.Type))
155+
}
153156
total, websites, err := websiteRepo.Page(req.Page, req.PageSize, opts...)
154157
if err != nil {
155158
return 0, nil, err

frontend/src/global/mimetype.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,3 +367,27 @@ export const StatusStrategy = [
367367
value: 'backup',
368368
},
369369
];
370+
371+
export const WebsiteTypes = [
372+
{
373+
label: i18n.global.t('website.deployment'),
374+
value: 'deployment',
375+
},
376+
{
377+
label: i18n.global.t('runtime.runtime'),
378+
value: 'runtime',
379+
},
380+
381+
{
382+
label: i18n.global.t('website.proxy'),
383+
value: 'proxy',
384+
},
385+
{
386+
label: i18n.global.t('website.static'),
387+
value: 'static',
388+
},
389+
{
390+
label: i18n.global.t('website.subsite'),
391+
value: 'subsite',
392+
},
393+
];

frontend/src/views/website/website/create/index.vue

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,7 @@
22
<DrawerPro v-model="open" :header="$t('website.create')" size="large" @close="handleClose">
33
<template #buttons>
44
<span class="drawer-header-button">
5-
<template
6-
v-for="item in [
7-
{
8-
label: i18n.global.t('website.deployment'),
9-
value: 'deployment',
10-
},
11-
{
12-
label: i18n.global.t('runtime.runtime'),
13-
value: 'runtime',
14-
},
15-
16-
{
17-
label: i18n.global.t('website.proxy'),
18-
value: 'proxy',
19-
},
20-
{
21-
label: i18n.global.t('website.static'),
22-
value: 'static',
23-
},
24-
{
25-
label: i18n.global.t('website.subsite'),
26-
value: 'subsite',
27-
},
28-
]"
29-
:key="item.value"
30-
>
5+
<template v-for="item in WebsiteTypes" :key="item.value">
316
<el-button
327
:class="website.type === item.value ? 'active-button' : ''"
338
@click="changeType(item.value)"
@@ -572,6 +547,7 @@ import { dateFormatSimple, getProvider, getAccountName } from '@/utils/util';
572547
import { Website } from '@/api/interface/website';
573548
import DomainCreate from '@/views/website/website/domain-create/index.vue';
574549
import { getPathByType } from '@/api/modules/files';
550+
import { WebsiteTypes } from '@/global/mimetype';
575551
576552
const websiteForm = ref<FormInstance>();
577553

frontend/src/views/website/website/index.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@
3333
</el-button>
3434
</template>
3535
<template v-if="!openNginxConfig && nginxIsExist" #rightToolBar>
36+
<el-select class="p-w-200" v-model="req.type" @change="search()" :disabled="nginxStatus != 'Running'">
37+
<template #prefix>{{ $t('commons.table.type') }}</template>
38+
<el-option :label="$t('commons.table.all')" :value="''"></el-option>
39+
<el-option
40+
v-for="item in WebsiteTypes"
41+
:label="item.label"
42+
:value="item.value"
43+
:key="item.value"
44+
></el-option>
45+
</el-select>
3646
<el-select
3747
v-model="req.websiteGroupId"
3848
@change="search()"
@@ -265,6 +275,7 @@ import { useI18n } from 'vue-i18n';
265275
import { getAgentGroupList } from '@/api/modules/group';
266276
import { Group } from '@/api/interface/group';
267277
import { GlobalStore } from '@/store';
278+
import { WebsiteTypes } from '@/global/mimetype';
268279
const globalStore = GlobalStore();
269280
270281
const shortcuts = [
@@ -317,6 +328,7 @@ let req = reactive({
317328
orderBy: 'createdAt',
318329
order: 'null',
319330
websiteGroupId: 0,
331+
type: '',
320332
});
321333
const mobile = computed(() => {
322334
return globalStore.isMobile();

0 commit comments

Comments
 (0)