mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-04 04:12:45 +00:00 
			
		
		
		
	Restructure corpora blueprint
This commit is contained in:
		@@ -5,53 +5,89 @@ nopaque.app.endpoints.Corpora = class Corpora {
 | 
			
		||||
    this.socket = io('/corpora', {transports: ['websocket'], upgrade: false});
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async delete(id) {
 | 
			
		||||
    const response = await this.socket.emitWithAck('delete', id);
 | 
			
		||||
  async delete(corpusId) {
 | 
			
		||||
    const options = {
 | 
			
		||||
      headers: {
 | 
			
		||||
        Accept: 'application/json'
 | 
			
		||||
      },
 | 
			
		||||
      method: 'DELETE'
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    if (response.status != 202) {
 | 
			
		||||
      throw new Error(`[${response.status}] ${response.statusText}`);
 | 
			
		||||
    }
 | 
			
		||||
    const response = await fetch(`/corpora/${corpusId}`, options);
 | 
			
		||||
    const data = await response.json();
 | 
			
		||||
 | 
			
		||||
    return response.body;
 | 
			
		||||
    if (!response.ok) {throw new Error(`${data.name}: ${data.description}`);}
 | 
			
		||||
 | 
			
		||||
    return data;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async build(id) {
 | 
			
		||||
    const response = await this.socket.emitWithAck('build', id);
 | 
			
		||||
  async build(corpusId) {
 | 
			
		||||
    const options = {
 | 
			
		||||
      headers: {
 | 
			
		||||
        Accept: 'application/json'
 | 
			
		||||
      },
 | 
			
		||||
      method: 'POST'
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    if (response.status != 202) {
 | 
			
		||||
      throw new Error(`[${response.status}] ${response.statusText}`);
 | 
			
		||||
    }
 | 
			
		||||
    const response = await fetch(`/corpora/${corpusId}/build`, options);
 | 
			
		||||
    const data = await response.json();
 | 
			
		||||
 | 
			
		||||
    return response.body;
 | 
			
		||||
    if (!response.ok) {throw new Error(`${data.name}: ${data.description}`);}
 | 
			
		||||
 | 
			
		||||
    return data;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async getStopwords() {
 | 
			
		||||
    const response = await this.socket.emitWithAck('get_stopwords');
 | 
			
		||||
  async getStopwords(corpusId) {
 | 
			
		||||
    const options = {
 | 
			
		||||
      headers: {
 | 
			
		||||
        Accept: 'application/json'
 | 
			
		||||
      }
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    if (response.status != 200) {
 | 
			
		||||
      throw new Error(`[${response.status}] ${response.statusText}`);
 | 
			
		||||
    }
 | 
			
		||||
    const response = await fetch(`/corpora/${corpusId}/analysis/stopwords`, options);
 | 
			
		||||
    const data = await response.json();
 | 
			
		||||
 | 
			
		||||
    return response.body;
 | 
			
		||||
    if (!response.ok) {throw new Error(`${data.name}: ${data.description}`);}
 | 
			
		||||
 | 
			
		||||
    return data;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async createShareLink(id, expirationDate, roleName) {
 | 
			
		||||
    const response = await this.socket.emitWithAck('create_share_link', id, expirationDate, roleName);
 | 
			
		||||
  async createShareLink(corpusId, expirationDate, roleName) {
 | 
			
		||||
    const options = {
 | 
			
		||||
      body: JSON.stringify({
 | 
			
		||||
        'expiration_date': expirationDate,
 | 
			
		||||
        'role_name': roleName
 | 
			
		||||
      }),
 | 
			
		||||
      headers: {
 | 
			
		||||
        Accept: 'application/json',
 | 
			
		||||
        'Content-Type': 'application/json'
 | 
			
		||||
      },
 | 
			
		||||
      method: 'POST'
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    if (response.status != 200) {
 | 
			
		||||
      throw new Error(`[${response.status}] ${response.statusText}`);
 | 
			
		||||
    }
 | 
			
		||||
    const response = await fetch(`/corpora/${corpusId}/create-share-link`, options);
 | 
			
		||||
    const data = await response.json();
 | 
			
		||||
 | 
			
		||||
    return response.body;
 | 
			
		||||
    if (!response.ok) {throw new Error(`${data.name}: ${data.description}`);}
 | 
			
		||||
 | 
			
		||||
    return data;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async setIsPublic(id, newValue) {
 | 
			
		||||
    const response = await this.socket.emitWithAck('set_is_public', id, newValue);
 | 
			
		||||
  async updateIsPublic(corpusId, newValue) {
 | 
			
		||||
    const options = {
 | 
			
		||||
      body: JSON.stringify(newValue),
 | 
			
		||||
      headers: {
 | 
			
		||||
        Accept: 'application/json',
 | 
			
		||||
        'Content-Type': 'application/json'
 | 
			
		||||
      },
 | 
			
		||||
      method: 'PUT',
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    if (response.status != 200) {
 | 
			
		||||
      throw new Error(`[${response.status}] ${response.statusText}`);
 | 
			
		||||
    }
 | 
			
		||||
    const response = await fetch(`/corpora/${corpusId}/is-public`, options);
 | 
			
		||||
    const data = await response.json();
 | 
			
		||||
 | 
			
		||||
    return response.body;
 | 
			
		||||
    if (!response.ok) {throw new Error(`${data.name}: ${data.description}`);}
 | 
			
		||||
 | 
			
		||||
    return data;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -73,7 +73,7 @@ nopaque.corpus_analysis.StaticVisualizationExtension = class StaticVisualization
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async getStopwords() {
 | 
			
		||||
    const stopwords = await app.corpora.getStopwords();
 | 
			
		||||
    const stopwords = await app.corpora.getStopwords(this.app.corpusId);
 | 
			
		||||
    this.data.originalStopwords = structuredClone(stopwords);
 | 
			
		||||
    this.data.stopwords = structuredClone(stopwords);
 | 
			
		||||
    return stopwords;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user