From 08fe53d8859d5265c999e5ae8f5277a6257d1eaa Mon Sep 17 00:00:00 2001 From: Tay Yi Hsuen Date: Thu, 26 Oct 2023 23:44:38 +0800 Subject: [PATCH 1/3] Fix service name errors on ingress files (#194) --- deployment/gke-prod-manifests/frontend-ingress.yaml | 2 +- deployment/gke-prod-manifests/gateway-http-ingress.yaml | 2 +- .../gke-prod-manifests/gateway-wscollaboration-ingress.yaml | 2 +- deployment/gke-prod-manifests/gateway-wsmatch-ingress.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deployment/gke-prod-manifests/frontend-ingress.yaml b/deployment/gke-prod-manifests/frontend-ingress.yaml index 86a8e8a7..c99b9e91 100644 --- a/deployment/gke-prod-manifests/frontend-ingress.yaml +++ b/deployment/gke-prod-manifests/frontend-ingress.yaml @@ -8,6 +8,6 @@ metadata: spec: defaultBackend: service: - name: frontend-service + name: frontend port: number: 3000 diff --git a/deployment/gke-prod-manifests/gateway-http-ingress.yaml b/deployment/gke-prod-manifests/gateway-http-ingress.yaml index 2af19c15..cb6434ae 100644 --- a/deployment/gke-prod-manifests/gateway-http-ingress.yaml +++ b/deployment/gke-prod-manifests/gateway-http-ingress.yaml @@ -8,6 +8,6 @@ metadata: spec: defaultBackend: service: - name: frontend-service + name: gateway port: number: 4000 diff --git a/deployment/gke-prod-manifests/gateway-wscollaboration-ingress.yaml b/deployment/gke-prod-manifests/gateway-wscollaboration-ingress.yaml index 72714ddc..b3900773 100644 --- a/deployment/gke-prod-manifests/gateway-wscollaboration-ingress.yaml +++ b/deployment/gke-prod-manifests/gateway-wscollaboration-ingress.yaml @@ -8,6 +8,6 @@ metadata: spec: defaultBackend: service: - name: gateway-service + name: gateway port: number: 4003 diff --git a/deployment/gke-prod-manifests/gateway-wsmatch-ingress.yaml b/deployment/gke-prod-manifests/gateway-wsmatch-ingress.yaml index 3f6c2064..5aea8575 100644 --- a/deployment/gke-prod-manifests/gateway-wsmatch-ingress.yaml +++ b/deployment/gke-prod-manifests/gateway-wsmatch-ingress.yaml @@ -8,6 +8,6 @@ metadata: spec: defaultBackend: service: - name: gateway-service + name: gateway port: number: 4002 From 152970b786ef5266b5237e44fbc4cbec4b3c7891 Mon Sep 17 00:00:00 2001 From: Tay Yi Hsuen Date: Fri, 27 Oct 2023 08:33:39 +0800 Subject: [PATCH 2/3] Create release 0.4.0 (#195) ## Change Note: - Remove unused FQDN from GKE managed certificate - Add server-side search for question title and filtering by difficulty --------- Co-authored-by: Lee Chun Wei <47494777+chunweii@users.noreply.github.com> --- .../gke-prod-manifests/gke-managed-cert.yaml | 1 - .../src/components/questions/data-table.tsx | 89 ++++++++++++++++--- 2 files changed, 78 insertions(+), 12 deletions(-) diff --git a/deployment/gke-prod-manifests/gke-managed-cert.yaml b/deployment/gke-prod-manifests/gke-managed-cert.yaml index 4390e533..4feaab2e 100644 --- a/deployment/gke-prod-manifests/gke-managed-cert.yaml +++ b/deployment/gke-prod-manifests/gke-managed-cert.yaml @@ -4,7 +4,6 @@ metadata: name: gke-managed-cert spec: domains: - - codeparty.org - www.codeparty.org - api.codeparty.org - wsmatch.codeparty.org diff --git a/frontend/src/components/questions/data-table.tsx b/frontend/src/components/questions/data-table.tsx index ee6cf166..617f0113 100644 --- a/frontend/src/components/questions/data-table.tsx +++ b/frontend/src/components/questions/data-table.tsx @@ -50,7 +50,7 @@ export function DataTable({ columns, isEditable = false, }: DataTableProps) { - const [sorting, setSorting] = useState([]); + const [sorting, setSorting] = useState([{"id": "title", "desc": false}]); const [columnFilters, setColumnFilters] = useState([]); const [columnVisibility, setColumnVisibility] = useState({}); const { user: currentUser, authIsReady } = useContext(AuthContext); @@ -60,19 +60,37 @@ export function DataTable({ const [{pageIndex, pageSize}, setPagination] = useState({ pageIndex: 0, pageSize: 10 }); + const [searchTitle, setSearchTitle] = useState(""); + const [filteredDifficulty, setFilteredDifficulty] = useState({"easy": true, "medium": true, "hard": true}); + const [localFilteredDifficulty, setLocalFilteredDifficulty] = useState({"easy": true, "medium": true, "hard": true}); + const fetchDataOptions = { pageIndex, pageSize, + searchTitle, + filteredDifficulty, + sorting, uid: currentUser?.uid ?? null, }; const dataQuery = useQuery({ queryKey: ["questions", fetchDataOptions], queryFn: async ({queryKey}) => { - const {uid, pageIndex, pageSize} = queryKey[1] as {uid: string | null, pageIndex: number, pageSize: number}; + const {uid, pageIndex, pageSize, searchTitle, filteredDifficulty, sorting} = queryKey[1] as typeof fetchDataOptions; if (!uid) throw new Error("Unauthenticated user"); setLoading(true); - const response = await fetchQuestions(currentUser, pageIndex, pageSize, (isEditable ? {"author": uid}: {})); + let conditions: any = {"difficulty": Object.keys(filteredDifficulty).filter((key) => (filteredDifficulty as any)[key])}; + if (isEditable) { + conditions = {...conditions, "author": uid}; + } + if (searchTitle) { + conditions = {...conditions, "searchTitle": searchTitle}; + } + if (sorting.length > 0) { + const sortObj = sorting.map(sortState => ({[sortState.id]: sortState.desc ? -1 : 1})).reduce((acc, curr) => ({...acc, ...curr}), {}); + conditions = {...conditions, "sort": sortObj}; + } + const response = await fetchQuestions(currentUser, pageIndex, pageSize, conditions); setLoading(false) if (pageIndex > maxPage.current.maxFetchedPage) { maxPage.current.maxFetchedPage = pageIndex; @@ -110,22 +128,71 @@ export function DataTable({ columnVisibility, pagination }, + manualSorting: true, manualPagination: true, onPaginationChange: setPagination, pageCount: maxPage.current.isMax ? maxPage.current.maxFetchedPage + 1 : -1, }); + + return (
- - table.getColumn("title")?.setFilterValue(event.target.value) - } - className="max-w-sm" - /> +
+ { + if (e.key === 'Enter') { + setSearchTitle((e.target as EventTarget & HTMLInputElement).value); + // reset pagination + setPagination({pageIndex: 0, pageSize: 10}); + maxPage.current = {maxFetchedPage: -1, isMax: false}; + } + }} + className="max-w-sm" + /> + { + if (!open) { + if (JSON.stringify(localFilteredDifficulty) !== JSON.stringify(filteredDifficulty)) { + setFilteredDifficulty(localFilteredDifficulty); + // reset pagination + setPagination({pageIndex: 0, pageSize: 10}); + maxPage.current = {maxFetchedPage: -1, isMax: false}; + } + } + }}> + + + + + {["easy", "medium", "hard"] + .map((difficulty) => { + return ( + + setLocalFilteredDifficulty(prevValue => { + const newValue = {...prevValue}; + (newValue as any)[difficulty] = !!value; + return newValue; + }) + } + onSelect={e => e.preventDefault()} + > + {difficulty} + + ); + })} + + +
+