Implement corpora endpoint/socket.io namespace

This commit is contained in:
Patrick Jentsch
2024-12-09 16:12:49 +01:00
parent 93344c9573
commit 328f85ba52
16 changed files with 339 additions and 182 deletions

View File

@ -11,6 +11,7 @@
'js/app.js',
'js/app/index.js',
'js/app/endpoints/index.js',
'js/app/endpoints/corpora.js',
'js/app/endpoints/jobs.js',
'js/app/endpoints/users.js',
'js/app/extensions/index.js',
@ -51,7 +52,6 @@
'js/requests/admin.js',
'js/requests/contributions.js',
'js/requests/corpora.js',
'js/requests/jobs.js',
'js/requests/users.js',
'js/corpus-analysis/index.js',

View File

@ -246,7 +246,7 @@
let publishingModalIsPublicSwitchElement = document.querySelector('#publishing-modal-is-public-switch');
publishingModalIsPublicSwitchElement.addEventListener('change', (event) => {
let newIsPublic = publishingModalIsPublicSwitchElement.checked;
nopaque.requests.corpora.entity.isPublic.update({{ corpus.hashid|tojson }}, newIsPublic)
app.corpora.setIsPublic.update({{ corpus.hashid|tojson }}, newIsPublic)
.catch((response) => {
publishingModalIsPublicSwitchElement.checked = !newIsPublic;
});
@ -256,7 +256,7 @@ publishingModalIsPublicSwitchElement.addEventListener('change', (event) => {
// #region Delete
let deleteModalDeleteButtonElement = document.querySelector('#delete-modal-delete-button');
deleteModalDeleteButtonElement.addEventListener('click', (event) => {
nopaque.requests.corpora.entity.delete({{ corpus.hashid|tojson }})
app.corpora.delete({{ corpus.hashid|tojson }})
.then((response) => {
window.location.href = {{ url_for('main.dashboard')|tojson }};
});
@ -346,19 +346,14 @@ M.Modal.init(
shareLinkModalOutputContainerElement.classList.add('hide');
}
}
)
);
shareLinkModalCreateButtonElement.addEventListener('click', (event) => {
let role = shareLinkModalCorpusFollowerRoleSelectElement.value;
let expiration = shareLinkModalExpirationDateDatepickerElement.value
nopaque.requests.corpora.entity.generateShareLink({{ corpus.hashid|tojson }}, role, expiration)
.then((response) => {
response.json()
.then((json) => {
shareLinkModalOutputContainerElement.classList.remove('hide');
shareLinkModalOutputFieldElement.value = json.corpusShareLink;
});
});
shareLinkModalCreateButtonElement.addEventListener('click', async (event) => {
const role = shareLinkModalCorpusFollowerRoleSelectElement.value;
const expiration = shareLinkModalExpirationDateDatepickerElement.value;
const shareLink = await app.corpora.createShareLink({{ corpus.hashid|tojson }}, expiration, role);
shareLinkModalOutputContainerElement.classList.remove('hide');
shareLinkModalOutputFieldElement.value = shareLink;
});
shareLinkModalOutputCopyButtonElement.addEventListener('click', (event) => {

View File

@ -273,7 +273,7 @@ publicCorpusFollowerList.add(
{% if cfr.has_permission('MANAGE_FILES') %}
let followerBuildRequest = document.querySelector('#follower-build-request');
followerBuildRequest.addEventListener('click', () => {
nopaque.requests.corpora.entity.build({{ corpus.hashid|tojson }})
app.corpora.build({{ corpus.hashid|tojson }})
.then((response) => {
window.location.reload();
});
@ -380,17 +380,12 @@ M.Modal.init(
}
)
shareLinkModalCreateButtonElement.addEventListener('click', (event) => {
let role = shareLinkModalCorpusFollowerRoleSelectElement.value;
let expiration = shareLinkModalExpirationDateDatepickerElement.value
nopaque.requests.corpora.entity.generateShareLink({{ corpus.hashid|tojson }}, role, expiration)
.then((response) => {
response.json()
.then((json) => {
shareLinkModalOutputContainerElement.classList.remove('hide');
shareLinkModalOutputFieldElement.value = json.corpusShareLink;
});
});
shareLinkModalCreateButtonElement.addEventListener('click', async (event) => {
const roleName = shareLinkModalCorpusFollowerRoleSelectElement.value;
const expirationDate = shareLinkModalExpirationDateDatepickerElement.value;
const shareLink = await app.corpora.createShareLink({{ corpus.hashid|tojson }}, expiration, role);
shareLinkModalOutputContainerElement.classList.remove('hide');
shareLinkModalOutputFieldElement.value = shareLink;
});
shareLinkModalOutputCopyButtonElement.addEventListener('click', (event) => {