share link generator update

This commit is contained in:
Inga Kirschnick
2023-02-21 16:18:04 +01:00
parent 5837e05024
commit 726e781692
3 changed files with 120 additions and 49 deletions

View File

@ -751,4 +751,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);
}
);
});
}
}