Skip to content

Commit

Permalink
Merge branch 'dev' into add-metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
nleroy917 authored Jun 10, 2024
2 parents d8c86bc + d8b2fd0 commit c16543b
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 90 deletions.
3 changes: 1 addition & 2 deletions bedhost/routers/bed_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

from genimtools.tokenizers import RegionSet


import tempfile
import os
import shutil
Expand Down Expand Up @@ -40,7 +39,6 @@
)
from ..const import EXAMPLE_BED


router = APIRouter(prefix="/v1/bed", tags=["bed"])


Expand Down Expand Up @@ -327,6 +325,7 @@ async def get_tokens(
Return univers of bed file
Example: bed: 0dcdf8986a72a3d85805bbc9493a1302 | universe: 58dee1672b7e581c8e1312bd4ca6b3c7
"""
_LOGGER.info(bbagent.config.config.s3)
try:
return bbagent.bed.get_tokenized(bed_id, universe_id)

Expand Down
193 changes: 105 additions & 88 deletions ui/src/components/search/search-results-table.tsx
Original file line number Diff line number Diff line change
@@ -1,97 +1,114 @@
import { ProgressBar } from 'react-bootstrap';
import { components } from '../../../bedbase-types';
import { roundToTwoDecimals } from '../../utils';
import { useBedCart } from '../../contexts/bedcart-context';
import {ProgressBar} from 'react-bootstrap';
import {components} from '../../../bedbase-types';
import {roundToTwoDecimals} from '../../utils';
import {useBedCart} from '../../contexts/bedcart-context';
import {OverlayTrigger, Tooltip} from 'react-bootstrap';
import toast from 'react-hot-toast';

type SearchResponse = components['schemas']['BedListSearchResult'];

type Props = {
results: SearchResponse;
results: SearchResponse;
};

export const SearchResultsTable = (props: Props) => {
const { results } = props;
const { cart, addBedToCart, removeBedFromCart } = useBedCart();
return (
<table className="table text-sm">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Genome</th>
<td scope="col">Cell Type</td>
<th scope="col">Description</th>
<th scope="col">Score</th>
{/* <th scope="col">BEDbase ID</th> */}
<th scope="col">Submitted</th>
<th scope="col" style={{ minWidth: '140px' }}>
Actions
</th>
</tr>
</thead>
<tbody>
{results.results?.map((result) => (
<tr key={result.id}>
<td>{result?.metadata?.name || 'No name'}</td>
<td>
<span className="badge text-bg-primary">{result?.payload.genome || 'N/A'}</span>
</td>
<td>{result?.payload.cell_type || 'No cell type'}</td>
<td className="text-truncate">{result?.payload.description || 'No description'}</td>
<td>
<ProgressBar
min={5}
now={result.score * 100}
label={`${roundToTwoDecimals(result.score * 100)}`}
variant="primary"
/>
</td>
{/* <td>{result?.metadata?.id || 'No id'}</td> */}
<td>
{result?.metadata?.submission_date === undefined
? 'No date'
: new Date(result.metadata?.submission_date).toLocaleDateString()}
</td>

<td>
<a className="me-1" href={`/bed/${result.metadata?.id}`}>
<button className="btn btn-sm btn-outline-primary">
<i className="bi bi-eye"></i>
</button>
</a>
{cart.includes(result?.metadata?.id || '') ? (
<button
className="btn btn-sm btn-outline-danger"
onClick={() => {
if (result.metadata?.id === undefined) {
toast.error('No bed ID found', { position: 'top-center' });
return;
}
removeBedFromCart(result.metadata?.id);
}}
>
Remove
<i className="bi bi-cart-dash ms-1"></i>
</button>
) : (
<button
className="btn btn-sm btn-outline-primary"
onClick={() => {
if (result.metadata?.id === undefined) {
toast.error('No bed ID found', { position: 'top-center' });
return;
}
addBedToCart(result.metadata?.id || '');
}}
>
Add
<i className="bi bi-cart-plus ms-1"></i>
</button>
)}
</td>
</tr>
))}
</tbody>
</table>
);
const {results} = props;
const {cart, addBedToCart, removeBedFromCart} = useBedCart();
return (
<table className="table text-sm">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Genome</th>
<th scope="col">Tissue</th>
<th scope="col">Cell Type</th>
<th scope="col">Antibody</th>
<th scope="col">Description</th>
<th scope="col">Score</th>
{/* <th scope="col">BEDbase ID</th> */}
<th scope="col" style={{minWidth: '140px'}}>
Actions
</th>
</tr>
</thead>
<tbody>
{results.results?.map((result) => (
<tr key={result.id}>
<td>{result?.metadata?.name || 'No name'}</td>
<td>
<span className="badge text-bg-primary">{result?.payload.genome || 'N/A'}</span>
</td>
<td>{result?.payload.tissue || 'N/A'}</td>
<td>{result?.payload.cell_type || 'N/A'}</td>
<td>{result?.payload.antibody || 'N/A'}</td>
{/*<td className="text-truncate">{result?.payload.description || 'No description'}</td>*/}
{/*<td className="bi bi-info-circle text-truncate text-center"></td>*/}
<td className="text-center">
<OverlayTrigger
placement="top"
overlay={
<Tooltip id={`tooltip-${result.id}`}>
{result?.payload.description || 'No description'}
</Tooltip>
}
>
<span className="bi bi-info-circle"></span>
</OverlayTrigger>
</td>
<td>
<ProgressBar
min={5}
now={result.score * 100}
label={`${roundToTwoDecimals(result.score * 100)}`}
variant="primary"
/>
</td>
{/* <td>{result?.metadata?.id || 'No id'}</td> */}
{/*<td>*/}
{/* /!*{result?.metadata?.submission_date === undefined*!/*/}
{/* /!* ? 'No date'*!/*/}
{/* /!* : new Date(result.metadata?.submission_date).toLocaleDateString()}*!/\*/}
{/* */}
{/*</td>*/}
<td>
<a className="me-1" href={`/bed/${result.metadata?.id}`}>
<button className="btn btn-sm btn-outline-primary">
<i className="bi bi-eye"></i>
</button>
</a>
{cart.includes(result?.metadata?.id || '') ? (
<button
className="btn btn-sm btn-outline-danger"
onClick={() => {
if (result.metadata?.id === undefined) {
toast.error('No bed ID found', {position: 'top-center'});
return;
}
removeBedFromCart(result.metadata?.id);
}}
>
Remove
<i className="bi bi-cart-dash ms-1"></i>
</button>
) : (
<button
className="btn btn-sm btn-outline-primary"
onClick={() => {
if (result.metadata?.id === undefined) {
toast.error('No bed ID found', {position: 'top-center'});
return;
}
addBedToCart(result.metadata?.id || '');
}}
>
Add
<i className="bi bi-cart-plus ms-1"></i>
</button>
)}
</td>
</tr>
))}
</tbody>
</table>
);
};

0 comments on commit c16543b

Please sign in to comment.