Skip to content

Commit

Permalink
#1514 added target_access_string to /api/download_structures, replace…
Browse files Browse the repository at this point in the history
…d /api/molgroup with /api/siteobservationgroup, minor fixes
  • Loading branch information
matej-vavrek committed Oct 1, 2024
1 parent e214bd7 commit f32410d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 35 deletions.
2 changes: 1 addition & 1 deletion js/components/projects/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ export const Projects = memo(({ }) => {
</TableCell>
</Tooltip>
<TableCell align="left" style={{ minWidth: '100px', padding: '0px 10px 0px 0px', margin: '0px' }}>
<Link to={`${URLS.target}${project.target}`}>
<Link to={`${URLS.target}${project.target.title}`}>
<div>{project.target.title === undefined ? project.target : project.target.title}</div>
</Link>
</TableCell>
Expand Down
16 changes: 9 additions & 7 deletions js/components/snapshot/modals/downloadStructuresDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const createFlagObjectFromFlagList = flagList => {
);
};

export const DownloadStructureDialog = memo(({}) => {
export const DownloadStructureDialog = memo(({ }) => {
const newDownload = '--- NEW DOWNLOAD ---';
const dispatch = useDispatch();
const classes = useStyles();
Expand All @@ -147,6 +147,7 @@ export const DownloadStructureDialog = memo(({}) => {
const taggedMolecules = useSelector(state => selectJoinedMoleculeList(state));
const downloadTags = useSelector(state => state.apiReducers.downloadTags);
const currentSnapshot = useSelector(state => state.projectReducers.currentSnapshot);
const currentProject = useSelector(state => state.targetReducers.currentProject);

const [structuresSelection, setStructuresSelection] = useState('allStructures');

Expand Down Expand Up @@ -236,6 +237,7 @@ export const DownloadStructureDialog = memo(({}) => {
} else {
requestObject = {
target_name: targetName,
target_access_string: currentProject?.target_access_string,
proteins: proteinNames,
...mapFiles,
...crystallographicFiles,
Expand All @@ -253,12 +255,12 @@ export const DownloadStructureDialog = memo(({}) => {
const prepareDownloadClicked = () => async (dispatch, getState) => {
const options = { link: { linkAction: downloadStructuresZip, linkText: 'Click to Download', linkParams: [] } };
if (selectedDownload !== newDownload) {
const donwloadTag = findDownload(selectedDownload);
if (donwloadTag) {
const downloadTag = findDownload(selectedDownload);
if (downloadTag) {
setGeneralError(false);
setZipPreparing(true);
setAlreadyInProgress(false);
getDownloadStructuresUrl(donwloadTag.additional_info.requestObject)
getDownloadStructuresUrl(downloadTag.additional_info.requestObject)
.then(resp => {
if (resp.status === 208) {
//same download is already preparing for someone else
Expand All @@ -276,7 +278,7 @@ export const DownloadStructureDialog = memo(({}) => {
if (resp) {
const fileSizeInBytes = resp.headers['content-length'];
setFileSize(getFileSizeString(fileSizeInBytes));
const url = generateUrlFromTagName(donwloadTag.tag);
const url = generateUrlFromTagName(downloadTag.tag);
options.link.linkParams = [url];
setDownloadTagUrl(url);
setZipPreparing(false);
Expand Down Expand Up @@ -534,8 +536,8 @@ export const DownloadStructureDialog = memo(({}) => {
<Grid item>
<Select className={classes.select} value={selectedDownload} onChange={onUpdateExistingDownload}>
<MenuItem value={newDownload}>{newDownload}</MenuItem>
{downloadTags.map(dt => (
<MenuItem value={dt.additional_info.downloadName}>{dt.additional_info.downloadName}</MenuItem>
{downloadTags.map((dt, index) => (
<MenuItem key={index} value={dt.additional_info.downloadName}>{dt.additional_info.downloadName}</MenuItem>
))}
</Select>
</Grid>
Expand Down
37 changes: 11 additions & 26 deletions js/components/target/redux/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,33 +154,18 @@ export const getTargetProjectCombinations = (targets, projects) => {
targetItems.forEach(([targetId, target]) => {
if (!target.isLegacy) {
const updatedTarget = target;
if (Array.isArray(target.project)) {
target.project.forEach(projectId => {
console.log('target.project array member', projectId);
const project = projects.find(project => project.id === projectId);
// const project = projects[projectId];
if (project) {
updatedTarget.project = project;
result.push({ updatedTarget });
} else {
console.log(
`User don't have access to project ${projectId} which is associated with target ${target.title}`
);
}
});
console.log('target.project', target.project);
// TODO debug this?
const projectId = typeof target.project === 'object' ? target.project.id : target.project;
const project = projects.find(project => project.id === projectId);
// const project = projects[projectId];
if (project) {
updatedTarget.project = project;
result.push({ updatedTarget });
} else {
console.log('target.project', target.project);
const projectId = typeof target.project === 'object' ? target.project.id : target.project;
const project = projects.find(project => project.id === projectId);
// const project = projects[projectId];
if (project) {
updatedTarget.project = project;
result.push({ updatedTarget });
} else {
console.log(
`User don't have access to project ${projectId} which is associated with target ${target.title}`
);
}
console.log(
`User don't have access to project ${projectId} which is associated with target ${target.title}`
);
}
} else {
result.push({ updatedTarget: { ...target, project: { target_access_string: 'Legacy' } } });
Expand Down
3 changes: 2 additions & 1 deletion js/utils/genericList.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ export const getUrl = ({
}
} else if (list_type === OBJECT_TYPE.MOLECULE_GROUP) {
if (target_on !== undefined) {
// api/molgroup was replaced by api/siteobservationgroup
get_params.target_id = target_on;
base_url += 'molgroup/';
base_url += 'siteobservationgroup/';
get_params.group_type = group_type;
}
} else if (list_type === listTypes.MOLECULE) {
Expand Down

0 comments on commit f32410d

Please sign in to comment.