mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 10:34:17 +00:00
Add corpus page.
This commit is contained in:
parent
633bd58087
commit
4dc331b2fe
@ -31,11 +31,28 @@ def corpus(corpus_id):
|
|||||||
files[file]['path'] = os.path.join(file)
|
files[file]['path'] = os.path.join(file)
|
||||||
|
|
||||||
return render_template('main/corpora/corpus.html.j2',
|
return render_template('main/corpora/corpus.html.j2',
|
||||||
|
corpus_id=corpus.id,
|
||||||
files=files,
|
files=files,
|
||||||
corpus=corpus,
|
|
||||||
title='Corpus')
|
title='Corpus')
|
||||||
|
|
||||||
|
|
||||||
|
@main.route('/corpora/<int:corpus_id>/download')
|
||||||
|
@login_required
|
||||||
|
def corpus_download(corpus_id):
|
||||||
|
file = request.args.get('file')
|
||||||
|
corpus = current_user.corpora.filter_by(id=corpus_id).first()
|
||||||
|
if not file or not corpus:
|
||||||
|
print('File not found.')
|
||||||
|
abort(404)
|
||||||
|
dir = os.path.join(current_app.config['OPAQUE_STORAGE'],
|
||||||
|
str(current_user.id),
|
||||||
|
'corpora',
|
||||||
|
str(corpus.id))
|
||||||
|
return send_from_directory(as_attachment=True,
|
||||||
|
directory=dir,
|
||||||
|
filename=file)
|
||||||
|
|
||||||
|
|
||||||
@main.route('/dashboard', methods=['GET', 'POST'])
|
@main.route('/dashboard', methods=['GET', 'POST'])
|
||||||
@login_required
|
@login_required
|
||||||
def dashboard():
|
def dashboard():
|
||||||
@ -100,7 +117,7 @@ def job(job_id):
|
|||||||
|
|
||||||
return render_template('main/jobs/job.html.j2',
|
return render_template('main/jobs/job.html.j2',
|
||||||
files=files,
|
files=files,
|
||||||
job=job,
|
job_id=job.id,
|
||||||
title='Job')
|
title='Job')
|
||||||
|
|
||||||
|
|
||||||
|
90
app/templates/main/corpora/corpus.html.j2
Normal file
90
app/templates/main/corpora/corpus.html.j2
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
{% extends "base.html.j2" %}
|
||||||
|
|
||||||
|
{% block page_content %}
|
||||||
|
<script>
|
||||||
|
var CORPUS_ID = {{ corpus_id }}
|
||||||
|
|
||||||
|
class InformationUpdater {
|
||||||
|
constructor(corpusId) {
|
||||||
|
this.corpusId = corpusId;
|
||||||
|
corporaSubscribers.push(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
_init() {
|
||||||
|
var creationDateElement, descriptionElement, titleElement;
|
||||||
|
|
||||||
|
this.corpus = corpora[this.corpusId];
|
||||||
|
creationDateElement = document.getElementById("creation-date");
|
||||||
|
creationDateElement.value = this.corpus.creation_date;
|
||||||
|
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>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col s12 m8">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-content">
|
||||||
|
<span class="card-title">Chronometrics</span>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col s12 m6">
|
||||||
|
<div class="input-field">
|
||||||
|
<input disabled value="" id="creation-date" type="text" class="validate">
|
||||||
|
<label for="creation-date">Creation date</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<span class="card-title">Files</span>
|
||||||
|
<p>
|
||||||
|
{% for file in files %}
|
||||||
|
<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>
|
||||||
|
{% endfor %}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
@ -53,8 +53,6 @@
|
|||||||
pathArray = operation.path.split("/").slice(1);
|
pathArray = operation.path.split("/").slice(1);
|
||||||
if (pathArray[0] != this.jobId) {continue;}
|
if (pathArray[0] != this.jobId) {continue;}
|
||||||
switch(operation.op) {
|
switch(operation.op) {
|
||||||
case "add":
|
|
||||||
break;
|
|
||||||
case "delete":
|
case "delete":
|
||||||
location.reload();
|
location.reload();
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user