mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-03 20:02:47 +00:00 
			
		
		
		
	Merge branch 'development' of gitlab.ub.uni-bielefeld.de:sfb1288inf/opaque into development
This commit is contained in:
		@@ -246,9 +246,6 @@ class JobInput(db.Model):
 | 
			
		||||
    filename = db.Column(db.String(255))
 | 
			
		||||
    dir = db.Column(db.String(255))
 | 
			
		||||
    job_id = db.Column(db.Integer, db.ForeignKey('jobs.id'))
 | 
			
		||||
    # Relationships
 | 
			
		||||
    results = db.relationship('JobResult', backref='job_input', lazy='dynamic',
 | 
			
		||||
                              cascade='save-update, merge, delete')
 | 
			
		||||
 | 
			
		||||
    def __repr__(self):
 | 
			
		||||
        """
 | 
			
		||||
@@ -260,8 +257,7 @@ class JobInput(db.Model):
 | 
			
		||||
        return {'id': self.id,
 | 
			
		||||
                'dir': self.dir,
 | 
			
		||||
                'filename': self.filename,
 | 
			
		||||
                'job_id': self.job_id,
 | 
			
		||||
                'results': [result.to_dict() for result in self.results]}
 | 
			
		||||
                'job_id': self.job_id}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class JobResult(db.Model):
 | 
			
		||||
@@ -274,7 +270,6 @@ class JobResult(db.Model):
 | 
			
		||||
    filename = db.Column(db.String(255))
 | 
			
		||||
    dir = db.Column(db.String(255))
 | 
			
		||||
    job_id = db.Column(db.Integer, db.ForeignKey('jobs.id'))
 | 
			
		||||
    job_input_id = db.Column(db.Integer, db.ForeignKey('job_inputs.id'))
 | 
			
		||||
 | 
			
		||||
    def __repr__(self):
 | 
			
		||||
        """
 | 
			
		||||
@@ -286,8 +281,7 @@ class JobResult(db.Model):
 | 
			
		||||
        return {'id': self.id,
 | 
			
		||||
                'dir': self.dir,
 | 
			
		||||
                'filename': self.filename,
 | 
			
		||||
                'job_id': self.job_id,
 | 
			
		||||
                'job_input_id': self.job_input_id}
 | 
			
		||||
                'job_id': self.job_id}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Job(db.Model):
 | 
			
		||||
 
 | 
			
		||||
@@ -243,6 +243,22 @@ class JobList extends List {
 | 
			
		||||
    return rowElement;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
JobList.DEFAULT_OPTIONS = {item: "<br>",
 | 
			
		||||
                           page: 4,
 | 
			
		||||
                           pagination: {innerWindow: 8, outerWindow: 1},
 | 
			
		||||
                           valueNames: ["description", "service", "status", "title", {data: ["id"]}]};
 | 
			
		||||
JobList.SERVICE_ICONS = {"merge_images": "burst_mode",
 | 
			
		||||
                         "nlp": "format_textdirection_l_to_r",
 | 
			
		||||
                         "ocr": "find_in_page",
 | 
			
		||||
                         "default": "help"};
 | 
			
		||||
JobList.STATUS_COLORS = {"submitted": "blue",
 | 
			
		||||
                         "preparing": "light-blue",
 | 
			
		||||
                         "pending": "orange",
 | 
			
		||||
                         "running": "amber",
 | 
			
		||||
                         "complete": "green",
 | 
			
		||||
                         "stopping": "orange",
 | 
			
		||||
                         "removing": "deep-orange",
 | 
			
		||||
                         "default": "red"};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ResultList extends List {
 | 
			
		||||
@@ -311,22 +327,3 @@ class ResultList extends List {
 | 
			
		||||
    return matchRowElement
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
JobList.DEFAULT_OPTIONS = {item: "<br>",
 | 
			
		||||
                           page: 4,
 | 
			
		||||
                           pagination: {innerWindow: 8, outerWindow: 1},
 | 
			
		||||
                           valueNames: ["description", "service", "status", "title", {data: ["id"]}]};
 | 
			
		||||
JobList.SERVICE_ICONS = {"merge_images": "burst_mode",
 | 
			
		||||
                         "nlp": "format_textdirection_l_to_r",
 | 
			
		||||
                         "ocr": "find_in_page",
 | 
			
		||||
                         "default": "help"};
 | 
			
		||||
JobList.STATUS_COLORS = {"submitted": "blue",
 | 
			
		||||
                         "preparing": "light-blue",
 | 
			
		||||
                         "pending": "orange",
 | 
			
		||||
                         "running": "amber",
 | 
			
		||||
                         "complete": "green",
 | 
			
		||||
                         "stopping": "orange",
 | 
			
		||||
                         "removing": "deep-orange",
 | 
			
		||||
                         "default": "red"};
 | 
			
		||||
 
 | 
			
		||||
@@ -76,7 +76,7 @@
 | 
			
		||||
  <h4>Input and result files</h4>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<div class="col s12 m8">
 | 
			
		||||
<div class="col s12 m7">
 | 
			
		||||
  <div class="card">
 | 
			
		||||
    <div class="card-content">
 | 
			
		||||
      <span class="card-title">Filewise</span>
 | 
			
		||||
@@ -85,10 +85,9 @@
 | 
			
		||||
          <tr>
 | 
			
		||||
            <th>Filename</th>
 | 
			
		||||
            <th>Download</th>
 | 
			
		||||
            <th>Result</th>
 | 
			
		||||
          </tr>
 | 
			
		||||
        </thead>
 | 
			
		||||
        <tbody>
 | 
			
		||||
        <tbody id="inputs">
 | 
			
		||||
          {% for input in job.inputs %}
 | 
			
		||||
          <tr>
 | 
			
		||||
            <td id="input-{{ input.id }}-filename">{{ input.filename }}</td>
 | 
			
		||||
@@ -97,7 +96,6 @@
 | 
			
		||||
                <i class="material-icons">file_download</i>
 | 
			
		||||
              </a>
 | 
			
		||||
            </td>
 | 
			
		||||
            <td id="input-{{ input.id }}-results"></td>
 | 
			
		||||
          </tr>
 | 
			
		||||
          {% endfor %}
 | 
			
		||||
        </tbody>
 | 
			
		||||
@@ -106,7 +104,7 @@
 | 
			
		||||
  </div>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<div class="col s12 m4">
 | 
			
		||||
<div class="col s12 m5">
 | 
			
		||||
  <div class="card">
 | 
			
		||||
    <div class="card-content">
 | 
			
		||||
      <span class="card-title">Bundled</span>
 | 
			
		||||
@@ -117,40 +115,7 @@
 | 
			
		||||
            <th>Download</th>
 | 
			
		||||
          </tr>
 | 
			
		||||
        </thead>
 | 
			
		||||
        <tbody>
 | 
			
		||||
          <tr>
 | 
			
		||||
            <td>AIO-Bundle</td>
 | 
			
		||||
            <td>
 | 
			
		||||
              <a class="waves-effect waves-light btn-small" download href="">
 | 
			
		||||
                <i class="material-icons">file_download</i>
 | 
			
		||||
              </a>
 | 
			
		||||
            </td>
 | 
			
		||||
          </tr>
 | 
			
		||||
          <tr>
 | 
			
		||||
            <td>PDF-Bundle</td>
 | 
			
		||||
            <td>
 | 
			
		||||
              <a class="waves-effect waves-light btn" download href="">
 | 
			
		||||
                <i class="material-icons">file_download</i>
 | 
			
		||||
              </a>
 | 
			
		||||
            </td>
 | 
			
		||||
          </tr>
 | 
			
		||||
          <tr>
 | 
			
		||||
            <td>TXT-Bundle</td>
 | 
			
		||||
            <td>
 | 
			
		||||
              <a class="waves-effect waves-light btn" download href="">
 | 
			
		||||
                <i class="material-icons">file_download</i>
 | 
			
		||||
              </a>
 | 
			
		||||
            </td>
 | 
			
		||||
          </tr>
 | 
			
		||||
          <tr>
 | 
			
		||||
            <td>XML-Bundle</td>
 | 
			
		||||
            <td>
 | 
			
		||||
              <a class="waves-effect waves-light btn" download href="">
 | 
			
		||||
                <i class="material-icons">file_download</i>
 | 
			
		||||
              </a>
 | 
			
		||||
            </td>
 | 
			
		||||
          </tr>
 | 
			
		||||
        </tbody>
 | 
			
		||||
        <tbody id="results"></tbody>
 | 
			
		||||
      </table>
 | 
			
		||||
    </div>
 | 
			
		||||
  </div>
 | 
			
		||||
@@ -166,7 +131,6 @@
 | 
			
		||||
          <tr>
 | 
			
		||||
            <th>Filename</th>
 | 
			
		||||
            <th>Download</th>
 | 
			
		||||
            <th>Results</th>
 | 
			
		||||
          </tr>
 | 
			
		||||
        </thead>
 | 
			
		||||
        <tbody>
 | 
			
		||||
@@ -228,12 +192,8 @@
 | 
			
		||||
      this.setStatus(job.status);
 | 
			
		||||
      // End date
 | 
			
		||||
      if (job.end_date) {this.setEndDate(job.end_date);}
 | 
			
		||||
      // Input results
 | 
			
		||||
      for (let input of job.inputs) {
 | 
			
		||||
        for (let result of input.results) {
 | 
			
		||||
          this.setResult(result);
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      // Results
 | 
			
		||||
      if (job.results) {this.setResults(job.results);}
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    _update(patch) {
 | 
			
		||||
@@ -245,7 +205,7 @@
 | 
			
		||||
        if (pathArray[0] != this.jobId) {continue;}
 | 
			
		||||
        switch(operation.op) {
 | 
			
		||||
          case "add":
 | 
			
		||||
            if (pathArray[1] === "inputs" && pathArray[3] === "results") {
 | 
			
		||||
            if (pathArray[1] === "results") {
 | 
			
		||||
              this.setResult(operation.value);
 | 
			
		||||
            }
 | 
			
		||||
            break;
 | 
			
		||||
@@ -277,22 +237,32 @@
 | 
			
		||||
      M.updateTextFields();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    setResult(result) {
 | 
			
		||||
      let resultsElement, resultDownloadButtonElement,
 | 
			
		||||
          resultDownloadButtonIconElement;
 | 
			
		||||
    setResults(results) {
 | 
			
		||||
      let resultElement, resultsElement, resultDownloadElement,
 | 
			
		||||
          resultDownloadButtonElement, resultDownloadButtonIconElement,
 | 
			
		||||
          resultTitleElement;
 | 
			
		||||
 | 
			
		||||
      resultsElement = document.getElementById(`input-${result.job_input_id}-results`);
 | 
			
		||||
      resultDownloadButtonElement = document.createElement("a");
 | 
			
		||||
      resultDownloadButtonElement.classList.add("waves-effect", "waves-light", "btn-small");
 | 
			
		||||
      resultDownloadButtonElement.href = `/jobs/${this.jobId}/results/${result.id}/download`;
 | 
			
		||||
      resultDownloadButtonElement.innerText = result.filename.split(".").reverse()[0];
 | 
			
		||||
      resultDownloadButtonElement.setAttribute("download", "");
 | 
			
		||||
      resultDownloadButtonIconElement = document.createElement("i");
 | 
			
		||||
      resultDownloadButtonIconElement.classList.add("material-icons", "left");
 | 
			
		||||
      resultDownloadButtonIconElement.innerText = "file_download";
 | 
			
		||||
      resultDownloadButtonElement.prepend(resultDownloadButtonIconElement);
 | 
			
		||||
      resultsElement.append(resultDownloadButtonElement);
 | 
			
		||||
      resultsElement.append(" ");
 | 
			
		||||
      resultsElement = document.getElementById("results");
 | 
			
		||||
 | 
			
		||||
      for (let result of results) {
 | 
			
		||||
        resultElement = document.createElement("tr");
 | 
			
		||||
        resultTitleElement = document.createElement("td");
 | 
			
		||||
        resultTitleElement.innerText = result.filename;
 | 
			
		||||
        resultElement.append(resultTitleElement);
 | 
			
		||||
        resultDownloadElement = document.createElement("td");
 | 
			
		||||
        resultDownloadButtonElement = document.createElement("a");
 | 
			
		||||
        resultDownloadButtonElement.classList.add("waves-effect", "waves-light",
 | 
			
		||||
                                                  "btn-small");
 | 
			
		||||
        resultDownloadButtonElement.href = `/jobs/${result.job_id}/results/${result.id}/download`;
 | 
			
		||||
        resultDownloadButtonElement.setAttribute("download", "");
 | 
			
		||||
        resultDownloadButtonIconElement = document.createElement("i");
 | 
			
		||||
        resultDownloadButtonIconElement.classList.add("material-icons");
 | 
			
		||||
        resultDownloadButtonIconElement.innerText = "file_download";
 | 
			
		||||
        resultDownloadButtonElement.append(resultDownloadButtonIconElement);
 | 
			
		||||
        resultDownloadElement.append(resultDownloadButtonElement)
 | 
			
		||||
        resultElement.append(resultDownloadElement);
 | 
			
		||||
        resultsElement.append(resultElement);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    setStatus(status) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user