mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-12 00:50:40 +00:00
Stop polling. Use SocketIO!
This commit is contained in:
@ -1,10 +1,12 @@
|
||||
class CorpusList extends List {
|
||||
constructor(idOrElement, options, live=false) {
|
||||
constructor(idOrElement, options) {
|
||||
super(idOrElement, options);
|
||||
corporaSubscribers.push(this);
|
||||
}
|
||||
|
||||
|
||||
init() {
|
||||
this.createCorpusElements(corpora);
|
||||
if (live) {
|
||||
subscribers.corpora.push(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -48,7 +50,7 @@ class CorpusList extends List {
|
||||
List.updatePagination(this);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
corporaUpdateHandler(delta) {
|
||||
var corpusElement, key, listItem;
|
||||
|
||||
@ -76,4 +78,5 @@ class CorpusList extends List {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
class JobList extends List {
|
||||
constructor(idOrElement, options, live=false) {
|
||||
constructor(idOrElement, options) {
|
||||
super(idOrElement, options);
|
||||
jobsSubscribers.push(this);
|
||||
}
|
||||
|
||||
|
||||
init() {
|
||||
this.createJobElements(jobs);
|
||||
if (live) {
|
||||
subscribers.jobs.push(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -51,7 +53,7 @@ class JobList extends List {
|
||||
List.updatePagination(this);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
jobsUpdateHandler(delta) {
|
||||
var jobElement, jobStatusElement, key, listItem;
|
||||
|
||||
@ -85,6 +87,7 @@ class JobList extends List {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
JobList.SERVICE_COLORS = {"nlp": "blue",
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,58 +0,0 @@
|
||||
var subscribers = {"corpora": [], "jobs": []};
|
||||
|
||||
|
||||
function getCorpora() {
|
||||
fetch("/api/v1.0/corpora")
|
||||
.then(function(response) {
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
return Promise.resolve(response);
|
||||
} else {
|
||||
return Promise.reject(new Error(response.statusText));
|
||||
}
|
||||
})
|
||||
.then(function(response) {
|
||||
return response.json();
|
||||
})
|
||||
.then(function(data) {
|
||||
if (JSON.stringify(corpora) != JSON.stringify(data)) {
|
||||
corpora = data;
|
||||
for (subscriber of subscribers.corpora) {
|
||||
subscriber.corporaUpdateHandler();
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(function(error) {
|
||||
console.log('Request failed', error);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function getJobs() {
|
||||
fetch("/api/v1.0/jobs")
|
||||
.then(function(response) {
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
return Promise.resolve(response);
|
||||
} else {
|
||||
return Promise.reject(new Error(response.statusText));
|
||||
}
|
||||
})
|
||||
.then(function(response) {
|
||||
return response.json();
|
||||
})
|
||||
.then(function(json) {
|
||||
var delta = jsondiffpatch.diff(jobs, json);
|
||||
if (delta) {
|
||||
jobs = json;
|
||||
for (subscriber of subscribers.jobs) {
|
||||
subscriber.jobsUpdateHandler(delta);
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(function(error) {
|
||||
console.log('Request failed', error);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
setInterval(getCorpora, 5000);
|
||||
setInterval(getJobs, 5000);
|
Reference in New Issue
Block a user