From 0e308b88a0464c9fdb06b79c095fd8f490022c24 Mon Sep 17 00:00:00 2001 From: boriskovar-m2ms Date: Fri, 6 Sep 2024 09:42:48 +0200 Subject: [PATCH] #1505 (#445) * 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 --------- Co-authored-by: matej --- .../molecule/moleculeView/moleculeView.js | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/js/components/preview/molecule/moleculeView/moleculeView.js b/js/components/preview/molecule/moleculeView/moleculeView.js index 5d7d6cc2a..2e78f35fd 100644 --- a/js/components/preview/molecule/moleculeView/moleculeView.js +++ b/js/components/preview/molecule/moleculeView/moleculeView.js @@ -480,12 +480,33 @@ const MoleculeView = memo( useEffect(() => { api({ - url: `${base_url}/api/canon_sites/`, + url: `${base_url}/api/canon_site_confs/`, method: METHOD.GET }) .then(resp => { - const canonSite = resp.data.results.find(canonSite => canonSite.id === data.canon_site_conf); - setCentroidRes(canonSite ? canonSite.centroid_res : ''); + const canonSiteConf = resp.data.results.find(canonSiteConf => canonSiteConf.id === data.canon_site_conf); + if (canonSiteConf) { + api({ + url: `${base_url}/api/canon_sites/`, + method: METHOD.GET + }) + .then(resp => { + const canonSite = resp.data.results.find(canonSite => canonSite.id === canonSiteConf.canon_site); + if (canonSite) { + setCentroidRes(canonSite.centroid_res); + } else { + console.log('there is not any matching canonSite object with ' + canonSiteConf.canon_site + ' id'); + setCentroidRes(''); + } + }) + .catch(err => { + console.log('error fetching centroid_res from canon_sites', err); + setCentroidRes(''); + }); + } else { + console.log('there is not any matching canonSiteConf object with ' + data.canon_site_conf + ' id'); + setCentroidRes(''); + } }) .catch(err => { console.log('error fetching centroid_res from canon_sites', err);