Add neww result recieving

This commit is contained in:
Stephan Porada
2020-03-23 12:14:32 +01:00
parent 94e71b41df
commit ac14bedc62
3 changed files with 27 additions and 19 deletions

View File

@ -32,13 +32,13 @@ function sendQuery(event) {
// full results object declaration, global declaration!
// will always be reset if a query is sent, so that only the chunks of the
// current query will be saved in it
result = {};
result["matches"] = [];
result["cpos_lookup"] = {};
result["text_lookup"] = {};
result["loaded_match_count"] = 0;
result["match_count"] = 0;
result["query"] = "";
result = {}; // full JSON object holding match results
result["matches"] = []; // list of all amtches with lc and rc
result["cpos_lookup"] = {}; // object contains all cpos as key value pair
result["text_lookup"] = {}; // same as above for all text ids
result["loaded_match_count"] = 0; // how many matches have been recieved
result["num_matches_total"]; // how many should have been recieved/total nr
result["query"] = ""; // the query as a string
// some hiding/showing for loading animation
queryLoadingElement.classList.remove("hide");
queryResultsTableElement.classList.add("hide");
@ -97,7 +97,7 @@ function recieveResults(response) {
return; // no further code execution of this code block
}
// logs the current recieved chunk
chunk = response["result"];
chunk = response["chunk"];
//chunk = response["chunk"];
console.log("### corpus_analysis chunk ###");
console.log(chunk);
@ -107,7 +107,7 @@ function recieveResults(response) {
result["matches"].push(...chunk["matches"]);
Object.assign(result["cpos_lookup"], chunk["cpos_lookup"]);
Object.assign(result["text_lookup"], chunk["text_lookup"]);
result["match_count"] = chunk["match_count"];
result["num_matches_total"] = response["num_matches_total"];
//result["match_count"] = response["match_count"];
console.log("Before Current match count", result["loaded_match_count"]);
queryData = getQueryData(queryFormElement);
@ -120,6 +120,7 @@ function recieveResults(response) {
queryResultsElement.innerHTML = "";
// check if query has any results
console.log("CHUNKLENGTH", chunk["matches"].length);
if (chunk["matches"].length === 0) {
queryResultsTableElement.classList.add("hide");
nopaque.toast("No results for this query!");
@ -144,13 +145,13 @@ function recieveResults(response) {
result["loaded_match_count"] += Object.keys(chunk["matches"]).length;
console.log("After current match count", result["loaded_match_count"]);
queryResultsMetadataElement = document.getElementById("query-results-metadata");
queryResultsMetadataElement.innerHTML = `<p>The query resulted in a total of ${chunk["match_count"]} matches. </p> <p> ${result["loaded_match_count"]} of ${result["match_count"]} matches in ${countCorpusFiles} corpus files have been loaded.</p><p><i class="material-icons" id="tooltip-info">help</i>The Server is still sending your results. Functions like "Export Results" and "Match Inspect" will be available after all matches have been loaded.</p>`;
queryResultsMetadataElement.innerHTML = `<p>The query resulted in a total of ${result["num_matches_total"]} matches. </p> <p> ${result["loaded_match_count"]} of ${result["num_matches_total"]} matches in ${countCorpusFiles} corpus files have been loaded.</p><p><i class="material-icons" id="tooltip-info">help</i>The Server is still sending your results. Functions like "Export Results" and "Match Inspect" will be available after all matches have been loaded.</p>`;
queryResultsInteractionElement = document.getElementById("interaction-elements");
queryResultsInteractionElement.appendChild(exportQueryResultsElement);
queryResultsHeadElement = document.getElementById("query-results-head");
queryResultsHeadElement.classList.remove("hide");
queryStatus = result["loaded_match_count"] / result["match_count"] * 100;
console.log(queryStatus);
queryStatus = response["progress"];
console.log("QUERY STATUS:", queryStatus);
queryResultsDeterminateElement.style["width"] = `${queryStatus}%`;
console.log(queryResultsDeterminateElement.style["width"]);
@ -160,7 +161,7 @@ function recieveResults(response) {
queryFinished = true; // global declaration to set downlaod button and inspects buttons back to disabled for new queries
queryResultsDeterminateElement.parentNode.parentNode.classList.add("hide");
exportQueryResultsElement.classList.remove("disabled");
queryResultsMetadataElement.innerHTML = `<p>The query resulted in a total of ${chunk["match_count"]} matches. </p> <p> ${result["loaded_match_count"]} of ${result["match_count"]} matches in ${countCorpusFiles} corpus files have been loaded.<i class="material-icons">check_circle</i></p>`;
queryResultsMetadataElement.innerHTML = `<p>The query resulted in a total of ${result["num_matches_total"]} matches. </p> <p> ${result["loaded_match_count"]} of ${result["num_matches_total"]} matches in ${countCorpusFiles} corpus files have been loaded.<i class="material-icons">check_circle</i></p>`;
activateInspect();
}
}