From 5f4461127d0542e3d5b694d47586e08352c45907 Mon Sep 17 00:00:00 2001 From: Chintan Mehta Date: Wed, 11 Oct 2023 16:32:59 +0100 Subject: [PATCH 01/20] pinned row download added --- .../AssociationsToolkit/DataDownloader.jsx | 155 +++++++++++++----- 1 file changed, 110 insertions(+), 45 deletions(-) diff --git a/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx b/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx index 704940c9e..3fcb61619 100644 --- a/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx +++ b/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx @@ -1,5 +1,5 @@ import FileSaver from 'file-saver'; -import { useState, useMemo } from 'react'; +import { useState, useMemo, useEffect } from 'react'; import _ from 'lodash'; import { Button, @@ -10,11 +10,19 @@ import { Popover, Alert, CircularProgress, + Dialog, + DialogTitle, + DialogContent, + FormGroup, + FormControlLabel, + Checkbox, + IconButton, + DialogActions, } from '@mui/material'; import { styled } from '@mui/material/styles'; import { makeStyles } from '@mui/styles'; import { Link } from 'ui'; -import { faCloudArrowDown } from '@fortawesome/free-solid-svg-icons'; +import { faCloudArrowDown, faLink } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import useBatchDownloader from './hooks/useBatchDownloader'; import useAotfContext from './hooks/useAotfContext'; @@ -223,9 +231,7 @@ const styles = makeStyles(theme => ({ })); function DataDownloader({ fileStem }) { - const [downloading, setDownloading] = useState(false); const classes = styles(); - const [anchorEl, setAnchorEl] = useState(null); const { id, query, @@ -234,7 +240,21 @@ function DataDownloader({ fileStem }) { enableIndirect, entityToGet, displayedTable, + modifiedSourcesDataControls, + pinnedEntries, + dataSourcesWeights, + dataSourcesRequired, } = useAotfContext(); + const [onlyPinnedCheckBox, setOnlyPinnedCheckBox] = useState(false); + const [weightControlCheckBox, setWeightControlCheckBox] = useState( + modifiedSourcesDataControls + ); + const [requiredControlCheckBox, setRequiredControlCheckBox] = useState( + modifiedSourcesDataControls + ); + + const [downloading, setDownloading] = useState(false); + const [anchorEl, setAnchorEl] = useState(null); const columns = useMemo(() => getExportedColumns(entityToGet), [entityToGet]); const queryResponseSelector = useMemo( @@ -242,14 +262,29 @@ function DataDownloader({ fileStem }) { [entityToGet] ); + const allAssociationsVariable = { + id, + filter: searhFilter, + sortBy: sorting[0].id, + enableIndirect, + datasource: dataSourcesWeights, + aggregationFilters: dataSourcesRequired, + }; + + const pinnedAssociationsVariable = { + ...allAssociationsVariable, + rowsFilter: pinnedEntries, + }; + + const getOnlyPinnedData = useBatchDownloader( + query, + pinnedAssociationsVariable, + queryResponseSelector + ); + const getAllAssociations = useBatchDownloader( query, - { - id, - filter: searhFilter, - sortBy: sorting[0].id, - enableIndirect, - }, + allAssociationsVariable, queryResponseSelector ); @@ -281,13 +316,26 @@ function DataDownloader({ fileStem }) { }; const handleClickDownloadJSON = async () => { - downloadData('json', columns, getAllAssociations, fileStem); + if (onlyPinnedCheckBox) + downloadData('json', columns, getOnlyPinnedData, fileStem); + else downloadData('json', columns, getAllAssociations, fileStem); }; const handleClickDownloadTSV = async () => { - downloadData('tsv', columns, getAllAssociations, fileStem); + if (onlyPinnedCheckBox) + downloadData('tsv', columns, getOnlyPinnedData, fileStem); + else downloadData('tsv', columns, getAllAssociations, fileStem); }; + const handleFormGroupChange = (event, fn) => { + fn(event.target.checked); + }; + + useEffect(() => { + setRequiredControlCheckBox(modifiedSourcesDataControls); + setWeightControlCheckBox(modifiedSourcesDataControls); + }, [modifiedSourcesDataControls]); + return (
- - + + Header Text + + + + handleFormGroupChange(e, setOnlyPinnedCheckBox) + } + /> + } + label="Only pinned / upload rows" + /> + + handleFormGroupChange(e, setWeightControlCheckBox) + } + /> + } + label="Include custom weight controls" + /> + + handleFormGroupChange(e, setRequiredControlCheckBox) + } + /> + } + label="Include custom required control" + /> + + + {isPartnerPreview && ( + + `The file will also include the target prioritisation data. + + )} + Download data as @@ -338,24 +419,8 @@ function DataDownloader({ fileStem }) { - - - Table with pre-set weights only. See{' '} - - here - {' '} - for more information. -
- {isPartnerPreview && - `The file will also include the target prioritisation data.`} -
-
-
-
+ + Date: Wed, 11 Oct 2023 16:50:09 +0100 Subject: [PATCH 02/20] copy button added --- .../AssociationsToolkit/DataDownloader.jsx | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx b/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx index 3fcb61619..099ae69e7 100644 --- a/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx +++ b/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx @@ -7,7 +7,6 @@ import { Typography, Snackbar, Slide, - Popover, Alert, CircularProgress, Dialog, @@ -16,8 +15,6 @@ import { FormGroup, FormControlLabel, Checkbox, - IconButton, - DialogActions, } from '@mui/material'; import { styled } from '@mui/material/styles'; import { makeStyles } from '@mui/styles'; @@ -255,7 +252,7 @@ function DataDownloader({ fileStem }) { const [downloading, setDownloading] = useState(false); const [anchorEl, setAnchorEl] = useState(null); - + const [urlSnackbar, setUrlSnackbar] = useState(false); const columns = useMemo(() => getExportedColumns(entityToGet), [entityToGet]); const queryResponseSelector = useMemo( () => getRowsQuerySelector(entityToGet), @@ -396,6 +393,16 @@ function DataDownloader({ fileStem }) { )} + Download data as @@ -438,6 +445,23 @@ function DataDownloader({ fileStem }) { } /> + + { + setUrlSnackbar(false); + }} + autoHideDuration={2000} + TransitionComponent={Slide} + ContentProps={{ + classes: { + root: classes.snackbarContentRoot, + message: classes.snackbarContentMessage, + }, + }} + message="URL copied" + />
); } From f7d43091105f85a67a828baa7ea92c4438aae3dc Mon Sep 17 00:00:00 2001 From: Chintan Mehta Date: Thu, 12 Oct 2023 14:46:25 +0100 Subject: [PATCH 03/20] required checkbox value --- .../src/components/AssociationsToolkit/DataDownloader.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx b/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx index 099ae69e7..6710984b3 100644 --- a/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx +++ b/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx @@ -264,8 +264,8 @@ function DataDownloader({ fileStem }) { filter: searhFilter, sortBy: sorting[0].id, enableIndirect, - datasource: dataSourcesWeights, - aggregationFilters: dataSourcesRequired, + datasources: dataSourcesWeights, + ...(requiredControlCheckBox && { aggregationFilters: dataSourcesRequired }), }; const pinnedAssociationsVariable = { From 577cd4f9fc3465f8c67f02265c19101a01b52ecf Mon Sep 17 00:00:00 2001 From: Chintan Mehta Date: Thu, 12 Oct 2023 14:58:10 +0100 Subject: [PATCH 04/20] aggregationFilters modified --- .../src/components/AssociationsToolkit/DataDownloader.jsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx b/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx index 6710984b3..5e63f9978 100644 --- a/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx +++ b/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx @@ -265,7 +265,12 @@ function DataDownloader({ fileStem }) { sortBy: sorting[0].id, enableIndirect, datasources: dataSourcesWeights, - ...(requiredControlCheckBox && { aggregationFilters: dataSourcesRequired }), + ...(requiredControlCheckBox && { + aggregationFilters: dataSourcesRequired.map(el => ({ + name: el.name, + path: el.path, + })), + }), }; const pinnedAssociationsVariable = { From 36ebf6943ff771e4f27e81e9ba2982847891b7ba Mon Sep 17 00:00:00 2001 From: Chintan Mehta Date: Mon, 16 Oct 2023 11:12:34 +0100 Subject: [PATCH 05/20] enabling export button on prioritisation tab --- .../src/components/AssociationsToolkit/DataDownloader.jsx | 8 -------- 1 file changed, 8 deletions(-) diff --git a/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx b/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx index 5e63f9978..6c775fdb7 100644 --- a/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx +++ b/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx @@ -345,7 +345,6 @@ function DataDownloader({ fileStem }) { onClick={handleClickBTN} variant="outlined" disableElevation - disabled={isPrioritisation} startIcon={} > Export @@ -391,13 +390,6 @@ function DataDownloader({ fileStem }) { label="Include custom required control" /> - - {isPartnerPreview && ( - - `The file will also include the target prioritisation data. - - )} - - Header Text + Export: {fileStem} data + + Advance export options: )} - Download data as From 47efe804844f3965b9d183cdbebd1bb8030c0012 Mon Sep 17 00:00:00 2001 From: Chintan Mehta Date: Wed, 18 Oct 2023 13:53:51 +0100 Subject: [PATCH 08/20] set value fn update --- .../AssociationsToolkit/DataDownloader.jsx | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx b/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx index a2a42e48f..0df9b0103 100644 --- a/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx +++ b/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx @@ -352,10 +352,6 @@ function DataDownloader({ fileStem }) { downloadData('tsv', columnToGet, data, fileStem); }; - const handleFormGroupChange = (event, fn) => { - fn(event.target.checked); - }; - useEffect(() => { setRequiredControlCheckBox(modifiedSourcesDataControls); setWeightControlCheckBox(modifiedSourcesDataControls); @@ -387,14 +383,13 @@ function DataDownloader({ fileStem }) { Advance export options: + - handleFormGroupChange(e, setOnlyPinnedCheckBox) - } + onChange={e => setOnlyPinnedCheckBox(e.target.checked)} /> } label="Only pinned / upload rows" @@ -404,9 +399,7 @@ function DataDownloader({ fileStem }) { - handleFormGroupChange(e, setWeightControlCheckBox) - } + onChange={e => setWeightControlCheckBox(e.target.checked)} /> } label="Include custom weight controls" @@ -416,9 +409,7 @@ function DataDownloader({ fileStem }) { - handleFormGroupChange(e, setRequiredControlCheckBox) - } + onChange={e => setRequiredControlCheckBox(e.target.checked)} /> } label="Include custom required control" @@ -429,7 +420,7 @@ function DataDownloader({ fileStem }) { handleFormGroupChange(e, setOnlyTargetData)} + onChange={e => setOnlyTargetData(e.target.checked)} /> } label="Only prioritisation data" From 8d6ac2ad31dc16a80c172892e0caf686682bbc19 Mon Sep 17 00:00:00 2001 From: Chintan Mehta Date: Wed, 18 Oct 2023 15:16:43 +0100 Subject: [PATCH 09/20] accordion added --- .../AssociationsToolkit/DataDownloader.jsx | 117 +++++++++++------- 1 file changed, 70 insertions(+), 47 deletions(-) diff --git a/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx b/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx index 0df9b0103..f028ae564 100644 --- a/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx +++ b/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx @@ -14,10 +14,18 @@ import { FormGroup, FormControlLabel, Checkbox, + Accordion, + AccordionSummary, + AccordionDetails, + Divider, } from '@mui/material'; import { styled } from '@mui/material/styles'; import { makeStyles } from '@mui/styles'; -import { faCloudArrowDown, faLink } from '@fortawesome/free-solid-svg-icons'; +import { + faCloudArrowDown, + faLink, + faCaretDown, +} from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import useBatchDownloader from './hooks/useBatchDownloader'; import useAotfContext from './hooks/useAotfContext'; @@ -28,6 +36,11 @@ const LabelContainer = styled('div')({ marginBottom: 12, }); +const BorderAccordion = styled(Accordion)(({ theme }) => ({ + boxShadow: "none", + border: `1px solid ${theme.palette.grey[300]}` +})); + const targetName = { id: 'symbol', label: 'Symbol', @@ -371,6 +384,62 @@ function DataDownloader({ fileStem }) { Export: {fileStem} data + + } + > + Advance export options: + + + + + setOnlyPinnedCheckBox(e.target.checked)} + /> + } + label="Only pinned / upload rows" + /> + setWeightControlCheckBox(e.target.checked)} + /> + } + label="Include custom weight controls" + /> + + setRequiredControlCheckBox(e.target.checked) + } + /> + } + label="Include custom required control" + /> + {entity === 'disease' && ( + setOnlyTargetData(e.target.checked)} + /> + } + label="Only prioritisation data" + /> + )} + + + - Advance export options: - - - setOnlyPinnedCheckBox(e.target.checked)} - /> - } - label="Only pinned / upload rows" - /> - setWeightControlCheckBox(e.target.checked)} - /> - } - label="Include custom weight controls" - /> - setRequiredControlCheckBox(e.target.checked)} - /> - } - label="Include custom required control" - /> - {entity === 'disease' && ( - setOnlyTargetData(e.target.checked)} - /> - } - label="Only prioritisation data" - /> - )} - Download data as From 3a855baf12f11cc4794829a87b5a0111471f4c68 Mon Sep 17 00:00:00 2001 From: Chintan Mehta Date: Wed, 18 Oct 2023 21:12:50 +0100 Subject: [PATCH 10/20] aggregation state added --- .../AssociationsToolkit/DataDownloader.jsx | 136 ++++++++++++++++-- 1 file changed, 123 insertions(+), 13 deletions(-) diff --git a/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx b/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx index f028ae564..93bc37760 100644 --- a/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx +++ b/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx @@ -18,6 +18,11 @@ import { AccordionSummary, AccordionDetails, Divider, + FormControl, + InputLabel, + Select, + MenuItem, + ListItemText, } from '@mui/material'; import { styled } from '@mui/material/styles'; import { makeStyles } from '@mui/styles'; @@ -37,8 +42,8 @@ const LabelContainer = styled('div')({ }); const BorderAccordion = styled(Accordion)(({ theme }) => ({ - boxShadow: "none", - border: `1px solid ${theme.palette.grey[300]}` + boxShadow: 'none', + border: `1px solid ${theme.palette.grey[300]}`, })); const targetName = { @@ -58,10 +63,10 @@ const getRowsQuerySelector = entityToGet => ? 'data.disease.associatedTargets' : 'data.target.associatedDiseases'; -const getExportedColumns = entityToGet => { +const getExportedColumns = (entityToGet, assocArr, prioArr) => { const nameColumn = entityToGet === 'target' ? targetName : diseaseName; let exportedColumns = []; - const sources = dataSources.map(({ id }) => ({ + const sources = assocArr.map(({ id }) => ({ id, exportValue: data => { const datatypeScore = data.datasourceScores.find( @@ -74,7 +79,7 @@ const getExportedColumns = entityToGet => { exportedColumns = [...sources]; if (entityToGet === 'target') { - const prioritisationExportCols = prioritizationCols.map(({ id }) => ({ + const prioritisationExportCols = prioArr.map(({ id }) => ({ id, exportValue: data => { const prioritisationScore = data.target.prioritisation.items.find( @@ -100,10 +105,10 @@ const getExportedColumns = entityToGet => { ]; }; -const getExportedPrioritisationColumns = () => { +const getExportedPrioritisationColumns = arr => { let exportedColumns = []; - const prioritisationExportCols = prioritizationCols.map(({ id }) => ({ + const prioritisationExportCols = arr.map(({ id }) => ({ id, exportValue: data => { const prioritisationScore = data.target.prioritisation.items.find( @@ -257,6 +262,13 @@ const styles = makeStyles(theme => ({ })); function DataDownloader({ fileStem }) { + const allAssociationsAggregation = [ + ...new Set(dataSources.map(e => e.aggregation)), + ]; + const allPrioritizationAggregation = [ + ...new Set(prioritizationCols.map(e => e.aggregation)), + ]; + const classes = styles(); const { id, @@ -281,13 +293,32 @@ function DataDownloader({ fileStem }) { ); const [onlyTargetData, setOnlyTargetData] = useState(false); + const [selectedAssociationColumns, setSelectedAssociationColumns] = useState([ + ...dataSources, + ]); + const [selectedPrioritizationColumns, setSelectedPrioritizationColumns] = + useState(prioritizationCols); + + const [associationAggregationSelect, setAssociationAggregationSelect] = + useState([...allAssociationsAggregation]); + const [prioritisationAggregationSelect, setPrioritisationAggregationSelect] = + useState([...allPrioritizationAggregation]); + const [downloading, setDownloading] = useState(false); const [anchorEl, setAnchorEl] = useState(null); const [urlSnackbar, setUrlSnackbar] = useState(false); - const columns = useMemo(() => getExportedColumns(entityToGet), [entityToGet]); + const columns = useMemo( + () => + getExportedColumns( + entityToGet, + selectedAssociationColumns, + selectedPrioritizationColumns + ), + [entityToGet, selectedAssociationColumns, selectedPrioritizationColumns] + ); const prioritisationColumns = useMemo( - () => getExportedPrioritisationColumns(), - [] + () => getExportedPrioritisationColumns(selectedPrioritizationColumns), + [selectedPrioritizationColumns] ); const queryResponseSelector = useMemo( () => getRowsQuerySelector(entityToGet), @@ -326,7 +357,7 @@ function DataDownloader({ fileStem }) { ); const open = Boolean(anchorEl); - const popoverId = open ? 'dowloader-popover' : undefined; + const popoverId = open ? 'downloader-popover' : undefined; const downloadData = async (format, dataColumns, rows, dataFileStem) => { let allRows = rows; @@ -370,6 +401,22 @@ function DataDownloader({ fileStem }) { setWeightControlCheckBox(modifiedSourcesDataControls); }, [modifiedSourcesDataControls]); + useEffect(() => { + const filteredValues = associationAggregationSelect.map(ag => + selectedAssociationColumns.filter(e => e.aggregation === ag) + ); + setSelectedAssociationColumns([...filteredValues.flat(1)]); + console.log(selectedAssociationColumns); + }, [associationAggregationSelect]); + + useEffect(() => { + const filteredValues = prioritisationAggregationSelect.map(ag => + selectedPrioritizationColumns.filter(e => e.aggregation === ag) + ); + setSelectedPrioritizationColumns([...filteredValues.flat(1)]); + console.log(selectedAssociationColumns); + }, [prioritisationAggregationSelect]); + return (
- - Download data as - - - + + - - - - - + + + + Download data as + + + + + + + + + + +
Date: Fri, 20 Oct 2023 16:36:55 +0100 Subject: [PATCH 12/20] styles and typo updated --- .../AssociationsToolkit/DataDownloader.jsx | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx b/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx index bcb943bab..6bf63f8dc 100644 --- a/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx +++ b/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx @@ -44,9 +44,18 @@ const LabelContainer = styled('div')({ const BorderAccordion = styled(Accordion)(({ theme }) => ({ boxShadow: 'none', - border: `1px solid ${theme.palette.grey[300]}`, + border: `1px solid ${theme.palette.primary.light}`, })); +const BlueAccordionSummary = styled(AccordionSummary)(({ theme }) => ({ + background: theme.palette.primary.light, + div: { + color: 'white', + }, +})); + +AccordionSummary; + const targetName = { id: 'symbol', label: 'Symbol', @@ -433,24 +442,24 @@ function DataDownloader({ fileStem }) { Export: {fileStem} data - } > - Advance export options: - + Advanced export options: + - Association Aggregation + Associations Aggregation - - + - + theme.spacing(1), + }, + }} + > Export: {fileStem} data From 671b89478b2092c0691f4e84bc5c443cf0224136 Mon Sep 17 00:00:00 2001 From: Chintan Mehta Date: Wed, 25 Oct 2023 14:46:26 +0100 Subject: [PATCH 19/20] fix lint errors --- .../AssociationsToolkit/DataDownloader.jsx | 198 +++++++----------- 1 file changed, 78 insertions(+), 120 deletions(-) diff --git a/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx b/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx index 875845c02..e229389a2 100644 --- a/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx +++ b/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx @@ -1,6 +1,6 @@ -import FileSaver from 'file-saver'; -import { useState, useMemo, useEffect, useReducer } from 'react'; -import _ from 'lodash'; +import FileSaver from "file-saver"; +import { useState, useMemo, useEffect, useReducer } from "react"; +import _ from "lodash"; import { Button, Grid, @@ -25,29 +25,25 @@ import { ListItemText, Box, FormHelperText, -} from '@mui/material'; -import { styled } from '@mui/material/styles'; -import { makeStyles } from '@mui/styles'; -import { - faCloudArrowDown, - faLink, - faCaretDown, -} from '@fortawesome/free-solid-svg-icons'; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { usePermissions } from 'ui'; -import useBatchDownloader from './hooks/useBatchDownloader'; -import useAotfContext from './hooks/useAotfContext'; -import OriginalDataSources from './static_datasets/dataSourcesAssoc'; -import prioritizationCols from './static_datasets/prioritizationCols'; +} from "@mui/material"; +import { styled } from "@mui/material/styles"; +import { makeStyles } from "@mui/styles"; +import { faCloudArrowDown, faLink, faCaretDown } from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import useBatchDownloader from "./hooks/useBatchDownloader"; +import useAotfContext from "./hooks/useAotfContext"; +import OriginalDataSources from "./static_datasets/dataSourcesAssoc"; +import prioritizationCols from "./static_datasets/prioritizationCols"; import { getRowsQuerySelector, getExportedColumns, getExportedPrioritisationColumns, createBlob, getFilteredColumnArray, -} from './utils/downloads'; +} from "./utils/downloads"; +import config from "ui/src/config"; -const { isPartnerPreview } = usePermissions(); +const { isPartnerPreview } = config.profile; const dataSources = OriginalDataSources.filter(e => { if (isPartnerPreview && e.isPrivate) { @@ -56,65 +52,61 @@ const dataSources = OriginalDataSources.filter(e => { return; }); -const LabelContainer = styled('div')({ +const LabelContainer = styled("div")({ marginBottom: 12, }); const BorderAccordion = styled(Accordion)(({ theme }) => ({ - boxShadow: 'none', + boxShadow: "none", border: `1px solid ${theme.palette.primary.light}`, borderRadius: `${theme.spacing(1)} !important`, })); const styles = makeStyles(theme => ({ messageProgress: { - marginRight: '1rem', - color: 'white !important', + marginRight: "1rem", + color: "white !important", }, snackbarContentMessage: { - display: 'flex', - justifyContent: 'flex-start', - alignItems: 'center', - padding: '.75rem 1rem', - width: '100%', + display: "flex", + justifyContent: "flex-start", + alignItems: "center", + padding: ".75rem 1rem", + width: "100%", }, snackbarContentRoot: { padding: 0, }, backdrop: { - '& .MuiBackdrop-root': { - opacity: '0 !important', + "& .MuiBackdrop-root": { + opacity: "0 !important", }, }, container: { - width: '80%', + width: "80%", backgroundColor: theme.palette.grey[300], }, paper: { - margin: '1.5rem', - padding: '1rem', + margin: "1.5rem", + padding: "1rem", }, title: { - display: 'flex', - justifyContent: 'space-between', - backgroundColor: 'white', - borderBottom: '1px solid #ccc', - fontSize: '1.2rem', - fontWeight: 'bold', - padding: '1rem', + display: "flex", + justifyContent: "space-between", + backgroundColor: "white", + borderBottom: "1px solid #ccc", + fontSize: "1.2rem", + fontWeight: "bold", + padding: "1rem", }, playgroundContainer: { - margin: '0 1.5rem 1.5rem 1.5rem', - height: '100%', + margin: "0 1.5rem 1.5rem 1.5rem", + height: "100%", }, })); -const allAssociationsAggregation = [ - ...new Set(dataSources.map(e => e.aggregation)), -]; -const allPrioritizationAggregation = [ - ...new Set(prioritizationCols.map(e => e.aggregation)), -]; +const allAssociationsAggregation = [...new Set(dataSources.map(e => e.aggregation))]; +const allPrioritizationAggregation = [...new Set(prioritizationCols.map(e => e.aggregation))]; const initialState = { associationAggregationSelectValue: allAssociationsAggregation, @@ -125,7 +117,7 @@ const initialState = { const reducer = (state = initialState, action) => { switch (action.type) { - case 'UPDATE_ASSOCIATION_COLUMNS': + case "UPDATE_ASSOCIATION_COLUMNS": return { ...state, associationAggregationSelectValue: action.payload, @@ -134,15 +126,14 @@ const reducer = (state = initialState, action) => { state.selectedAssociationAggregationColumnObjectValue ), }; - case 'UPDATE_PRIORITISATION_COLUMNS': + case "UPDATE_PRIORITISATION_COLUMNS": return { ...state, prioritisationAggregationSelectValue: action.payload, - selectedPrioritisationAggregationColumnObjectValue: - getFilteredColumnArray( - action.payload, - state.selectedPrioritisationAggregationColumnObjectValue - ), + selectedPrioritisationAggregationColumnObjectValue: getFilteredColumnArray( + action.payload, + state.selectedPrioritisationAggregationColumnObjectValue + ), }; default: return state; @@ -151,11 +142,11 @@ const reducer = (state = initialState, action) => { const actions = { UPDATE_ASSOCIATION_COLUMNS: payload => ({ - type: 'UPDATE_ASSOCIATION_COLUMNS', + type: "UPDATE_ASSOCIATION_COLUMNS", payload, }), UPDATE_PRIORITISATION_COLUMNS: payload => ({ - type: 'UPDATE_PRIORITISATION_COLUMNS', + type: "UPDATE_PRIORITISATION_COLUMNS", payload, }), }; @@ -179,9 +170,7 @@ function DataDownloader({ fileStem }) { dataSourcesRequired, } = useAotfContext(); const [onlyPinnedCheckBox, setOnlyPinnedCheckBox] = useState(false); - const [weightControlCheckBox, setWeightControlCheckBox] = useState( - modifiedSourcesDataControls - ); + const [weightControlCheckBox, setWeightControlCheckBox] = useState(modifiedSourcesDataControls); const [requiredControlCheckBox, setRequiredControlCheckBox] = useState( modifiedSourcesDataControls ); @@ -205,15 +194,10 @@ function DataDownloader({ fileStem }) { ); const prioritisationColumns = useMemo( () => - getExportedPrioritisationColumns( - state.selectedPrioritisationAggregationColumnObjectValue - ), + getExportedPrioritisationColumns(state.selectedPrioritisationAggregationColumnObjectValue), [state.selectedPrioritisationAggregationColumnObjectValue] ); - const queryResponseSelector = useMemo( - () => getRowsQuerySelector(entityToGet), - [entityToGet] - ); + const queryResponseSelector = useMemo(() => getRowsQuerySelector(entityToGet), [entityToGet]); const allAssociationsVariable = { id, @@ -247,11 +231,11 @@ function DataDownloader({ fileStem }) { ); const open = Boolean(anchorEl); - const popoverId = open ? 'downloader-popover' : undefined; + const popoverId = open ? "downloader-popover" : undefined; const downloadData = async (format, dataColumns, rows, dataFileStem) => { let allRows = rows; - if (typeof rows === 'function') { + if (typeof rows === "function") { setDownloading(true); allRows = await rows(); setDownloading(false); @@ -277,13 +261,13 @@ function DataDownloader({ fileStem }) { const handleClickDownloadJSON = async () => { const data = onlyPinnedCheckBox ? getOnlyPinnedData : getAllAssociations; const columnToGet = onlyTargetData ? prioritisationColumns : columns; - downloadData('json', columnToGet, data, fileStem); + downloadData("json", columnToGet, data, fileStem); }; const handleClickDownloadTSV = async () => { const data = onlyPinnedCheckBox ? getOnlyPinnedData : getAllAssociations; const columnToGet = onlyTargetData ? prioritisationColumns : columns; - downloadData('tsv', columnToGet, data, fileStem); + downloadData("tsv", columnToGet, data, fileStem); }; useEffect(() => { @@ -306,7 +290,7 @@ function DataDownloader({ fileStem }) { onClose={handleClosePopover} open={open} sx={{ - '.MuiDialog-paper': { + ".MuiDialog-paper": { width: "70%", maxWidth: "800px !important", borderRadius: theme => theme.spacing(1), @@ -316,15 +300,13 @@ function DataDownloader({ fileStem }) { Export: {fileStem} data - } - > + }> Advanced export options: - + Associations Aggregation @@ -334,13 +316,11 @@ function DataDownloader({ fileStem }) { labelId="select-association-small-label" value={state.associationAggregationSelectValue} label="Associations Aggregation" - renderValue={selected => selected.join(', ')} + renderValue={selected => selected.join(", ")} onChange={e => { dispatch( actions.UPDATE_ASSOCIATION_COLUMNS( - e.target.value.length - ? String(e.target.value).split(',') - : [] + e.target.value.length ? String(e.target.value).split(",") : [] ) ); }} @@ -348,24 +328,20 @@ function DataDownloader({ fileStem }) { {allAssociationsAggregation.map(ds => ( -1 - } + checked={state.associationAggregationSelectValue.indexOf(ds) > -1} /> ))} - Selected {state.associationAggregationSelectValue.length} of{' '} + Selected {state.associationAggregationSelectValue.length} of{" "} {allAssociationsAggregation.length} - {entity === 'disease' && ( - + {entity === "disease" && ( + Prioritization Aggregation @@ -375,13 +351,11 @@ function DataDownloader({ fileStem }) { labelId="select-prioritization-small-label" value={state.prioritisationAggregationSelectValue} label="Prioritization Aggregation" - renderValue={selected => selected.join(', ')} + renderValue={selected => selected.join(", ")} onChange={e => { dispatch( actions.UPDATE_PRIORITISATION_COLUMNS( - e.target.value.length - ? String(e.target.value).split(',') - : [] + e.target.value.length ? String(e.target.value).split(",") : [] ) ); }} @@ -389,19 +363,14 @@ function DataDownloader({ fileStem }) { {allPrioritizationAggregation.map(ds => ( -1 - } + checked={state.prioritisationAggregationSelectValue.indexOf(ds) > -1} /> ))} - Selected{' '} - {state.prioritisationAggregationSelectValue.length} of{' '} + Selected {state.prioritisationAggregationSelectValue.length} of{" "} {allPrioritizationAggregation.length} @@ -424,9 +393,7 @@ function DataDownloader({ fileStem }) { - setRequiredControlCheckBox(e.target.checked) - } + onChange={e => setRequiredControlCheckBox(e.target.checked)} /> } label="Include custom required control" @@ -443,14 +410,13 @@ function DataDownloader({ fileStem }) { label="Only pinned / upload rows" /> - {entity === 'disease' && ( + {entity === "disease" && ( setOnlyTargetData(e.target.checked)} @@ -464,9 +430,9 @@ function DataDownloader({ fileStem }) { @@ -487,20 +453,12 @@ function DataDownloader({ fileStem }) { - - @@ -510,7 +468,7 @@ function DataDownloader({ fileStem }) { { setUrlSnackbar(false); From ac5edc1ee38487ff4b2dc8502b0a6d466ada0e92 Mon Sep 17 00:00:00 2001 From: Chintan Mehta Date: Wed, 25 Oct 2023 15:46:43 +0100 Subject: [PATCH 20/20] using local config --- .../src/components/AssociationsToolkit/DataDownloader.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx b/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx index e229389a2..ee0561b65 100644 --- a/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx +++ b/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx @@ -41,7 +41,7 @@ import { createBlob, getFilteredColumnArray, } from "./utils/downloads"; -import config from "ui/src/config"; +import config from "../../config"; const { isPartnerPreview } = config.profile;