diff --git a/docker-compose.dev.vector.yml b/docker-compose.dev.vector.yml index 7248ff0e2..64d8bc97f 100644 --- a/docker-compose.dev.vector.yml +++ b/docker-compose.dev.vector.yml @@ -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 diff --git a/js/components/datasets/datasetMoleculeList.js b/js/components/datasets/datasetMoleculeList.js index 0b303ef13..701521892 100644 --- a/js/components/datasets/datasetMoleculeList.js +++ b/js/components/datasets/datasetMoleculeList.js @@ -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 ) ); diff --git a/js/components/preview/projectHistoryPanel/JobConfigurationDialog.js b/js/components/preview/projectHistoryPanel/JobConfigurationDialog.js index b4952d272..c48772f36 100644 --- a/js/components/preview/projectHistoryPanel/JobConfigurationDialog.js +++ b/js/components/preview/projectHistoryPanel/JobConfigurationDialog.js @@ -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'; @@ -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); }; @@ -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 => { @@ -267,6 +265,7 @@ const JobConfigurationDialog = ({ snapshots }) => { const onSubmitForm = async ({ job, inputs, snapshot }) => { try { + setIsLaunchButtonDisabled(true); let chosenLHSCompounds = null; // TODO: chosenRHSCompounds let chosenRHSCompounds = null; @@ -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*/); @@ -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 { @@ -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 { @@ -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); @@ -582,7 +586,7 @@ const JobConfigurationDialog = ({ snapshots }) => { {errorMsg?.message ?? errorMsg} )} - diff --git a/js/components/snapshot/redux/dispatchActions.js b/js/components/snapshot/redux/dispatchActions.js index b2ee8a807..7ac500137 100644 --- a/js/components/snapshot/redux/dispatchActions.js +++ b/js/components/snapshot/redux/dispatchActions.js @@ -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) => { @@ -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 @@ -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); @@ -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));