From 3c60628a82b48b6895308f2af9fe0b0a1c817571 Mon Sep 17 00:00:00 2001 From: boriskovar-m2ms Date: Tue, 23 Jul 2024 09:19:17 +0200 Subject: [PATCH] Implements #1474 (#437) * #1403 fixed timer when services are not available * #1389 applied tag.hidden logic, reduced autohide time for tags toasts to 5 seconds * Squashed commit of the following: commit 7511b573482d4a1097286cfdc354b374ec5900e6 Author: Boris Kovar Date: Tue Apr 23 08:27:24 2024 +0200 - finished #1348 commit 6074d79ca46cdd141d166789af1e7268c0e7bf33 Author: Boris Kovar Date: Wed Apr 17 09:50:06 2024 +0200 - #1348 - fixed cases when all pdbs are missing commit 49f0ae8750ac9056dbc6d545a1a151e73f0d3b81 Author: Boris Kovar Date: Wed Apr 10 13:41:50 2024 +0200 - checkpoint commit 13a315ef93d0d5f411b3cb3091696a6bc166ce1d Author: Boris Kovar Date: Wed Apr 3 12:30:06 2024 +0200 - checkpoint commit a5b8cca53af12a5a2f5d20ca74f3c91d9104e4f2 Merge: 34b75f78 756a25be Author: Boris Kovar Date: Mon Mar 25 12:24:01 2024 +0100 Merge branch '#1348' of https://github.com/m2ms/fragalysis-frontend into #1348 commit 34b75f78782360ac20c5c6b5e0f650558ae0e401 Author: Boris Kovar Date: Tue Mar 12 12:35:21 2024 +0100 - latest backend commit 1308cb28c79ea746d2ac6847baa1ee489089d94d Author: Boris Kovar Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 1ee15e78086164142fb79eb8102df2827b28a2c1 Author: Boris Kovar Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit a033b68c5f093743c8fd1deb6eb3e2d1e3aac314 Author: Boris Kovar Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 7149081d50a30191434605dedde5b112539d0141 Author: Boris Kovar Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 623de4fa1750e4d1acf013ae266b1b68fadd8449 Author: Boris Kovar Date: Tue Mar 12 09:48:51 2024 +0100 - using official backend version commit eec204c5771885f95b05a1beb036e483302b987e Author: Boris Kovar Date: Tue Feb 27 12:16:45 2024 +0100 - checkpoint commit dbc93a71846312f0c40c96b7fac207a3380b3c01 Author: Boris Kovar Date: Tue Feb 27 10:27:08 2024 +0100 - checkpoint commit b933243938573b4a2bb23b6d92a0e5eeaf396b10 Author: Boris Kovar Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 4a0e17154d2e947d23668e851ef19c5eaf4d412a Author: Boris Kovar Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 634ed03beb909e1e69c748ddb33a09ada83bd609 Author: Boris Kovar Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 6e65faecf8a1cb880363d5374f9777403b2cf6c1 Author: Boris Kovar Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 1bff7bf46ac041d3d480a9978c340868e98a7e08 Author: Boris Kovar Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 07f21b61bd1204e14db02f424590decfeb527f51 Author: Boris Kovar Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 021366ef147e36a14567b22a1d97628987d13c8e Author: Boris Kovar Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 36f87b4daf9d385b558d4a0663abed13d5e3d13e Author: Boris Kovar Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 87e765a7594fcada946ad65082dd854bc0092328 Author: Boris Kovar Date: Tue Mar 12 12:35:21 2024 +0100 - latest backend commit 72c94f05cbd60bb33f477de4aef471920f1c29bf Author: Boris Kovar Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 224ca2345f734a8819d88125fcabc72aedffb8b2 Author: Boris Kovar Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 36f03f843dce0b603a5f38a246f1cded8ebd9c71 Author: Boris Kovar Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 807292042c5063582f61b642f32762cc013b2323 Author: Boris Kovar Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit e3190563cbd25a4860bb45317fcd18e149214942 Author: Boris Kovar Date: Tue Mar 12 09:48:51 2024 +0100 - using official backend version commit 187e7f39614be2a60857f843bfc8398bb94874f5 Author: Boris Kovar Date: Tue Feb 27 12:16:45 2024 +0100 - checkpoint commit b6aa0a4dbe30d1a1e57092cc2e253b078f49825b Author: Boris Kovar Date: Tue Feb 27 10:27:08 2024 +0100 - checkpoint commit fccf97682fa65b6f86226e85713f3bda283726b4 Author: Boris Kovar Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 965be5ecc97b316a5605ccc3acfbf3646e04e524 Author: Boris Kovar Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit b01cdbf01d85855bfca6f60a3981888334f64d7b Author: Boris Kovar Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit e04fbf2a8b54cb3bad30889e6cd64144fdd74c9c Author: Boris Kovar Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 5d64c26ca47113b78d1680c9381c389260d330f9 Author: Boris Kovar Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit dbb155c0ea79aa6295e6ed18498a4d0b121f0133 Author: Boris Kovar Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit b1c0f3c0c3547eb71d0b756da6b2f11d090df2ad Author: Boris Kovar Date: Thu Feb 29 10:32:27 2024 +0100 - checkpoint commit abc8cc993165970d1827898dbb4cc7795b23835d Author: Boris Kovar Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 2ef004ad1324989890dc2460cb4d991a4d0e3a9d Author: Boris Kovar Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 756a25be46950e2762e3c8c399583132a1d37d57 Merge: f686ef4a f474ff6c Author: Boris Kovar Date: Thu Mar 14 10:00:02 2024 +0100 Merge branch '#1348' of https://github.com/m2ms/fragalysis-frontend into #1348 commit f686ef4a96e57571ab53ce1901927676a85a7eb1 Author: Boris Kovar Date: Tue Mar 12 12:35:21 2024 +0100 - latest backend commit df6209c149d048ff8cc6f5faef40fb4657a51578 Author: Boris Kovar Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit f5a842f250d2706e1fdaba819876fef766b754a1 Author: Boris Kovar Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 83ffcccc99d813815496d1b97443e23bd3e72ae3 Author: Boris Kovar Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 0ecff35ab72e0f679211fd6266a86b9bda3814e0 Author: Boris Kovar Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit d3a90c7e6c5538b46f8c1ed0aa5fa48fd718e951 Author: Boris Kovar Date: Tue Mar 12 09:48:51 2024 +0100 - using official backend version commit 50800b9c05cc94fc783b63e918c419a8f1c95d7b Author: Boris Kovar Date: Tue Feb 27 12:16:45 2024 +0100 - checkpoint commit 2af18fdc661a84342af49b1eaab7e3e09a5f702b Author: Boris Kovar Date: Tue Feb 27 10:27:08 2024 +0100 - checkpoint commit cd75a275c858acfd77eea28c1833175a25ba1776 Author: Boris Kovar Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit c485389796dce1817d14d923e8d41e26875533eb Author: Boris Kovar Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 96296e919e3b15d0bbc0ee66f63c0ee4f7564942 Author: Boris Kovar Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 760152bdc448a9f91c22de292fd4e41b7aa0b626 Author: Boris Kovar Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 8a30204864a5858c94bc0ee6341c9337c1deeff4 Author: Boris Kovar Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 6235e9c320920bb57928af515c7c003eba06d80e Author: Boris Kovar Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit e2e46cb4c68a8c2a2a92a720de978a8935813815 Author: Boris Kovar Date: Thu Feb 29 10:32:27 2024 +0100 - checkpoint commit 8176514e81f7e67a1be034207d7d33ac96a41259 Author: Boris Kovar Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 6aa51082e3832f0a678c270b5cd5d8958de88a96 Author: Boris Kovar Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit f474ff6c01b12c9b1775323bae5eab18b5717d95 Merge: 56c0b85c e728f49c Author: Boris Kovar Date: Thu Mar 14 08:30:00 2024 +0100 Merge branch '#1348' of https://github.com/m2ms/fragalysis-frontend into #1348 # Conflicts: # js/components/preview/tags/details/tagDetails.js commit 56c0b85cc08afe9f56bbf2f78297a3d1251dbc62 Author: Boris Kovar Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit a185933a1639d78238f6f2145f1eae2a0ac4d3c6 Author: Boris Kovar Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 09c97b53e59d30576859a13d5e443fdd6e827e98 Author: Boris Kovar Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit c6d0738d3e376de9082192de4f6d6b91808bafac Author: Boris Kovar Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 72f36b0de20159bb8bbbc2217b073f302c41315e Author: Boris Kovar Date: Thu Feb 29 10:32:27 2024 +0100 - checkpoint commit 971799dffdcfd51601943e981786fc19aa0d672c Author: Boris Kovar Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 1bb53263961016ce3d7a2e3f977a5cbaf2e8e9fb Author: Boris Kovar Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit e728f49cb7e08238afb349039b7cf15d4290555f Author: Boris Kovar Date: Tue Mar 12 12:35:21 2024 +0100 - latest backend commit 125b8d48589d0180d261e781fc18f3b88787cc05 Author: Boris Kovar Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 0e4155177fde3500404a15cd514bc774f3836b43 Author: Boris Kovar Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 8cf43e054416ed1a54565604859a411530ba1837 Author: Boris Kovar Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit d336352f1856fa02722eb27f19511e29f26781c0 Author: Boris Kovar Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 2fb59dcd5c2c14941fd8c74282473822af87b0fb Author: Boris Kovar Date: Tue Mar 12 09:48:51 2024 +0100 - using official backend version commit 9439f5d40bb696f2247f412901b65db8d1ea5ea6 Author: Boris Kovar Date: Thu Mar 7 13:59:03 2024 +0100 - partial fix for purple release for #1370 commit 4ff5f945954ea6533f9c3728c0565b20c79b2b0d Author: Boris Kovar Date: Thu Mar 7 10:10:41 2024 +0100 - implemented #1376 - also fixed bug in download structures dialog where only first download got added to the dropdown menu commit 66a98f3c617d0d110e73cf4df09048c572b3edee Author: Boris Kovar Date: Wed Mar 6 09:47:12 2024 +0100 - implemented #1361 - improvements for #1354 commit 8a193a551faa91e4441783429b980608c116665c Author: Boris Kovar Date: Tue Mar 5 13:24:11 2024 +0100 - cleanup for #1354 commit bb3bf3b6ceafdd40b0778157ff95d01ecceb6f8e Author: Boris Kovar Date: Tue Mar 5 13:21:32 2024 +0100 - updated message for #1354 commit a3dc8191aadd627f4de6f7425c9dfb72c34c1d23 Author: Boris Kovar Date: Tue Mar 5 13:05:12 2024 +0100 - first implementation of #1354 commit 4121519dad01feb107c1a4b2751caefb620f5471 Author: Boris Kovar Date: Tue Mar 5 08:17:49 2024 +0100 - implemented #1357 commit 4d96ff464b940f7aca3340819496e1d6fa03d1cf Author: Boris Kovar Date: Mon Mar 4 10:07:06 2024 +0100 - implemented changes requested in #1326 commit 03158bec02a2a6a8ded44bae99bfccd0f1df49ca Author: Boris Kovar Date: Mon Mar 4 08:45:22 2024 +0100 - fixed problem with tags not visually updating on observations commit 8765a3c69ef662a8c34ce73806bedfa306ab12f7 Author: matej Date: Mon Feb 26 21:36:12 2024 +0100 #1341 "pin" edit tag row outside of tag list commit 6db8b22ca6133eddeb7322cc0bd0ab52a5272fd6 Author: Boris Kovar Date: Thu Feb 29 10:32:27 2024 +0100 - checkpoint commit 027eaf0eacd1ea929eb00bfca4aef9e34ba1deab Author: Boris Kovar Date: Tue Feb 27 12:16:45 2024 +0100 - checkpoint commit 7407dbd02fe0cf50dcb069740475e914010e9016 Author: Boris Kovar Date: Tue Feb 27 10:27:08 2024 +0100 - checkpoint commit c13628b494bb5bfcd3b889b7a040568b683549a8 Author: Boris Kovar Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit e39721c2353fe40249ea7cac6d7d01bc58186fe2 Author: Boris Kovar Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint * - using official backend now * Squashed commit of the following: commit 8fe886a84214d86fc9b0436a8737a3bf29697bc9 Author: Boris Kovar Date: Wed May 15 09:00:04 2024 +0200 Squashed commit of the following: commit 68132195b92c9793ddbde000e7a0e9c64e7330b4 Author: matej Date: Mon Apr 29 07:38:30 2024 +0200 #1261 added icon for "Manage grouping" button commit a665ed53bbe132ab1d2751ed09a521479d58ca09 Author: matej Date: Sun Apr 28 23:23:25 2024 +0200 #1261 added buttons into observation dialog for later poses handling commit 70a5e702d01dcb09ec9b20d131a0a940cc9a1650 Author: Boris Kovar Date: Mon Apr 29 09:20:46 2024 +0200 - #1261 - initial implementation * - now FE point to local dev env * - pointing to correct backend * - #1440 implemented fix * fixed tag reset in edit modal * added better default values handling in tag edit modal * Squashed commit of the following: commit 68132195b92c9793ddbde000e7a0e9c64e7330b4 Author: matej Date: Mon Apr 29 07:38:30 2024 +0200 commit a665ed53bbe132ab1d2751ed09a521479d58ca09 Author: matej Date: Sun Apr 28 23:23:25 2024 +0200 * #1393 - small bug fix for csv name * - implementation of #1441 * Squashed commit of the following: commit e68fab1d063a15fbce043b9c44dd6f135efeb743 Author: Boris Kovar Date: Mon Jun 10 13:56:06 2024 +0200 - optimized snapshot creation - optimized snapshot restoration - fixed bugs when switching between snapshots in one project * #1322 main redesign of hits and observations views * #1322 changed min width of lhs * #1322 count also tags without curator tags as untagged * #1322 remove selected tag if was set as hidden * #1465 updated companies in credits and logic behind for better manageability * #1465 changed some logos for bigger ones, added tooltip also for header logos, removed duplicate of openDiscourseLink * increased font size of mui tooltip * #1322 updated tooltip of tag info boxes with tag upload name * #1465 changed naming IMAGE_SIZE to MAX_IMAGE_HEIGHT to be more descriptive * Squashed commit of the following: commit 1ec9788be865160762b35b81ff5192f04a154e79 Author: Boris Kovar Date: Tue Jul 23 08:47:00 2024 +0200 - ported csv generation functionality from backend to frontend --------- Co-authored-by: matej --- js/components/datasets/compoundSetList.js | 26 ++++---- .../datasets/selectedCompoundsList.js | 29 +++++---- js/utils/csv.js | 64 +++++++++++++++++++ 3 files changed, 93 insertions(+), 26 deletions(-) create mode 100644 js/utils/csv.js diff --git a/js/components/datasets/compoundSetList.js b/js/components/datasets/compoundSetList.js index 09d68b0f5..29220ce8f 100644 --- a/js/components/datasets/compoundSetList.js +++ b/js/components/datasets/compoundSetList.js @@ -14,6 +14,7 @@ import SearchField from '../common/Components/SearchField'; import { base_url } from '../routes/constants'; import { METHOD, api } from '../../utils/api'; import { compoundsColors } from '../preview/compounds/redux/constants'; +import { downloadRHSCSVExport } from '../../utils/csv'; const useStyles = makeStyles(theme => ({ table: { @@ -197,19 +198,20 @@ export const CompoundSetList = () => { const fileName = `${datasetID}.csv`; const reqObj = { title: datasetID, filename: fileName, dict: listOfMols }; - const jsonString = JSON.stringify(reqObj); + downloadRHSCSVExport(reqObj); + // const jsonString = JSON.stringify(reqObj); - api({ - url: `${base_url}/api/dicttocsv/`, - method: METHOD.POST, - data: jsonString - }).then(resp => { - var anchor = document.createElement('a'); - anchor.href = `${base_url}/api/dicttocsv/?file_url=${resp.data['file_url']}`; - anchor.target = '_blank'; - anchor.download = `${fileName}`; //'download'; - anchor.click(); - }); + // api({ + // url: `${base_url}/api/dicttocsv/`, + // method: METHOD.POST, + // data: jsonString + // }).then(resp => { + // var anchor = document.createElement('a'); + // anchor.href = `${base_url}/api/dicttocsv/?file_url=${resp.data['file_url']}`; + // anchor.target = '_blank'; + // anchor.download = `${fileName}`; //'download'; + // anchor.click(); + // }); }; useEffect(() => { diff --git a/js/components/datasets/selectedCompoundsList.js b/js/components/datasets/selectedCompoundsList.js index 7cc277d8e..338932cc5 100644 --- a/js/components/datasets/selectedCompoundsList.js +++ b/js/components/datasets/selectedCompoundsList.js @@ -72,6 +72,7 @@ import { ARROW_TYPE, VIEWS } from '../../constants/constants'; import { useScrollToCompound } from './useScrollToCompound'; import useDisableNglControlButtons from '../preview/molecule/useDisableNglControlButtons'; import useDisableDatasetNglControlButtons from './useDisableDatasetNglControlButtons'; +import { downloadRHSCSVExport } from '../../utils/csv'; const useStyles = makeStyles(theme => ({ container: { @@ -572,20 +573,20 @@ export const SelectedCompoundList = memo(() => { const fileName = `${targetName}-RHS-selection.csv`; // console.log(`href - ${fileName}`); const reqObj = { title: sharedSnapshot.url, filename: fileName, dict: listOfMols }; - const jsonString = JSON.stringify(reqObj); - - api({ - url: `${base_url}/api/dicttocsv/`, - method: METHOD.POST, - data: jsonString - }).then(resp => { - var anchor = document.createElement('a'); - anchor.href = `${base_url}/api/dicttocsv/?file_url=${resp.data['file_url']}`; - // console.log(`href - ${base_url}/api/dicttocsv/?file_url=${resp.data['file_url']}`); - anchor.target = '_blank'; - anchor.download = `${fileName}`; //'download'; - anchor.click(); - }); + downloadRHSCSVExport(reqObj); + // const jsonString = JSON.stringify(reqObj); + + // api({ + // url: `${base_url}/api/dicttocsv/`, + // method: METHOD.POST, + // data: jsonString + // }).then(resp => { + // var anchor = document.createElement('a'); + // anchor.href = `${base_url}/api/dicttocsv/?file_url=${resp.data['file_url']}`; + // anchor.target = '_blank'; + // anchor.download = `${fileName}`; //'download'; + // anchor.click(); + // }); }); }; diff --git a/js/utils/csv.js b/js/utils/csv.js new file mode 100644 index 000000000..7ad10516f --- /dev/null +++ b/js/utils/csv.js @@ -0,0 +1,64 @@ +export const downloadRHSCSVExport = data => { + const csvContent = generateCSVExportFromObject(data); + const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' }); + const url = URL.createObjectURL(blob); + const link = document.createElement('a'); + link.setAttribute('href', url); + link.setAttribute('download', data.filename); + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); +}; + +export const generateCSVExportFromObject = data => { + let csvContent = ''; + const filename = data.filename; + + let newLine = '\r\n'; + + csvContent += data.title + newLine; + + if (data?.dict?.length < 1) { + return ''; + } + + const headerKeys = getReferenceDataForHeader(data.dict[0]); + csvContent += generateCSVHeaderFromKeys(headerKeys) + newLine; + + for (let i = 0; i < data.dict.length; i++) { + const row = data.dict[i]; + csvContent += generateCSVRowFromObject(row, headerKeys) + newLine; + } + + return csvContent; +}; + +const generateCSVRowFromObject = (row, keys) => { + let csvRow = ''; + + for (let i = 0; i < keys.length; i++) { + csvRow += row[keys[i]] ? row[keys[i]] : ''; + if (i < keys.length - 1) { + csvRow += ','; + } + } + + return csvRow; +}; + +const generateCSVHeaderFromKeys = keys => { + let csvHeader = ''; + + for (let i = 0; i < keys.length; i++) { + csvHeader += keys[i]; + if (i < keys.length - 1) { + csvHeader += ','; + } + } + + return csvHeader; +}; + +const getReferenceDataForHeader = data => { + return Object.keys(data); +};