mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-04-11 19:51:06 +00:00
38 lines
852 B
JavaScript
38 lines
852 B
JavaScript
nopaque.app.endpoints.Jobs = class Jobs {
|
|
constructor(app) {
|
|
this.app = app;
|
|
|
|
this.socket = io('/jobs', {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 log(id) {
|
|
const response = await this.socket.emitWithAck('log', id);
|
|
|
|
if (response.status != 200) {
|
|
throw new Error(`[${response.status}] ${response.statusText}`);
|
|
}
|
|
|
|
return response.body;
|
|
}
|
|
|
|
async restart(id) {
|
|
const response = await this.socket.emitWithAck('restart', id);
|
|
|
|
if (response.status != 202) {
|
|
throw new Error(`[${response.status}] ${response.statusText}`);
|
|
}
|
|
|
|
return response.body;
|
|
}
|
|
}
|