From 74e5c47e3b460f323891dbdef63e894ce3843b52 Mon Sep 17 00:00:00 2001 From: Stephan Porada Date: Mon, 20 Jan 2020 15:53:53 +0100 Subject: [PATCH] Enhance analysis UI add first iteration of results download --- app/corpora/events.py | 5 +- app/corpora/forms.py | 3 +- app/static/css/nopaque.css | 2 +- app/templates/corpora/analyse_corpus.html.j2 | 226 +++++++++++-------- 4 files changed, 138 insertions(+), 98 deletions(-) diff --git a/app/corpora/events.py b/app/corpora/events.py index 226e8a5b..4cf2c583 100644 --- a/app/corpora/events.py +++ b/app/corpora/events.py @@ -45,7 +45,7 @@ def corpus_analysis(message): # Prepare and execute a query corpus_name = 'CORPUS' query = str(message['query']) - result_len = 500 + result_len = 100 context_len = int(message['context']) result_offset = 0 client.select_corpus(corpus_name) @@ -55,12 +55,13 @@ def corpus_analysis(message): logger.warning(e) socketio.emit('corpus_analysis', str(e), room=request.sid) else: + logger.warning('====== Initial query {} ======'.format(query)) results = client.show_query_results(result_len=result_len, context_len=context_len, result_offset=result_offset) result_offset += result_len # initial offfset is plus result len because client.show_query_results has been already executed once while result_offset < client.total_nr_matches: - logger.warning('===While loop start.===') + logger.warning('====== While loop start for {} ======'.format(query)) logger.warning('result_offset: {}'.format(result_offset)) results_append = client.show_query_results(result_len=result_len, context_len=context_len, diff --git a/app/corpora/forms.py b/app/corpora/forms.py index 2612cf9f..52bbb36a 100644 --- a/app/corpora/forms.py +++ b/app/corpora/forms.py @@ -81,5 +81,6 @@ class QueryDownloadForm(FlaskForm): choices=[('', 'Choose file type'), ('csv', 'csv'), ('json', 'json'), - ('excel', 'excel')], + ('excel', 'excel'), + ('html', 'html-table')], validators=[DataRequired()]) diff --git a/app/static/css/nopaque.css b/app/static/css/nopaque.css index b62b7e7e..1efba483 100644 --- a/app/static/css/nopaque.css +++ b/app/static/css/nopaque.css @@ -28,7 +28,7 @@ main { padding-left: 300px; } - .modal { + .modal:not(.bottom-sheet) { left: 300px; } diff --git a/app/templates/corpora/analyse_corpus.html.j2 b/app/templates/corpora/analyse_corpus.html.j2 index 9b20440c..90c13046 100644 --- a/app/templates/corpora/analyse_corpus.html.j2 +++ b/app/templates/corpora/analyse_corpus.html.j2 @@ -38,113 +38,133 @@
-
-
-
-
-
- search - {{ query_form.query() }} - {{ query_form.query.label }} - help CQP query language tutorial - {% for error in query_form.query.errors %} - {{ error }} - {% endfor %} +
-
-
- -
-
-
-
- Options -
- format_list_numbered - {{ query_form.hits_per_page() }} - {{ query_form.hits_per_page.label }} - {% for error in query_form.hits_per_page.errors %} - {{ error }} - {% endfor %} -
-
- short_text - {{ query_form.context() }} - {{ query_form.context.label }} - {% for error in query_form.context.errors %} - {{ error }} - {% endfor %} -
-
- -
-
-
-
+ +
-
-
-
- Query Link - Download Results -

Downlaod all results of the current query as csv, excel or json file.

-
- insert_drive_file - {{ query_download_form.file_type() }} - {{ query_download_form.file_type.label }} - {% for error in query_download_form.file_type.errors %} - {{ error }} - {% endfor %} -
- + + + +
-
-
-
- Fetching your results! -
-
-
+
+
+
+
+ Fetching your results! +
+
+
+
-
-
-
- Query Results -

-
    - - - - - - - - - - -
    TitleLeft contextMatchRight Context
    -
      +
      +
      +
      +
      + Query Results +

      + +

      +
        + + + + + + + + + + +
        TitleLeft contextMatchRight Context
        +
          +
          @@ -179,6 +199,7 @@ {% endblock %}