Add notifications on status changes of jobs and corpora

This commit is contained in:
Patrick Jentsch 2020-04-24 15:22:04 +02:00
parent 606c8cf761
commit 7fc1084749
3 changed files with 21 additions and 2 deletions

View File

@ -29,7 +29,10 @@ def add_corpus():
flash('[ERROR]: Could not add corpus!')
corpus.delete()
else:
flash('Corpus added!')
corpus_url = url_for('corpora.corpus', corpus_id=corpus.id)
flash('<i class="left material-icons">book</i>'
'[<a href="{}">{}</a>] added'.format(corpus_url,
corpus.title))
return redirect(url_for('corpora.corpus', corpus_id=corpus.id))
return render_template('corpora/add_corpus.html.j2',
add_corpus_form=add_corpus_form,

View File

@ -74,7 +74,9 @@ def service(service):
db.session.add(job_input)
job.status = 'submitted'
db.session.commit()
flash('Job added!')
job_url = url_for('jobs.job', job_id=job.id)
flash('<i class="left material-icons">work</i>'
'[<a href="{}">{}</a>] added'.format(job_url, job.title))
return make_response(
{'redirect_url': url_for('jobs.job', job_id=job.id)}, 201)
return render_template('services/{}.html.j2'.format(service),

View File

@ -43,6 +43,13 @@ nopaque.socket.init = function() {
var patch;
patch = JSON.parse(msg);
for (operation of patch) {
/* "/corpusId/valueName" -> ["corpusId", "valueName"] */
pathArray = operation.path.split("/").slice(1);
if (operation.op === "replace" && pathArray[1] === "status") {
nopaque.flash(`<i class="left material-icons">book</i>[<a href="/jobs/${pathArray[0]}">${nopaque.corpora[pathArray[0]].title}</a>] New status: ${operation.value}`);
}
}
nopaque.corpora = jsonpatch.apply_patch(nopaque.corpora, patch);
for (let subscriber of nopaque.corporaSubscribers) {subscriber._update(patch);}
});
@ -51,6 +58,13 @@ nopaque.socket.init = function() {
var patch;
patch = JSON.parse(msg);
for (operation of patch) {
/* "/jobId/valueName" -> ["jobId", "valueName"] */
pathArray = operation.path.split("/").slice(1);
if (operation.op === "replace" && pathArray[1] === "status") {
nopaque.flash(`<i class="left material-icons">work</i>[<a href="/jobs/${pathArray[0]}">${nopaque.jobs[pathArray[0]].title}</a>] New status: ${operation.value}`);
}
}
nopaque.jobs = jsonpatch.apply_patch(nopaque.jobs, patch);
for (let subscriber of nopaque.jobsSubscribers) {subscriber._update(patch);}
});