mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 02:44:18 +00:00
Enhance analysis UI add first iteration of results download
This commit is contained in:
parent
5c5f7012eb
commit
74e5c47e3b
@ -45,7 +45,7 @@ def corpus_analysis(message):
|
|||||||
# Prepare and execute a query
|
# Prepare and execute a query
|
||||||
corpus_name = 'CORPUS'
|
corpus_name = 'CORPUS'
|
||||||
query = str(message['query'])
|
query = str(message['query'])
|
||||||
result_len = 500
|
result_len = 100
|
||||||
context_len = int(message['context'])
|
context_len = int(message['context'])
|
||||||
result_offset = 0
|
result_offset = 0
|
||||||
client.select_corpus(corpus_name)
|
client.select_corpus(corpus_name)
|
||||||
@ -55,12 +55,13 @@ def corpus_analysis(message):
|
|||||||
logger.warning(e)
|
logger.warning(e)
|
||||||
socketio.emit('corpus_analysis', str(e), room=request.sid)
|
socketio.emit('corpus_analysis', str(e), room=request.sid)
|
||||||
else:
|
else:
|
||||||
|
logger.warning('====== Initial query {} ======'.format(query))
|
||||||
results = client.show_query_results(result_len=result_len,
|
results = client.show_query_results(result_len=result_len,
|
||||||
context_len=context_len,
|
context_len=context_len,
|
||||||
result_offset=result_offset)
|
result_offset=result_offset)
|
||||||
result_offset += result_len # initial offfset is plus result len because client.show_query_results has been already executed once
|
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:
|
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))
|
logger.warning('result_offset: {}'.format(result_offset))
|
||||||
results_append = client.show_query_results(result_len=result_len,
|
results_append = client.show_query_results(result_len=result_len,
|
||||||
context_len=context_len,
|
context_len=context_len,
|
||||||
|
@ -81,5 +81,6 @@ class QueryDownloadForm(FlaskForm):
|
|||||||
choices=[('', 'Choose file type'),
|
choices=[('', 'Choose file type'),
|
||||||
('csv', 'csv'),
|
('csv', 'csv'),
|
||||||
('json', 'json'),
|
('json', 'json'),
|
||||||
('excel', 'excel')],
|
('excel', 'excel'),
|
||||||
|
('html', 'html-table')],
|
||||||
validators=[DataRequired()])
|
validators=[DataRequired()])
|
||||||
|
@ -28,7 +28,7 @@ main {
|
|||||||
padding-left: 300px;
|
padding-left: 300px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal {
|
.modal:not(.bottom-sheet) {
|
||||||
left: 300px;
|
left: 300px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,8 +38,12 @@
|
|||||||
|
|
||||||
<form id="query-form">
|
<form id="query-form">
|
||||||
<div class="col s12">
|
<div class="col s12">
|
||||||
<div class="card">
|
<ul class="collapsible expandable">
|
||||||
<div class="card-content">
|
<li class="active">
|
||||||
|
<!-- <div class="collapsible-header">
|
||||||
|
<i class="material-icons">search</i>CQP Query
|
||||||
|
</div> -->
|
||||||
|
<div class="collapsible-body" style="padding: 0px 2rem;">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col s12 m11">
|
<div class="col s12 m11">
|
||||||
<div class="input-field">
|
<div class="input-field">
|
||||||
@ -53,19 +57,20 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col s12 m1">
|
<div class="col s12 m1">
|
||||||
<p class="hide-on-small-only"> </p>
|
<p class="hide-on-small-only" style="
|
||||||
|
margin: 0px;"> </p>
|
||||||
<button class="waves-effect waves-light btn-small right" type="submit">Send<i class="material-icons right">send</i></button>
|
<button class="waves-effect waves-light btn-small right" type="submit">Send<i class="material-icons right">send</i></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</li>
|
||||||
|
<li class="hoverable">
|
||||||
|
<div class="collapsible-header">
|
||||||
|
<i class="material-icons">settings</i>Display Options
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="collapsible-body">
|
||||||
|
<div class="row">
|
||||||
<div class="col s12 m3">
|
<div class="col s6">
|
||||||
<div class="card">
|
|
||||||
<div class="card-content">
|
|
||||||
<div id="query-form">
|
|
||||||
<span class="card-title">Options</span>
|
|
||||||
<div class="input-field">
|
<div class="input-field">
|
||||||
<i class="material-icons prefix">format_list_numbered</i>
|
<i class="material-icons prefix">format_list_numbered</i>
|
||||||
{{ query_form.hits_per_page() }}
|
{{ query_form.hits_per_page() }}
|
||||||
@ -74,6 +79,8 @@
|
|||||||
<span class="helper-text red-text">{{ error }}</span>
|
<span class="helper-text red-text">{{ error }}</span>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col s6">
|
||||||
<div class="input-field">
|
<div class="input-field">
|
||||||
<i class="material-icons prefix">short_text</i>
|
<i class="material-icons prefix">short_text</i>
|
||||||
{{ query_form.context() }}
|
{{ query_form.context() }}
|
||||||
@ -82,6 +89,9 @@
|
|||||||
<span class="helper-text red-text">{{ error }}</span>
|
<span class="helper-text red-text">{{ error }}</span>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
<div class="switch">
|
<div class="switch">
|
||||||
<label>
|
<label>
|
||||||
Expert Mode
|
Expert Mode
|
||||||
@ -91,16 +101,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div class="col s12 hide">
|
<div id="export-query-results-modal" class="modal modal-fixed-footer no-autoinit">
|
||||||
<div class="card">
|
<!-- <form id="download-query-results-form" method="post"> -->
|
||||||
<div class="card-content">
|
<div class="modal-content">
|
||||||
<span class="card-title">Query Link</span>
|
{{ query_download_form.hidden_tag() }}
|
||||||
<span class="card-title">Download Results</span>
|
<h4>Download current query Results</h4>
|
||||||
<p>Downlaod all results of the current query as csv, excel or json file.</p>
|
<p>The results of the current query can be downlaoded as several files like csv or json. Those files can be used in other software like excel. Also it is easy to publish your results as raw data like this!</p>
|
||||||
<div class="input-field">
|
<div class="input-field">
|
||||||
<i class="material-icons prefix">insert_drive_file</i>
|
<i class="material-icons prefix">insert_drive_file</i>
|
||||||
{{ query_download_form.file_type() }}
|
{{ query_download_form.file_type() }}
|
||||||
@ -109,12 +120,16 @@
|
|||||||
<span class="helper-text red-text">{{ error }}</span>
|
<span class="helper-text red-text">{{ error }}</span>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
<button class="btn waves-effect waves-light" id="download-form-submit" style="width: 100%;" type="submit">Download</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<!-- <button class="btn waves-effect waves-light" id="download-form-submit" type="submit">Download</button> -->
|
||||||
|
<a class="btn waves-effect waves-light" id="downloadAnchorElem">Download</a>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- </form> -->
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="col s12 m9 hide" id="getting-query-results">
|
<div class="row">
|
||||||
|
<div class="col s12 hide" id="getting-query-results">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<span class="card-title">Fetching your results!</span>
|
<span class="card-title">Fetching your results!</span>
|
||||||
@ -125,13 +140,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col s12 m9" id="recieved-query-results">
|
<div class="row">
|
||||||
|
<div class="col s12" id="recieved-query-results">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-content" id="result-list">
|
<div class="card-content" id="result-list">
|
||||||
<span class="card-title">Query Results</span>
|
<span class="card-title">Query Results</span>
|
||||||
<p id="query-results-metadata"></p>
|
<p id="query-results-metadata">
|
||||||
|
<button id="export-query-results" class="waves-effect waves-light btn-small right hide" type="submit">Export Results<i class="material-icons right">file_download</i></button>
|
||||||
|
</p>
|
||||||
<ul class="pagination paginationTop"></ul>
|
<ul class="pagination paginationTop"></ul>
|
||||||
<table class="responsive-table highlight">
|
<table class="responsive-table highlight">
|
||||||
<thead>
|
<thead>
|
||||||
@ -147,6 +166,7 @@
|
|||||||
<ul class="pagination paginationBottom"></ul>
|
<ul class="pagination paginationBottom"></ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="loading-modal" class="modal no-autoinit">
|
<div id="loading-modal" class="modal no-autoinit">
|
||||||
@ -179,6 +199,7 @@
|
|||||||
<script>
|
<script>
|
||||||
var contextModal;
|
var contextModal;
|
||||||
var loadingModal;
|
var loadingModal;
|
||||||
|
var exportModal;
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
contextModal = M.Modal.init(document.getElementById("context-modal"),
|
contextModal = M.Modal.init(document.getElementById("context-modal"),
|
||||||
{"onCloseEnd": function() {
|
{"onCloseEnd": function() {
|
||||||
@ -186,6 +207,9 @@
|
|||||||
document.getElementById("context-modal-ready").classList.add("hide");}});
|
document.getElementById("context-modal-ready").classList.add("hide");}});
|
||||||
loadingModal = M.Modal.init(document.getElementById("loading-modal"),
|
loadingModal = M.Modal.init(document.getElementById("loading-modal"),
|
||||||
{"dismissible": false});
|
{"dismissible": false});
|
||||||
|
exportModal = M.Modal.init(document.getElementById("export-query-results-modal"),
|
||||||
|
{"dismissible": true});
|
||||||
|
M.Collapsible.init(elem, {accordion: false});
|
||||||
loadingModal.open();
|
loadingModal.open();
|
||||||
nopaque.socket.emit("request_corpus_analysis", {{ corpus_id }});
|
nopaque.socket.emit("request_corpus_analysis", {{ corpus_id }});
|
||||||
});
|
});
|
||||||
@ -217,6 +241,10 @@
|
|||||||
var queryFormElement = document.getElementById("query-form");
|
var queryFormElement = document.getElementById("query-form");
|
||||||
var queryResultsElement = document.getElementById("query-results");
|
var queryResultsElement = document.getElementById("query-results");
|
||||||
var queryResultsMetadataElement = document.getElementById("query-results-metadata")
|
var queryResultsMetadataElement = document.getElementById("query-results-metadata")
|
||||||
|
var exportQueryResults = document.getElementById("export-query-results")
|
||||||
|
exportQueryResults.onclick = function() {
|
||||||
|
exportModal.open();
|
||||||
|
};
|
||||||
var contextResultsElement = document.getElementById("context-results");
|
var contextResultsElement = document.getElementById("context-results");
|
||||||
var queryLoadingElement = document.getElementById("getting-query-results");
|
var queryLoadingElement = document.getElementById("getting-query-results");
|
||||||
var queryResultsTableElement = document.getElementById("recieved-query-results");
|
var queryResultsTableElement = document.getElementById("recieved-query-results");
|
||||||
@ -257,7 +285,9 @@
|
|||||||
} else {
|
} else {
|
||||||
total_nr_matches = message["total_nr_matches"];
|
total_nr_matches = message["total_nr_matches"];
|
||||||
let count_corpus_files = Object.keys(message["text_lookup"]).length;
|
let count_corpus_files = Object.keys(message["text_lookup"]).length;
|
||||||
queryResultsMetadataElement.innerText = message["total_nr_matches"] + " matches in " + count_corpus_files + " corpus files.";
|
queryResultsMetadataElement.innerHTML = message["total_nr_matches"] + " matches in " + count_corpus_files + " corpus files.";
|
||||||
|
queryResultsMetadataElement.appendChild(exportQueryResults);
|
||||||
|
exportQueryResults.classList.remove("hide");
|
||||||
|
|
||||||
var matchElement;
|
var matchElement;
|
||||||
var matchTextTitlesElement;
|
var matchTextTitlesElement;
|
||||||
@ -362,12 +392,19 @@
|
|||||||
var inspectBtn = inspectBtns[i];
|
var inspectBtn = inspectBtns[i];
|
||||||
var dataIndex = inspectBtn.parentNode.parentNode.getAttribute("data-index");
|
var dataIndex = inspectBtn.parentNode.parentNode.getAttribute("data-index");
|
||||||
inspectBtn.onclick = function() {
|
inspectBtn.onclick = function() {
|
||||||
contextModal.open();
|
exportModal.open();
|
||||||
nopaque.socket.emit("inspect_match", {"cpos": matches[dataIndex]["hit"]});
|
nopaque.socket.emit("inspect_match", {"cpos": matches[dataIndex]["hit"]});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
// download results as JSON
|
||||||
|
var dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(message, undefined, 2));
|
||||||
|
console.log(dataStr);
|
||||||
|
var downloadAnchorElem = document.getElementById("downloadAnchorElem");
|
||||||
|
downloadAnchorElem.setAttribute("href", dataStr);
|
||||||
|
downloadAnchorElem.setAttribute("download", "results.json");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function addToolTipToTokenElement(tokenElement, token) {
|
function addToolTipToTokenElement(tokenElement, token) {
|
||||||
M.Tooltip.init(tokenElement,
|
M.Tooltip.init(tokenElement,
|
||||||
{"html": `<table>
|
{"html": `<table>
|
||||||
@ -434,6 +471,7 @@
|
|||||||
contextResultsElement.append(sentenceElement);
|
contextResultsElement.append(sentenceElement);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// collapsible display options
|
||||||
|
var elem = document.querySelector('.collapsible.expandable');
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user