mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-10-15 03:01:57 +00:00
Implement corpora endpoint/socket.io namespace
This commit is contained in:
57
app/static/js/app/endpoints/corpora.js
Normal file
57
app/static/js/app/endpoints/corpora.js
Normal file
@@ -0,0 +1,57 @@
|
||||
nopaque.app.endpoints.Corpora = class Corpora {
|
||||
constructor(app) {
|
||||
this.app = app;
|
||||
|
||||
this.socket = io('/corpora', {transports: ['websocket'], upgrade: false});
|
||||
}
|
||||
|
||||
async delete(id) {
|
||||
const response = await this.socket.emitWithAck('delete', id);
|
||||
|
||||
if (response.status != 202) {
|
||||
throw new Error(`[${response.status}] ${response.statusText}`);
|
||||
}
|
||||
|
||||
return response.body;
|
||||
}
|
||||
|
||||
async build(id) {
|
||||
const response = await this.socket.emitWithAck('build', id);
|
||||
|
||||
if (response.status != 202) {
|
||||
throw new Error(`[${response.status}] ${response.statusText}`);
|
||||
}
|
||||
|
||||
return response.body;
|
||||
}
|
||||
|
||||
async getStopwords() {
|
||||
const response = await this.socket.emitWithAck('get_stopwords');
|
||||
|
||||
if (response.status != 200) {
|
||||
throw new Error(`[${response.status}] ${response.statusText}`);
|
||||
}
|
||||
|
||||
return response.body;
|
||||
}
|
||||
|
||||
async createShareLink(id, expirationDate, roleName) {
|
||||
const response = await this.socket.emitWithAck('create_share_link', id, expirationDate, roleName);
|
||||
|
||||
if (response.status != 200) {
|
||||
throw new Error(`[${response.status}] ${response.statusText}`);
|
||||
}
|
||||
|
||||
return response.body;
|
||||
}
|
||||
|
||||
async setIsPublic(id, newValue) {
|
||||
const response = await this.socket.emitWithAck('set_is_public', id, newValue);
|
||||
|
||||
if (response.status != 200) {
|
||||
throw new Error(`[${response.status}] ${response.statusText}`);
|
||||
}
|
||||
|
||||
return response.body;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user