Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging Bento 4.1.0 into CTDC-4.0.0 #994

Open
wants to merge 31 commits into
base: CTDC-4.0.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0ca29ea
Merge pull request #864 from CBIIT/4.0.0
n2iw Jun 14, 2023
93dc2be
Added duplicate copy of favicon.
iksheth Jun 15, 2023
ce808c1
Merge pull request #869 from CBIIT/4.0.0_fav_icon_2
iksheth Jun 15, 2023
f8a164a
display all active filters in query bar
rana22 Sep 13, 2023
0312a37
README update
rana22 Sep 13, 2023
1eacb69
ICDC-3287
rana22 Sep 22, 2023
9ae86c9
enable expanded feature to display hidden active filter
rana22 Feb 1, 2024
ad1c359
code clean up
rana22 Feb 1, 2024
b979328
Code clean up
rana22 Feb 1, 2024
3c0cd50
Display all active filters
rana22 Feb 1, 2024
81e7b2b
Create README.md
iksheth Feb 6, 2024
591495c
Update README.md
iksheth Feb 6, 2024
a3e6d76
Merge pull request #938 from CBIIT/readme_master
iksheth Feb 6, 2024
6112157
Merge pull request #930 from CBIIT/expand_active_filter_items_in_quer…
iksheth Feb 16, 2024
e28dd42
Default Expand feature.
rana22 Mar 4, 2024
38a1917
Merge pull request #946 from CBIIT/expand_active_filter_items_in_quer…
iksheth Mar 11, 2024
4fb69d0
Update README.md
iksheth Mar 12, 2024
fee79a8
Merge pull request #954 from CBIIT/ReadmeMDUpdate3
iksheth Mar 12, 2024
aceba87
Update README.md
iksheth Mar 12, 2024
529c82b
Merge pull request #955 from CBIIT/ReadMEUpdate4
iksheth Mar 12, 2024
2553e62
Set default expand state, display eclipses only for collapse state
rana22 Mar 21, 2024
ffc05aa
Merge pull request #960 from CBIIT/ICDC-3232
iksheth Apr 9, 2024
f1f4211
Added .nx to gitignore
iksheth Apr 22, 2024
591822c
added lerna changed bash file
iksheth Apr 22, 2024
a7d6677
updated query bar version and removed the last_changed shell script.
iksheth Apr 22, 2024
a5d1f21
Publish
iksheth Apr 22, 2024
8daddef
Update Dockerfile
michael-fleming Apr 30, 2024
7acfbe8
Merge branch 'master' into 4.1.0
michael-fleming Jun 18, 2024
8160a03
Update Dockerfile
michael-fleming Jul 22, 2024
5d4a644
Update Dockerfile
michael-fleming Sep 9, 2024
380c02a
Merge pull request #1002 from CBIIT/michael-fleming-patch-2
michael-fleming Sep 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ yarn-error.log*

# WebStrom
.idea

