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

[Platform]: Moving aotf playground to another component #363

Merged
merged 3 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { ApiPlaygroundDrawer } from "ui";
import useAotfContext from "./hooks/useAotfContext";

function AotfApiPlayground() {
const {
id,
pagination,
searhFilter,
sorting,
enableIndirect,
dataSourcesWeights,
entity,
dataSourcesRequired,
query,
} = useAotfContext();

const aggregationFilters = dataSourcesRequired.map(({ id, ...obj }) => ({ ...obj }));

const variables = {
id,
index: pagination.pageIndex,
size: pagination.pageSize,
filter: searhFilter,
sortBy: sorting[0].id,
enableIndirect,
datasources: dataSourcesWeights,
entity,
aggregationFilters,
};

return <ApiPlaygroundDrawer query={query.loc.source.body} variables={variables} />;
}
export default AotfApiPlayground;
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const actions = {
}),
};

function DataDownloader({ fileStem }) {
function DataDownloader() {
const [state, dispatch] = useReducer(reducer, initialState);
const { version } = useConfigContext();
const classes = styles();
Expand All @@ -166,6 +166,7 @@ function DataDownloader({ fileStem }) {
dataSourcesWeights,
dataSourcesRequired,
} = useAotfContext();
const fileStem = `OT-${id}-associated-${entityToGet}s`;
const [onlyPinnedCheckBox, setOnlyPinnedCheckBox] = useState(false);
const [weightControlCheckBox, setWeightControlCheckBox] = useState(modifiedSourcesDataControls);
const [onlyTargetData, setOnlyTargetData] = useState(false);
Expand Down
1 change: 1 addition & 0 deletions apps/platform/src/components/AssociationsToolkit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export { default as TargetPrioritisationSwitch } from "./TargetPrioritisationSwi
export { default as SearhInput } from "./SearchInput";
export { default as DataDownloader } from "./DataDownloader";
export { default as DataUploader } from "./DataUploader/DataUploader";
export { default as AotfApiPlayground } from "./AotfApiPlayground";
export {
default as AssociationsContext,
AssociationsStateProvider as AssociationsProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,12 @@ import {
OptionsControlls,
AotFLoader,
DataUploader,
AotfApiPlayground,
} from "../../../components/AssociationsToolkit";
carcruz marked this conversation as resolved.
Show resolved Hide resolved
import DISEASE_ASSOCIATIONS_QUERY from "./DiseaseAssociationsQuery.gql";
import { ApiPlaygroundDrawer } from "ui";

function AssociationsWrapper() {
const {
initialLoading,
id,
pagination,
searhFilter,
sorting,
enableIndirect,
dataSourcesWeights,
entity,
dataSourcesRequired,
} = useAotfContext();

const aggregationFilters = dataSourcesRequired.map(({ id, ...obj }) => ({ ...obj }));

const variables = {
id,
index: pagination.pageIndex,
size: pagination.pageSize,
filter: searhFilter,
sortBy: sorting[0].id,
enableIndirect,
datasources: dataSourcesWeights,
entity,
aggregationFilters,
};
const { initialLoading, id } = useAotfContext();

if (initialLoading) return <AotFLoader />;

Expand All @@ -56,11 +32,8 @@ function AssociationsWrapper() {
<DataUploader />
</PrivateWrapper>
<Divider orientation="vertical" />
<DataDownloader fileStem={`OT-${id}-associated-targets`} />
<ApiPlaygroundDrawer
query={DISEASE_ASSOCIATIONS_QUERY.loc.source.body}
variables={variables}
/>
<DataDownloader />
<AotfApiPlayground />
</OptionsControlls>
</Box>
<Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,12 @@ import {
OptionsControlls,
AotFLoader,
DataUploader,
AotfApiPlayground,
} from "../../../components/AssociationsToolkit";
import TARGET_ASSOCIATIONS_QUERY from "./TargetAssociationsQuery.gql";
import { ApiPlaygroundDrawer } from "ui";

function AssociationsWrapper() {
const {
initialLoading,
id,
pagination,
searhFilter,
sorting,
enableIndirect,
dataSourcesWeights,
entity,
dataSourcesRequired,
} = useContext(AssociationsContext);

const aggregationFilters = dataSourcesRequired.map(({ id, ...obj }) => ({ ...obj }));

const variables = {
id,
index: pagination.pageIndex,
size: pagination.pageSize,
filter: searhFilter,
sortBy: sorting[0].id,
enableIndirect,
datasources: dataSourcesWeights,
entity,
aggregationFilters,
};
const { initialLoading, id } = useContext(AssociationsContext);

if (initialLoading) return <AotFLoader />;

Expand All @@ -56,11 +32,8 @@ function AssociationsWrapper() {
<DataUploader />
</PrivateWrapper>
<Divider orientation="vertical" />
<DataDownloader fileStem={`OT-${id}-associated-diseases`} />
<ApiPlaygroundDrawer
query={TARGET_ASSOCIATIONS_QUERY.loc.source.body}
variables={variables}
/>
<DataDownloader />
<AotfApiPlayground />
</OptionsControlls>
</Box>
<Box></Box>
Expand Down
Loading