mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
Merge branch 'development' of gitlab.ub.uni-bielefeld.de:sfb1288inf/opaque into development
This commit is contained in:
commit
68eb1d1972
@ -61,6 +61,9 @@ class Corpus(Model):
|
|||||||
subattr_value
|
subattr_value
|
||||||
return lookups
|
return lookups
|
||||||
|
|
||||||
|
def drop(self):
|
||||||
|
return self.client.api.corpus_drop_corpus(self.attrs['api_name'])
|
||||||
|
|
||||||
def query(self, query, subcorpus_name='Results'):
|
def query(self, query, subcorpus_name='Results'):
|
||||||
return self.client.api.cqp_query(self.attrs['api_name'],
|
return self.client.api.cqp_query(self.attrs['api_name'],
|
||||||
subcorpus_name, query)
|
subcorpus_name, query)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from flask import (abort, current_app, flash, redirect, request,
|
from flask import (abort, current_app, flash, make_response, redirect, request,
|
||||||
render_template, url_for, send_from_directory)
|
render_template, url_for, send_from_directory)
|
||||||
from flask_login import current_user, login_required
|
from flask_login import current_user, login_required
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
@ -99,8 +99,8 @@ def add_corpus_file(corpus_id):
|
|||||||
for corpus_file in corpus.files:
|
for corpus_file in corpus.files:
|
||||||
if filename == corpus_file.filename:
|
if filename == corpus_file.filename:
|
||||||
flash('File already registered to this corpus.')
|
flash('File already registered to this corpus.')
|
||||||
return redirect(url_for('corpora.add_corpus_file',
|
return make_response({'redirect_url': url_for('corpora.corpus', corpus_id=corpus.id)}, 500)
|
||||||
corpus_id=corpus_id))
|
# return redirect(url_for('corpora.add_corpus_file', corpus_id=corpus_id))
|
||||||
# Save the file
|
# Save the file
|
||||||
dir = os.path.join(str(corpus.user_id), 'corpora', str(corpus.id))
|
dir = os.path.join(str(corpus.user_id), 'corpora', str(corpus.id))
|
||||||
file.save(os.path.join(current_app.config['NOPAQUE_STORAGE'],
|
file.save(os.path.join(current_app.config['NOPAQUE_STORAGE'],
|
||||||
@ -125,7 +125,10 @@ def add_corpus_file(corpus_id):
|
|||||||
corpus_file.id))
|
corpus_file.id))
|
||||||
thread.start()
|
thread.start()
|
||||||
flash('Corpus file added!')
|
flash('Corpus file added!')
|
||||||
return redirect(url_for('corpora.corpus', corpus_id=corpus_id))
|
return make_response(
|
||||||
|
{'redirect_url': url_for('corpora.corpus', corpus_id=corpus.id)},
|
||||||
|
201)
|
||||||
|
# return redirect(url_for('corpora.corpus', corpus_id=corpus_id))
|
||||||
return render_template('corpora/add_corpus_file.html.j2',
|
return render_template('corpora/add_corpus_file.html.j2',
|
||||||
add_corpus_file_form=add_corpus_file_form,
|
add_corpus_file_form=add_corpus_file_form,
|
||||||
corpus=corpus, title='Add corpus file')
|
corpus=corpus, title='Add corpus file')
|
||||||
|
@ -426,6 +426,24 @@ class CorpusFile(db.Model):
|
|||||||
self.corpus.status = 'unprepared'
|
self.corpus.status = 'unprepared'
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
def to_dict(self):
|
||||||
|
return {'id': self.id,
|
||||||
|
'address': self.address,
|
||||||
|
'author': self.author,
|
||||||
|
'booktitle': self.booktitle,
|
||||||
|
'chapter': self.chapter,
|
||||||
|
'dir': self.dir,
|
||||||
|
'editor': self.editor,
|
||||||
|
'filename': self.filename,
|
||||||
|
'institution': self.institution,
|
||||||
|
'journal': self.journal,
|
||||||
|
'pages': self.pages,
|
||||||
|
'publisher': self.publisher,
|
||||||
|
'publishing_year': self.publishing_year,
|
||||||
|
'school': self.school,
|
||||||
|
'title': self.title,
|
||||||
|
'corpus_id': self.corpus_id}
|
||||||
|
|
||||||
|
|
||||||
class Corpus(db.Model):
|
class Corpus(db.Model):
|
||||||
"""
|
"""
|
||||||
@ -455,6 +473,7 @@ class Corpus(db.Model):
|
|||||||
return {'id': self.id,
|
return {'id': self.id,
|
||||||
'creation_date': self.creation_date.timestamp(),
|
'creation_date': self.creation_date.timestamp(),
|
||||||
'description': self.description,
|
'description': self.description,
|
||||||
|
'files': [file.to_dict() for file in self.files],
|
||||||
'status': self.status,
|
'status': self.status,
|
||||||
'title': self.title,
|
'title': self.title,
|
||||||
'user_id': self.user_id}
|
'user_id': self.user_id}
|
||||||
|
@ -68,12 +68,19 @@ indicator will show up how the column is sorted right now.; */
|
|||||||
z-index: 999; /* tmp fix */
|
z-index: 999; /* tmp fix */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.show-if-only-child:not(:only-child) {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
/* class for expert view */
|
/* class for expert view */
|
||||||
.expert-view {
|
.expert-view {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* styles for resource lists */
|
/* styles for resource lists */
|
||||||
|
.analyse-link[href=""] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
.service[data-service]:before {
|
.service[data-service]:before {
|
||||||
content: "help";
|
content: "help";
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ RessourceList.dataMapper = {
|
|||||||
corpus: corpus => ({creation_date: corpus.creation_date,
|
corpus: corpus => ({creation_date: corpus.creation_date,
|
||||||
description: corpus.description,
|
description: corpus.description,
|
||||||
id: corpus.id,
|
id: corpus.id,
|
||||||
"analyse-link": `/corpora/${corpus.id}/analyse`,
|
"analyse-link": ["analysing", "prepared", "start analysis"].includes(corpus.status) ? `/corpora/${corpus.id}/analyse` : "",
|
||||||
"edit-link": `/corpora/${corpus.id}`,
|
"edit-link": `/corpora/${corpus.id}`,
|
||||||
status: corpus.status,
|
status: corpus.status,
|
||||||
title: corpus.title}),
|
title: corpus.title}),
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col s12 m8">
|
<div class="col s12 m8">
|
||||||
<form method="POST" enctype="multipart/form-data">
|
<form class="nopaque-job-form" data-progress-modal="progress-modal">
|
||||||
{{ add_corpus_file_form.hidden_tag() }}
|
{{ add_corpus_file_form.hidden_tag() }}
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
@ -103,4 +103,16 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="progress-modal" class="modal">
|
||||||
|
<div class="modal-content">
|
||||||
|
<h4><i class="material-icons prefix">file_upload</i> Uploading files for <span class="title"></span></h4>
|
||||||
|
<div class="progress">
|
||||||
|
<div class="determinate" style="width: 0%"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<a href="#!" class="modal-close waves-effect waves-light btn red abort-request">Cancel</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -35,9 +35,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="card-action right-align">
|
<div class="card-action right-align">
|
||||||
<a href="{{ url_for('corpora.analyse_corpus', corpus_id=corpus.id) }}" class="btn disabled hide waves-effect waves-light" id="analyze"><i class="material-icons left">search</i>Analyze</a>
|
<a href="{{ url_for('corpora.analyse_corpus', corpus_id=corpus.id) }}" class="btn disabled hide waves-effect waves-light" id="analyze"><i class="material-icons left">search</i>Analyze</a>
|
||||||
{% if corpus.files[0] is defined %}
|
<a href="{{ url_for('corpora.prepare_corpus', corpus_id=corpus.id) }}" class="btn disabled hide waves-effect waves-light" id="compile"><i class="material-icons left">merge_type</i>Compile</a>
|
||||||
<a href="{{ url_for('corpora.prepare_corpus', corpus_id=corpus.id) }}" class="btn disabled hide waves-effect waves-light" id="build"><i class="material-icons left">build</i>Build</a>
|
|
||||||
{% endif %}
|
|
||||||
<a data-target="delete-corpus-modal" class="btn modal-trigger red waves-effect waves-light"><i class="material-icons left">delete</i>Delete</a>
|
<a data-target="delete-corpus-modal" class="btn modal-trigger red waves-effect waves-light"><i class="material-icons left">delete</i>Delete</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -49,6 +47,7 @@
|
|||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-content" style="overflow: hidden;">
|
<div class="card-content" style="overflow: hidden;">
|
||||||
<span class="card-title">Files</span>
|
<span class="card-title">Files</span>
|
||||||
|
|
||||||
<table class="highlight responsive-table">
|
<table class="highlight responsive-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -60,6 +59,12 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<tr class="show-if-only-child">
|
||||||
|
<td colspan="5">
|
||||||
|
<span class="card-title"><i class="material-icons left">book</i>Nothing here...</span>
|
||||||
|
<p>Corpus is empty. Add texts using the option below.</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
{% for file in corpus.files %}
|
{% for file in corpus.files %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ file.filename }}</td>
|
<td>{{ file.filename }}</td>
|
||||||
@ -114,6 +119,7 @@
|
|||||||
constructor(corpusId, foreignCorpusFlag) {
|
constructor(corpusId, foreignCorpusFlag) {
|
||||||
this.corpusId = corpusId;
|
this.corpusId = corpusId;
|
||||||
this.foreignCorpusFlag = foreignCorpusFlag;
|
this.foreignCorpusFlag = foreignCorpusFlag;
|
||||||
|
|
||||||
if (this.foreignCorpusFlag) {
|
if (this.foreignCorpusFlag) {
|
||||||
nopaque.foreignCorporaSubscribers.push(this);
|
nopaque.foreignCorporaSubscribers.push(this);
|
||||||
} else {
|
} else {
|
||||||
@ -124,14 +130,11 @@
|
|||||||
_init() {
|
_init() {
|
||||||
let corpus;
|
let corpus;
|
||||||
|
|
||||||
if (this.foreignCorpusFlag) {
|
corpus = (this.foreignCorpusFlag ? nopaque.foreignCorpora[this.corpusId]
|
||||||
corpus = nopaque.foreignCorpora[this.corpusId];
|
: nopaque.corpora[this.corpusId]);
|
||||||
} else {
|
|
||||||
corpus = nopaque.corpora[this.corpusId];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
this.setStatus(corpus.status);
|
this.setStatus(corpus.status, corpus.files.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
_update(patch) {
|
_update(patch) {
|
||||||
@ -160,7 +163,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
setStatus(status) {
|
setStatus(status) {
|
||||||
let analyzeElement, buildElement, progressIndicatorElement, statusElement;
|
let analyzeElement, compileElement, numFiles, progressIndicatorElement, statusElement;
|
||||||
|
|
||||||
|
numFiles = (this.foreignCorpusFlag ? nopaque.foreignCorpora[this.corpusId] : nopaque.corpora[this.corpusId]).files.length;
|
||||||
|
|
||||||
progressIndicatorElement = document.getElementById("progress-indicator");
|
progressIndicatorElement = document.getElementById("progress-indicator");
|
||||||
if (["queued", "running", "start analysis", "stop analysis"].includes(status)) {
|
if (["queued", "running", "start analysis", "stop analysis"].includes(status)) {
|
||||||
@ -180,11 +185,11 @@
|
|||||||
analyzeElement.classList.add("disabled", "hide");
|
analyzeElement.classList.add("disabled", "hide");
|
||||||
}
|
}
|
||||||
|
|
||||||
buildElement = document.getElementById("build");
|
compileElement = document.getElementById("compile");
|
||||||
if (status === 'unprepared') {
|
if (status === "unprepared" && numFiles > 0) {
|
||||||
buildElement.classList.remove("disabled", "hide");
|
compileElement.classList.remove("disabled", "hide");
|
||||||
} else {
|
} else {
|
||||||
buildElement.classList.add("disabled", "hide");
|
compileElement.classList.add("disabled", "hide");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,6 +146,7 @@
|
|||||||
constructor(jobId, foreignJobFlag) {
|
constructor(jobId, foreignJobFlag) {
|
||||||
this.jobId = jobId;
|
this.jobId = jobId;
|
||||||
this.foreignJobFlag = foreignJobFlag;
|
this.foreignJobFlag = foreignJobFlag;
|
||||||
|
|
||||||
if (this.foreignJobFlag) {
|
if (this.foreignJobFlag) {
|
||||||
nopaque.foreignJobsSubscribers.push(this);
|
nopaque.foreignJobsSubscribers.push(this);
|
||||||
} else {
|
} else {
|
||||||
@ -156,11 +157,8 @@
|
|||||||
_init() {
|
_init() {
|
||||||
let job;
|
let job;
|
||||||
|
|
||||||
if (this.foreignJobFlag) {
|
job = (this.foreignJobFlag ? nopaque.foreignJobs[this.jobId]
|
||||||
job = nopaque.foreignJobs[this.jobId];
|
: nopaque.jobs[this.jobId]);
|
||||||
} else {
|
|
||||||
job = nopaque.jobs[this.jobId];
|
|
||||||
}
|
|
||||||
|
|
||||||
// End date
|
// End date
|
||||||
this.setEndDate(job.end_date);
|
this.setEndDate(job.end_date);
|
||||||
|
Loading…
Reference in New Issue
Block a user