# NX
.nx/*
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN NODE_OPTIONS="--max-old-space-size=4096" npm install

RUN NODE_OPTIONS="--max-old-space-size=4096" npx lerna run build

FROM nginx:1.25.2-alpine3.18-slim
FROM nginx:1.27.1-alpine3.20-slim AS fnl_base_image

COPY --from=build /usr/src/app/packages/bento-frontend/dist /usr/share/nginx/html
COPY --from=build /usr/src/app/conf/inject.template.js /usr/share/nginx/html/inject.template.js
Expand Down
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Bento Frontend Installation Guide

> ℹ️ **NOTE:** This guide is only for Bento Framework development. If you would like to consume Bento Framework for your project, please refer to the [How get my copy of Bento Frontend?](https://github.com/CBIIT/bento-frontend?tab=readme-ov-file#creating-custom-applications-how-get-my-copy-of-bento-frontend).

🍱 Welcome to the Bento Frontend Installation Guide! 🍱
---
### Prerequisites:
- Node 16.17.1
- NPM 8.15.0
- Lerna 6.6.7

### Lerna Installation Steps:

1. **Install Lerna globally:**
```bash
npm install -g [email protected]

### Bento Frontend Installation Steps:

1. **Clone Bento Frontend Repository:**
```bash
git clone https://github.com/CBIIT/bento-frontend.git
cd bento-frontend
```

2. **Install Node Modules:**
```bash
npm install
```

3. **Navigate to Nginx Configuration Directory:**
```bash
cd packages/bento-frontend/nginx/
```

4. **Install Nginx:**
- Use the provided guide "local-nginx-setup-for-frontend.txt" to install Nginx on your Linux-based system.

5. **Return to the Root Folder:**
```bash
cd ../../../
```

6. **Run Lerna to Start Bento Frontend:**
```bash
lerna run start
```

---

### Creating Custom Applications (How get my copy of Bento Frontend?):

🛠️ If you want to create a custom application using Bento, you can use the following command:

```bash
npx @bento-core/create-bento-app <My Application Name>
```

ℹ️ This command will scaffold a new Bento application for you to customize according to your needs.

🚀 Following these steps should have Bento Frontend up and running on your system. Enjoy exploring Bento! 🚀
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/all/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bento-core/all",
"version": "1.0.0",
"version": "1.1.0",
"description": "",
"main": "dist/index.js",
"scripts": {
Expand All @@ -27,7 +27,7 @@
"@bento-core/nav-bar": "^1.0.0",
"@bento-core/paginated-table": "^1.0.0",
"@bento-core/profile": "^1.0.0",
"@bento-core/query-bar": "^1.0.0",
"@bento-core/query-bar": "^1.1.0",
"@bento-core/session-timeout": "^1.0.0",
"@bento-core/stats-bar": "^1.0.0",
"@bento-core/tab": "^1.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ const QueryBarView = ({ data, statusReducer, localFind }) => {
mappedFilterState.sort((a, b) => sectionOrder.indexOf(a.datafield) - sectionOrder.indexOf(b.datafield));

const { QueryBar } = QueryBarGenerator({
config: {
displayAllActiveFilters: true,
},
functions: {
clearAll: () => {
dispatch(resetAllData());
Expand Down
5 changes: 5 additions & 0 deletions packages/query-bar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ const CONFIG = {
* @var {number}
*/
maxItems: 2,
/**
* overirdes maxItems to display all the active filter items
* @var {boolean}
*/
displayAllActiveFilters: false,
},

