mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 02:24:20 +00:00
bug fixes
This commit is contained in:
parent
3e9d749574
commit
5df3c8be35
@ -16,10 +16,24 @@ class App {
|
||||
this.data.promises.getUser[userId] = new Promise((resolve, reject) => {
|
||||
fetch(`/users/${userId}?backrefs=true&relationships=true`, {headers: {Accept: 'application/json'}})
|
||||
.then(
|
||||
(response) => {return response.json();},
|
||||
(response) => {
|
||||
if (response.status === 403) {this.flash('Forbidden', 'error');}
|
||||
if (response.status === 404) {this.flash('Not Found', 'error');}
|
||||
switch (response.status) {
|
||||
case 403: {
|
||||
this.flash('Forbidden', 'error');
|
||||
break;
|
||||
}
|
||||
case 404: {
|
||||
this.flash('Not Found', 'error');
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
response.json();
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
(response) => {
|
||||
this.flash('Something went wrong', 'error');
|
||||
reject(response);
|
||||
}
|
||||
)
|
||||
|
@ -31,7 +31,7 @@ class SpaCyNLPPipelineModelList extends RessourceList {
|
||||
<td><b><span class="title"></span> <span class="version"></span></b><br><i><span class="description"></span></i></td>
|
||||
<td><a class="publisher-url"><span class="publisher"></span></a> (<span class="publishing-year"></span>)<br><a class="publishing-url"><span class="publishing-url-2"></span></a></td>
|
||||
<td>
|
||||
<div class="switch action-switch center-align" data-action="share-request">
|
||||
<div class="switch action-switch center-align" data-action="share-request" data-user-role=>
|
||||
<span class="share"></span>
|
||||
<label>
|
||||
<input type="checkbox" class="shared">
|
||||
@ -86,6 +86,11 @@ class SpaCyNLPPipelineModelList extends RessourceList {
|
||||
|
||||
init (user) {
|
||||
this._init(user.spacy_nlp_pipeline_models);
|
||||
for (let switchElement of this.listjs.list.querySelectorAll('.shared')) {
|
||||
if (user.role.name !== 'Administrator' || user.role.name !== 'Contributor') {
|
||||
switchElement.setAttribute('disabled', '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_init(ressources) {
|
||||
|
@ -12,13 +12,27 @@ class Utils {
|
||||
fetch(`/corpora/${corpus.id}/build`, {method: 'POST', headers: {Accept: 'application/json'}})
|
||||
.then(
|
||||
(response) => {
|
||||
app.flash(`Corpus "${corpus.title}" marked for building`, 'corpus');
|
||||
resolve(response);
|
||||
switch(response.status) {
|
||||
case 403:
|
||||
app.flash('Forbidden', 'error');
|
||||
reject(response);
|
||||
break;
|
||||
case 404:
|
||||
app.flash('Not Found', 'error');
|
||||
reject(response);
|
||||
break;
|
||||
case 409:
|
||||
app.flash('Conflict', 'error');
|
||||
reject(response);
|
||||
break;
|
||||
default:
|
||||
app.flash(`Corpus "${corpus.title}" marked for building`, 'corpus');
|
||||
resolve(response);
|
||||
break;
|
||||
}
|
||||
},
|
||||
(response) => {
|
||||
if (response.status === 403) {app.flash('Forbidden', 'error');}
|
||||
if (response.status === 404) {app.flash('Not Found', 'error');}
|
||||
if (response.status === 409) {app.flash('Conflict', 'error');}
|
||||
app.flash('Something went wrong', 'error');
|
||||
reject(response);
|
||||
}
|
||||
);
|
||||
@ -61,12 +75,23 @@ class Utils {
|
||||
fetch(`/corpora/${corpus.id}`, {method: 'DELETE', headers: {Accept: 'application/json'}})
|
||||
.then(
|
||||
(response) => {
|
||||
app.flash(`Corpus "${corpusTitle}" marked for deletion`, 'corpus');
|
||||
resolve(response);
|
||||
switch(response.status) {
|
||||
case 403:
|
||||
app.flash('Forbidden', 'error');
|
||||
reject(response);
|
||||
break;
|
||||
case 404:
|
||||
app.flash('Not Found', 'error');
|
||||
reject(response);
|
||||
break;
|
||||
default:
|
||||
app.flash(`Corpus "${corpus.title}" marked for deletion`, 'corpus');
|
||||
resolve(response);
|
||||
break;
|
||||
}
|
||||
},
|
||||
(response) => {
|
||||
if (response.status === 403) {app.flash('Forbidden', 'error');}
|
||||
if (response.status === 404) {app.flash('Not Found', 'error');}
|
||||
app.flash('Something went wrong', 'error');
|
||||
reject(response);
|
||||
}
|
||||
);
|
||||
@ -112,12 +137,23 @@ class Utils {
|
||||
fetch(`/corpora/${corpusId}/files/${corpusFileId}`, {method: 'DELETE', headers: {Accept: 'application/json'}})
|
||||
.then(
|
||||
(response) => {
|
||||
app.flash(`Corpus file "${corpusFileTitle}" marked for deletion`, 'corpus');
|
||||
resolve(response);
|
||||
switch(response.status) {
|
||||
case 403:
|
||||
app.flash('Forbidden', 'error');
|
||||
reject(response);
|
||||
break;
|
||||
case 404:
|
||||
app.flash('Not Found', 'error');
|
||||
reject(response);
|
||||
break;
|
||||
default:
|
||||
app.flash(`Corpus file "${corpusFileTitle}" marked for deletion`, 'corpus');
|
||||
resolve(response);
|
||||
break;
|
||||
}
|
||||
},
|
||||
(response) => {
|
||||
if (response.status === 403) {app.flash('Forbidden', 'error');}
|
||||
if (response.status === 404) {app.flash('Not Found', 'error');}
|
||||
app.flash('Something went wrong', 'error');
|
||||
reject(response);
|
||||
}
|
||||
);
|
||||
@ -160,12 +196,23 @@ class Utils {
|
||||
fetch(`/contributions/spacy-nlp-pipeline-models/${spaCyNLPPipelineModelId}`, {method: 'DELETE'})
|
||||
.then(
|
||||
(response) => {
|
||||
app.flash(`SpaCy NLP Pipeline Model "${spaCyNLPPipelineModelTitle}" marked for deletion`);
|
||||
resolve(response);
|
||||
switch(response.status) {
|
||||
case 403:
|
||||
app.flash('Forbidden', 'error');
|
||||
reject(response);
|
||||
break;
|
||||
case 404:
|
||||
app.flash('Not Found', 'error');
|
||||
reject(response);
|
||||
break;
|
||||
default:
|
||||
app.flash(`SpaCy NLP Pipeline Model "${spaCyNLPPipelineModelTitle}" marked for deletion`);
|
||||
resolve(response);
|
||||
break;
|
||||
}
|
||||
},
|
||||
(response) => {
|
||||
if (response.status === 403) {app.flash('Forbidden', 'error');}
|
||||
if (response.status === 404) {app.flash('Not Found', 'error');}
|
||||
app.flash('Something went wrong', 'error');
|
||||
reject(response);
|
||||
}
|
||||
);
|
||||
@ -208,12 +255,24 @@ class Utils {
|
||||
fetch(`/contributions/tesseract-ocr-pipeline-models/${tesseractOCRPipelineModelId}`, {method: 'DELETE'})
|
||||
.then(
|
||||
(response) => {
|
||||
app.flash(`Tesseract OCR Pipeline Model "${tesseractOCRPipelineModelTitle}" marked for deletion`);
|
||||
resolve(response);
|
||||
switch(response.status) {
|
||||
case 403:
|
||||
app.flash('Forbidden', 'error');
|
||||
reject(response);
|
||||
break;
|
||||
case 404:
|
||||
app.flash('Not Found', 'error');
|
||||
reject(response);
|
||||
break;
|
||||
default:
|
||||
app.flash(`Tesseract OCR Pipeline Model "${tesseractOCRPipelineModelTitle}" marked for deletion`);
|
||||
resolve(response);
|
||||
break;
|
||||
}
|
||||
|
||||
},
|
||||
(response) => {
|
||||
if (response.status === 403) {app.flash('Forbidden', 'error');}
|
||||
if (response.status === 404) {app.flash('Not Found', 'error');}
|
||||
app.flash('Something went wrong', 'error');
|
||||
reject(response);
|
||||
}
|
||||
);
|
||||
@ -258,12 +317,23 @@ class Utils {
|
||||
fetch(`/jobs/${job.id}`, {method: 'DELETE', headers: {Accept: 'application/json'}})
|
||||
.then(
|
||||
(response) => {
|
||||
app.flash(`Job "${jobTitle}" marked for deletion`, 'job');
|
||||
resolve(response);
|
||||
switch(response.status) {
|
||||
case 403:
|
||||
app.flash('Forbidden', 'error');
|
||||
reject(response);
|
||||
break;
|
||||
case 404:
|
||||
app.flash('Not Found', 'error');
|
||||
reject(response);
|
||||
break;
|
||||
default:
|
||||
app.flash(`Job "${jobTitle}" marked for deletion`, 'job');
|
||||
resolve(response);
|
||||
break;
|
||||
}
|
||||
},
|
||||
(response) => {
|
||||
if (response.status === 403) {app.flash('Forbidden', 'error');}
|
||||
if (response.status === 404) {app.flash('Not Found', 'error');}
|
||||
app.flash('Something went wrong', 'error');
|
||||
reject(response);
|
||||
}
|
||||
);
|
||||
@ -279,12 +349,23 @@ class Utils {
|
||||
fetch(`/jobs/${job.id}/log`, {method: 'GET', headers: {Accept: 'application/json, text/plain'}})
|
||||
.then(
|
||||
(response) => {
|
||||
resolve(response);
|
||||
return response.text();
|
||||
switch(response.status) {
|
||||
case 403:
|
||||
app.flash('Forbidden', 'error');
|
||||
reject(response);
|
||||
break;
|
||||
case 404:
|
||||
app.flash('Not Found', 'error');
|
||||
reject(response);
|
||||
break;
|
||||
default:
|
||||
resolve(response);
|
||||
response.text();
|
||||
break;
|
||||
}
|
||||
},
|
||||
(response) => {
|
||||
if (response.status === 403) {app.flash('Forbidden', 'error');}
|
||||
if (response.status === 404) {app.flash('Not Found', 'error');}
|
||||
app.flash('Something went wrong', 'error');
|
||||
reject(response);
|
||||
}
|
||||
)
|
||||
@ -355,13 +436,26 @@ class Utils {
|
||||
fetch(`/jobs/${job.id}/restart`, {method: 'POST', headers: {Accept: 'application/json'}})
|
||||
.then(
|
||||
(response) => {
|
||||
app.flash(`Job "${jobTitle}" restarted.`, 'job');
|
||||
resolve(response);
|
||||
switch(response.status) {
|
||||
case 403:
|
||||
app.flash('Forbidden', 'error');
|
||||
reject(response);
|
||||
break;
|
||||
case 404:
|
||||
app.flash('Not Found', 'error');
|
||||
reject(response);
|
||||
break;
|
||||
case 409:
|
||||
app.flash('Conflict', 'error');
|
||||
reject(response);
|
||||
default:
|
||||
app.flash(`Job "${jobTitle}" restarted.`, 'job');
|
||||
resolve(response);
|
||||
break;
|
||||
}
|
||||
},
|
||||
(response) => {
|
||||
if (response.status === 403) {app.flash('Forbidden', 'error');}
|
||||
if (response.status === 404) {app.flash('Not Found', 'error');}
|
||||
if (response.status === 409) {app.flash('Conflict', 'error');}
|
||||
app.flash('Something went wrong', 'error');
|
||||
reject(response);
|
||||
}
|
||||
);
|
||||
@ -406,12 +500,24 @@ class Utils {
|
||||
fetch(`/users/${user.id}`, {method: 'DELETE', headers: {Accept: 'application/json'}})
|
||||
.then(
|
||||
(response) => {
|
||||
app.flash(`User "${userName}" marked for deletion`);
|
||||
resolve(response);
|
||||
switch(response.status) {
|
||||
case 403:
|
||||
app.flash('Forbidden', 'error');
|
||||
reject(response);
|
||||
break;
|
||||
case 404:
|
||||
app.flash('Not Found', 'error');
|
||||
reject(response);
|
||||
break;
|
||||
default:
|
||||
app.flash(`User "${userName}" marked for deletion`);
|
||||
resolve(response);
|
||||
break;
|
||||
}
|
||||
|
||||
},
|
||||
(response) => {
|
||||
if (response.status === 403) {app.flash('Forbidden', 'error');}
|
||||
if (response.status === 404) {app.flash('Not Found', 'error');}
|
||||
app.flash('Something went wrong', 'error');
|
||||
reject(response);
|
||||
}
|
||||
);
|
||||
@ -432,11 +538,19 @@ class Utils {
|
||||
fetch(`/contributions/tesseract-ocr-pipeline-models/${tesseractOCRPipelineModel.id}/toggle-public-status`, {method: 'POST', headers: {Accept: 'application/json'}})
|
||||
.then(
|
||||
(response) => {
|
||||
app.flash(msg, 'corpus');
|
||||
resolve(response);
|
||||
switch(response.status) {
|
||||
case 403:
|
||||
app.flash('Forbidden', 'error');
|
||||
reject(response);
|
||||
break;
|
||||
default:
|
||||
app.flash(msg, 'corpus');
|
||||
resolve(response);
|
||||
break;
|
||||
}
|
||||
},
|
||||
(response) => {
|
||||
if (response.status === 403) {app.flash('Forbidden', 'error');}
|
||||
app.flash('Something went wrong', 'error');
|
||||
reject(response);
|
||||
}
|
||||
);
|
||||
@ -455,11 +569,19 @@ class Utils {
|
||||
fetch(`/contributions/spacy-nlp-pipeline-models/${spaCyNLPPipelineModel.id}/toggle-public-status`, {method: 'POST', headers: {Accept: 'application/json'}})
|
||||
.then(
|
||||
(response) => {
|
||||
app.flash(msg, 'corpus');
|
||||
resolve(response);
|
||||
switch(response.status) {
|
||||
case 403:
|
||||
app.flash('Forbidden', 'error');
|
||||
reject(response);
|
||||
break;
|
||||
default:
|
||||
app.flash(msg, 'corpus');
|
||||
resolve(response);
|
||||
break;
|
||||
}
|
||||
},
|
||||
(response) => {
|
||||
if (response.status === 403) {app.flash('Forbidden', 'error');}
|
||||
app.flash('Something went wrong', 'error');
|
||||
reject(response);
|
||||
}
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user