mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-12 09:00:40 +00:00
Make it work again
This commit is contained in:
@ -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) {
|
||||
|
Reference in New Issue
Block a user