From 8b8e1084324d9f0e739ab46b896aff47d45240f2 Mon Sep 17 00:00:00 2001 From: vikasg11 Date: Wed, 13 Nov 2024 18:35:04 +0000 Subject: [PATCH] jbrowse page width fixed. --- .../organisms/GeneSearch/GeneSearchForm.tsx | 179 +++++++++--------- .../pages/GeneViewerPage.module.scss | 30 ++- .../src/components/pages/GeneViewerPage.tsx | 174 +++++++++-------- 3 files changed, 208 insertions(+), 175 deletions(-) diff --git a/dataportal-app/src/components/organisms/GeneSearch/GeneSearchForm.tsx b/dataportal-app/src/components/organisms/GeneSearch/GeneSearchForm.tsx index 60536d6..438a802 100644 --- a/dataportal-app/src/components/organisms/GeneSearch/GeneSearchForm.tsx +++ b/dataportal-app/src/components/organisms/GeneSearch/GeneSearchForm.tsx @@ -110,56 +110,54 @@ const GeneSearchForm: React.FC = ({ // Fetch search results based on the query, selected species, page, sort field, and sort order const fetchSearchResults = useCallback( - async (page = 1, sortField = currentSortField, sortOrder = currentSortOrder) => { - const params = new URLSearchParams({ - 'query': query.trim() || '', - 'page': String(page), - 'per_page': String(pageSize), - 'sortField': sortField, - 'sortOrder': sortOrder, - }); - - // Ensure genomeFilter is an array of objects with id and name - const genomeFilter = selectedGenomes && selectedGenomes.length > 0 - ? selectedGenomes.map((genome) => ({ id: genome.id, name: genome.name })) - : undefined; - - // Use selectedSpecies directly if only one species is selected, or undefined otherwise - const speciesFilter = selectedSpecies && selectedSpecies.length === 1 - ? selectedSpecies - : undefined; - - try { - const response = await fetchGeneSearchResults( - query, page, pageSize, sortField, sortOrder, genomeFilter, speciesFilter - ); - - if (response && response.results) { - setResults(response.results); - setCurrentPage(response.page_number); - setTotalPages(response.num_pages); - setHasPrevious(response.has_previous); - setHasNext(response.has_next); - } else { + async (page = 1, sortField = currentSortField, sortOrder = currentSortOrder) => { + const params = new URLSearchParams({ + 'query': query.trim() || '', + 'page': String(page), + 'per_page': String(pageSize), + 'sortField': sortField, + 'sortOrder': sortOrder, + }); + + // Ensure genomeFilter is an array of objects with id and name + const genomeFilter = selectedGenomes && selectedGenomes.length > 0 + ? selectedGenomes.map((genome) => ({id: genome.id, name: genome.name})) + : undefined; + + // Use selectedSpecies directly if only one species is selected, or undefined otherwise + const speciesFilter = selectedSpecies && selectedSpecies.length === 1 + ? selectedSpecies + : undefined; + + try { + const response = await fetchGeneSearchResults( + query, page, pageSize, sortField, sortOrder, genomeFilter, speciesFilter + ); + + if (response && response.results) { + setResults(response.results); + setCurrentPage(response.page_number); + setTotalPages(response.num_pages); + setHasPrevious(response.has_previous); + setHasNext(response.has_next); + } else { + setResults([]); + setCurrentPage(1); + setTotalPages(1); + setHasPrevious(false); + setHasNext(false); + } + } catch (error) { + console.error('Error fetching data:', error); setResults([]); setCurrentPage(1); setTotalPages(1); setHasPrevious(false); setHasNext(false); } - } catch (error) { - console.error('Error fetching data:', error); - setResults([]); - setCurrentPage(1); - setTotalPages(1); - setHasPrevious(false); - setHasNext(false); - } - }, - [query, selectedSpecies, selectedGenomes, currentSortField, currentSortOrder, pageSize] -); - - + }, + [query, selectedSpecies, selectedGenomes, currentSortField, currentSortOrder, pageSize] + ); useEffect(() => { @@ -205,61 +203,58 @@ const GeneSearchForm: React.FC = ({ }; return ( -
+

-
-
-

Search Gene

-
-

-

- setSuggestions([])} + +

Search Gene

+
+

+

+ setSuggestions([])} + /> +
+

 

