mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
Make it work again
This commit is contained in:
parent
e3fde2d5c9
commit
2db9677659
@ -82,7 +82,7 @@ def pj_corpus_analysis_session_handler(app, corpus_id, user_id, session_id):
|
||||
while corpus.status != 'analysing':
|
||||
db.session.refresh(corpus)
|
||||
socketio.sleep(3)
|
||||
client = CQiClient('pj_corpus_{}_analysis'.format(corpus_id))
|
||||
client = CQiClient('corpus_{}_analysis'.format(corpus_id))
|
||||
try:
|
||||
client.connect()
|
||||
except Exception:
|
||||
|
@ -5,54 +5,52 @@ class CorpusAnalysisClient {
|
||||
this.displays = {};
|
||||
this.socket = socket;
|
||||
|
||||
socket.on("corpus_analysis_init", (response) => {
|
||||
socket.on("pj_corpus_analysis_init", (response) => {
|
||||
if (response.code === 200) {
|
||||
console.log(`corpus_analysis_init: ${response.code} - ${response.msg}`);
|
||||
if (this.callbacks.init) {this.callbacks.init(response.msg);}
|
||||
if (this.displays.init) {this.displays.init.setVisibilityByStatus("success");}
|
||||
console.log(`pj_corpus_analysis_init: ${response.code} - ${response.msg}`);
|
||||
if (this.callbacks.init != undefined) {this.callbacks.init(response.msg);}
|
||||
if (this.displays.init != undefined) {this.displays.init.setVisibilityByStatus("success");}
|
||||
} else {
|
||||
if (this.displays.init) {
|
||||
this.displays.init.errorContainer.innerHTML = `<p class="red-text"><i class="material-icons tiny">error</i> Error ${response.code}: ${response.msg}</p>`;
|
||||
if (this.displays.init != undefined) {
|
||||
if (this.displays.init.errorContainer != undefined) {this.displays.init.errorContainer.innerHTML = `<p class="red-text"><i class="material-icons tiny">error</i> Error ${response.code}: ${response.msg}</p>`;}
|
||||
this.displays.init.setVisibilityByStatus("error");
|
||||
}
|
||||
console.error(`corpus_analysis_init: ${response.code} - ${response.msg}`);
|
||||
console.error(`pj_corpus_analysis_init: ${response.code} - ${response.msg}`);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on("corpus_analysis_query", (response) => {
|
||||
socket.on("pj_corpus_analysis_query", (response) => {
|
||||
if (response.code === 200) {
|
||||
console.log(`corpus_analysis_query: ${response.code} - ${response.msg}`);
|
||||
if (this.callbacks.query) {this.callbacks.query(response.data);}
|
||||
if (this.displays.query) {this.displays.query.setVisibilityByStatus("success");}
|
||||
console.log(`pj_corpus_analysis_query: ${response.code} - ${response.msg}`);
|
||||
if (this.callbacks.query != undefined) {this.callbacks.query(response.data);}
|
||||
if (this.displays.query != undefined) {this.displays.query.setVisibilityByStatus("success");}
|
||||
} else {
|
||||
nopaque.flash("error", `Error ${response.code}: ${response.msg}`);
|
||||
this.displays.query.errorContainer.innerHTML = `<p class="red-text"><i class="material-icons tiny">error</i> Error ${response.code}: ${response.msg}</p>`;
|
||||
if (this.displays.query) {this.displays.query.setVisibilityByStatus("error");}
|
||||
console.error(`corpus_analysis_query: ${response.code} - ${response.msg}`)
|
||||
if (this.displays.query.errorContainer != undefined) {this.displays.query.errorContainer.innerHTML = `<p class="red-text"><i class="material-icons tiny">error</i> Error ${response.code}: ${response.msg}</p>`;}
|
||||
if (this.displays.query != undefined) {this.displays.query.setVisibilityByStatus("error");}
|
||||
console.error(`pj_corpus_analysis_query: ${response.code} - ${response.msg}`)
|
||||
}
|
||||
});
|
||||
|
||||
socket.on("corpus_analysis_query_results", (response) => {
|
||||
console.log("corpus_analysis_query_results:")
|
||||
console.log(response);
|
||||
if (this.callbacks.query_results) {this.callbacks.query_results(response);}
|
||||
socket.on("pj_corpus_analysis_query_results", (response) => {
|
||||
if (this.callbacks.query_results != undefined) {this.callbacks.query_results(response);}
|
||||
});
|
||||
}
|
||||
|
||||
init() {
|
||||
if (this.displays.init) {
|
||||
this.displays.init.errorContainer.innerHTML == "";
|
||||
if (this.displays.init.errorContainer != undefined) {this.displays.init.errorContainer.innerHTML == "";}
|
||||
this.displays.init.setVisibilityByStatus("waiting");
|
||||
}
|
||||
this.socket.emit("corpus_analysis_init", this.corpusId);
|
||||
this.socket.emit("pj_corpus_analysis_init", this.corpusId);
|
||||
}
|
||||
|
||||
query(query) {
|
||||
if (this.displays.query) {
|
||||
this.displays.query.errorContainer.innerHTML == "";
|
||||
if (this.displays.query.errorContainer != undefined) {this.displays.query.errorContainer.innerHTML == "";}
|
||||
this.displays.query.setVisibilityByStatus("waiting");
|
||||
}
|
||||
nopaque.socket.emit("corpus_analysis_query", query);
|
||||
nopaque.socket.emit("pj_corpus_analysis_query", query);
|
||||
}
|
||||
|
||||
setCallback(type, callback) {
|
||||
|
@ -79,27 +79,13 @@
|
||||
<div class="error-container hide show-on-error"></div>
|
||||
<div class="hide show-on-success">
|
||||
<p>
|
||||
<span id="received-match-num"></span> of <span id="total-match-num"></span> matches loaded.<br>
|
||||
<span id="received-match-num"></span> of <span id="match-num"></span> matches loaded.<br>
|
||||
Matches occured in <span id="text-lookup-num"></span> corpus files.
|
||||
</p>
|
||||
<div class="progress" id="query-results-progress">
|
||||
<div class="determinate" id="query-results-determinate"></div>
|
||||
</div>
|
||||
<ul class="pagination paginationTop"></ul>
|
||||
<!-- Query results table -->
|
||||
<table class="highlight responsive-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 2%">Nr.</th>
|
||||
<th style="width: 3%">Title</th>
|
||||
<th style="width: 25%">Left context</th>
|
||||
<th style="width: 45%">Match</th>
|
||||
<th style="width: 25%">Right Context</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="list"></tbody>
|
||||
</table>
|
||||
<ul class="pagination paginationBottom"></ul>
|
||||
<div id="query-results"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -130,8 +116,8 @@
|
||||
var queryResultsDeterminateElement = document.getElementById("query-results-determinate");
|
||||
var queryResultsProgressElement = document.getElementById("query-results-progress");
|
||||
var receivedMatchNumElement = document.getElementById("received-match-num");
|
||||
var matchNumElement = document.getElementById("match-num");
|
||||
var textLookupNumElement = document.getElementById("text-lookup-num");
|
||||
var totalMatchNumElement = document.getElementById("total-match-num");
|
||||
|
||||
var results = undefined;
|
||||
|
||||
@ -151,7 +137,7 @@
|
||||
queryResultsDeterminateElement.style.width = "0%";
|
||||
receivedMatchNumElement.innerText = "0";
|
||||
textLookupNumElement.innerText = "0";
|
||||
totalMatchNumElement.innerText = response.num_matches;
|
||||
matchNumElement.innerText = response.num_matches;
|
||||
});
|
||||
client.setCallback("query_results", (response) => {
|
||||
// This is called when results are transmitted.
|
||||
|
Loading…
Reference in New Issue
Block a user