mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-21 05:20:36 +00:00
Updated URL Logic for admin package
This commit is contained in:
@ -1,83 +1,6 @@
|
||||
{% extends "limited_width.html.j2" %}
|
||||
|
||||
{% block page_content %}
|
||||
<script>
|
||||
{% if corpus.creator == current_user %}
|
||||
var foreignCorpusFlag = false;
|
||||
{% else %}
|
||||
var foreignCorpusFlag = true;
|
||||
socket.emit('subscribe_foreign_user_ressources', {{ corpus.user_id }});
|
||||
{% endif %}
|
||||
|
||||
class InformationUpdater {
|
||||
constructor(corpusId) {
|
||||
this.corpusId = corpusId;
|
||||
if (foreignCorpusFlag) {
|
||||
foreignCorporaSubscribers.push(this);
|
||||
} else {
|
||||
corporaSubscribers.push(this);
|
||||
}
|
||||
}
|
||||
|
||||
_init() {
|
||||
if (foreignCorpusFlag) {
|
||||
this.corpus = foreignCorpora[this.corpusId];
|
||||
} else {
|
||||
this.corpus = corpora[this.corpusId];
|
||||
}
|
||||
|
||||
// Status
|
||||
this.setStatus(this.corpus.status);
|
||||
}
|
||||
|
||||
_update(patch) {
|
||||
var pathArray;
|
||||
|
||||
for (let operation of patch) {
|
||||
/* "/corpusId/valueName" -> ["corpusId", "valueName"] */
|
||||
pathArray = operation.path.split("/").slice(1);
|
||||
if (pathArray[0] != this.corpusId) {continue;}
|
||||
switch(operation.op) {
|
||||
case "add":
|
||||
location.reload();
|
||||
break;
|
||||
case "delete":
|
||||
location.reload();
|
||||
break;
|
||||
case "replace":
|
||||
if (pathArray[1] === "status") {
|
||||
this.setStatus(operation.value);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setStatus(status) {
|
||||
var statusElement;
|
||||
statusElement = document.getElementById("status");
|
||||
statusElement.classList.remove(...Object.values(CorpusList.STATUS_COLORS));
|
||||
statusElement.classList.add(CorpusList.STATUS_COLORS[status] || CorpusList.STATUS_COLORS['default']);
|
||||
statusElement.innerText = status;
|
||||
var analyseBtn = document.getElementById('analyse');
|
||||
if (status === 'prepared' || status === 'analysing') {
|
||||
analyseBtn.classList.remove('hide', 'disabled');
|
||||
} else if (status === 'start analysis' || status === 'stop analysis') {
|
||||
analyseBtn.classList.remove('hide');
|
||||
analyseBtn.classList.add('disabled');
|
||||
}
|
||||
if (status === 'prepared' || status === 'preparable' || status === 'preparing' || status === 'start analysis' || status === 'analysing' || status === 'stop analysis') {
|
||||
var prepareBtn = document.getElementById('prepare');
|
||||
prepareBtn.classList.add('hide');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var informationUpdater = new InformationUpdater({{ corpus.id }});
|
||||
</script>
|
||||
|
||||
<div class="col s12 m4">
|
||||
<h3 id="title">{{ corpus.title }}</h3>
|
||||
<p id="description">{{ corpus.description }}</p>
|
||||
@ -146,11 +69,12 @@
|
||||
</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 {{corpus.title}}? All files will be permanently deleted!</p>
|
||||
<p>Do you really want to delete the corpus {{corpus.title}}? All files will be permanently deleted!</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#!" class="modal-close waves-effect waves-green btn cancel">Cancel</a>
|
||||
@ -169,5 +93,78 @@
|
||||
<a class="modal-close waves-effect waves-green btn red" href="{{ url_for('corpora.delete_corpus_file', corpus_file_id=file.id, corpus_id=corpus.id) }}">Confirm<i class="material-icons right">send</i></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
class InformationUpdater {
|
||||
constructor(corpusId, foreignCorpusFlag) {
|
||||
this.corpusId = corpusId;
|
||||
this.foreignCorpusFlag = foreignCorpusFlag;
|
||||
if (this.foreignCorpusFlag) {
|
||||
foreignCorporaSubscribers.push(this);
|
||||
} else {
|
||||
corporaSubscribers.push(this);
|
||||
}
|
||||
}
|
||||
|
||||
_init() {
|
||||
var corpus = this.foreignCorpusFlag ? foreignCorpora[this.corpusId] : corpora[this.corpusId];
|
||||
|
||||
// Status
|
||||
this.setStatus(corpus.status);
|
||||
}
|
||||
|
||||
_update(patch) {
|
||||
var pathArray;
|
||||
|
||||
for (let operation of patch) {
|
||||
/* "/corpusId/valueName" -> ["corpusId", "valueName"] */
|
||||
pathArray = operation.path.split("/").slice(1);
|
||||
if (pathArray[0] != this.corpusId) {continue;}
|
||||
switch(operation.op) {
|
||||
case "add":
|
||||
location.reload();
|
||||
break;
|
||||
case "delete":
|
||||
location.reload();
|
||||
break;
|
||||
case "replace":
|
||||
if (pathArray[1] === "status") {
|
||||
this.setStatus(operation.value);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setStatus(status) {
|
||||
var statusElement;
|
||||
statusElement = document.getElementById("status");
|
||||
statusElement.classList.remove(...Object.values(CorpusList.STATUS_COLORS));
|
||||
statusElement.classList.add(CorpusList.STATUS_COLORS[status] || CorpusList.STATUS_COLORS['default']);
|
||||
statusElement.innerText = status;
|
||||
var analyseBtn = document.getElementById('analyse');
|
||||
if (status === 'prepared' || status === 'analysing') {
|
||||
analyseBtn.classList.remove('hide', 'disabled');
|
||||
} else if (status === 'start analysis' || status === 'stop analysis') {
|
||||
analyseBtn.classList.remove('hide');
|
||||
analyseBtn.classList.add('disabled');
|
||||
}
|
||||
if (status === 'prepared' || status === 'preparable' || status === 'preparing' || status === 'start analysis' || status === 'analysing' || status === 'stop analysis') {
|
||||
var prepareBtn = document.getElementById('prepare');
|
||||
prepareBtn.classList.add('hide');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{% if corpus.creator == current_user %}
|
||||
var informationUpdater = new InformationUpdater({{ corpus.id }}, false);
|
||||
{% else %}
|
||||
var informationUpdater = new InformationUpdater({{ corpus.id }}, true);
|
||||
socket.emit('subscribe_foreign_user_ressources', {{ corpus.user_id }});
|
||||
{% endif %}
|
||||
</script>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
Reference in New Issue
Block a user