mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-21 21:40:34 +00:00
Rewrite download function to use ressource ids instead of paths
This commit is contained in:
@ -1,85 +1,9 @@
|
||||
{% extends "limited_width.html.j2" %}
|
||||
|
||||
{% block page_content %}
|
||||
<script>
|
||||
var corpus_user_id = {{ corpus.user_id|tojson|safe }}
|
||||
socket.emit('inspect_user', {{ corpus_user_id }});
|
||||
</script>
|
||||
<script>
|
||||
var CORPUS_ID = {{ corpus.id|tojson|safe }}
|
||||
var foreignCorpusFlag;
|
||||
{% if current_user.id == corpus.user_id %}
|
||||
foreignCorpusFlag = false;
|
||||
{% else %}
|
||||
foreignCorpusFlag = true;
|
||||
{% endif %}
|
||||
|
||||
class InformationUpdater {
|
||||
constructor(corpusId) {
|
||||
this.corpusId = corpusId;
|
||||
if (foreignCorpusFlag) {
|
||||
foreignCorpusSubscribers.push(this);
|
||||
} else {
|
||||
corporaSubscribers.push(this);
|
||||
}
|
||||
}
|
||||
|
||||
_init() {
|
||||
var creationDateElement, descriptionElement, titleElement;
|
||||
|
||||
if (foreignCorpusFlag) {
|
||||
this.corpus = foreignCorpora[this.corpusId];
|
||||
} else {
|
||||
this.corpus = corpora[this.corpusId];
|
||||
}
|
||||
creationDateElement = document.getElementById("creation-date");
|
||||
creationDateElement.value = (new Date(this.corpus.creation_date * 1000)).toLocaleString();
|
||||
descriptionElement = document.getElementById("description");
|
||||
descriptionElement.innerHTML = this.corpus.description;
|
||||
titleElement = document.getElementById("title");
|
||||
titleElement.innerHTML = this.corpus.title;
|
||||
|
||||
M.updateTextFields();
|
||||
}
|
||||
|
||||
_update(patch) {
|
||||
var newStatusColor, operation, pathArray, status, statusColor,
|
||||
updatedElement;
|
||||
|
||||
for (operation of patch) {
|
||||
/* "/corpusId/valueName" -> ["corpusId", "valueName"] */
|
||||
pathArray = operation.path.split("/").slice(1);
|
||||
if (pathArray[0] != this.jobId) {continue;}
|
||||
switch(operation.op) {
|
||||
case "delete":
|
||||
location.reload();
|
||||
break;
|
||||
case "replace":
|
||||
switch(pathArray[1]) {
|
||||
case "description":
|
||||
updatedElement = document.getElementById("description");
|
||||
updatedElement.innerHTML = operation.value;
|
||||
break;
|
||||
case "title":
|
||||
updatedElement = document.getElementById("title");
|
||||
updatedElement.innerHTML = operation.value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var informationUpdater = new InformationUpdater(CORPUS_ID);
|
||||
</script>
|
||||
|
||||
<div class="col s12 m4">
|
||||
<h3 id="title"></h3>
|
||||
<p id="description"></p>
|
||||
<h3 id="title">{{ corpus.title }}</h3>
|
||||
<p id="description">{{ corpus.description }}</p>
|
||||
<h2>Actions:</h2>
|
||||
<!-- Confirm deletion of job with modal dialogue
|
||||
Modal Trigger-->
|
||||
@ -106,29 +30,33 @@
|
||||
<div class="row">
|
||||
<div class="col s12 m6">
|
||||
<div class="input-field">
|
||||
<input disabled value="" id="creation-date" type="text" class="validate">
|
||||
<input disabled value="{{ corpus.creation_date.strftime('%m/%d/%Y, %H:%M:%S %p') }}" id="creation-date" type="text" class="validate">
|
||||
<label for="creation-date">Creation date</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<span class="card-title">Files</span>
|
||||
<table>
|
||||
<table class="highlight responsive-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 50%;">Inputs</th>
|
||||
<th>Filename</th>
|
||||
<th>Download</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for file in files %}
|
||||
{% for file in corpus.files %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{{ url_for('main.corpus_download', corpus_id=corpus.id, file=files[file]['path']) }}" class="waves-effect waves-light btn-small"><i class="material-icons left">file_download</i>{{ file }}</a>
|
||||
<td id="file-{{ file.id }}-filename">{{ file.filename }}</td>
|
||||
<td id="file-{{ file.id }}-download">
|
||||
<a class="waves-effect waves-light btn-small" download href="{{ url_for('main.corpus_download', corpus_id=corpus.id, corpus_file_id=file.id) }}">
|
||||
<i class="material-icons">file_download</i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
Reference in New Issue
Block a user