Skip to content
Snippets Groups Projects
Commit 715c3781 authored by Patrick Jentsch's avatar Patrick Jentsch
Browse files

First RessourceList update

parent 889c568c
No related branches found
No related tags found
No related merge requests found
......@@ -6,20 +6,24 @@ def init_logger():
'''
Functions initiates a logger instance.
'''
if not os.path.isfile('logs/nopaqued.log'):
file_path = os.path.join(os.getcwd(), 'logs/nopaqued.log')
log = open(file_path, 'w+')
log.close()
logging.basicConfig(datefmt='%Y-%m-%d %H:%M:%S',
filemode='w', filename='logs/nopaqued.log',
format='%(asctime)s - %(levelname)s - %(name)s - '
'%(filename)s - %(lineno)d - %(message)s')
logger = logging.getLogger(__name__)
if os.environ.get('FLASK_CONFIG') == 'development':
logger.setLevel(logging.DEBUG)
if os.environ.get('FLASK_CONFIG') == 'production':
logger.setLevel(logging.WARNING)
return logger
os.makedirs('logs', exist_ok=True)
logging.basicConfig(filename='logs/nopaqued.log',
format='[%(asctime)s] %(levelname)s in '
'%(pathname)s:%(lineno)d - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S', filemode='w')
NOPAQUE_LOG_LEVEL = os.environ.get('NOPAQUE_LOG_LEVEL')
if NOPAQUE_LOG_LEVEL is None:
FLASK_CONFIG = os.environ.get('FLASK_CONFIG')
if FLASK_CONFIG == 'development':
logging.basicConfig(level='DEBUG')
elif FLASK_CONFIG == 'testing':
# TODO: Set an appropriate log level
pass
elif FLASK_CONFIG == 'production':
logging.basicConfig(level='ERROR')
else:
logging.basicConfig(level=NOPAQUE_LOG_LEVEL)
return logging.getLogger(__name__)
if __name__ == '__main__':
......
......@@ -40,6 +40,6 @@ services:
volumes:
- "/srv/nopaque/db:/var/lib/postgresql/data"
redis:
image: redis:5
image: redis:6
volumes:
- "redis-trash1:/data"
......@@ -169,10 +169,10 @@ def download_corpus_file(corpus_id, corpus_file_id):
filename=corpus_file.filename)
@corpora.route('/<int:corpus_id>/files/<int:corpus_file_id>/edit',
@corpora.route('/<int:corpus_id>/files/<int:corpus_file_id>',
methods=['GET', 'POST'])
@login_required
def edit_corpus_file(corpus_id, corpus_file_id):
def corpus_file(corpus_id, corpus_file_id):
corpus = Corpus.query.get_or_404(corpus_id)
corpus_file = CorpusFile.query.get_or_404(corpus_file_id)
if not corpus_file.corpus_id == corpus_id:
......@@ -212,7 +212,7 @@ def edit_corpus_file(corpus_id, corpus_file_id):
edit_corpus_file_form.publishing_year.data = corpus_file.publishing_year
edit_corpus_file_form.school.data = corpus_file.school
edit_corpus_file_form.title.data = corpus_file.title
return render_template('corpora/edit_corpus_file.html.j2',
return render_template('corpora/corpus_file.html.j2',
corpus_file=corpus_file, corpus=corpus,
edit_corpus_file_form=edit_corpus_file_form,
title='Edit corpus file')
......
......@@ -43,7 +43,6 @@ nopaque.socket.init = function() {
for (let subscriber of nopaque.queryResultsSubscribers) {
subscriber._init(nopaque.user.query_results);
}
RessourceList.modifyTooltips(false)
});
nopaque.socket.on("user_data_stream_update", function(msg) {
......@@ -86,7 +85,6 @@ nopaque.socket.init = function() {
for (let subscriber of nopaque.foreignQueryResultsSubscribers) {
subscriber._init(nopaque.foreignUser.query_results);
}
RessourceList.modifyTooltips(false)
});
nopaque.socket.on("foreign_user_data_stream_update", function(msg) {
......
This diff is collapsed.
......@@ -33,9 +33,10 @@
</div>
<script>
var ressources = {{ users|tojson|safe }};
var users = {{ users|tojson|safe }};
var userList = new RessourceList('users', null, "User");
userList.addRessources(ressources);
RessourceList.modifyTooltips();
document.addEventListener("DOMContentLoaded", () => {
userList.addRessources(users);
});
</script>
{% endblock %}
......@@ -122,12 +122,6 @@
<script>
// create corpus file table
var ressources = {{ corpus_files|tojson|safe }};
var corpusFilesList = new RessourceList("corpus-files", null, "CorpusFile");
corpusFilesList.addRessources(ressources);
RessourceList.modifyTooltips();
class InformationUpdater {
constructor(corpusId, foreignCorpusFlag) {
this.corpusId = corpusId;
......@@ -215,5 +209,9 @@
nopaque.socket.emit("foreign_user_data_stream_init", {{ corpus.user_id }});
});
{% endif %}
var corpusFilesList = new RessourceList("corpus-files", null, "CorpusFile");
document.addEventListener("DOMContentLoaded", () => {
corpusFilesList._add({{ corpus_files|tojson|safe }});
});
</script>
{% endblock %}
......@@ -158,12 +158,6 @@
<script>
// job_input_table code
var ressources = {{ job_inputs|tojson|safe }};
var jobInputsList = new RessourceList("inputs", null, "JobInput");
jobInputsList.addRessources(ressources);
RessourceList.modifyTooltips();
class InformationUpdater {
constructor(jobId, foreignJobFlag) {
this.jobId = jobId;
......@@ -299,5 +293,9 @@
nopaque.socket.emit("foreign_user_data_stream_init", {{ job.user_id }});
});
{% endif %}
let jobInputsList = new RessourceList("inputs", null, "JobInput");
document.addEventListener("DOMContentLoaded", () => {
jobInputsList._add({{ job_inputs|tojson|safe }});
});
</script>
{% endblock %}
......@@ -112,143 +112,49 @@
<p><a class="modal-trigger waves-effect waves-light btn" href="#" data-target="new-job-modal"><i class="material-icons left">add</i>New job</a></p>
</div>
</div>
</div>
<!-- Modals -->
<div id="delete-corpus-modal" class="modal">
<div class="modal-content">
<h4>Confirm corpus deletion</h4>
<p>Do you really want to delete the corpus <b id="selected-corpus-title"></b>? All files will be permanently deleted!</p>
</div>
<div class="modal-footer">
<a href="#!" class="btn modal-close waves-effect waves-light">Cancel</a>
<a class="btn modal-close red waves-effect waves-light" id="selected-corpus-delete-link"><i class="material-icons left">delete</i>Delete</a>
</div>
</div>
<div id="delete-job-modal" class="modal">
<div class="modal-content">
<h4>Confirm job deletion</h4>
<p>Do you really want to delete the job <b id="selected-job-title"></b>? All files will be permanently deleted!</p>
</div>
<div class="modal-footer">
<a href="#!" class="btn modal-close waves-effect waves-light">Cancel</a>
<a class="btn modal-close red waves-effect waves-light" id="selected-job-delete-link"><i class="material-icons left">delete</i>Delete</a>
</div>
</div>
<div id="delete-query-result-modal" class="modal no-autoinit">
<div class="modal-content">
<h4>Confirm query result deletion</h4>
<p>Do you really want to delete the query result <b id="selected-query-result-title"></b>? It will be permanently deleted.</p>
</div>
<div class="modal-footer">
<a href="#!" class="btn modal-close waves-effect waves-light">Cancel</a>
<a class="btn modal-close red waves-effect waves-light" id="selected-query-result-delete-link"><i class="material-icons left">delete</i>Delete</a>
</div>
</div>
<div id="new-job-modal" class="modal">
<div class="modal-content">
<h4>Select a service</h4>
<div class="row">
<div class="col s12 m4">
<a href="{{ url_for('services.service', service='file-setup') }}" style="color: rgba(0,0,0,0.87);">
<div class="card-panel center-align hoverable">
<i class="large material-icons" style="color: #ee6e73;">burst_mode</i>
<p>File setup</p>
<p class="light">Digital copies of text based research data (books, letters, etc.) often comprise various files and formats. nopaque converts and merges those files to facilitate further processing and the application of other services.</p>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="{{ url_for('services.service', service='ocr') }}" style="color: rgba(0,0,0,0.87);">
<div class="card-panel center-align hoverable">
<i class="large material-icons" style="color: #ee6e73;">find_in_page</i>
<p>Optical Character Recognition</p>
<p class="light">nopaque converts your image data – like photos or scans – into text data through a process called OCR. This step enables you to proceed with further computational analysis of your documents.</p>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="{{ url_for('services.service', service='nlp') }}" style="color: rgba(0,0,0,0.87);">
<div class="card-panel center-align hoverable">
<i class="large material-icons" style="color: #ee6e73;">format_textdirection_l_to_r</i>
<p>Natural Language Processing</p>
<p class="light">By means of computational linguistic data processing (tokenization, lemmatization, part-of-speech tagging and named-entity recognition) nopaque extracts additional information from your text.</p>
</div>
</a>
<div id="new-job-modal" class="modal">
<div class="modal-content">
<h4>Select a service</h4>
<div class="row">
<div class="col s12 m4">
<a href="{{ url_for('services.service', service='file-setup') }}" style="color: rgba(0,0,0,0.87);">
<div class="card-panel center-align hoverable">
<i class="large material-icons" style="color: #ee6e73;">burst_mode</i>
<p>File setup</p>
<p class="light">Digital copies of text based research data (books, letters, etc.) often comprise various files and formats. nopaque converts and merges those files to facilitate further processing and the application of other services.</p>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="{{ url_for('services.service', service='ocr') }}" style="color: rgba(0,0,0,0.87);">
<div class="card-panel center-align hoverable">
<i class="large material-icons" style="color: #ee6e73;">find_in_page</i>
<p>Optical Character Recognition</p>
<p class="light">nopaque converts your image data – like photos or scans – into text data through a process called OCR. This step enables you to proceed with further computational analysis of your documents.</p>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="{{ url_for('services.service', service='nlp') }}" style="color: rgba(0,0,0,0.87);">
<div class="card-panel center-align hoverable">
<i class="large material-icons" style="color: #ee6e73;">format_textdirection_l_to_r</i>
<p>Natural Language Processing</p>
<p class="light">By means of computational linguistic data processing (tokenization, lemmatization, part-of-speech tagging and named-entity recognition) nopaque extracts additional information from your text.</p>
</div>
</a>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<a href="#!" class="modal-close waves-effect waves-light btn-flat">Close</a>
<div class="modal-footer">
<a href="#!" class="modal-close waves-effect waves-light btn-flat">Close</a>
</div>
</div>
</div>
<script>
var corpusList = new RessourceList("corpora", nopaque.corporaSubscribers,
"Corpus");
var corpusList = new RessourceList("corpora", nopaque.corporaSubscribers, "Corpus");
var jobList = new RessourceList("jobs", nopaque.jobsSubscribers, "Job");
var queryResultList = new RessourceList("query-results",
nopaque.queryResultsSubscribers,
"QueryResult", {page: 10});
var deleteCorpusModalElement = document.getElementById("delete-corpus-modal");
var deleteCorpusModal;
var deleteJobModalElement = document.getElementById("delete-job-modal");
var deleteJobModal;
var deleteQueryResultModalElement = document.getElementById("delete-query-result-modal");
var deleteQueryResultModal;
var selectedCorpusDeleteLinkElement = document.getElementById("selected-corpus-delete-link");
var selectedCorpusTitleElement = document.getElementById("selected-corpus-title");
var selectedJobDeleteLinkElement = document.getElementById("selected-job-delete-link");
var selectedJobTitleElement = document.getElementById("selected-job-title");
var selectedQueryResultDeleteLinkElement = document.getElementById("selected-query-result-delete-link");
var selectedQueryResultTitleElement = document.getElementById("selected-query-result-title");
function prepareDeleteCorpusModal(selectedCorpusId) {
var selectedCorpus;
if (selectedCorpusId in nopaque.user.corpora) {
selectedCorpus = nopaque.user.corpora[selectedCorpusId];
selectedCorpusDeleteLinkElement.href = `/corpora/${selectedCorpus.id}/delete`;
selectedCorpusTitleElement.innerText = selectedCorpus.title;
} else {
selectedQueryResult = undefined;
selectedCorpusDeleteLinkElement.href = "";
selectedCorpusTitleElement.innerText = "";
}
deleteCorpusModal.open();
}
function prepareDeleteJobModal(selectedJobId) {
var selectedJob;
if (selectedJobId in nopaque.user.jobs) {
selectedJob = nopaque.user.jobs[selectedJobId];
selectedJobDeleteLinkElement.href = `/jobs/${selectedJob.id}/delete`;
selectedJobTitleElement.innerText = selectedJob.title;
} else {
selectedJob = undefined;
selectedJobDeleteLinkElement.href = "";
selectedJobTitleElement.innerText = "";
}
deleteJobModal.open();
}
function prepareDeleteQueryResultModal(selectedQueryResultId) {
var selectedQueryResult;
if (selectedQueryResultId in nopaque.user.query_results) {
selectedQueryResult = nopaque.user.query_results[selectedQueryResultId];
selectedQueryResultDeleteLinkElement.href = `/query_results/${selectedQueryResult.id}/delete`;
selectedQueryResultTitleElement.innerText = selectedQueryResult.title;
} else {
selectedQueryResult = undefined;
selectedQueryResultDeleteLinkElement.href = "";
selectedQueryResultTitleElement.innerText = "";
}
deleteQueryResultModal.open();
}
document.addEventListener("DOMContentLoaded", () => {
deleteCorpusModal = M.Modal.init(deleteCorpusModalElement);
deleteJobModal = M.Modal.init(deleteJobModalElement);
deleteQueryResultModal = M.Modal.init(deleteQueryResultModalElement);
});
var queryResultList = new RessourceList("query-results", nopaque.queryResultsSubscribers, "QueryResult");
</script>
{% endblock %}
......@@ -83,72 +83,8 @@
</div>
</div>
<!-- Modals -->
<div id="delete-corpus-modal" class="modal">
<div class="modal-content">
<h4>Confirm corpus deletion</h4>
<p>Do you really want to delete the corpus <b id="selected-corpus-title"></b>? All files will be permanently deleted!</p>
</div>
<div class="modal-footer">
<a href="#!" class="btn modal-close waves-effect waves-light">Cancel</a>
<a class="btn modal-close red waves-effect waves-light" id="selected-corpus-delete-link"><i class="material-icons left">delete</i>Delete</a>
</div>
</div>
<div id="delete-query-result-modal" class="modal no-autoinit">
<div class="modal-content">
<h4>Confirm query result deletion</h4>
<p>Do you really want to delete the query result <b id="selected-query-result-title"></b>? It will be permanently deleted.</p>
</div>
<div class="modal-footer">
<a href="#!" class="btn modal-close waves-effect waves-light">Cancel</a>
<a class="btn modal-close red waves-effect waves-light" id="selected-query-result-delete-link"><i class="material-icons left">delete</i>Delete</a>
</div>
</div>
<script>
var corpusList = new RessourceList("corpora", nopaque.corporaSubscribers,
"Corpus", {page: 10});
var queryResultList = new RessourceList("query-results",
nopaque.queryResultsSubscribers,
"QueryResult", {page: 10});
var deleteCorpusModalElement = document.getElementById("delete-corpus-modal");
var deleteCorpusModal;
var deleteQueryResultModalElement = document.getElementById("delete-query-result-modal");
var deleteQueryResultModal;
var selectedCorpusDeleteLinkElement = document.getElementById("selected-corpus-delete-link");
var selectedCorpusTitleElement = document.getElementById("selected-corpus-title");
var selectedQueryResultDeleteLinkElement = document.getElementById("selected-query-result-delete-link");
var selectedQueryResultTitleElement = document.getElementById("selected-query-result-title");
function prepareDeleteCorpusModal(selectedCorpusId) {
var selectedCorpus;
if (selectedCorpusId in nopaque.user.corpora) {
selectedCorpus = nopaque.user.corpora[selectedCorpusId];
selectedCorpusDeleteLinkElement.href = `/corpora/${selectedCorpus.id}/delete`;
selectedCorpusTitleElement.innerText = selectedCorpus.title;
} else {
selectedQueryResult = undefined;
selectedCorpusDeleteLinkElement.href = "";
selectedCorpusTitleElement.innerText = "";
}
deleteCorpusModal.open();
}
function prepareDeleteQueryResultModal(selectedQueryResultId) {
var selectedQueryResult;
if (selectedQueryResultId in nopaque.user.query_results) {
selectedQueryResult = nopaque.user.query_results[selectedQueryResultId];
selectedQueryResultDeleteLinkElement.href = `/query_results/${selectedQueryResult.id}/delete`;
selectedQueryResultTitleElement.innerText = selectedQueryResult.title;
} else {
selectedQueryResult = undefined;
selectedQueryResultDeleteLinkElement.href = "";
selectedQueryResultTitleElement.innerText = "";
}
deleteQueryResultModal.open();
}
document.addEventListener("DOMContentLoaded", () => {
deleteCorpusModal = M.Modal.init(deleteCorpusModalElement);
deleteQueryResultModal = M.Modal.init(deleteQueryResultModalElement);
});
var corpusList = new RessourceList("corpora", nopaque.corporaSubscribers, "Corpus");
var queryResultList = new RessourceList("query-results", nopaque.queryResultsSubscribers, "QueryResult");
</script>
{% endblock %}
......@@ -47,12 +47,7 @@ class Config:
@staticmethod
def init_app(app):
proxy_fix_kwargs = {
'x_for': 1,
'x_host': 1,
'x_port': 1,
'x_proto': 1,
}
proxy_fix_kwargs = {'x_for': 1, 'x_host': 1, 'x_port': 1, 'x_proto': 1}
app.wsgi_app = ProxyFix(app.wsgi_app, **proxy_fix_kwargs)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment