From f566e276a1b65c4b895b07c160a245f5ccf75725 Mon Sep 17 00:00:00 2001
From: Patrick Jentsch
Date: Wed, 4 Oct 2023 12:32:27 +0200
Subject: [PATCH] use better js naming conventions
---
.../Requests/contributions/contributions.js | 5 -
.../spacy_nlp_pipeline_models.js | 26 -----
.../tesseract_ocr_pipeline_models.js | 26 -----
app/static/js/Requests/corpora/corpora.js | 53 ---------
app/static/js/Requests/corpora/files.js | 15 ---
app/static/js/Requests/corpora/followers.js | 35 ------
app/static/js/Requests/users/settings.js | 17 ---
.../js/cqi/api/{package.js => index.js} | 0
app/static/js/cqi/{package.js => index.js} | 0
.../js/cqi/models/{package.js => index.js} | 0
.../js/{Requests/admin => requests}/admin.js | 3 +-
app/static/js/requests/contributions.js | 58 ++++++++++
app/static/js/requests/corpora.js | 102 ++++++++++++++++++
.../Requests.js => requests/index.js} | 2 +-
.../js/{Requests/jobs => requests}/jobs.js | 3 +-
.../js/{Requests/users => requests}/users.js | 18 +++-
app/templates/_scripts.html.j2 | 60 ++++++-----
17 files changed, 211 insertions(+), 212 deletions(-)
delete mode 100644 app/static/js/Requests/contributions/contributions.js
delete mode 100644 app/static/js/Requests/contributions/spacy_nlp_pipeline_models.js
delete mode 100644 app/static/js/Requests/contributions/tesseract_ocr_pipeline_models.js
delete mode 100644 app/static/js/Requests/corpora/corpora.js
delete mode 100644 app/static/js/Requests/corpora/files.js
delete mode 100644 app/static/js/Requests/corpora/followers.js
delete mode 100644 app/static/js/Requests/users/settings.js
rename app/static/js/cqi/api/{package.js => index.js} (100%)
rename app/static/js/cqi/{package.js => index.js} (100%)
rename app/static/js/cqi/models/{package.js => index.js} (100%)
rename app/static/js/{Requests/admin => requests}/admin.js (78%)
create mode 100644 app/static/js/requests/contributions.js
create mode 100644 app/static/js/requests/corpora.js
rename app/static/js/{Requests/Requests.js => requests/index.js} (98%)
rename app/static/js/{Requests/jobs => requests}/jobs.js (83%)
rename app/static/js/{Requests/users => requests}/users.js (59%)
diff --git a/app/static/js/Requests/contributions/contributions.js b/app/static/js/Requests/contributions/contributions.js
deleted file mode 100644
index 2d9cf26a..00000000
--- a/app/static/js/Requests/contributions/contributions.js
+++ /dev/null
@@ -1,5 +0,0 @@
-/*****************************************************************************
-* Contributions *
-* Fetch requests for /contributions routes *
-*****************************************************************************/
-Requests.contributions = {};
diff --git a/app/static/js/Requests/contributions/spacy_nlp_pipeline_models.js b/app/static/js/Requests/contributions/spacy_nlp_pipeline_models.js
deleted file mode 100644
index e1422c1e..00000000
--- a/app/static/js/Requests/contributions/spacy_nlp_pipeline_models.js
+++ /dev/null
@@ -1,26 +0,0 @@
-/*****************************************************************************
-* SpaCy NLP Pipeline Models *
-* Fetch requests for /contributions/spacy-nlp-pipeline-models routes *
-*****************************************************************************/
-Requests.contributions.spacy_nlp_pipeline_models = {};
-
-Requests.contributions.spacy_nlp_pipeline_models.entity = {};
-
-Requests.contributions.spacy_nlp_pipeline_models.entity.delete = (spacyNlpPipelineModelId) => {
- let input = `/contributions/spacy-nlp-pipeline-models/${spacyNlpPipelineModelId}`;
- let init = {
- method: 'DELETE'
- };
- return Requests.JSONfetch(input, init);
-};
-
-Requests.contributions.spacy_nlp_pipeline_models.entity.isPublic = {};
-
-Requests.contributions.spacy_nlp_pipeline_models.entity.isPublic.update = (spacyNlpPipelineModelId, value) => {
- let input = `/contributions/spacy-nlp-pipeline-models/${spacyNlpPipelineModelId}/is_public`;
- let init = {
- method: 'PUT',
- body: JSON.stringify(value)
- };
- return Requests.JSONfetch(input, init);
-};
diff --git a/app/static/js/Requests/contributions/tesseract_ocr_pipeline_models.js b/app/static/js/Requests/contributions/tesseract_ocr_pipeline_models.js
deleted file mode 100644
index 13feb42a..00000000
--- a/app/static/js/Requests/contributions/tesseract_ocr_pipeline_models.js
+++ /dev/null
@@ -1,26 +0,0 @@
-/*****************************************************************************
-* Tesseract OCR Pipeline Models *
-* Fetch requests for /contributions/tesseract-ocr-pipeline-models routes *
-*****************************************************************************/
-Requests.contributions.tesseract_ocr_pipeline_models = {};
-
-Requests.contributions.tesseract_ocr_pipeline_models.entity = {};
-
-Requests.contributions.tesseract_ocr_pipeline_models.entity.delete = (tesseractOcrPipelineModelId) => {
- let input = `/contributions/tesseract-ocr-pipeline-models/${tesseractOcrPipelineModelId}`;
- let init = {
- method: 'DELETE'
- };
- return Requests.JSONfetch(input, init);
-};
-
-Requests.contributions.tesseract_ocr_pipeline_models.entity.isPublic = {};
-
-Requests.contributions.tesseract_ocr_pipeline_models.entity.isPublic.update = (tesseractOcrPipelineModelId, value) => {
- let input = `/contributions/tesseract-ocr-pipeline-models/${tesseractOcrPipelineModelId}/is_public`;
- let init = {
- method: 'PUT',
- body: JSON.stringify(value)
- };
- return Requests.JSONfetch(input, init);
-};
diff --git a/app/static/js/Requests/corpora/corpora.js b/app/static/js/Requests/corpora/corpora.js
deleted file mode 100644
index 3118a153..00000000
--- a/app/static/js/Requests/corpora/corpora.js
+++ /dev/null
@@ -1,53 +0,0 @@
-/*****************************************************************************
-* Corpora *
-* Fetch requests for /corpora routes *
-*****************************************************************************/
-Requests.corpora = {};
-
-Requests.corpora.entity = {};
-
-Requests.corpora.entity.delete = (corpusId) => {
- let input = `/corpora/${corpusId}`;
- let init = {
- method: 'DELETE'
- };
- return Requests.JSONfetch(input, init);
-};
-
-Requests.corpora.entity.build = (corpusId) => {
- let input = `/corpora/${corpusId}/build`;
- let init = {
- method: 'POST',
- };
- return Requests.JSONfetch(input, init);
-};
-
-Requests.corpora.entity.generateShareLink = (corpusId, role, expiration) => {
- let input = `/corpora/${corpusId}/generate-share-link`;
- let init = {
- method: 'POST',
- body: JSON.stringify({role: role, expiration: expiration})
- };
- return Requests.JSONfetch(input, init);
-};
-
-Requests.corpora.entity.getStopwords = () => {
- let input = `/corpora/stopwords`;
- let init = {
- method: 'GET'
- };
- return Requests.JSONfetch(input, init);
-};
-
-Requests.corpora.entity.isPublic = {};
-
-Requests.corpora.entity.isPublic.update = (corpusId, isPublic) => {
- let input = `/corpora/${corpusId}/is_public`;
- let init = {
- method: 'PUT',
- body: JSON.stringify(isPublic)
- };
- return Requests.JSONfetch(input, init);
-};
-
-
diff --git a/app/static/js/Requests/corpora/files.js b/app/static/js/Requests/corpora/files.js
deleted file mode 100644
index 9ff9ba87..00000000
--- a/app/static/js/Requests/corpora/files.js
+++ /dev/null
@@ -1,15 +0,0 @@
-/*****************************************************************************
-* Corpora *
-* Fetch requests for /corpora//files routes *
-*****************************************************************************/
-Requests.corpora.entity.files = {};
-
-Requests.corpora.entity.files.ent = {};
-
-Requests.corpora.entity.files.ent.delete = (corpusId, corpusFileId) => {
- let input = `/corpora/${corpusId}/files/${corpusFileId}`;
- let init = {
- method: 'DELETE',
- };
- return Requests.JSONfetch(input, init);
-};
diff --git a/app/static/js/Requests/corpora/followers.js b/app/static/js/Requests/corpora/followers.js
deleted file mode 100644
index f7f7877f..00000000
--- a/app/static/js/Requests/corpora/followers.js
+++ /dev/null
@@ -1,35 +0,0 @@
-/*****************************************************************************
-* Corpora *
-* Fetch requests for /corpora//followers routes *
-*****************************************************************************/
-Requests.corpora.entity.followers = {};
-
-Requests.corpora.entity.followers.add = (corpusId, usernames) => {
- let input = `/corpora/${corpusId}/followers`;
- let init = {
- method: 'POST',
- body: JSON.stringify(usernames)
- };
- return Requests.JSONfetch(input, init);
-};
-
-Requests.corpora.entity.followers.entity = {};
-
-Requests.corpora.entity.followers.entity.delete = (corpusId, followerId) => {
- let input = `/corpora/${corpusId}/followers/${followerId}`;
- let init = {
- method: 'DELETE',
- };
- return Requests.JSONfetch(input, init);
-};
-
-Requests.corpora.entity.followers.entity.role = {};
-
-Requests.corpora.entity.followers.entity.role.update = (corpusId, followerId, value) => {
- let input = `/corpora/${corpusId}/followers/${followerId}/role`;
- let init = {
- method: 'PUT',
- body: JSON.stringify(value)
- };
- return Requests.JSONfetch(input, init);
-};
diff --git a/app/static/js/Requests/users/settings.js b/app/static/js/Requests/users/settings.js
deleted file mode 100644
index 609ecb35..00000000
--- a/app/static/js/Requests/users/settings.js
+++ /dev/null
@@ -1,17 +0,0 @@
-/*****************************************************************************
-* Settings *
-* Fetch requests for /users//settings routes *
-*****************************************************************************/
-Requests.users.entity.settings = {};
-
-Requests.users.entity.settings.profilePrivacy = {};
-
-Requests.users.entity.settings.profilePrivacy.update = (userId, profilePrivacySetting, enabled) => {
- let input = `/users/${userId}/settings/profile-privacy/${profilePrivacySetting}`;
- let init = {
- method: 'PUT',
- body: JSON.stringify(enabled)
- };
- return Requests.JSONfetch(input, init);
-};
-
diff --git a/app/static/js/cqi/api/package.js b/app/static/js/cqi/api/index.js
similarity index 100%
rename from app/static/js/cqi/api/package.js
rename to app/static/js/cqi/api/index.js
diff --git a/app/static/js/cqi/package.js b/app/static/js/cqi/index.js
similarity index 100%
rename from app/static/js/cqi/package.js
rename to app/static/js/cqi/index.js
diff --git a/app/static/js/cqi/models/package.js b/app/static/js/cqi/models/index.js
similarity index 100%
rename from app/static/js/cqi/models/package.js
rename to app/static/js/cqi/models/index.js
diff --git a/app/static/js/Requests/admin/admin.js b/app/static/js/requests/admin.js
similarity index 78%
rename from app/static/js/Requests/admin/admin.js
rename to app/static/js/requests/admin.js
index 77fdb6b1..fdfe5dcd 100644
--- a/app/static/js/Requests/admin/admin.js
+++ b/app/static/js/requests/admin.js
@@ -1,6 +1,5 @@
/*****************************************************************************
-* Admin *
-* Fetch requests for /admin routes *
+ * Requests for /admin routes *
*****************************************************************************/
Requests.admin = {};
diff --git a/app/static/js/requests/contributions.js b/app/static/js/requests/contributions.js
new file mode 100644
index 00000000..cd6329b6
--- /dev/null
+++ b/app/static/js/requests/contributions.js
@@ -0,0 +1,58 @@
+/*****************************************************************************
+* Requests for /contributions routes *
+*****************************************************************************/
+Requests.contributions = {};
+
+
+/*****************************************************************************
+* Requests for /contributions/spacy-nlp-pipeline-models routes *
+*****************************************************************************/
+Requests.contributions.spacy_nlp_pipeline_models = {};
+
+Requests.contributions.spacy_nlp_pipeline_models.entity = {};
+
+Requests.contributions.spacy_nlp_pipeline_models.entity.delete = (spacyNlpPipelineModelId) => {
+ let input = `/contributions/spacy-nlp-pipeline-models/${spacyNlpPipelineModelId}`;
+ let init = {
+ method: 'DELETE'
+ };
+ return Requests.JSONfetch(input, init);
+};
+
+Requests.contributions.spacy_nlp_pipeline_models.entity.isPublic = {};
+
+Requests.contributions.spacy_nlp_pipeline_models.entity.isPublic.update = (spacyNlpPipelineModelId, value) => {
+ let input = `/contributions/spacy-nlp-pipeline-models/${spacyNlpPipelineModelId}/is_public`;
+ let init = {
+ method: 'PUT',
+ body: JSON.stringify(value)
+ };
+ return Requests.JSONfetch(input, init);
+};
+
+
+/*****************************************************************************
+* Requests for /contributions/tesseract-ocr-pipeline-models routes *
+*****************************************************************************/
+Requests.contributions.tesseract_ocr_pipeline_models = {};
+
+Requests.contributions.tesseract_ocr_pipeline_models.entity = {};
+
+Requests.contributions.tesseract_ocr_pipeline_models.entity.delete = (tesseractOcrPipelineModelId) => {
+ let input = `/contributions/tesseract-ocr-pipeline-models/${tesseractOcrPipelineModelId}`;
+ let init = {
+ method: 'DELETE'
+ };
+ return Requests.JSONfetch(input, init);
+};
+
+Requests.contributions.tesseract_ocr_pipeline_models.entity.isPublic = {};
+
+Requests.contributions.tesseract_ocr_pipeline_models.entity.isPublic.update = (tesseractOcrPipelineModelId, value) => {
+ let input = `/contributions/tesseract-ocr-pipeline-models/${tesseractOcrPipelineModelId}/is_public`;
+ let init = {
+ method: 'PUT',
+ body: JSON.stringify(value)
+ };
+ return Requests.JSONfetch(input, init);
+};
diff --git a/app/static/js/requests/corpora.js b/app/static/js/requests/corpora.js
new file mode 100644
index 00000000..4c65a7ee
--- /dev/null
+++ b/app/static/js/requests/corpora.js
@@ -0,0 +1,102 @@
+/*****************************************************************************
+* Requests for /corpora routes *
+*****************************************************************************/
+Requests.corpora = {};
+
+Requests.corpora.entity = {};
+
+Requests.corpora.entity.delete = (corpusId) => {
+ let input = `/corpora/${corpusId}`;
+ let init = {
+ method: 'DELETE'
+ };
+ return Requests.JSONfetch(input, init);
+};
+
+Requests.corpora.entity.build = (corpusId) => {
+ let input = `/corpora/${corpusId}/build`;
+ let init = {
+ method: 'POST',
+ };
+ return Requests.JSONfetch(input, init);
+};
+
+Requests.corpora.entity.generateShareLink = (corpusId, role, expiration) => {
+ let input = `/corpora/${corpusId}/generate-share-link`;
+ let init = {
+ method: 'POST',
+ body: JSON.stringify({role: role, expiration: expiration})
+ };
+ return Requests.JSONfetch(input, init);
+};
+
+Requests.corpora.entity.getStopwords = () => {
+ let input = `/corpora/stopwords`;
+ let init = {
+ method: 'GET'
+ };
+ return Requests.JSONfetch(input, init);
+};
+
+Requests.corpora.entity.isPublic = {};
+
+Requests.corpora.entity.isPublic.update = (corpusId, isPublic) => {
+ let input = `/corpora/${corpusId}/is_public`;
+ let init = {
+ method: 'PUT',
+ body: JSON.stringify(isPublic)
+ };
+ return Requests.JSONfetch(input, init);
+};
+
+
+/*****************************************************************************
+* Requests for /corpora//files routes *
+*****************************************************************************/
+Requests.corpora.entity.files = {};
+
+Requests.corpora.entity.files.ent = {};
+
+Requests.corpora.entity.files.ent.delete = (corpusId, corpusFileId) => {
+ let input = `/corpora/${corpusId}/files/${corpusFileId}`;
+ let init = {
+ method: 'DELETE',
+ };
+ return Requests.JSONfetch(input, init);
+};
+
+
+/*****************************************************************************
+* Requests for /corpora//followers routes *
+*****************************************************************************/
+Requests.corpora.entity.followers = {};
+
+Requests.corpora.entity.followers.add = (corpusId, usernames) => {
+ let input = `/corpora/${corpusId}/followers`;
+ let init = {
+ method: 'POST',
+ body: JSON.stringify(usernames)
+ };
+ return Requests.JSONfetch(input, init);
+};
+
+Requests.corpora.entity.followers.entity = {};
+
+Requests.corpora.entity.followers.entity.delete = (corpusId, followerId) => {
+ let input = `/corpora/${corpusId}/followers/${followerId}`;
+ let init = {
+ method: 'DELETE',
+ };
+ return Requests.JSONfetch(input, init);
+};
+
+Requests.corpora.entity.followers.entity.role = {};
+
+Requests.corpora.entity.followers.entity.role.update = (corpusId, followerId, value) => {
+ let input = `/corpora/${corpusId}/followers/${followerId}/role`;
+ let init = {
+ method: 'PUT',
+ body: JSON.stringify(value)
+ };
+ return Requests.JSONfetch(input, init);
+};
diff --git a/app/static/js/Requests/Requests.js b/app/static/js/requests/index.js
similarity index 98%
rename from app/static/js/Requests/Requests.js
rename to app/static/js/requests/index.js
index 7282f0f7..c5bb8a1f 100644
--- a/app/static/js/Requests/Requests.js
+++ b/app/static/js/requests/index.js
@@ -1,4 +1,4 @@
-let Requests = {};
+var Requests = {};
Requests.JSONfetch = (input, init={}) => {
return new Promise((resolve, reject) => {
diff --git a/app/static/js/Requests/jobs/jobs.js b/app/static/js/requests/jobs.js
similarity index 83%
rename from app/static/js/Requests/jobs/jobs.js
rename to app/static/js/requests/jobs.js
index 64e523db..68f06987 100644
--- a/app/static/js/Requests/jobs/jobs.js
+++ b/app/static/js/requests/jobs.js
@@ -1,6 +1,5 @@
/*****************************************************************************
-* Jobs *
-* Fetch requests for /jobs routes *
+* Requests for /jobs routes *
*****************************************************************************/
Requests.jobs = {};
diff --git a/app/static/js/Requests/users/users.js b/app/static/js/requests/users.js
similarity index 59%
rename from app/static/js/Requests/users/users.js
rename to app/static/js/requests/users.js
index 4baf4717..fb76cb07 100644
--- a/app/static/js/Requests/users/users.js
+++ b/app/static/js/requests/users.js
@@ -22,7 +22,6 @@ Requests.users.entity.acceptTermsOfUse = () => {
return Requests.JSONfetch(input, init);
};
-
Requests.users.entity.avatar = {};
Requests.users.entity.avatar.delete = (userId) => {
@@ -33,3 +32,20 @@ Requests.users.entity.avatar.delete = (userId) => {
return Requests.JSONfetch(input, init);
}
+
+/*****************************************************************************
+* Requests for /users//settings routes *
+*****************************************************************************/
+Requests.users.entity.settings = {};
+
+Requests.users.entity.settings.profilePrivacy = {};
+
+Requests.users.entity.settings.profilePrivacy.update = (userId, profilePrivacySetting, enabled) => {
+ let input = `/users/${userId}/settings/profile-privacy/${profilePrivacySetting}`;
+ let init = {
+ method: 'PUT',
+ body: JSON.stringify(enabled)
+ };
+ return Requests.JSONfetch(input, init);
+};
+
diff --git a/app/templates/_scripts.html.j2 b/app/templates/_scripts.html.j2
index 98ddb732..14999fc4 100644
--- a/app/templates/_scripts.html.j2
+++ b/app/templates/_scripts.html.j2
@@ -4,23 +4,6 @@
-{%- assets
- filters='rjsmin',
- output='gen/cqi.%(version)s.js',
- 'js/cqi/package.js',
- 'js/cqi/errors.js',
- 'js/cqi/status.js',
- 'js/cqi/api/package.js',
- 'js/cqi/api/client.js',
- 'js/cqi/models/package.js',
- 'js/cqi/models/resource.js',
- 'js/cqi/models/attributes.js',
- 'js/cqi/models/subcorpora.js',
- 'js/cqi/models/corpora.js',
- 'js/cqi/client.js'
-%}
-
-{%- endassets %}
{%- assets
filters='rjsmin',
output='gen/app.%(version)s.js',
@@ -30,6 +13,25 @@
%}
{%- endassets %}
+
+{%- assets
+ filters='rjsmin',
+ output='gen/cqi.%(version)s.js',
+ 'js/cqi/index.js',
+ 'js/cqi/errors.js',
+ 'js/cqi/status.js',
+ 'js/cqi/api/index.js',
+ 'js/cqi/api/client.js',
+ 'js/cqi/models/index.js',
+ 'js/cqi/models/resource.js',
+ 'js/cqi/models/attributes.js',
+ 'js/cqi/models/subcorpora.js',
+ 'js/cqi/models/corpora.js',
+ 'js/cqi/client.js'
+%}
+
+{%- endassets %}
+
{%- assets
filters='rjsmin',
output='gen/Forms.%(version)s.js',
@@ -40,6 +42,7 @@
%}
{%- endassets %}
+
{%- assets
filters='rjsmin',
output='gen/ResourceDisplays.%(version)s.js',
@@ -49,6 +52,7 @@
%}
{%- endassets %}
+
{%- assets
filters='rjsmin',
output='gen/ResourceLists.%(version)s.js',
@@ -70,23 +74,20 @@
%}
{%- endassets %}
+
{%- assets
filters='rjsmin',
- output='gen/Requests.%(version)s.js',
- 'js/Requests/Requests.js',
- 'js/Requests/admin/admin.js',
- 'js/Requests/contributions/contributions.js',
- 'js/Requests/contributions/spacy_nlp_pipeline_models.js',
- 'js/Requests/contributions/tesseract_ocr_pipeline_models.js',
- 'js/Requests/corpora/corpora.js',
- 'js/Requests/corpora/files.js',
- 'js/Requests/corpora/followers.js',
- 'js/Requests/jobs/jobs.js',
- 'js/Requests/users/users.js',
- 'js/Requests/users/settings.js'
+ output='gen/requests.%(version)s.js',
+ 'js/requests/index.js',
+ 'js/requests/admin.js',
+ 'js/requests/contributions.js',
+ 'js/requests/corpora.js',
+ 'js/requests/jobs.js',
+ 'js/requests/users.js'
%}
{%- endassets %}
+
{%- assets
filters='rjsmin',
output='gen/CorpusAnalysis.%(version)s.js',
@@ -102,6 +103,7 @@
%}
{%- endassets %}
+