rename Requests namespace to requests

This commit is contained in:
Patrick Jentsch 2023-10-04 14:07:39 +02:00
parent f36600f06c
commit 53f4400731
15 changed files with 39 additions and 38 deletions

View File

@ -75,7 +75,7 @@ class CorpusAnalysisStaticVisualization {
getStopwords() {
this.data.promises.getStopwords = new Promise((resolve, reject) => {
Requests.corpora.entity.getStopwords()
requests.corpora.entity.getStopwords()
.then((response) => {
response.json()
.then((json) => {

View File

@ -5,7 +5,7 @@ class CorpusDisplay extends ResourceDisplay {
this.displayElement
.querySelector('.action-button[data-action="build-request"]')
.addEventListener('click', (event) => {
Requests.corpora.entity.build(this.corpusId);
requests.corpora.entity.build(this.corpusId);
});
}

View File

@ -91,7 +91,7 @@ class AdminUserList extends ResourceList {
let listAction = listActionElement === null ? 'view' : listActionElement.dataset.listAction;
switch (listAction) {
case 'delete': {
Requests.users.entity.delete(itemId);
requests.users.entity.delete(itemId);
if (itemId === currentUserId) {window.location.href = '/';}
break;
}

View File

@ -153,12 +153,12 @@ class CorpusFileList extends ResourceList {
let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]');
confirmElement.addEventListener('click', (event) => {
if (currentUserId != this.userId) {
Requests.corpora.entity.files.ent.delete(this.corpusId, itemId)
requests.corpora.entity.files.ent.delete(this.corpusId, itemId)
.then(() => {
window.location.reload();
});
} else {
Requests.corpora.entity.files.ent.delete(this.corpusId, itemId)
requests.corpora.entity.files.ent.delete(this.corpusId, itemId)
}
});
modal.open();
@ -250,12 +250,12 @@ class CorpusFileList extends ResourceList {
confirmElement.addEventListener('click', (event) => {
this.selectedItemIds.forEach(selectedItemId => {
if (currentUserId != this.userId) {
Requests.corpora.entity.files.ent.delete(this.corpusId, selectedItemId)
requests.corpora.entity.files.ent.delete(this.corpusId, selectedItemId)
.then(() => {
window.location.reload();
});
} else {
Requests.corpora.entity.files.ent.delete(this.corpusId, selectedItemId);
requests.corpora.entity.files.ent.delete(this.corpusId, selectedItemId);
}
});
this.selectedItemIds.clear();

View File

@ -124,7 +124,7 @@ class CorpusFollowerList extends ResourceList {
case 'update-role': {
let followerId = listItemElement.dataset.followerId;
let roleName = event.target.value;
Requests.corpora.entity.followers.entity.role.update(this.corpusId, followerId, roleName);
requests.corpora.entity.followers.entity.role.update(this.corpusId, followerId, roleName);
break;
}
default: {
@ -144,12 +144,12 @@ class CorpusFollowerList extends ResourceList {
case 'unfollow-request': {
let followerId = listItemElement.dataset.followerId;
if (currentUserId != this.userId) {
Requests.corpora.entity.followers.entity.delete(this.corpusId, followerId)
requests.corpora.entity.followers.entity.delete(this.corpusId, followerId)
.then(() => {
window.location.reload();
});
} else {
Requests.corpora.entity.followers.entity.delete(this.corpusId, followerId);
requests.corpora.entity.followers.entity.delete(this.corpusId, followerId);
}
break;
}

View File

@ -171,12 +171,12 @@ class CorpusList extends ResourceList {
let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]');
confirmElement.addEventListener('click', (event) => {
if (!values['is-owner']) {
Requests.corpora.entity.followers.entity.delete(itemId, currentUserId)
requests.corpora.entity.followers.entity.delete(itemId, currentUserId)
.then((response) => {
window.location.reload();
});
} else {
Requests.corpora.entity.delete(itemId);
requests.corpora.entity.delete(itemId);
}
});
modal.open();
@ -272,9 +272,9 @@ class CorpusList extends ResourceList {
let listItem = this.listjs.get('id', selectedItemId)[0].elm;
let values = this.listjs.get('id', listItem.dataset.id)[0].values();
if (values['is-owner']) {
Requests.corpora.entity.delete(selectedItemId);
requests.corpora.entity.delete(selectedItemId);
} else {
Requests.corpora.entity.followers.entity.delete(selectedItemId, currentUserId);
requests.corpora.entity.followers.entity.delete(selectedItemId, currentUserId);
setTimeout(() => {
window.location.reload();
}, 1000);

View File

@ -143,7 +143,7 @@ class JobList extends ResourceList {
);
let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]');
confirmElement.addEventListener('click', (event) => {
Requests.jobs.entity.delete(itemId);
requests.jobs.entity.delete(itemId);
});
modal.open();
break;
@ -228,7 +228,7 @@ class JobList extends ResourceList {
let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]');
confirmElement.addEventListener('click', (event) => {
this.selectedItemIds.forEach(selectedItemId => {
Requests.jobs.entity.delete(selectedItemId);
requests.jobs.entity.delete(selectedItemId);
});
this.selectedItemIds.clear();
this.renderingItemSelection();

View File

@ -120,7 +120,7 @@ class SpaCyNLPPipelineModelList extends ResourceList {
switch (listAction) {
case 'toggle-is-public': {
let newIsPublicValue = listActionElement.checked;
Requests.contributions.spacy_nlp_pipeline_models.entity.isPublic.update(itemId, newIsPublicValue)
requests.contributions.spacy_nlp_pipeline_models.entity.isPublic.update(itemId, newIsPublicValue)
.catch((response) => {
listActionElement.checked = !newIsPublicValue;
});
@ -169,7 +169,7 @@ class SpaCyNLPPipelineModelList extends ResourceList {
);
let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]');
confirmElement.addEventListener('click', (event) => {
Requests.contributions.spacy_nlp_pipeline_models.entity.delete(itemId);
requests.contributions.spacy_nlp_pipeline_models.entity.delete(itemId);
});
modal.open();
break;

View File

@ -129,7 +129,7 @@ class TesseractOCRPipelineModelList extends ResourceList {
switch (listAction) {
case 'toggle-is-public': {
let newIsPublicValue = listActionElement.checked;
Requests.contributions.tesseract_ocr_pipeline_models.entity.isPublic.update(itemId, newIsPublicValue)
requests.contributions.tesseract_ocr_pipeline_models.entity.isPublic.update(itemId, newIsPublicValue)
.catch((response) => {
listActionElement.checked = !newIsPublicValue;
});
@ -178,7 +178,7 @@ class TesseractOCRPipelineModelList extends ResourceList {
);
let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]');
confirmElement.addEventListener('click', (event) => {
Requests.contributions.tesseract_ocr_pipeline_models.entity.delete(itemId);
requests.contributions.tesseract_ocr_pipeline_models.entity.delete(itemId);
});
modal.open();
break;

View File

@ -105,6 +105,7 @@
{%- endassets %}
<script>
// TODO: Implement an app.run method and use this for all of the following
const app = new App();
{%- if current_user.is_authenticated %}
const currentUserId = {{ current_user.hashid|tojson }};
@ -169,7 +170,7 @@
{
dismissible: false,
onCloseEnd: () => {
Requests.users.entity.acceptTermsOfUse();
requests.users.entity.acceptTermsOfUse();
}
}
);

View File

@ -57,7 +57,7 @@
let userConfirmedSwitchElement = document.querySelector('#user-confirmed-switch');
userConfirmedSwitchElement.addEventListener('change', (event) => {
let newConfirmed = userConfirmedSwitchElement.checked;
Requests.admin.users.entity.confirmed.update({{ user.hashid|tojson }}, newConfirmed)
requests.admin.users.entity.confirmed.update({{ user.hashid|tojson }}, newConfirmed)
.catch((response) => {
userConfirmedSwitchElement.checked = !userConfirmedSwitchElement;
});

View File

@ -242,7 +242,7 @@ let corpusDisplay = new CorpusDisplay(document.querySelector('#corpus-display'))
{# {% if current_user.is_following_corpus(corpus) %}
let unfollowRequestElement = document.querySelector('.action-button[data-action="unfollow-request"]');
unfollowRequestElement.addEventListener('click', () => {
Requests.corpora.entity.followers.entity.delete({{ corpus.hashid|tojson }}, {{ current_user.hashid|tojson }})
requests.corpora.entity.followers.entity.delete({{ corpus.hashid|tojson }}, {{ current_user.hashid|tojson }})
.then((response) => {
window.location.reload();
});
@ -254,7 +254,7 @@ let corpusDisplay = new CorpusDisplay(document.querySelector('#corpus-display'))
{# let publishingModalIsPublicSwitchElement = document.querySelector('#publishing-modal-is-public-switch');
publishingModalIsPublicSwitchElement.addEventListener('change', (event) => {
let newIsPublic = publishingModalIsPublicSwitchElement.checked;
Requests.corpora.entity.isPublic.update({{ corpus.hashid|tojson }}, newIsPublic)
requests.corpora.entity.isPublic.update({{ corpus.hashid|tojson }}, newIsPublic)
.catch((response) => {
publishingModalIsPublicSwitchElement.checked = !newIsPublic;
});
@ -264,7 +264,7 @@ publishingModalIsPublicSwitchElement.addEventListener('change', (event) => {
// #region Delete
let deleteModalDeleteButtonElement = document.querySelector('#delete-modal-delete-button');
deleteModalDeleteButtonElement.addEventListener('click', (event) => {
Requests.corpora.entity.delete({{ corpus.hashid|tojson }})
requests.corpora.entity.delete({{ corpus.hashid|tojson }})
.then((response) => {
window.location.href = {{ url_for('main.dashboard')|tojson }};
});
@ -314,7 +314,7 @@ M.Modal.init(
inviteUserModalInviteButtonElement.addEventListener('click', (event) => {
let usernames = inviteUserModalSearch.chipsData.map((chipData) => chipData.tag);
Requests.corpora.entity.followers.add({{ corpus.hashid|tojson }}, usernames);
requests.corpora.entity.followers.add({{ corpus.hashid|tojson }}, usernames);
});
// #endregion Invite user
@ -359,7 +359,7 @@ M.Modal.init(
shareLinkModalCreateButtonElement.addEventListener('click', (event) => {
let role = shareLinkModalCorpusFollowerRoleSelectElement.value;
let expiration = shareLinkModalExpirationDateDatepickerElement.value
Requests.corpora.entity.generateShareLink({{ corpus.hashid|tojson }}, role, expiration)
requests.corpora.entity.generateShareLink({{ corpus.hashid|tojson }}, role, expiration)
.then((response) => {
response.json()
.then((json) => {

View File

@ -273,7 +273,7 @@ publicCorpusFollowerList.add(
{% if cfr.has_permission('MANAGE_FILES') %}
let followerBuildRequest = document.querySelector('#follower-build-request');
followerBuildRequest.addEventListener('click', () => {
Requests.corpora.entity.build({{ corpus.hashid|tojson }})
requests.corpora.entity.build({{ corpus.hashid|tojson }})
.then((response) => {
window.location.reload();
});
@ -285,7 +285,7 @@ followerBuildRequest.addEventListener('click', () => {
{% if current_user.is_following_corpus(corpus) %}
let unfollowRequestElement = document.querySelector('.action-button[data-action="unfollow-request"]');
unfollowRequestElement.addEventListener('click', () => {
Requests.corpora.entity.followers.entity.delete({{ corpus.hashid|tojson }}, {{ current_user.hashid|tojson }})
requests.corpora.entity.followers.entity.delete({{ corpus.hashid|tojson }}, {{ current_user.hashid|tojson }})
.then((response) => {
window.location.reload();
});
@ -335,7 +335,7 @@ M.Modal.init(
inviteUserModalInviteButtonElement.addEventListener('click', (event) => {
let usernames = inviteUserModalSearch.chipsData.map((chipData) => chipData.tag);
Requests.corpora.entity.followers.add({{ corpus.hashid|tojson }}, usernames)
requests.corpora.entity.followers.add({{ corpus.hashid|tojson }}, usernames)
.then((response) => {
window.location.reload();
});
@ -383,7 +383,7 @@ M.Modal.init(
shareLinkModalCreateButtonElement.addEventListener('click', (event) => {
let role = shareLinkModalCorpusFollowerRoleSelectElement.value;
let expiration = shareLinkModalExpirationDateDatepickerElement.value
Requests.corpora.entity.generateShareLink({{ corpus.hashid|tojson }}, role, expiration)
requests.corpora.entity.generateShareLink({{ corpus.hashid|tojson }}, role, expiration)
.then((response) => {
response.json()
.then((json) => {

View File

@ -154,16 +154,16 @@
let deleteJobRequestElement = document.querySelector('#delete-job-request');
let restartJobRequestElement = document.querySelector('#restart-job-request');
deleteJobRequestElement.addEventListener('click', (event) => {
Requests.jobs.entity.delete({{ job.hashid|tojson }});
requests.jobs.entity.delete({{ job.hashid|tojson }});
});
restartJobRequestElement.addEventListener('click', (event) => {
Requests.jobs.entity.restart({{ job.hashid|tojson }});
requests.jobs.entity.restart({{ job.hashid|tojson }});
});
if ({{ current_user.is_administrator()|tojson }}) {
let jobLogButtonElement = document.querySelector('#job-log-button');
jobLogButtonElement.addEventListener('click', (event) => {
Requests.jobs.entity.log({{ job.hashid|tojson }})
requests.jobs.entity.log({{ job.hashid|tojson }})
.then(
(response) => {
response.json()

View File

@ -221,7 +221,7 @@ avatarUploadElement.addEventListener('change', () => {
});
document.querySelector('#delete-avatar').addEventListener('click', () => {
Requests.users.entity.avatar.delete({{ user.hashid|tojson }})
requests.users.entity.avatar.delete({{ user.hashid|tojson }})
.then(
(response) => {
avatarPreviewElement.src = {{ url_for('static', filename='images/user_avatar.png')|tojson }};
@ -230,7 +230,7 @@ document.querySelector('#delete-avatar').addEventListener('click', () => {
}); #}
document.querySelector('#delete-user').addEventListener('click', (event) => {
Requests.users.entity.delete({{ user.hashid|tojson }})
requests.users.entity.delete({{ user.hashid|tojson }})
.then((response) => {window.location.href = '/';});
});
@ -255,7 +255,7 @@ for (let collapsibleElement of document.querySelectorAll('.collapsible.no-autoin
let profilePrivacySettingCheckboxElements = document.querySelectorAll('.profile-privacy-setting-checkbox');
profileIsPublicSwitchElement.addEventListener('change', (event) => {
let newEnabled = profileIsPublicSwitchElement.checked;
Requests.users.entity.settings.profilePrivacy.update({{ user.hashid|tojson }}, 'is-public', newEnabled)
requests.users.entity.settings.profilePrivacy.update({{ user.hashid|tojson }}, 'is-public', newEnabled)
.then(
(response) => {
for (let profilePrivacySettingCheckboxElement of document.querySelectorAll('.profile-privacy-setting-checkbox')) {
@ -271,7 +271,7 @@ for (let profilePrivacySettingCheckboxElement of profilePrivacySettingCheckboxEl
profilePrivacySettingCheckboxElement.addEventListener('change', (event) => {
let newEnabled = profilePrivacySettingCheckboxElement.checked;
let valueName = profilePrivacySettingCheckboxElement.dataset.profilePrivacySettingName;
Requests.users.entity.settings.profilePrivacy.update({{ user.hashid|tojson }}, valueName, newEnabled)
requests.users.entity.settings.profilePrivacy.update({{ user.hashid|tojson }}, valueName, newEnabled)
.catch((response) => {
profilePrivacySettingCheckboxElement.checked = !newEnabled;
});