From 07d79d3714eb0ddeb66ed4d8119772b7f5618e6f Mon Sep 17 00:00:00 2001 From: Yuanyue Li Date: Mon, 2 Oct 2023 16:06:26 -0700 Subject: [PATCH] Fix a bug in building index. --- frontend/package.json | 2 +- frontend/src/Pages/Result/GetData.jsx | 9 +++++++ .../src/Pages/Result/SearchResultTable.jsx | 24 +++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/frontend/package.json b/frontend/package.json index 7a29485..b7bb938 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "entropy_search", - "version": "1.0.1", + "version": "1.1.0", "description": "GUI for Entropy Search", "author": { "name": "Yuanyue Li" diff --git a/frontend/src/Pages/Result/GetData.jsx b/frontend/src/Pages/Result/GetData.jsx index fcfe78b..640f290 100644 --- a/frontend/src/Pages/Result/GetData.jsx +++ b/frontend/src/Pages/Result/GetData.jsx @@ -56,6 +56,15 @@ const Main = () => { onSuccess: (result, params) => { const data = result.data; console.log("getOneSpectrum", data) + if(data.is_error){ + errorNotification.error({ + message: 'Error', + description: data.status, + duration: 0, + placement: "top", + }); + return; + } setAtomGlobalSpectrum(data); setAtomUpperSpectrum({ precursor_mz: data.precursor_mz, diff --git a/frontend/src/Pages/Result/SearchResultTable.jsx b/frontend/src/Pages/Result/SearchResultTable.jsx index d0e0c80..6ced0b5 100644 --- a/frontend/src/Pages/Result/SearchResultTable.jsx +++ b/frontend/src/Pages/Result/SearchResultTable.jsx @@ -10,6 +10,7 @@ import { atomLowerSpectrumData } from "../Global/Atoms"; import {useRequest} from "ahooks"; +import {Parser} from "@json2csv/plainjs"; const atomSearchScore = atom([]); const atomLibraryInfo = atom([]); @@ -100,6 +101,20 @@ export default () => { } }, [getAtomSearchScore, stateSearchType]) + const [stateTextFile, setStateTextFile] = useState(null); + useEffect(() => { + if(stateTableData && stateTableData.length > 0){ + const parser = new Parser(); + const csv = parser.parse(stateTableData); + const data = new Blob([csv], {type: 'text/plain'}); + if (stateTextFile !== null) { + window.URL.revokeObjectURL(stateTextFile); + } + const textFile = window.URL.createObjectURL(data); + setStateTextFile(textFile); + } + },[stateTableData]); + return <> @@ -134,5 +149,14 @@ export default () => { columns={column} dataSource={stateTableData}/> + + <> + { + stateTextFile ? <> + + : <> + } + + ; };