From 1e4254130370ac14300f9fad651254d6e4b57315 Mon Sep 17 00:00:00 2001 From: vmonakhov Date: Sat, 28 Sep 2024 00:42:25 +0300 Subject: [PATCH 01/14] json result --- src/components/CognateAnalysisModal/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/CognateAnalysisModal/index.js b/src/components/CognateAnalysisModal/index.js index c83b1c57..3e274d25 100644 --- a/src/components/CognateAnalysisModal/index.js +++ b/src/components/CognateAnalysisModal/index.js @@ -208,6 +208,7 @@ const computeSwadeshAnalysisMutation = gql` transcription_count result xlsx_url + json_url minimum_spanning_tree embedding_2d embedding_3d @@ -236,6 +237,7 @@ const computeMorphCognateAnalysisMutation = gql` transcription_count result xlsx_url + json_url minimum_spanning_tree embedding_2d embedding_3d @@ -1260,6 +1262,7 @@ class CognateAnalysisModal extends React.Component { result: null, xlsx_url: "", + json_url: "", figure_url: "", minimum_spanning_tree: [], @@ -2890,6 +2893,8 @@ class CognateAnalysisModal extends React.Component { {this.state.result.length > 0 && mode !== "suggestions" && mode !== "multi_suggestions" && (
{this.context("XLSX-exported analysis results")} +

+ {this.context("JSON-exported analysis results")}

)} From 63b4522b0f0361792c29fed0c4523a9a5d84f766 Mon Sep 17 00:00:00 2001 From: vmonakhov Date: Sat, 28 Sep 2024 22:05:22 +0300 Subject: [PATCH 02/14] fixe and refactoring --- src/components/CognateAnalysisModal/index.js | 35 ++++++++++++-------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/components/CognateAnalysisModal/index.js b/src/components/CognateAnalysisModal/index.js index 3e274d25..f1156677 100644 --- a/src/components/CognateAnalysisModal/index.js +++ b/src/components/CognateAnalysisModal/index.js @@ -176,6 +176,7 @@ const computeCognateAnalysisMutation = gql` translation_count result xlsx_url + json_url figure_url minimum_spanning_tree embedding_2d @@ -2801,9 +2802,28 @@ class CognateAnalysisModal extends React.Component { const { language_list, perspectiveSelectionCountMap } = this.state; + const disabledCompute = ( + (!multi && (this.perspective_list.length <= 1 || + !this.state.perspectiveSelectionList.some(enabled => enabled))) || + (multi && + (language_list.length <= 0 || + (mode === "multi_reconstruction" && + language_list.filter(language => perspectiveSelectionCountMap[id2str(language.id)] > 0).length <= + 1) || + perspectiveSelectionCountMap[""] <= 0)) || + this.state.computing + ) + return (
- + { + if (e.key === 'Enter' && !disabledCompute) this.handleCreate(); }} + tabIndex = "0" + closeIcon + onClose={this.props.closeModal} + dimmer open + size="fullscreen" className="lingvo-modal2"> {mode === "acoustic" ? this.context("Cognate acoustic analysis") @@ -2842,18 +2862,7 @@ class CognateAnalysisModal extends React.Component { ) } onClick={this.handleCreate} - disabled={ - (!multi && - (this.perspective_list.length <= 1 || - !this.state.perspectiveSelectionList.some(enabled => enabled))) || - (multi && - (language_list.length <= 0 || - (mode === "multi_reconstruction" && - language_list.filter(language => perspectiveSelectionCountMap[id2str(language.id)] > 0).length <= - 1) || - perspectiveSelectionCountMap[""] <= 0)) || - this.state.computing - } + disabled={disabledCompute} className="lingvo-button-violet" />
From ffe558f5cb36e97747e1862049e09138f37957a3 Mon Sep 17 00:00:00 2001 From: vmonakhov Date: Wed, 2 Oct 2024 22:53:35 +0300 Subject: [PATCH 08/14] enhanced frontend --- src/pages/ComplexDistance/index.js | 147 +++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 src/pages/ComplexDistance/index.js diff --git a/src/pages/ComplexDistance/index.js b/src/pages/ComplexDistance/index.js new file mode 100644 index 00000000..8227f784 --- /dev/null +++ b/src/pages/ComplexDistance/index.js @@ -0,0 +1,147 @@ +import { connect } from "react-redux"; +import { Button, Dimmer, Icon, Input, Label, Loader, Message, Segment } from "semantic-ui-react"; +import { gql, useMutation } from "@apollo/client"; +import React, { useContext, useState, useEffect } from "react"; + +import TranslationContext from "Layout/TranslationContext"; + +const complexDistanceMutation = gql` + mutation complexDistance ( + $resultPool: [ObjectVal]! + $debugFlag: Boolean + ) { + complex_distance( + result_pool: $resultPool + debug_flag: $debugFlag + ) { + result + minimum_spanning_tree + embedding_2d + embedding_3d + language_name_list + message + triumph + } + } +`; + +const ComplexDistance = connect(state => state.user)(({user}) => { + + const [cleanResult, setCleanResult] = useState(false); + const [fileSuite, setFileSuite] = useState(null); + const [getComplexDistance, { data, error, loading }] = useMutation(complexDistanceMutation); + + useEffect(() => setCleanResult(false), [loading, data]); + const getTranslation = useContext(TranslationContext); + + const debugFlag = false; + + const runMutation = () => { + + if (loading) + return; + + const resultPool = []; + + for (const file of fileSuite) { + const reader = new FileReader(); + reader.onload = () => { resultPool.push(JSON.parse(reader.result)); } + reader.readAsText(file); + }; + + if (resultPool.length > 0) { + getComplexDistance( + { variables: + { + resultPool, + debugFlag + } + } + ); + } + } + + const fail = !data || !data.complex_distance.triumph; + + return ( +
+ {(user.id === undefined) && !loading ? ( + + {getTranslation("Please sign in")} +

{getTranslation("This page is available for registered users only")}

+
+ ) : loading ? ( + + + {getTranslation("Loading")}... + + + ) : ( + { if (e.key === 'Enter') runMutation(); }} tabIndex="0"> + + { getTranslation( + fileSuite ? "Json file(s) for complex result:" : "Please select result file(s) for calculating." + )} + + + { fileSuite && fileSuite.map(({ name: fileName }) => ( + + ))} + + + + setFileSuite(Array.from(e.target.files))} + /> +

+

+ ); +}) + +ComplexDistance.contextType = TranslationContext; + +export default ComplexDistance; From 798e0579947ef1942c881aa5c3f459b538a8ee25 Mon Sep 17 00:00:00 2001 From: vmonakhov Date: Thu, 3 Oct 2024 18:51:54 +0300 Subject: [PATCH 09/14] debugging --- src/pages/ComplexDistance/index.js | 32 ++++++++++++++++-------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/pages/ComplexDistance/index.js b/src/pages/ComplexDistance/index.js index 8227f784..4483a21d 100644 --- a/src/pages/ComplexDistance/index.js +++ b/src/pages/ComplexDistance/index.js @@ -41,23 +41,24 @@ const ComplexDistance = connect(state => state.user)(({user}) => { if (loading) return; - const resultPool = []; + const resultPool = new Array(fileSuite.length); - for (const file of fileSuite) { + for (const [index, file] of fileSuite.entries()) { const reader = new FileReader(); - reader.onload = () => { resultPool.push(JSON.parse(reader.result)); } - reader.readAsText(file); - }; - - if (resultPool.length > 0) { - getComplexDistance( - { variables: - { - resultPool, - debugFlag - } + reader.onload = () => { + resultPool[index] = JSON.parse(reader.result); + if ((index + 1) == fileSuite.length) { + getComplexDistance( + { variables: + { + resultPool, + debugFlag + } + } + ); } - ); + }; + reader.readAsText(file); } } @@ -77,7 +78,7 @@ const ComplexDistance = connect(state => state.user)(({user}) => { ) : ( - { if (e.key === 'Enter') runMutation(); }} tabIndex="0"> + { if (e.key === 'Enter') document.getElementById("get-result").click(); }} tabIndex="0"> { getTranslation( fileSuite ? "Json file(s) for complex result:" : "Please select result file(s) for calculating." @@ -105,6 +106,7 @@ const ComplexDistance = connect(state => state.user)(({user}) => {

+ + this.setState({ fileSuite: Array.from(e.target.files) })} + /> + + ) + } + render() { if (!this.state.initialized) { return ( @@ -3141,7 +3237,7 @@ class CognateAnalysisModal extends React.Component { )} - {! /swadesh$/.test(mode) && ! /morphology$/.test(mode) && ( + {! /swadesh$/.test(mode) && ! /morphology$/.test(mode) && ! /complex_distance$/.test(mode) && (

{this.state.result}
) || (
@@ -3160,7 +3256,9 @@ CognateAnalysisModal.propTypes = { perspectiveId: PropTypes.array.isRequired, closeModal: PropTypes.func.isRequired, computeCognateAnalysis: PropTypes.func.isRequired, - computeSwadeshAnalysis: PropTypes.func.isRequired + computeSwadeshAnalysis: PropTypes.func.isRequired, + computeMorphCognateAnalysis: PropTypes.func.isRequired, + computeComplexDistance: PropTypes.func.isRequired }; export default compose( @@ -3173,6 +3271,7 @@ export default compose( graphql(computeCognateAnalysisMutation, { name: "computeCognateAnalysis" }), graphql(computeSwadeshAnalysisMutation, { name: "computeSwadeshAnalysis" }), graphql(computeMorphCognateAnalysisMutation, { name: "computeMorphCognateAnalysis" }), + graphql(computeComplexDistanceMutation, { name: "computeComplexDistance" }), graphql(connectMutation, { name: "connectGroup" }), withApollo )(CognateAnalysisModal); diff --git a/src/pages/ToolsRoute/index.js b/src/pages/ToolsRoute/index.js index 9eae121d..08fc86c2 100644 --- a/src/pages/ToolsRoute/index.js +++ b/src/pages/ToolsRoute/index.js @@ -1,7 +1,7 @@ import React, { useContext } from "react"; import { connect } from "react-redux"; import { Link } from "react-router-dom"; - +import { Button } from "semantic-ui-react"; import Footer from "components/Footer"; import TranslationContext from "Layout/TranslationContext"; @@ -13,6 +13,8 @@ import imageSearch from "../../images/location_search.svg"; import imageTranslations from "../../images/text_field.svg"; import imageValency from "../../images/verb_valency.svg"; +import { openModal as cognateAnalysisOpenModal } from "ducks/cognateAnalysis"; + import "./styles.scss"; function ToolsRoute(props) { @@ -77,10 +79,10 @@ function ToolsRoute(props) { )} {props.user.id !== undefined && ( - + )} From cceeebbfd9e25d616074b17d4eaac383d9f710fe Mon Sep 17 00:00:00 2001 From: Ivan Beloborodov Date: Fri, 4 Oct 2024 23:24:38 +0300 Subject: [PATCH 12/14] + --- src/pages/ToolsRoute/index.js | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/pages/ToolsRoute/index.js b/src/pages/ToolsRoute/index.js index 08fc86c2..50253875 100644 --- a/src/pages/ToolsRoute/index.js +++ b/src/pages/ToolsRoute/index.js @@ -1,6 +1,7 @@ import React, { useContext } from "react"; import { connect } from "react-redux"; import { Link } from "react-router-dom"; +import { bindActionCreators } from "redux"; import { Button } from "semantic-ui-react"; import Footer from "components/Footer"; import TranslationContext from "Layout/TranslationContext"; @@ -17,7 +18,7 @@ import { openModal as cognateAnalysisOpenModal } from "ducks/cognateAnalysis"; import "./styles.scss"; -function ToolsRoute(props) { +function ToolsRoute({ user, actions }) { const getTranslation = useContext(TranslationContext); return ( @@ -44,7 +45,7 @@ function ToolsRoute(props) { - {props.user && props.user.id && ( + {user && user.id && ( @@ -54,32 +55,32 @@ function ToolsRoute(props) { - {props.user && props.user.id == 1 && ( + {user && user.id == 1 && ( )} - {props.user.id !== undefined && ( + {user.id !== undefined && ( )} - {props.user.id !== undefined && ( + {user.id !== undefined && ( )} - {props.user.id !== undefined && ( + {user.id !== undefined && ( )} - {props.user.id !== undefined && ( - @@ -92,4 +93,13 @@ function ToolsRoute(props) { ); } -export default connect(state => state.user)(ToolsRoute); +export default connect( + state => state.user, + dispatch => ({ + actions: bindActionCreators({ + cognateAnalysisOpenModal, + }, + dispatch) + }) +)( +ToolsRoute); From 7e9a2abc24886d39ae3e2d48b0c4bcfb05936180 Mon Sep 17 00:00:00 2001 From: vmonakhov Date: Mon, 7 Oct 2024 21:14:40 +0300 Subject: [PATCH 13/14] new frontend --- src/components/CognateAnalysisModal/index.js | 285 ++++++++++--------- 1 file changed, 143 insertions(+), 142 deletions(-) diff --git a/src/components/CognateAnalysisModal/index.js b/src/components/CognateAnalysisModal/index.js index 37f19ec9..062bba97 100644 --- a/src/components/CognateAnalysisModal/index.js +++ b/src/components/CognateAnalysisModal/index.js @@ -12,7 +12,9 @@ import { Loader, Modal, Pagination, - Select + Select, + Input, + Label } from "semantic-ui-react"; import { gql } from "@apollo/client"; import { graphql, withApollo } from "@apollo/client/react/hoc"; @@ -260,7 +262,7 @@ const computeComplexDistanceMutation = gql` minimum_spanning_tree embedding_2d embedding_3d - language_name_list + perspective_name_list: language_name_list message triumph } @@ -1286,6 +1288,8 @@ class CognateAnalysisModal extends React.Component { json_url: "", figure_url: "", fileSuite: null, + lang_mode: null, + clearResult: false, minimum_spanning_tree: [], embedding_2d: [], @@ -1361,12 +1365,18 @@ class CognateAnalysisModal extends React.Component { this.admin_section_render = this.admin_section_render.bind(this); this.suggestions_render = this.suggestions_render.bind(this); - this.brose_files_render = this.brose_files_render.bind(this); + this.browse_files_render = this.browse_files_render.bind(this); this.sg_connect = this.sg_connect.bind(this); } componentDidMount() { + + if (this.props.mode === "complex_distance") { + this.setState({ lang_mode: "none", initialized: true }); + return; + } + const multi = this.props.mode === "multi_analysis" || this.props.mode === "multi_reconstruction" || @@ -1375,6 +1385,7 @@ class CognateAnalysisModal extends React.Component { this.props.mode === "multi_morphology"; (multi ? this.initialize_multi : this.initialize_single)(); + this.setState({ lang_mode: multi ? "multi" : "single" }); } initialize_common(allFields, columns, tree, english_status) { @@ -1822,13 +1833,7 @@ class CognateAnalysisModal extends React.Component { /* Selecting grouping field for many languages. */ - if ( - this.props.mode === "multi_analysis" || - this.props.mode === "multi_reconstruction" || - this.props.mode === "multi_suggestions" || - this.props.mode === "multi_swadesh" || - this.props.mode === "multi_morphology" - ) { + if (this.state.lang_mode === "multi") { this.state.groupFieldIdStr = value; const { perspectiveSelectionMap, perspectiveSelectionCountMap } = this.state; @@ -1867,7 +1872,7 @@ class CognateAnalysisModal extends React.Component { this.setState({ groupFieldIdStr: value }); - } else { + } else if (this.state.lang_mode === "single") { /* Selecting grouping field for a single language. */ this.setState({ groupFieldIdStr: value, @@ -2143,63 +2148,58 @@ class CognateAnalysisModal extends React.Component { computeComplexDistance } = this.props; - const groupField = this.fieldDict[this.state.groupFieldIdStr]; - - /* Gathering info of perspectives we are to analyze. */ + if (this.state.lang_mode === "single" || this.state.lang_mode === "multi") { + const groupField = this.fieldDict[this.state.groupFieldIdStr]; - let perspectiveInfoList = []; - const multiList = []; + /* Gathering info of perspectives we are to analyze. */ + let perspectiveInfoList = []; + const multiList = []; - if ( - this.props.mode === "multi_analysis" || - this.props.mode === "multi_reconstruction" || - this.props.mode === "multi_suggestions" || - this.props.mode === "multi_swadesh" || - this.props.mode === "multi_morphology" - ) { - for (const language of this.state.language_list) { - let p_count = 0; + if (this.state.lang_mode === "multi") { + for (const language of this.state.language_list) { + let p_count = 0; - for (const { perspective, treePathList: [subLanguage,] } of language.perspective_list) { - const p_key = id2str(perspective.id); + for (const { perspective, treePathList: [subLanguage,] } of language.perspective_list) { + const p_key = id2str(perspective.id); - if (this.state.perspectiveSelectionMap[p_key]) { - perspectiveInfoList.push([ - subLanguage.__typename === "Language" ? subLanguage.id : this.baseLanguageId, - perspective.id, - this.fieldDict[this.state.transcriptionFieldIdStrMap[p_key]].id, - this.fieldDict[this.state.translationFieldIdStrMap[p_key]].id, - this.fieldDict[this.state.lexemeFieldIdStrMap[p_key]].id - ]); + if (this.state.perspectiveSelectionMap[p_key]) { + perspectiveInfoList.push([ + subLanguage.__typename === "Language" ? subLanguage.id : this.baseLanguageId, + perspective.id, + this.fieldDict[this.state.transcriptionFieldIdStrMap[p_key]].id, + this.fieldDict[this.state.translationFieldIdStrMap[p_key]].id, + this.fieldDict[this.state.lexemeFieldIdStrMap[p_key]].id + ]); - p_count++; + p_count++; + } } + + multiList.push([language.id, p_count]); } + } else { + perspectiveInfoList = this.perspective_list - multiList.push([language.id, p_count]); + .map(({ perspective, treePathList: [subLanguage,] }, index) => [ + subLanguage.__typename === "Language" ? subLanguage.id : this.baseLanguageId, + perspective.id, + this.fieldDict[this.state.transcriptionFieldIdStrList[index]].id, + this.fieldDict[this.state.translationFieldIdStrList[index]].id, + this.fieldDict[this.state.lexemeFieldIdStrList[index]].id + ]) + + .filter((perspective_info, index) => this.state.perspectiveSelectionList[index]); } - } else { - perspectiveInfoList = this.perspective_list - .map(({ perspective, treePathList: [subLanguage,] }, index) => [ - subLanguage.__typename === "Language" ? subLanguage.id : this.baseLanguageId, - perspective.id, - this.fieldDict[this.state.transcriptionFieldIdStrList[index]].id, - this.fieldDict[this.state.translationFieldIdStrList[index]].id, - this.fieldDict[this.state.lexemeFieldIdStrList[index]].id - ]) + /* Match translations parameter for suggestions. */ - .filter((perspective_info, index) => this.state.perspectiveSelectionList[index]); + const matchTranslationsValue = this.state.matchTranslationsFlag + ? this.state.matchTranslationsValue === "first_three" + ? 1 + : 2 + : 0; } - /* Match translations parameter for suggestions. */ - - const matchTranslationsValue = this.state.matchTranslationsFlag - ? this.state.matchTranslationsValue === "first_three" - ? 1 - : 2 - : 0; - /* If we are to perform acoustic analysis, we will try to launch it in the background. */ if (this.props.mode === "acoustic") { @@ -2227,7 +2227,7 @@ class CognateAnalysisModal extends React.Component { } ); } else if (this.props.mode === "swadesh" || this.props.mode === "multi_swadesh") { - this.setState({ computing: true }); + this.setState({ computing: true, clearResult: false }); computeSwadeshAnalysis({ variables: { sourcePerspectiveId: perspectiveId, @@ -2240,7 +2240,7 @@ class CognateAnalysisModal extends React.Component { error_data => this.handleError(error_data) ); } else if (this.props.mode === "morphology" || this.props.mode === "multi_morphology") { - this.setState({ computing: true }); + this.setState({ computing: true, clearResult: false }); computeMorphCognateAnalysis({ variables: { sourcePerspectiveId: perspectiveId, @@ -2253,7 +2253,7 @@ class CognateAnalysisModal extends React.Component { error_data => this.handleError(error_data) ); } else if (this.props.mode === "complex_distance") { - this.setState({ computing: true }); + this.setState({ computing: true, clearResult: false }); const { fileSuite, debugFlag } = this.state; const resultPool = new Array(fileSuite.length); @@ -2278,9 +2278,7 @@ class CognateAnalysisModal extends React.Component { } } else { /* Otherwise we will launch it as usual and then will wait for results to display them. */ - this.setState({ - computing: true - }); + this.setState({ computing: true, clearResult: false }); const backend_mode = this.props.mode === "multi_analysis" @@ -2846,27 +2844,29 @@ class CognateAnalysisModal extends React.Component { ); } - brose_files_render() { + browse_files_render() { const { fileSuite } = this.state; return ( -
- - { getTranslation( - fileSuite ? "Json file(s) for complex result:" : "Please select result file(s) for calculating." +
+ + { this.context( + fileSuite + ? "Json file(s) for complex result:" + : "Please choose result files for merging (use Ctrl button for multiselect)" )} { fileSuite && fileSuite.map(({ name: fileName }) => ( -
) @@ -2891,19 +2891,13 @@ class CognateAnalysisModal extends React.Component { const { mode } = this.props; - const multi = - mode === "multi_analysis" || - mode === "multi_reconstruction" || - mode === "multi_suggestions" || - mode === "multi_swadesh" || - mode === "multi_morphology"; - - const { language_list, perspectiveSelectionCountMap } = this.state; + const { language_list, perspectiveSelectionCountMap, lang_mode, fileSuite } = this.state; const disabledCompute = ( - (!multi && (this.perspective_list.length <= 1 || + (lang_mode === "none" && !fileSuite) || + (lang_mode === "single" && (this.perspective_list.length <= 1 || !this.state.perspectiveSelectionList.some(enabled => enabled))) || - (multi && + (lang_mode === "multi" && (language_list.length <= 0 || (mode === "multi_reconstruction" && language_list.filter(language => perspectiveSelectionCountMap[id2str(language.id)] > 0).length <= @@ -2943,10 +2937,12 @@ class CognateAnalysisModal extends React.Component { ? this.context("Morphology distance") : mode === "multi_morphology" ? this.context("Morphology distance multi-language") + : mode === "complex_distance" + ? this.context("Complex distance") : this.context("Cognate analysis")} - {this.language_render(multi)} + { lang_mode === "none" ? this.browse_files_render() : this.language_render(lang_mode === "multi") } + this.setState({ clearResult: true, fileSuite: Array.from(e.target.files) })} + onChange={e => this.setState({ cleanResult: true, fileSuite: Array.from(e.target.files) })} />
) @@ -2967,7 +2978,7 @@ class CognateAnalysisModal extends React.Component { { (/swadesh$/.test(mode) || /morphology$/.test(mode) || this.state.library_present - ) && this.state.result !== null && ! this.state.clearResult && ( + ) && this.state.result !== null && ! this.state.cleanResult && ( { ! /complex_distance$/.test(mode) && ( diff --git a/src/pages/ComplexDistance/index.js b/src/pages/ComplexDistance/index.js deleted file mode 100644 index 3693338c..00000000 --- a/src/pages/ComplexDistance/index.js +++ /dev/null @@ -1,149 +0,0 @@ -import { connect } from "react-redux"; -import { Button, Dimmer, Icon, Input, Label, Loader, Message, Segment } from "semantic-ui-react"; -import { gql, useMutation } from "@apollo/client"; -import React, { useContext, useState, useEffect } from "react"; - -import "./style.scss"; - -import TranslationContext from "Layout/TranslationContext"; - -const complexDistanceMutation = gql` - mutation complexDistance ( - $resultPool: [ObjectVal]! - $debugFlag: Boolean - ) { - complex_distance( - result_pool: $resultPool - debug_flag: $debugFlag - ) { - result - minimum_spanning_tree - embedding_2d - embedding_3d - language_name_list - message - triumph - } - } -`; - -const ComplexDistance = connect(state => state.user)(({user}) => { - - const [cleanResult, setCleanResult] = useState(false); - const [fileSuite, setFileSuite] = useState(null); - const [getComplexDistance, { data, error, loading }] = useMutation(complexDistanceMutation); - - useEffect(() => setCleanResult(false), [loading, data]); - const getTranslation = useContext(TranslationContext); - - const debugFlag = false; - - const runMutation = () => { - - if (loading) - return; - - const resultPool = new Array(fileSuite.length); - - for (const [index, file] of fileSuite.entries()) { - const reader = new FileReader(); - reader.onload = () => { - resultPool[index] = JSON.parse(reader.result); - if ((index + 1) == fileSuite.length) { - getComplexDistance( - { variables: - { - resultPool, - debugFlag - } - } - ); - } - }; - reader.readAsText(file); - } - } - - return ( -
- {(user.id === undefined) && !loading ? ( - - {getTranslation("Please sign in")} -

{getTranslation("This page is available for registered users only")}

-
- ) : loading ? ( - - - {getTranslation("Loading")}... - - - ) : ( - { if (e.key === 'Enter') document.getElementById("get-result").click(); }} tabIndex="0"> - - { getTranslation( - fileSuite ? "Json file(s) for complex result:" : "Please select result file(s) for calculating." - )} - - - { fileSuite && fileSuite.map(({ name: fileName }) => ( - - ))} - - - - setFileSuite(Array.from(e.target.files))} - /> -

-

- ); -}) - -ComplexDistance.contextType = TranslationContext; - -export default ComplexDistance; diff --git a/src/pages/ComplexDistance/style.scss b/src/pages/ComplexDistance/style.scss deleted file mode 100644 index 47d93f0b..00000000 --- a/src/pages/ComplexDistance/style.scss +++ /dev/null @@ -1,3 +0,0 @@ -pre { - white-space: pre-wrap; -} \ No newline at end of file