mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-04 12:22:47 +00:00 
			
		
		
		
	Make it work again
This commit is contained in:
		@@ -82,7 +82,7 @@ def pj_corpus_analysis_session_handler(app, corpus_id, user_id, session_id):
 | 
				
			|||||||
        while corpus.status != 'analysing':
 | 
					        while corpus.status != 'analysing':
 | 
				
			||||||
            db.session.refresh(corpus)
 | 
					            db.session.refresh(corpus)
 | 
				
			||||||
            socketio.sleep(3)
 | 
					            socketio.sleep(3)
 | 
				
			||||||
        client = CQiClient('pj_corpus_{}_analysis'.format(corpus_id))
 | 
					        client = CQiClient('corpus_{}_analysis'.format(corpus_id))
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            client.connect()
 | 
					            client.connect()
 | 
				
			||||||
        except Exception:
 | 
					        except Exception:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,54 +5,52 @@ class CorpusAnalysisClient {
 | 
				
			|||||||
    this.displays = {};
 | 
					    this.displays = {};
 | 
				
			||||||
    this.socket = socket;
 | 
					    this.socket = socket;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    socket.on("corpus_analysis_init", (response) => {
 | 
					    socket.on("pj_corpus_analysis_init", (response) => {
 | 
				
			||||||
      if (response.code === 200) {
 | 
					      if (response.code === 200) {
 | 
				
			||||||
        console.log(`corpus_analysis_init: ${response.code} - ${response.msg}`);
 | 
					        console.log(`pj_corpus_analysis_init: ${response.code} - ${response.msg}`);
 | 
				
			||||||
        if (this.callbacks.init) {this.callbacks.init(response.msg);}
 | 
					        if (this.callbacks.init != undefined) {this.callbacks.init(response.msg);}
 | 
				
			||||||
        if (this.displays.init) {this.displays.init.setVisibilityByStatus("success");}
 | 
					        if (this.displays.init != undefined) {this.displays.init.setVisibilityByStatus("success");}
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        if (this.displays.init) {
 | 
					        if (this.displays.init != undefined) {
 | 
				
			||||||
          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.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");
 | 
					          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) {
 | 
					      if (response.code === 200) {
 | 
				
			||||||
        console.log(`corpus_analysis_query: ${response.code} - ${response.msg}`);
 | 
					        console.log(`pj_corpus_analysis_query: ${response.code} - ${response.msg}`);
 | 
				
			||||||
        if (this.callbacks.query) {this.callbacks.query(response.data);}
 | 
					        if (this.callbacks.query != undefined) {this.callbacks.query(response.data);}
 | 
				
			||||||
        if (this.displays.query) {this.displays.query.setVisibilityByStatus("success");}
 | 
					        if (this.displays.query != undefined) {this.displays.query.setVisibilityByStatus("success");}
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        nopaque.flash("error", `Error ${response.code}: ${response.msg}`);
 | 
					        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.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) {this.displays.query.setVisibilityByStatus("error");}
 | 
					        if (this.displays.query != undefined) {this.displays.query.setVisibilityByStatus("error");}
 | 
				
			||||||
        console.error(`corpus_analysis_query: ${response.code} - ${response.msg}`)
 | 
					        console.error(`pj_corpus_analysis_query: ${response.code} - ${response.msg}`)
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    socket.on("corpus_analysis_query_results", (response) => {
 | 
					    socket.on("pj_corpus_analysis_query_results", (response) => {
 | 
				
			||||||
        console.log("corpus_analysis_query_results:")
 | 
					        if (this.callbacks.query_results != undefined) {this.callbacks.query_results(response);}
 | 
				
			||||||
        console.log(response);
 | 
					 | 
				
			||||||
        if (this.callbacks.query_results) {this.callbacks.query_results(response);}
 | 
					 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  init() {
 | 
					  init() {
 | 
				
			||||||
    if (this.displays.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.displays.init.setVisibilityByStatus("waiting");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    this.socket.emit("corpus_analysis_init", this.corpusId);
 | 
					    this.socket.emit("pj_corpus_analysis_init", this.corpusId);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  query(query) {
 | 
					  query(query) {
 | 
				
			||||||
    if (this.displays.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");
 | 
					      this.displays.query.setVisibilityByStatus("waiting");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    nopaque.socket.emit("corpus_analysis_query", query);
 | 
					    nopaque.socket.emit("pj_corpus_analysis_query", query);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  setCallback(type, callback) {
 | 
					  setCallback(type, callback) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -79,27 +79,13 @@
 | 
				
			|||||||
      <div class="error-container hide show-on-error"></div>
 | 
					      <div class="error-container hide show-on-error"></div>
 | 
				
			||||||
      <div class="hide show-on-success">
 | 
					      <div class="hide show-on-success">
 | 
				
			||||||
        <p>
 | 
					        <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.
 | 
					          Matches occured in <span id="text-lookup-num"></span> corpus files.
 | 
				
			||||||
        </p>
 | 
					        </p>
 | 
				
			||||||
        <div class="progress" id="query-results-progress">
 | 
					        <div class="progress" id="query-results-progress">
 | 
				
			||||||
          <div class="determinate" id="query-results-determinate"></div>
 | 
					          <div class="determinate" id="query-results-determinate"></div>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
        <ul class="pagination paginationTop"></ul>
 | 
					        <div id="query-results"></div>
 | 
				
			||||||
        <!-- 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>
 | 
					      </div>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
  </div>
 | 
					  </div>
 | 
				
			||||||
@@ -130,8 +116,8 @@
 | 
				
			|||||||
  var queryResultsDeterminateElement = document.getElementById("query-results-determinate");
 | 
					  var queryResultsDeterminateElement = document.getElementById("query-results-determinate");
 | 
				
			||||||
  var queryResultsProgressElement = document.getElementById("query-results-progress");
 | 
					  var queryResultsProgressElement = document.getElementById("query-results-progress");
 | 
				
			||||||
  var receivedMatchNumElement = document.getElementById("received-match-num");
 | 
					  var receivedMatchNumElement = document.getElementById("received-match-num");
 | 
				
			||||||
 | 
					  var matchNumElement = document.getElementById("match-num");
 | 
				
			||||||
  var textLookupNumElement = document.getElementById("text-lookup-num");
 | 
					  var textLookupNumElement = document.getElementById("text-lookup-num");
 | 
				
			||||||
  var totalMatchNumElement = document.getElementById("total-match-num");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  var results = undefined;
 | 
					  var results = undefined;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -151,7 +137,7 @@
 | 
				
			|||||||
      queryResultsDeterminateElement.style.width = "0%";
 | 
					      queryResultsDeterminateElement.style.width = "0%";
 | 
				
			||||||
      receivedMatchNumElement.innerText = "0";
 | 
					      receivedMatchNumElement.innerText = "0";
 | 
				
			||||||
      textLookupNumElement.innerText = "0";
 | 
					      textLookupNumElement.innerText = "0";
 | 
				
			||||||
      totalMatchNumElement.innerText = response.num_matches;
 | 
					      matchNumElement.innerText = response.num_matches;
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    client.setCallback("query_results", (response) => {
 | 
					    client.setCallback("query_results", (response) => {
 | 
				
			||||||
      // This is called when results are transmitted.
 | 
					      // This is called when results are transmitted.
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user