From c244d20e9855a22ca2b85a0c95aa03c13faf40d3 Mon Sep 17 00:00:00 2001 From: matej <60509086+matej-vavrek@users.noreply.github.com> Date: Tue, 1 Oct 2024 12:41:00 +0200 Subject: [PATCH] #1497 (#454) * Squashed commit of the following: commit e61321646b0f62c6ba81ca8dbbb8a328405819c4 Author: Boris Kovar Date: Wed Jul 31 13:57:02 2024 +0200 - implemented #1251 * #1482 added TagName and CentroidRes columns for expanded view of observation dialog * #1489 show warning toast message if is defined on target load * #1322 added longcode column * updated general function for tag comparison * #1505 adjusted getting of centroid_res * #1458 allow to tag XCA sites, temp commit # Conflicts: # js/components/preview/molecule/observationsDialog.js * #1458 adjusted functionality and styling to proper change tag * #1508 removed TagName column in expanded observation dialog, changed order of columns, adjusted labels and tooltips, show observation dialog in its full height * #1508 adjusted column order and width calculation * #1501 added upload links to menu * #1520 show tag alias instead of upload_name on hit navigator CanonSites & ConformerSites box tooltip * #1519 keep tag in edit window after save * #1497 added Path column for extended view of observations --------- Co-authored-by: Boris Kovar --- .../molecule/moleculeView/moleculeView.js | 36 +++++++++++++++++++ .../preview/molecule/observationsDialog.js | 4 +++ 2 files changed, 40 insertions(+) diff --git a/js/components/preview/molecule/moleculeView/moleculeView.js b/js/components/preview/molecule/moleculeView/moleculeView.js index 1ffab6b4e..80c7dedbf 100644 --- a/js/components/preview/molecule/moleculeView/moleculeView.js +++ b/js/components/preview/molecule/moleculeView/moleculeView.js @@ -58,6 +58,8 @@ import { DJANGO_CONTEXT } from '../../../../utils/djangoContext'; import { getFontColorByBackgroundColor } from '../../../../utils/colors'; import { api, METHOD } from '../../../../utils/api'; import { base_url } from '../../../routes/constants'; +import { ContentCopyRounded } from '@mui/icons-material'; +import { ToastContext } from '../../../toast'; const useStyles = makeStyles(theme => ({ container: { @@ -411,6 +413,7 @@ const MoleculeView = memo( const [tagEditModalOpenNew, setTagEditModalOpenNew] = useState(tagEditorOpenObs); const { getNglView } = useContext(NglContext); + const { toastInfo } = useContext(ToastContext); const stage = getNglView(VIEWS.MAJOR_VIEW) && getNglView(VIEWS.MAJOR_VIEW).stage; const isLigandOn = L; @@ -465,6 +468,7 @@ const MoleculeView = memo( const [moleculeTooltipOpen, setMoleculeTooltipOpen] = useState(false); const [tagPopoverOpen, setTagPopoverOpen] = useState(null); const [centroidRes, setCentroidRes] = useState(''); + const [experimentalPath, setExperimentalPath] = useState(''); const moleculeImgRef = useRef(null); @@ -514,6 +518,26 @@ const MoleculeView = memo( }); }, [data.canon_site_conf]); + useEffect(() => { + api({ + url: `${base_url}/api/experiments/`, + method: METHOD.GET + }) + .then(resp => { + const experiment = resp.data.results.find(experiment => experiment.id === data.experiment); + if (experiment) { + setExperimentalPath(experiment.pdb_info_source_file ?? ''); + } else { + console.log('there is not any matching canonSiteConf object with ' + data.experiment + ' id'); + setExperimentalPath(''); + } + }) + .catch(err => { + console.log('error fetching experiment from experiments api', err); + setExperimentalPath(''); + }); + }, [data.experiment]); + useEffect(() => { if (showExpandedView) { setHeaderWidthsHandler(centroidRes, 'CentroidRes'); @@ -1134,6 +1158,11 @@ const MoleculeView = memo( return tagTooltip; }, [getTagType]); + const copyExperimentalPaths = async () => { + await navigator.clipboard.writeText(experimentalPath); + toastInfo('Link was copied to the clipboard', { autoHideDuration: 5000 }); + }; + return ( <> + 0 ? experimentalPath : 'empty path'}> + + + + + + } LongCode + + Path + )}