From 1b853f3338aaa7ec7b4d5f7d20a8c803dca7ce69 Mon Sep 17 00:00:00 2001 From: Stephan Porada Date: Tue, 21 Jul 2020 13:40:17 +0200 Subject: [PATCH] Soem clean up and restructure --- web/app/static/js/nopaque.callbacks.js | 4 +- web/app/static/js/nopaque.lists.js | 83 ++++ .../templates/corpora/analyse_corpus.html.j2 | 462 +----------------- .../templates/interactions/analysis.html.j2 | 28 ++ web/app/templates/interactions/cite.html.j2 | 28 ++ web/app/templates/interactions/create.html.j2 | 32 ++ .../templates/interactions/display.html.j2 | 17 + web/app/templates/interactions/export.html.j2 | 46 ++ web/app/templates/interactions/infos.html.j2 | 44 ++ .../macros/query_result_macro.html.j2 | 2 +- .../templates/modals/analysis_init.html.j2 | 12 + .../templates/modals/context_modal.html.j2 | 77 +++ .../modals/export_query_results.html.j2 | 54 ++ .../templates/modals/show_metadata.html.j2 | 22 + .../modals/show_text_details.html.j2 | 12 + .../templates/query_results/inspect.html.j2 | 169 +------ .../templates/tables/query_results.html.j2 | 21 + 17 files changed, 509 insertions(+), 604 deletions(-) create mode 100644 web/app/templates/interactions/analysis.html.j2 create mode 100644 web/app/templates/interactions/cite.html.j2 create mode 100644 web/app/templates/interactions/create.html.j2 create mode 100644 web/app/templates/interactions/display.html.j2 create mode 100644 web/app/templates/interactions/export.html.j2 create mode 100644 web/app/templates/interactions/infos.html.j2 create mode 100644 web/app/templates/modals/analysis_init.html.j2 create mode 100644 web/app/templates/modals/context_modal.html.j2 create mode 100644 web/app/templates/modals/export_query_results.html.j2 create mode 100644 web/app/templates/modals/show_metadata.html.j2 create mode 100644 web/app/templates/modals/show_text_details.html.j2 create mode 100644 web/app/templates/tables/query_results.html.j2 diff --git a/web/app/static/js/nopaque.callbacks.js b/web/app/static/js/nopaque.callbacks.js index 45a40e9c..a3a9b870 100644 --- a/web/app/static/js/nopaque.callbacks.js +++ b/web/app/static/js/nopaque.callbacks.js @@ -112,8 +112,6 @@ function queryRenderResults(payload, imported=false) { } else { results.data["cpos_ranges"] = false; } - // update progress bar - queryResultsDeterminateElement.style.width = `${payload.progress}%`; // building the result list js list from incoming chunk resultItems = []; // list for holding every row item // get infos for full match row @@ -121,6 +119,8 @@ function queryRenderResults(payload, imported=false) { resultItems.push({...match, ...{"index": index + results.data.matches.length}}); } if (!imported) { + // update progress bar + queryResultsDeterminateElement.style.width = `${payload.progress}%`; results.jsList.add(resultItems, (items) => { for (let item of items) { item.elm = results.jsList.createResultRowElement(item, payload.chunk); diff --git a/web/app/static/js/nopaque.lists.js b/web/app/static/js/nopaque.lists.js index 91b6ef47..c461ed26 100644 --- a/web/app/static/js/nopaque.lists.js +++ b/web/app/static/js/nopaque.lists.js @@ -1015,4 +1015,87 @@ class ResultsList extends List { } return matchRowElement } + + // creates the HTML table code for the metadata vie in the corpus analysis interface + createMetaDataForModal(metaDataObject) { + let table = `
+ + + + + + + + ` + for (let [outerKey, outerValue] of Object.entries(metaDataObject)) { + table += ` + ` + if (outerKey === "corpus_all_texts" || outerKey === "text_lookup") { + table += `` + } + table += `` + } + table += ` +
Metadata DescriptionValue
${outerKey} + ` + for (let [innerKey, innerValue] of Object.entries(outerValue)) { + table += ` + + ` + } + table += ` +
+ ${innerValue.title} written + by ${innerValue.author} + in ${innerValue.publishing_year} + More + + info_outline + + +
` + } else { + table += `
${outerValue}
` + return table + } + + // Creates the text details for the texts shown in the corpus analysis metadata modal. + createTextDetails(metaDataObject) { + let modal = document.getElementById("modal-text-details"); + modal = M.Modal.init(modal, {"dismissible": true}); + modal.open(); + let metadataKey = event.target.dataset.metadataKey; + let textKey = event.target.dataset.textKey; + let textData = metaDataObject[metadataKey][textKey]; + let bibliographicData = document.getElementById("bibliographic-data"); + bibliographicData.innerHTML = ""; + let table = document.createElement("table"); + for (let [key, value] of Object.entries(textData)) { + table.insertAdjacentHTML("afterbegin", + ` + + ${key} + ${value} + + `); + } + table.insertAdjacentHTML("afterbegin", + ` + + Description + Value + + `) + bibliographicData.appendChild(table); + } + } diff --git a/web/app/templates/corpora/analyse_corpus.html.j2 b/web/app/templates/corpora/analyse_corpus.html.j2 index 5c1aeedf..a6c272a7 100644 --- a/web/app/templates/corpora/analyse_corpus.html.j2 +++ b/web/app/templates/corpora/analyse_corpus.html.j2 @@ -3,6 +3,7 @@ {% set headline = ' ' %} {% set full_width = True %} +{% set imported = False %} {% block page_content %}
@@ -42,378 +43,25 @@
-
-
Infos
-
-
-
- -
-
-

- - of - - matches loaded. -
- Matches occured in - - corpus files: -
- -

-

- help - The Server is still sending your results. - Functions like "Export Results" and "Match Inspect" will be - available after all matches have been loaded. -

-
-
-
-
-
-
-
-
Export
-
-
-
- - -
-
- - -
-
-
-
-
Create
-
-
-
-
- Sub-Results creation: - -
-
-
-
-

matches marked - for Sub-Results:

- -
-
-
-
-
-
Display
-
-
-
-
- {{ M.render_field(display_options_form.results_per_page, - material_icon='format_list_numbered') }} - {{ M.render_field(display_options_form.result_context, - material_icon='short_text') }} - {{ M.render_field(display_options_form.expert_mode) }} -
-
-
-
-
-
Analysis
-
-
-
- -
-
- -
-
-
-
-
Cite Nopaque
-
-
-
- -
-
- -
-
-
-
- -
-
    - - - - - - - - - - - - - -
    Nr.TitleLeft contextMatchActionsRight Context
    -
      + {% include 'interactions/infos.html.j2' %} + {% include 'interactions/export.html.j2' %} + {% include 'interactions/create.html.j2' %} + {% include 'interactions/display.html.j2' %} + {% include 'interactions/analysis.html.j2' %} + {% include 'interactions/cite.html.j2' %}
      + {% include 'tables/query_results.html.j2' %}
      - - -{% import "macros/query_result_macro.html.j2" as metadata %} - - - - - - - - - - - - - +{% include 'modals/show_metadata.html.j2' %} +{% include 'modals/show_text_details.html.j2' %} +{% include 'modals/analysis_init.html.j2' %} +{% include 'modals/export_query_results.html.j2' %} +{% include 'modals/context_modal.html.j2' %} @@ -208,7 +61,6 @@ // ###### global variables ###### var full_result_json; var result_json; - var queryResultsDeterminateElement; // The progress bar for recieved results var receivedMatchCountElement; // Nr. of loaded matches will be displayed in this element var textLookupCountElement // Nr of texts the matches occured in will be shown in this element var textTitlesElement; // matched text titles @@ -231,7 +83,6 @@ // ###### Initializing variables ###### displayOptionsFormElement = document.getElementById("display-options-form"); resultItems = []; - queryResultsDeterminateElement = document.getElementById("query-results-determinate"); receivedMatchCountElement = document.getElementById("received-match-count"); textLookupCountElement = document.getElementById("text-lookup-count"); textTitlesElement = document.getElementById("text-titles"); diff --git a/web/app/templates/tables/query_results.html.j2 b/web/app/templates/tables/query_results.html.j2 new file mode 100644 index 00000000..4635df03 --- /dev/null +++ b/web/app/templates/tables/query_results.html.j2 @@ -0,0 +1,21 @@ + + +
      + + + + + + + + + + + + + + +
      Nr.TitleLeft contextMatchActionsRight Context
      + +
      \ No newline at end of file