Skip to content

Commit

Permalink
- last fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
boriskovar-m2ms committed Feb 4, 2025
1 parent d8f9811 commit 119bb81
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 71 deletions.
4 changes: 2 additions & 2 deletions docker-compose.dev.vector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ services:
start_period: 10s
web:
container_name: web_dock
# image: xchem/fragalysis-stack:latest
image: xchem/fragalysis-backend:m2ms-1649-refresh-fix
image: xchem/fragalysis-stack:latest
# image: xchem/fragalysis-backend:m2ms-1649-refresh-fix
# image: boriskovarm2ms/fragalysis-stack:experiment2
# image: kaliif/fragalysis-backend:latest
command: /bin/bash /code/launch-stack.sh
Expand Down
6 changes: 3 additions & 3 deletions js/components/datasets/datasetMoleculeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,11 +492,11 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
const isSelectedTypeOn = (typeList, isLHSReference) => {
if (typeList) {
if (!isLHSReference) {
return typeList.some(molId => allMolecules?.some(mol => mol.id === molId));
return typeList?.some(molId => allMolecules?.some(mol => mol.id === molId));
} else {
const molsWithLHSReference = allMolecules?.filter(mol => mol.site_observation_code);
return typeList.some(molId =>
molsWithLHSReference.some(
return typeList?.some(molId =>
molsWithLHSReference?.some(
mol => mol.site_observation_code === allMoleculesList?.find(m => m.id === molId)?.code
)
);
Expand Down
58 changes: 31 additions & 27 deletions js/components/preview/projectHistoryPanel/JobConfigurationDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
} from '../../projects/redux/dispatchActions';
import { areArraysSame } from '../../../utils/array';
import { setDisableRedirect, setDontShowShareSnapshot } from '../../snapshot/redux/actions';
import { createNewSnapshot } from '../../snapshot/redux/dispatchActions';
import { changeSnapshot, createNewSnapshot } from '../../snapshot/redux/dispatchActions';
import { NglContext } from '../../nglView/nglProvider';
import moment from 'moment';
import { SnapshotType } from '../../projects/redux/constants';
Expand Down Expand Up @@ -167,6 +167,8 @@ const JobConfigurationDialog = ({ snapshots }) => {
const [open, setOpen] = useState(false);
const [isError, setIsError] = useState(false);
const [errorMsg, setErrorMsg] = useState(null);
const [isLaunchButtonDisabled, setIsLaunchButtonDisabled] = useState(false);

const handleTooltipClose = () => {
setOpen(false);
};
Expand Down Expand Up @@ -228,31 +230,27 @@ const JobConfigurationDialog = ({ snapshots }) => {
dispatch(setDisableRedirect(true));
dispatch(setDontShowShareSnapshot(true));

// With the above flags set, createNewSnapshot returns the ID of newly created snapshot as the second item in the array
const snapshotId = (
await dispatch(
createNewSnapshot({
title,
description,
type,
author,
parent,
session_project,
nglViewList,
stage,
overwriteSnapshot: false,
createDiscourse: true
})
)
)[1];

// Create new snapshot
const newSnapshot = await dispatch(getSnapshotAttributesByID(snapshotId));

// Trigger graph rerender
dispatch(refreshJobsData());

return newSnapshot;
return dispatch(
createNewSnapshot({
title,
description,
type,
author,
parent,
session_project,
nglViewList,
stage,
overwriteSnapshot: false,
createDiscourse: true
})
)
.then(snapshotId => {
return dispatch(getSnapshotAttributesByID(snapshotId));
})
.then(snapshot => {
dispatch(refreshJobsData());
return snapshot;
});
};

const validate = values => {
Expand All @@ -267,6 +265,7 @@ const JobConfigurationDialog = ({ snapshots }) => {

const onSubmitForm = async ({ job, inputs, snapshot }) => {
try {
setIsLaunchButtonDisabled(true);
let chosenLHSCompounds = null;
// TODO: chosenRHSCompounds
let chosenRHSCompounds = null;
Expand All @@ -276,6 +275,7 @@ const JobConfigurationDialog = ({ snapshots }) => {
chosenSnapshot = snapshot;
if (!snapshot.additional_info) {
chosenSnapshot = await createSnapshot();
dispatch(changeSnapshot(currentSessionProject.projectID, chosenSnapshot.id, stage, true));
const currentSnapshotSelectedCompounds = allMolecules
.filter(molecule => currentSnapshotSelectedCompoundsIDs.includes(molecule.id))
.map(molecule => molecule /*.code*/);
Expand Down Expand Up @@ -339,6 +339,7 @@ const JobConfigurationDialog = ({ snapshots }) => {
// || !areArraysSame(savedSelection, currentSnapshotSelectedDatasetsCompounds)
) {
chosenSnapshot = await createSnapshot();
dispatch(changeSnapshot(currentSessionProject.projectID, chosenSnapshot.id, stage, true));
chosenLHSCompounds = currentSnapshotSelectedCompounds;
chosenRHSCompounds = currentSnapshotSelectedDatasetsCompounds;
} else {
Expand Down Expand Up @@ -384,6 +385,7 @@ const JobConfigurationDialog = ({ snapshots }) => {
!areArraysSame(savedVisibleCompounds, currentSnapshotVisibleDatasetCompounds)
) {
chosenSnapshot = await createSnapshot();
dispatch(changeSnapshot(currentSessionProject.projectID, chosenSnapshot.id, stage, true));
chosenLHSCompounds = currentSnapshotVisibleCompounds;
chosenRHSCompounds = currentSnapshotVisibleDatasetCompounds;
} else {
Expand Down Expand Up @@ -451,7 +453,9 @@ const JobConfigurationDialog = ({ snapshots }) => {
setErrorMsg("There's no selected inputs to run the job.");
setIsError(true);
}
setIsLaunchButtonDisabled(false);
} catch (err) {
setIsLaunchButtonDisabled(false);
console.error(err);
setErrorMsg(err.response.data);
setIsError(true);
Expand Down Expand Up @@ -582,7 +586,7 @@ const JobConfigurationDialog = ({ snapshots }) => {
{errorMsg?.message ?? errorMsg}
</Paper>
)}
<Button color="primary" size="large" type="submit">
<Button color="primary" size="large" type="submit" disabled={isLaunchButtonDisabled}>
Launch
</Button>
</div>
Expand Down
87 changes: 48 additions & 39 deletions js/components/snapshot/redux/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import {
} from './utilitySnapshotShapes';
import { setEntireState } from '../../../reducers/actions';
import { VIEWS } from '../../../constants/constants';
import { fr } from 'date-fns/locale';
// import { display } from 'html2canvas/dist/types/css/property-descriptors/display';

export const getListOfSnapshots = () => (dispatch, getState) => {
Expand Down Expand Up @@ -627,7 +628,7 @@ export const getCleanStateForSnapshot = () => (dispatch, getState) => {
return snapshotData;
};

export const changeSnapshot = (projectID, snapshotID, stage) => async (dispatch, getState) => {
export const changeSnapshot = (projectID, snapshotID, stage, fromJobExec = false) => async (dispatch, getState) => {
dispatch(setSnapshotLoadingInProgress(true));
dispatch(setIsSnapshot(true));
// A hacky way of changing the URL without triggering react-router
Expand All @@ -652,45 +653,51 @@ export const changeSnapshot = (projectID, snapshotID, stage) => async (dispatch,
})
);

//orientation animation
const newOrientation = snapshotState.nglReducers.nglOrientations[VIEWS.MAJOR_VIEW];
await stage.animationControls.orient(newOrientation.elements, 2000); //.then(() => {
let currentState = getState();
const toBeDisplayedLHSCurrent = currentState.selectionReducers.toBeDisplayedList;
const toBeDisplayedRHSCurrent = currentState.datasetsReducers.toBeDisplayedList;
const toBeDisplayedLHSNew = snapshotState.selectionReducers.toBeDisplayedList;
const toBeDisplayedRHSNew = snapshotState.datasetsReducers.toBeDisplayedList;

//remove LHS stuff that is not in the new snapshot
const toBeNoLongerDisplayedLHS = toBeDisplayedLHSCurrent.filter(
currentStruct =>
!toBeDisplayedLHSNew.find(newStruct => newStruct.id === currentStruct.id && newStruct.type === currentStruct.type)
);
toBeNoLongerDisplayedLHS.forEach(notToBeDisplayed =>
toBeDisplayedLHSNew.push({ ...notToBeDisplayed, display: false })
);
let toBeDisplayedLHSNewDeepCopy = null;
let toBeDisplayedRHSNewDeepCopy = null;
if (!fromJobExec) {
//orientation animation
const newOrientation = snapshotState.nglReducers.nglOrientations[VIEWS.MAJOR_VIEW];
await stage.animationControls.orient(newOrientation.elements, 2000); //.then(() => {
const toBeDisplayedLHSCurrent = currentState.selectionReducers.toBeDisplayedList;
const toBeDisplayedRHSCurrent = currentState.datasetsReducers.toBeDisplayedList;
const toBeDisplayedLHSNew = snapshotState.selectionReducers.toBeDisplayedList;
const toBeDisplayedRHSNew = snapshotState.datasetsReducers.toBeDisplayedList;

//remove LHS stuff that is not in the new snapshot
const toBeNoLongerDisplayedLHS = toBeDisplayedLHSCurrent.filter(
currentStruct =>
!toBeDisplayedLHSNew.find(
newStruct => newStruct.id === currentStruct.id && newStruct.type === currentStruct.type
)
);
toBeNoLongerDisplayedLHS.forEach(notToBeDisplayed =>
toBeDisplayedLHSNew.push({ ...notToBeDisplayed, display: false })
);

//remove RHS stuff that is not in the new snapshot
const toBeNoLongerDisplayedRHS = [];
Object.keys(toBeDisplayedRHSCurrent).forEach(datasetID => {
const currentDataset = toBeDisplayedRHSCurrent[datasetID];
const newDataset = toBeDisplayedRHSNew[datasetID];
if (newDataset) {
const toBeNoLongerDisplayed = currentDataset.filter(
currentStruct =>
!newDataset.find(newStruct => newStruct.id === currentStruct.id && newStruct.type === currentStruct.type)
);
toBeNoLongerDisplayedRHS.push(...toBeNoLongerDisplayed);
}
});
toBeNoLongerDisplayedRHS.forEach(notToBeDisplayed =>
toBeDisplayedRHSNew[notToBeDisplayed.datasetID]
? toBeDisplayedRHSNew[notToBeDisplayed.datasetID].push({ ...notToBeDisplayed, display: false })
: (toBeDisplayedRHSNew[notToBeDisplayed.datasetID] = [{ ...notToBeDisplayed, display: false }])
);
//remove RHS stuff that is not in the new snapshot
const toBeNoLongerDisplayedRHS = [];
Object.keys(toBeDisplayedRHSCurrent).forEach(datasetID => {
const currentDataset = toBeDisplayedRHSCurrent[datasetID];
const newDataset = toBeDisplayedRHSNew[datasetID];
if (newDataset) {
const toBeNoLongerDisplayed = currentDataset.filter(
currentStruct =>
!newDataset.find(newStruct => newStruct.id === currentStruct.id && newStruct.type === currentStruct.type)
);
toBeNoLongerDisplayedRHS.push(...toBeNoLongerDisplayed);
}
});
toBeNoLongerDisplayedRHS.forEach(notToBeDisplayed =>
toBeDisplayedRHSNew[notToBeDisplayed.datasetID]
? toBeDisplayedRHSNew[notToBeDisplayed.datasetID].push({ ...notToBeDisplayed, display: false })
: (toBeDisplayedRHSNew[notToBeDisplayed.datasetID] = [{ ...notToBeDisplayed, display: false }])
);

const toBeDisplayedLHSNewDeepCopy = deepClone(toBeDisplayedLHSNew);
const toBeDisplayedRHSNewDeepCopy = deepClone(toBeDisplayedRHSNew) || {};
toBeDisplayedLHSNewDeepCopy = deepClone(toBeDisplayedLHSNew);
toBeDisplayedRHSNewDeepCopy = deepClone(toBeDisplayedRHSNew) || {};
}

currentState = getState();
// const copyOfCurrentState = deepClone(currentState);
Expand All @@ -701,8 +708,10 @@ export const changeSnapshot = (projectID, snapshotID, stage) => async (dispatch,
SNAPSHOT_VALUES_NOT_TO_BE_DELETED_SWITCHING_TARGETS
);

dispatch(setToBeDisplayedList(toBeDisplayedLHSNewDeepCopy));
dispatch(setToBeDisplayedLists(toBeDisplayedRHSNewDeepCopy));
if (!fromJobExec) {
dispatch(setToBeDisplayedList(toBeDisplayedLHSNewDeepCopy));
dispatch(setToBeDisplayedLists(toBeDisplayedRHSNewDeepCopy));
}
// });
// await new Promise(r => setTimeout(r, 2000));

Expand Down

0 comments on commit 119bb81

Please sign in to comment.