From 83199c41cba3f95320b568dc06b049b6763e28f5 Mon Sep 17 00:00:00 2001 From: zhengkunwang223 Date: Fri, 30 Dec 2022 16:13:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=BD=91=E7=AB=99=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=92=8C=E5=88=86=E7=BB=84=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/dto/request/website.go | 2 + backend/app/repo/website.go | 9 ++- backend/app/service/website.go | 15 +++- frontend/src/api/interface/website.ts | 1 + frontend/src/lang/modules/zh.ts | 1 + frontend/src/styles/common.scss | 5 ++ frontend/src/views/app-store/apps/index.vue | 5 ++ .../src/views/app-store/installed/index.vue | 20 +++--- frontend/src/views/website/website/index.vue | 68 ++++++++++++++++--- 9 files changed, 101 insertions(+), 25 deletions(-) diff --git a/backend/app/dto/request/website.go b/backend/app/dto/request/website.go index ecb38844e..a546bb7a6 100644 --- a/backend/app/dto/request/website.go +++ b/backend/app/dto/request/website.go @@ -6,6 +6,8 @@ import ( type WebsiteSearch struct { dto.PageInfo + Name string `json:"name"` + WebsiteGroupID uint `json:"websiteGroupId"` } type WebsiteCreate struct { diff --git a/backend/app/repo/website.go b/backend/app/repo/website.go index cb891ed26..772efcd65 100644 --- a/backend/app/repo/website.go +++ b/backend/app/repo/website.go @@ -13,6 +13,7 @@ type IWebsiteRepo interface { WithDomain(domain string) DBOption WithAlias(alias string) DBOption WithWebsiteSSLID(sslId uint) DBOption + WithGroupID(groupId uint) DBOption Page(page, size int, opts ...DBOption) (int64, []model.Website, error) List(opts ...DBOption) ([]model.Website, error) GetFirst(opts ...DBOption) (model.Website, error) @@ -49,7 +50,13 @@ func (w *WebsiteRepo) WithAlias(alias string) DBOption { func (w *WebsiteRepo) WithWebsiteSSLID(sslId uint) DBOption { return func(db *gorm.DB) *gorm.DB { - return db.Where("web_site_ssl_id = ?", sslId) + return db.Where("website_ssl_id = ?", sslId) + } +} + +func (w *WebsiteRepo) WithGroupID(groupId uint) DBOption { + return func(db *gorm.DB) *gorm.DB { + return db.Where("website_group_id = ?", groupId) } } diff --git a/backend/app/service/website.go b/backend/app/service/website.go index a318157f1..5313949dd 100644 --- a/backend/app/service/website.go +++ b/backend/app/service/website.go @@ -8,6 +8,7 @@ import ( "fmt" "github.com/1Panel-dev/1Panel/backend/app/dto/request" "github.com/1Panel-dev/1Panel/backend/app/dto/response" + "github.com/1Panel-dev/1Panel/backend/app/repo" "github.com/1Panel-dev/1Panel/backend/buserr" "os" "path" @@ -55,8 +56,18 @@ func NewWebsiteService() IWebsiteService { } func (w WebsiteService) PageWebsite(req request.WebsiteSearch) (int64, []response.WebsiteDTO, error) { - var websiteDTOs []response.WebsiteDTO - total, websites, err := websiteRepo.Page(req.Page, req.PageSize) + var ( + websiteDTOs []response.WebsiteDTO + opts []repo.DBOption + ) + opts = append(opts, commonRepo.WithOrderBy("created_at desc")) + if req.Name != "" { + opts = append(opts, websiteRepo.WithDomain(req.Name)) + } + if req.WebsiteGroupID != 0 { + opts = append(opts, websiteRepo.WithGroupID(req.WebsiteGroupID)) + } + total, websites, err := websiteRepo.Page(req.Page, req.PageSize, opts...) if err != nil { return 0, nil, err } diff --git a/frontend/src/api/interface/website.ts b/frontend/src/api/interface/website.ts index d20e952fa..fb2059c5a 100644 --- a/frontend/src/api/interface/website.ts +++ b/frontend/src/api/interface/website.ts @@ -29,6 +29,7 @@ export namespace Website { export interface WebSiteSearch extends ReqPage { name: string; + websiteGroupId: number; } export interface WebSiteRecover { diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index bb485fb1b..8682f3dc7 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -949,6 +949,7 @@ export default { data: '数据', ever: '永久', nextYear: '一年后', + allGroup: '所有分组', }, nginx: { serverNamesHashBucketSizeHelper: '服务器名字的hash表大小', diff --git a/frontend/src/styles/common.scss b/frontend/src/styles/common.scss index d7da66764..1269917cf 100644 --- a/frontend/src/styles/common.scss +++ b/frontend/src/styles/common.scss @@ -186,3 +186,8 @@ left: 50%; transform: translate(-50%, -50%); } + +.table-button { + display: inline; + margin-right: 5px; +} diff --git a/frontend/src/views/app-store/apps/index.vue b/frontend/src/views/app-store/apps/index.vue index 9e5b7ac07..1fa3ff6d7 100644 --- a/frontend/src/views/app-store/apps/index.vue +++ b/frontend/src/views/app-store/apps/index.vue @@ -200,4 +200,9 @@ onMounted(() => { .a-card:hover { transform: scale(1.1); } + +.table-button { + display: inline; + margin-right: 5px; +} diff --git a/frontend/src/views/app-store/installed/index.vue b/frontend/src/views/app-store/installed/index.vue index ab363b10f..8ebe216ba 100644 --- a/frontend/src/views/app-store/installed/index.vue +++ b/frontend/src/views/app-store/installed/index.vue @@ -8,17 +8,8 @@
- - + + {{ $t('app.search') }}
@@ -302,7 +293,7 @@ onUnmounted(() => { }); - diff --git a/frontend/src/views/website/website/index.vue b/frontend/src/views/website/website/index.vue index 2331e8134..de84320c5 100644 --- a/frontend/src/views/website/website/index.vue +++ b/frontend/src/views/website/website/index.vue @@ -8,10 +8,40 @@ = new Map(); +let groups = ref([]); const paginationConfig = reactive({ currentPage: 1, pageSize: 20, total: 0, }); +let req = reactive({ + name: '', + page: paginationConfig.currentPage, + pageSize: paginationConfig.pageSize, + websiteGroupId: 0, +}); const search = async () => { - const req = { - name: '', - page: paginationConfig.currentPage, - pageSize: paginationConfig.pageSize, - }; + req.page = paginationConfig.currentPage; + req.pageSize = paginationConfig.currentPage; SearchWebsites(req).then((res) => { data.value = res.data.items; paginationConfig.total = res.data.total; }); }; + +const listGroup = async () => { + await ListGroups().then((res) => { + groups.value = res.data; + }); +}; + const setting = () => { openNginxConfig.value = true; }; @@ -314,5 +355,12 @@ const opWebsite = (op: string, id: number) => { onMounted(() => { search(); + listGroup(); }); +