mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-04 12:22:47 +00:00 
			
		
		
		
	Move jobs namespace back to http routes
This commit is contained in:
		@@ -1,4 +1,4 @@
 | 
			
		||||
nopaque.App = class App {
 | 
			
		||||
nopaque.app.Client = class Client {
 | 
			
		||||
  constructor() {
 | 
			
		||||
    this.socket = io({transports: ['websocket'], upgrade: false});
 | 
			
		||||
 | 
			
		||||
@@ -1,37 +1,47 @@
 | 
			
		||||
nopaque.app.endpoints.Jobs = class Jobs {
 | 
			
		||||
  constructor(app) {
 | 
			
		||||
    this.app = app;
 | 
			
		||||
  async delete(jobId) {
 | 
			
		||||
    const options = {
 | 
			
		||||
      headers: {
 | 
			
		||||
        Accept: 'application/json'
 | 
			
		||||
      },
 | 
			
		||||
      method: 'DELETE'
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    this.socket = io('/jobs', {transports: ['websocket'], upgrade: false});
 | 
			
		||||
    const response = await fetch(`/jobs/${jobId}`, options);
 | 
			
		||||
    const data = await response.json();
 | 
			
		||||
 | 
			
		||||
    if (!response.ok) {throw new Error(`${data.name}: ${data.description}`);}
 | 
			
		||||
 | 
			
		||||
    return data;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async delete(id) {
 | 
			
		||||
    const response = await this.socket.emitWithAck('delete', id);
 | 
			
		||||
  async log(jobId) {
 | 
			
		||||
    const options = {
 | 
			
		||||
      headers: {
 | 
			
		||||
        Accept: 'application/json'
 | 
			
		||||
      }
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    if (response.status != 202) {
 | 
			
		||||
      throw new Error(`[${response.status}] ${response.statusText}`);
 | 
			
		||||
    }
 | 
			
		||||
    const response = await fetch(`/jobs/${jobId}/log`, options);
 | 
			
		||||
    const data = await response.json();
 | 
			
		||||
 | 
			
		||||
    return response.body;
 | 
			
		||||
    if (!response.ok) {throw new Error(`${data.name}: ${data.description}`);}
 | 
			
		||||
 | 
			
		||||
    return data;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async log(id) {
 | 
			
		||||
    const response = await this.socket.emitWithAck('log', id);
 | 
			
		||||
  async restart(jobId) {
 | 
			
		||||
    const options = {
 | 
			
		||||
      headers: {
 | 
			
		||||
        Accept: 'application/json'
 | 
			
		||||
      }
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    if (response.status != 200) {
 | 
			
		||||
      throw new Error(`[${response.status}] ${response.statusText}`);
 | 
			
		||||
    }
 | 
			
		||||
    const response = await fetch(`/jobs/${jobId}/restart`, options);
 | 
			
		||||
    const data = await response.json();
 | 
			
		||||
 | 
			
		||||
    return response.body;
 | 
			
		||||
  }
 | 
			
		||||
    if (!response.ok) {throw new Error(`${data.name}: ${data.description}`);}
 | 
			
		||||
 | 
			
		||||
  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;
 | 
			
		||||
    return data;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user