From 4c19529152cd47d6fc25e650475ec608c2e569c6 Mon Sep 17 00:00:00 2001 From: Anil Durmus Date: Thu, 23 Feb 2023 15:31:31 +0300 Subject: [PATCH 1/3] push --- api/internal/handler/route/route.go | 17 +++++++++++++++++ api/internal/handler/service/service.go | 10 ++++++++++ api/internal/handler/upstream/upstream.go | 9 +++++++++ web/src/pages/Route/List.tsx | 4 +--- web/src/pages/Route/service.ts | 5 ++++- web/src/pages/Service/List.tsx | 4 +--- web/src/pages/Service/service.ts | 2 ++ web/src/pages/Upstream/List.tsx | 2 -- web/src/pages/Upstream/service.ts | 2 ++ 9 files changed, 46 insertions(+), 9 deletions(-) diff --git a/api/internal/handler/route/route.go b/api/internal/handler/route/route.go index fae4429d99..d100c85b40 100644 --- a/api/internal/handler/route/route.go +++ b/api/internal/handler/route/route.go @@ -194,6 +194,9 @@ type ListInput struct { URI string `auto_read:"uri,query"` Label string `auto_read:"label,query"` Status string `auto_read:"status,query"` + Host string `auto_read:"host,query"` + ID string `auto_read:"id,query"` + Desc string `auto_read:"desc,query"` store.Pagination } @@ -236,6 +239,20 @@ func (h *Handler) List(c droplet.Context) (interface{}, error) { return false } + if input.Host != "" && !strings.Contains(obj.(*entity.Route).Host, input.Host) { + return false + } + + if input.Desc != "" && !strings.Contains(obj.(*entity.Route).Desc, input.Desc) { + return false + } + + if obj != nil && obj.(*entity.Route) != nil && obj.(*entity.Route).ID != nil && input.ID != "" { + if !strings.Contains(utils.InterfaceToString(obj.(*entity.Route).ID), input.ID) { + return false // IDs do not match, so object should not be included in the filtered result + } + } + return true }, Format: func(obj interface{}) interface{} { diff --git a/api/internal/handler/service/service.go b/api/internal/handler/service/service.go index fe382b0685..ab94bfd804 100644 --- a/api/internal/handler/service/service.go +++ b/api/internal/handler/service/service.go @@ -90,6 +90,8 @@ func (h *Handler) Get(c droplet.Context) (interface{}, error) { type ListInput struct { Name string `auto_read:"name,query"` + ID string `auto_read:"id,query"` + Desc string `auto_read:"desc,query"` store.Pagination } @@ -135,6 +137,14 @@ func (h *Handler) List(c droplet.Context) (interface{}, error) { if input.Name != "" { return strings.Contains(obj.(*entity.Service).Name, input.Name) } + + if input.Desc != "" { + return strings.Contains(obj.(*entity.Service).Desc, input.Desc) + } + + if input.ID != "" { + return strings.Contains(utils.InterfaceToString(obj.(*entity.Service).ID), input.ID) + } return true }, Format: func(obj interface{}) interface{} { diff --git a/api/internal/handler/upstream/upstream.go b/api/internal/handler/upstream/upstream.go index 3157fdda8d..55c08a50bd 100644 --- a/api/internal/handler/upstream/upstream.go +++ b/api/internal/handler/upstream/upstream.go @@ -96,6 +96,8 @@ func (h *Handler) Get(c droplet.Context) (interface{}, error) { type ListInput struct { Name string `auto_read:"name,query"` + ID string `auto_read:"id,query"` + Desc string `auto_read:"desc,query"` store.Pagination } @@ -141,6 +143,13 @@ func (h *Handler) List(c droplet.Context) (interface{}, error) { if input.Name != "" { return strings.Contains(obj.(*entity.Upstream).Name, input.Name) } + + if input.Desc != "" { + return strings.Contains(obj.(*entity.Upstream).Desc, input.Desc) + } + if input.ID != "" { + return strings.Contains(utils.InterfaceToString(obj.(*entity.Upstream).ID), input.ID) + } return true }, Format: func(obj interface{}) interface{} { diff --git a/web/src/pages/Route/List.tsx b/web/src/pages/Route/List.tsx index cbacd4f259..7ff4d7de2a 100755 --- a/web/src/pages/Route/List.tsx +++ b/web/src/pages/Route/List.tsx @@ -322,13 +322,12 @@ const Page: React.FC = () => { }, { title: formatMessage({ id: 'component.global.id' }), - hideInSearch: true, dataIndex: 'id', width: 200, }, { title: formatMessage({ id: 'page.route.host' }), - hideInSearch: true, + dataIndex: 'host', width: 224, render: (_, record) => { const list = record.hosts || (record.host && [record.host]) || []; @@ -361,7 +360,6 @@ const Page: React.FC = () => { { title: formatMessage({ id: 'component.global.description' }), dataIndex: 'desc', - hideInSearch: true, ellipsis: true, width: 200, }, diff --git a/web/src/pages/Route/service.ts b/web/src/pages/Route/service.ts index dbd182a503..794db91598 100644 --- a/web/src/pages/Route/service.ts +++ b/web/src/pages/Route/service.ts @@ -41,7 +41,7 @@ export const fetchItem = (rid: number) => request(`/routes/${rid}`).then((data) => transformRouteData(data.data)); export const fetchList = ({ current = 1, pageSize = 10, ...res }) => { - const { labels = [], API_VERSION = [], status } = res; + const { labels = [], API_VERSION = [], host = "", id = "", desc = "", status} = res; return request>>('/routes', { params: { @@ -51,6 +51,9 @@ export const fetchList = ({ current = 1, pageSize = 10, ...res }) => { page: current, page_size: pageSize, status, + host, + desc, + id, }, }).then(({ data }) => { return { diff --git a/web/src/pages/Service/List.tsx b/web/src/pages/Service/List.tsx index c509a95b65..05feb47aab 100644 --- a/web/src/pages/Service/List.tsx +++ b/web/src/pages/Service/List.tsx @@ -42,9 +42,8 @@ const Page: React.FC = () => { const columns: ProColumns[] = [ { - title: 'ID', + title: formatMessage({ id: 'component.global.id' }), dataIndex: 'id', - hideInSearch: true, }, { title: formatMessage({ id: 'component.global.name' }), @@ -53,7 +52,6 @@ const Page: React.FC = () => { { title: formatMessage({ id: 'component.global.description' }), dataIndex: 'desc', - hideInSearch: true, }, { title: formatMessage({ id: 'component.global.operation' }), diff --git a/web/src/pages/Service/service.ts b/web/src/pages/Service/service.ts index b652335601..def2860b3b 100644 --- a/web/src/pages/Service/service.ts +++ b/web/src/pages/Service/service.ts @@ -21,6 +21,8 @@ import { transformData } from './transform'; export const fetchList = ({ current = 1, pageSize = 10, ...res }) => request('/services', { params: { + id: res.id || '', + desc: res.desc || '', name: res.name, page: current, page_size: pageSize, diff --git a/web/src/pages/Upstream/List.tsx b/web/src/pages/Upstream/List.tsx index c593b1eabc..5c31749d67 100644 --- a/web/src/pages/Upstream/List.tsx +++ b/web/src/pages/Upstream/List.tsx @@ -45,7 +45,6 @@ const Page: React.FC = () => { { title: formatMessage({ id: 'page.upstream.list.id' }), dataIndex: 'id', - hideInSearch: true, }, { title: formatMessage({ id: 'page.upstream.list.name' }), @@ -59,7 +58,6 @@ const Page: React.FC = () => { { title: formatMessage({ id: 'page.upstream.list.description' }), dataIndex: 'desc', - hideInSearch: true, }, { title: formatMessage({ id: 'page.upstream.list.edit.time' }), diff --git a/web/src/pages/Upstream/service.ts b/web/src/pages/Upstream/service.ts index a04925fdc6..a4d5ffefbe 100644 --- a/web/src/pages/Upstream/service.ts +++ b/web/src/pages/Upstream/service.ts @@ -21,6 +21,8 @@ import { convertToFormData } from '@/components/Upstream/service'; export const fetchList = ({ current = 1, pageSize = 10, ...res }) => { return request>>('/upstreams', { params: { + id: res.id || '', + desc: res.desc || '', name: res.name, page: current, page_size: pageSize, From 4bbf1c808c478deb9c3f0291ba734be810d0b3d0 Mon Sep 17 00:00:00 2001 From: Anil Durmus Date: Wed, 1 Mar 2023 14:36:45 +0200 Subject: [PATCH 2/3] e2e test added --- web/cypress/e2e/route/search-route.cy.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/cypress/e2e/route/search-route.cy.js b/web/cypress/e2e/route/search-route.cy.js index d947d977a7..65e02323dc 100644 --- a/web/cypress/e2e/route/search-route.cy.js +++ b/web/cypress/e2e/route/search-route.cy.js @@ -148,6 +148,8 @@ context('Create and Search Route', () => { cy.contains('Route').click(); cy.wait(timeout); // full match + // expand search + cy.get(selector.expandSearch).click(); cy.get(selector.pathSearchInput).type(data.uris1); cy.contains('Search').click(); cy.contains(data.uris1).should('contain', data.uris1); From 34e6ecf89dd5182c0d114c42928ab2d05c83dfa0 Mon Sep 17 00:00:00 2001 From: Anil Durmus Date: Wed, 1 Mar 2023 15:15:48 +0200 Subject: [PATCH 3/3] e2e test : waiting for deletion --- web/cypress/e2e/route/search-route.cy.js | 1 + 1 file changed, 1 insertion(+) diff --git a/web/cypress/e2e/route/search-route.cy.js b/web/cypress/e2e/route/search-route.cy.js index 65e02323dc..622881437d 100644 --- a/web/cypress/e2e/route/search-route.cy.js +++ b/web/cypress/e2e/route/search-route.cy.js @@ -199,6 +199,7 @@ context('Create and Search Route', () => { force: true, multiple: true, }); + cy.wait(timeout); } }); });