mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 02:24:20 +00:00
(Re)Implement live update of corpus and job lists.
This commit is contained in:
parent
1955d3c015
commit
7702de8770
@ -46,8 +46,7 @@ class CorpusList extends List {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
corporaUpdateHandler(delta) {
|
||||
updateWithPatch(delta) {
|
||||
var corpusElement, key, listItem;
|
||||
|
||||
for (key in delta) {
|
||||
@ -74,5 +73,4 @@ class CorpusList extends List {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
@ -49,8 +49,7 @@ class JobList extends List {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
jobsUpdateHandler(delta) {
|
||||
updateWithPatch(delta) {
|
||||
var jobElement, jobStatusElement, key, listItem;
|
||||
|
||||
for (key in delta) {
|
||||
@ -83,7 +82,6 @@ class JobList extends List {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
JobList.SERVICE_COLORS = {"nlp": "blue",
|
||||
|
4913
app/static/js/jsondiffpatch.umd.js
Normal file
4913
app/static/js/jsondiffpatch.umd.js
Normal file
File diff suppressed because it is too large
Load Diff
36
app/static/js/jsonpatch.min.js
vendored
Normal file
36
app/static/js/jsonpatch.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -12,6 +12,8 @@
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/materialize.min.css') }}" media="screen,projection"/>
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/opaque.css') }}" media="screen,projection"/>
|
||||
<script src="{{ url_for('static', filename='js/socket.io.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/jsonpatch.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/jsondiffpatch.umd.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/list.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/list.utils.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/CorpusList.js') }}"></script>
|
||||
@ -21,29 +23,47 @@
|
||||
var corporaSubscribers = [];
|
||||
var jobs;
|
||||
var jobsSubscribers = [];
|
||||
</script>
|
||||
<script>
|
||||
var socket = io();
|
||||
|
||||
socket.on('init-corpora', function(msg) {
|
||||
var subscriber;
|
||||
|
||||
corpora = JSON.parse(msg);
|
||||
for (subscriber of corporaSubscribers) {subscriber.init();}
|
||||
});
|
||||
|
||||
|
||||
socket.on('init-jobs', function(msg) {
|
||||
var subscriber;
|
||||
|
||||
jobs = JSON.parse(msg);
|
||||
for (subscriber of jobsSubscribers) {subscriber.init();}
|
||||
});
|
||||
|
||||
|
||||
socket.on('update-corpora', function(msg) {
|
||||
console.log(msg);
|
||||
var patch, patchedCorpora, subscriber;
|
||||
|
||||
patch = JSON.parse(msg);
|
||||
patchedCorpora = jsonpatch.apply_patch(corpora, patch);
|
||||
delta = jsondiffpatch.diff(corpora, patchedCorpora);
|
||||
corpora = patchedCorpora;
|
||||
for (subscriber of corporaSubscribers) {
|
||||
subscriber.updateWithPatch(delta);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
socket.on('update-jobs', function(msg) {
|
||||
console.log(msg);
|
||||
var patch, patchedJobs, subscriber;
|
||||
|
||||
patch = JSON.parse(msg);
|
||||
patchedJobs = jsonpatch.apply_patch(jobs, patch);
|
||||
delta = jsondiffpatch.diff(jobs, patchedJobs);
|
||||
jobs = patchedJobs;
|
||||
for (subscriber of jobsSubscribers) {
|
||||
subscriber.updateWithPatch(delta);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user