Skip to content

Commit

Permalink
#1393 - file name part implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
boriskovar-m2ms committed May 28, 2024
1 parent b412ec3 commit 3117c22
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 5 additions & 3 deletions js/components/datasets/compoundSetList.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const CompoundSetList = () => {
const greenInput = useSelector(state => state.previewReducers.compounds[compoundsColors.green.key]);
const purpleInput = useSelector(state => state.previewReducers.compounds[compoundsColors.purple.key]);
const apricotInput = useSelector(state => state.previewReducers.compounds[compoundsColors.apricot.key]);
const targetName = useSelector(state => state.apiReducers.target_on_name);

const inputs = {
[compoundsColors.blue.key]: blueInput,
Expand Down Expand Up @@ -130,7 +131,7 @@ export const CompoundSetList = () => {
const cmpColorsForDataset = compoundColors[datasetID];
if (cmpColorsForDataset) {
shoppingCartColors = cmpColorsForDataset[compound.id];
shoppingCartColors.forEach(color => {
shoppingCartColors?.forEach(color => {
if (!colorsTemplate.hasOwnProperty(color)) {
colorsTemplate[color] = '';
if (inputs.hasOwnProperty(color) && inputs[color]) {
Expand Down Expand Up @@ -194,7 +195,8 @@ export const CompoundSetList = () => {
listOfMols.push(molObj);
});

const reqObj = { title: datasetID, dict: listOfMols };
const fileName = `${targetName}-RHS-selection.csv`;
const reqObj = { title: datasetID, filename: fileName, dict: listOfMols };
const jsonString = JSON.stringify(reqObj);

api({
Expand All @@ -205,7 +207,7 @@ export const CompoundSetList = () => {
var anchor = document.createElement('a');
anchor.href = `${base_url}/api/dicttocsv/?file_url=${resp.data['file_url']}`;
anchor.target = '_blank';
anchor.download = 'download';
anchor.download = `${fileName}`; //'download';
anchor.click();
});
};
Expand Down
9 changes: 7 additions & 2 deletions js/components/datasets/selectedCompoundsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ export const SelectedCompoundList = memo(() => {
const moleculeLists = useSelector(state => state.datasetsReducers.moleculeLists);
const allMoleculesList = useSelector(state => state.apiReducers.all_mol_lists);

const targetName = useSelector(state => state.apiReducers.target_on_name);

const compoundsToBuyList = useSelector(state => state.datasetsReducers.compoundsToBuyDatasetMap);

let selectedMolecules = [];
Expand Down Expand Up @@ -567,7 +569,9 @@ export const SelectedCompoundList = memo(() => {
listOfMols.push(molObj);
});

const reqObj = { title: sharedSnapshot.url, dict: listOfMols };
const fileName = `${targetName}-RHS-selection.csv`;
// console.log(`href - ${fileName}`);
const reqObj = { title: sharedSnapshot.url, filename: fileName, dict: listOfMols };
const jsonString = JSON.stringify(reqObj);

api({
Expand All @@ -577,8 +581,9 @@ export const SelectedCompoundList = memo(() => {
}).then(resp => {
var anchor = document.createElement('a');
anchor.href = `${base_url}/api/dicttocsv/?file_url=${resp.data['file_url']}`;
// console.log(`href - ${base_url}/api/dicttocsv/?file_url=${resp.data['file_url']}`);
anchor.target = '_blank';
anchor.download = 'download';
anchor.download = `${fileName}`; //'download';
anchor.click();
});
});
Expand Down

0 comments on commit 3117c22

Please sign in to comment.