Create and use a nopaque namespace for functions and ressources

This commit is contained in:
Patrick Jentsch
2020-01-20 09:49:39 +01:00
parent cc74871f90
commit 3e85daf8ab
7 changed files with 115 additions and 97 deletions

View File

@ -122,14 +122,20 @@
this.jobId = jobId;
this.foreignJobFlag = foreignJobFlag;
if (this.foreignJobFlag) {
foreignJobsSubscribers.push(this);
nopaque.foreignJobsSubscribers.push(this);
} else {
jobsSubscribers.push(this);
nopaque.jobsSubscribers.push(this);
}
}
_init() {
var job = this.foreignJobFlag ? foreignJobs[this.jobId] : jobs[this.jobId];
let job;
if (this.foreignJobFlag) {
job = nopaque.foreignJobs[this.jobId];
} else {
job = nopaque.jobs[this.jobId];
}
// End date
this.setEndDate(job.end_date);
@ -146,7 +152,7 @@
}
_update(patch) {
var pathArray;
let pathArray;
for (let operation of patch) {
/* "/jobId/valueName" -> ["jobId", "valueName"] */
@ -175,7 +181,8 @@
}
setEndDate(timestamp) {
var end_date;
let end_date;
if (timestamp === null) {
end_date = "N.a.";
} else {
@ -186,8 +193,9 @@
}
setResult(result) {
var resultsElement, resultDownloadButtonElement,
let resultsElement, resultDownloadButtonElement,
resultDownloadButtonIconElement;
resultsElement = document.getElementById(`input-${result.job_input_id}-results`);
resultDownloadButtonElement = document.createElement("a");
resultDownloadButtonElement.classList.add("waves-effect", "waves-light", "btn-small");
@ -203,7 +211,8 @@
}
setStatus(status) {
var statusElement;
let statusElement;
statusElement = document.getElementById("status");
statusElement.classList.remove(...Object.values(JobList.STATUS_COLORS));
statusElement.classList.add(JobList.STATUS_COLORS[status] || JobList.STATUS_COLORS['default']);
@ -215,7 +224,7 @@
var informationUpdater = new InformationUpdater({{ job.id }}, false);
{% else %}
var informationUpdater = new InformationUpdater({{ job.id }}, true);
socket.emit('subscribe_foreign_user_ressources', {{ job.user_id }});
nopaque.socket.emit('subscribe_foreign_user_ressources', {{ job.user_id }});
{% endif %}
</script>
{% endblock %}