diff --git a/app/corpora/pj_events.py b/app/corpora/pj_events.py index 8ad49731..66e9cd56 100644 --- a/app/corpora/pj_events.py +++ b/app/corpora/pj_events.py @@ -75,8 +75,6 @@ def pj_corpus_analysis_query(query): progress = 0 client.status = 'running' while chunk_start <= results.size: - logger.warning(client.status) - print(client.status) if client.status == 'abort': break chunk = results.export(context=context, cutoff=chunk_size, @@ -95,9 +93,9 @@ def pj_corpus_analysis_query(query): client.status = 'ready' -@socketio.on('pj_inspect-match') +@socketio.on('pj_corpus_analysis_inspect_match') @socketio_login_required -def pj_corpus_analysis_query(payload): +def pj_corpus_analysis_inspect_match(payload): logger.warning(payload) client = pj_corpus_analysis_clients.get(request.sid) if client is None: @@ -107,10 +105,10 @@ def pj_corpus_analysis_query(payload): # Get more context for given match CPOS corpus = client.corpora.get('CORPUS') s = corpus.attributes.structural.get('s') - match_context = s.export(payload["cpos"][0], payload["cpos"][1], - context=3, - expand_lists=True) - socketio.emit('pj_match_context', {"payload": match_context}, room=request.sid) + match_context = s.export(payload['first_cpos'], payload['last_cpos'], + context=3, expand_lists=True) + socketio.emit('pj_corpus_analysis_inspect_match', + {'payload': match_context}, room=request.sid) def pj_corpus_analysis_session_handler(app, corpus_id, user_id, session_id): diff --git a/app/static/js/nopaque.CorpusAnalysisClient.js b/app/static/js/nopaque.CorpusAnalysisClient.js index 894220a9..016d6222 100644 --- a/app/static/js/nopaque.CorpusAnalysisClient.js +++ b/app/static/js/nopaque.CorpusAnalysisClient.js @@ -69,7 +69,7 @@ class CorpusAnalysisClient { this.socket.emit("pj_corpus_analysis_init", this.corpusId); } - sendQuery(queryStr) { + query(queryStr) { let displayOptionsData; let resultListOptions; diff --git a/app/static/js/nopaque.pj_analyse_corpus.js b/app/static/js/nopaque.pj_analyse_corpus.js index 15daa24c..370b4317 100644 --- a/app/static/js/nopaque.pj_analyse_corpus.js +++ b/app/static/js/nopaque.pj_analyse_corpus.js @@ -82,12 +82,14 @@ function activateInspect(progress) { } //gets result cpos infos for one dataIndex to send back to the server -function inspect(dataIndex, socket) { +function inspect(dataIndex) { + // This function should be in the AnalysisClient class as a method. console.log("Inspect!"); console.log(results.resultsJSON.matches[dataIndex].c); contextModal.open(); - socket.emit("pj_inspect_match", - {"payload": {"cpos": results.resultsJSON.matches[dataIndex].c} }); + nopaque.socket.emit("pj_corpus_analysis_inspect_match", + {payload: {first_cpos: results.resultsJSON.matches[dataIndex].c[0], + last_cpos: results.resultsJSON.matches[dataIndex].c[1]}}); } function showMatchContext(payload) { @@ -254,4 +256,4 @@ function expertModeOff(tokenElements) { tokenElement.classList.remove("expert-view"); tokenElement.outerHTML = tokenElement.outerHTML; // this is actually a workaround, but it works pretty fast } -} \ No newline at end of file +} diff --git a/app/templates/corpora/pj_analyse_corpus.html.j2 b/app/templates/corpora/pj_analyse_corpus.html.j2 index 5e4b99ed..748e42b2 100644 --- a/app/templates/corpora/pj_analyse_corpus.html.j2 +++ b/app/templates/corpora/pj_analyse_corpus.html.j2 @@ -322,7 +322,7 @@ resultsList.clear(); // Get query string and send query to server let queryStr = getQueryStr(queryFormElement); - client.sendQuery(queryStr); + client.query(queryStr); }); // get context of one match if inspected via socket.io