+
+
0 ? 'block' : 'none'}}> + + {/* Page size dropdown and pagination */} +
+
+ + +
- -
-

 

+ {totalPages > 1 && ( + + )}
-
0 ? 'block' : 'none'}}> - - {/* Page size dropdown and pagination */} -
-
- - -
+
+ - {totalPages > 1 && ( - - )} -
-
- -

 

 

diff --git a/dataportal-app/src/components/pages/GeneViewerPage.module.scss b/dataportal-app/src/components/pages/GeneViewerPage.module.scss index bea28f1..3767a62 100644 --- a/dataportal-app/src/components/pages/GeneViewerPage.module.scss +++ b/dataportal-app/src/components/pages/GeneViewerPage.module.scss @@ -1,6 +1,34 @@ +.mainContainer { + max-width: 800px; + width: 100%; + margin: 0 auto; + padding: 0 16px; + display: flex; + flex-direction: column; +} + +.vfContent { + width: 100% !important; + min-width: 800px; + float: left !important; + padding-right: 20px; + justify-content: normal; +} + +.jbrowseViewer { + display: flex; + flex-direction: column; + align-items: center; + width: 100%; + min-width: 800px; + margin: 0 auto; +} + .jbrowse-container { width: 100%; - height: 600px; + height: 100%; + overflow: hidden; + min-width: 800px; } .breadcrumbsItem { diff --git a/dataportal-app/src/components/pages/GeneViewerPage.tsx b/dataportal-app/src/components/pages/GeneViewerPage.tsx index 3420ab1..edb7e01 100644 --- a/dataportal-app/src/components/pages/GeneViewerPage.tsx +++ b/dataportal-app/src/components/pages/GeneViewerPage.tsx @@ -145,93 +145,103 @@ const GeneViewerPage: React.FC = () => { }; return ( -
- {/* Breadcrumb Section */} - - {/* Gene Search Section */} -
-
- setGeneSearchQuery(e.target.value)} - onSearchSubmit={handleGeneSearch} - selectedGenomes={genomeId ? [{id: parseInt(genomeId, 10), name: ''}] : []} - results={geneResults} - onSortClick={(sortField) => console.log('Sort by:', sortField)} - currentPage={geneCurrentPage} - totalPages={totalPages} - handlePageClick={(page) => setGeneCurrentPage(page)} - linkData={linkData} - viewState={localViewState} - /> + {/* Genome Metadata Section */} +
+ {genomeMeta ? ( +
+

{genomeMeta.species}: {genomeMeta.isolate_name}

+

Assembly Name:  + {genomeMeta.assembly_name} + +

+

Annotations:  + {genomeMeta.gff_file} + +

+

ENA Accession:  + + {genomeMeta.assembly_accession ? `XX000000${genomeMeta.assembly_accession}` : "Not Available"} + +

+
+ ) : ( +

Loading genome meta information...

+ )}
-
- {/* JBrowse Component Section */} -
-
+ + {/* Gene Search Section */} +
+
+ setGeneSearchQuery(e.target.value)} + onSearchSubmit={handleGeneSearch} + selectedGenomes={genomeId ? [{id: parseInt(genomeId, 10), name: ''}] : []} + results={geneResults} + onSortClick={(sortField) => console.log('Sort by:', sortField)} + currentPage={geneCurrentPage} + totalPages={totalPages} + handlePageClick={(page) => setGeneCurrentPage(page)} + linkData={linkData} + viewState={localViewState} + /> +
+
+ + {/* JBrowse Component Section */} +
{localViewState ? ( -
-
+
+