/* Component Helper Functions */
Expand Down
2 changes: 1 addition & 1 deletion packages/query-bar/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bento-core/query-bar",
"version": "1.0.0",
"version": "1.1.0",
"description": "",
"main": "dist/index.js",
"scripts": {
Expand Down
31 changes: 26 additions & 5 deletions packages/query-bar/src/components/CheckboxFilter.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import React from 'react';
import React, { useState } from 'react';
import clsx from 'clsx';

export default ({
index, data, classes, maxItems,
onSectionClick, onItemClick,
}) => {
const { items, section } = data;
const [expand, setExpand] = useState(true);
const noOfItems = expand ? items.length : maxItems;

const clsName = (text = '', attr = '') => `facetSection${text.replace(/\s+/g, '')}${attr}`;

return (
<span>
<span>
{' '}
{index !== 0 ? <span className={classes.operators}> AND </span> : ''}
<span
className={clsx(classes.filterName, classes[`facetSection${section}Background`])}
className={clsx(classes.filterName, classes[`${clsName(section, 'Background')}`])}
onClick={() => onSectionClick(data)}
>
{data.label}
Expand All @@ -26,10 +30,10 @@ export default ({
{items.length === 1 ? 'IS ' : 'IN '}
</span>
{items.length > 1 && <span className={classes.bracketsOpen}>(</span>}
{items.slice(0, maxItems).map((d, idx) => (
{items.slice(0, noOfItems).map((d, idx) => (
<>
<span
className={clsx(classes.filterCheckboxes, classes[`facetSection${section}`])}
className={clsx(classes.filterCheckboxes, classes[clsName(section)])}
key={idx}
onClick={() => onItemClick(data, d)}
>
Expand All @@ -38,7 +42,24 @@ export default ({
{idx === (maxItems - 1) ? null : ' '}
</>
))}
{items.length > maxItems && '...'}
{(items.length > maxItems && !expand) && (
<>
<span
className={classes.expandBtn}
onClick={() => setExpand(!expand)}
>
...
</span>
</>
)}
{(expand && items.length > maxItems) && (
<span
className={classes.collapseBtn}
onClick={() => setExpand(!expand)}
>
{' LESS'}
</span>
)}
{items.length > 1 && <span className={classes.bracketsClose}>)</span>}
</span>
</span>
Expand Down
79 changes: 51 additions & 28 deletions packages/query-bar/src/generators/QueryBarGenerator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import { withStyles, Button } from '@material-ui/core';
import { InputTypes } from '@bento-core/facet-filter';
import clsx from 'clsx';
Expand All @@ -13,8 +13,11 @@ import DEFAULT_CONFIG from './config';
* @returns {object} { QueryBar }
*/
export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
const { config, functions } = uiConfig;
const { config, functions, customStyles = {} } = uiConfig;
const { CHECKBOX } = InputTypes;
const styles = () => (
{ ...DEFAULT_STYLES(), ...customStyles }
);

const maxItems = config && typeof config.maxItems === 'number'
? config.maxItems
Expand Down Expand Up @@ -48,29 +51,30 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
? functions.resetFacetSlider
: DEFAULT_CONFIG.functions.resetFacetSlider;

const clsName = (text = 'filter-section') => text.replace(/\s+/g, '-').toLowerCase();

return {
QueryBar: withStyles(DEFAULT_STYLES, { withTheme: true })((props) => {
QueryBar: withStyles(styles, { withTheme: true })((props) => {
const { statusReducer, localFind, classes } = props;

const { autocomplete, upload } = localFind;

const [expand, setExpand] = useState(true);
const noOfItems = expand ? autocomplete.length : maxItems;

// Remove any sections without checkboxes selected
const mappedInputs = statusReducer.filter((facet) => facet.section && facet.type)
.map((facet) => {
if (facet.type !== CHECKBOX) { return facet; }

const { data, items } = facet;
const { items } = facet;
const itemKeys = Object.keys(items);
itemKeys.sort((a, b) => a.localeCompare(b));

/* Find any SELECTED CHECKBOXES that do NOT have any data
* and remove them from the list of selected checkboxes artificially */
itemKeys.forEach((item) => {
if (data.findIndex((d) => d.group === item) < 0) {
itemKeys.splice(itemKeys.indexOf(item), 1);
}
});

/**
* to display all the active filters in the query bar
* ICDC-3287
*/
return { ...facet, items: itemKeys };
})
.filter((facet) => facet.items.length > 0);
Expand Down Expand Up @@ -138,7 +142,7 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
{' '}
</>
) : null}
{autocomplete.slice(0, maxItems).map((d, idx) => (
{autocomplete.slice(0, noOfItems).map((d, idx) => (
<>
<span
className={clsx(classes.filterCheckboxes, classes.facetSectionCases)}
Expand All @@ -147,10 +151,27 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
>
{d.title}
</span>
{idx === (maxItems - 1) ? null : ' '}
{idx === (noOfItems - 1) ? null : ' '}
</>
))}
{autocomplete.length > maxItems && '...'}
{(autocomplete.length > maxItems && !expand) && (
<>
<span
className={classes.expandBtn}
onClick={() => setExpand(!expand)}
>
...
</span>
</>
)}
{(expand && autocomplete.length > maxItems) && (
<span
className={classes.collapseBtn}
onClick={() => setExpand(!expand)}
>
{' LESS'}
</span>
)}
{(((upload.length > 0 ? 1 : 0) + autocomplete.length) > 1)
? <span className={classes.bracketsClose}>)</span>
: null}
Expand All @@ -163,19 +184,21 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
? <span className={classes.operators}> AND </span>
: null}
{mappedInputs.map((filter, index) => (
<Filter
index={index}
type={filter.type}
data={filter}
maxItems={maxItems}
classes={classes}
onSectionClick={filter.type === CHECKBOX
? resetFacetSection
: resetFacetSlider}
onItemClick={filter.type === CHECKBOX
? resetFacetCheckbox
: resetFacetSlider}
/>
<span className={clsName(filter.section)}>
<Filter
index={index}
type={filter.type}
data={filter}
maxItems={maxItems}
classes={classes}
onSectionClick={filter.type === CHECKBOX
? resetFacetSection
: resetFacetSlider}
onItemClick={filter.type === CHECKBOX
? resetFacetCheckbox
: resetFacetSlider}
/>
</span>
))}
</span>
</div>
Expand Down
5 changes: 5 additions & 0 deletions packages/query-bar/src/generators/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ export default {
* @var {number}
*/
maxItems: 2,
/**
* overirdes maxItems to display all the active filter items
* @var {boolean}
*/
displayAllActiveFilters: false,
},

/* Component Helper Functions */
Expand Down
10 changes: 10 additions & 0 deletions packages/query-bar/src/generators/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,14 @@ export default () => ({
facetSectionSamplesBackground: {
backgroundColor: '#C3EAF5',
},
expandBtn: {
'&:hover': {
cursor: 'pointer',
},
},
collapseBtn: {
'&:hover': {
cursor: 'pointer',
},
},
});
Binary file added public/favicon.ico
Binary file not shown.