Merge branch 'public-corpus' of gitlab.ub.uni-bielefeld.de:sfb1288inf/nopaque into public-corpus

This commit is contained in:
Patrick Jentsch
2023-02-21 16:23:14 +01:00
3 changed files with 118 additions and 47 deletions

View File

@ -777,4 +777,34 @@ class Utils {
);
});
}
static generateCorpusShareLinkRequest(corpusId, permission, expiration) {
return new Promise((resolve, reject) => {
const data = {permission: permission, expiration: expiration};
fetch(`/corpora/${corpusId}/generate-corpus-share-link`, {method: 'POST', headers: {Accept: 'text/plain'}, body: JSON.stringify(data)})
.then(
(response) => {
if (!response.ok) {
app.flash(`Something went wrong: ${response.status} ${response.statusText}`, 'error');
reject(response);
return;
}
return response.text();
},
(response) => {
// Something went wrong during the HTTP request
app.flash('Something went wrong', 'error');
reject(response);
}
)
.then(
(corpusShareLink) => {resolve(corpusShareLink);},
(error) => {
// Something went wrong during ReadableStream processing
app.flash('Something went wrong', 'error');
reject(error);
}
);
});
}
}