mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-27 03:44:19 +00:00
Compare commits
No commits in common. "61be3345be189197e5d95227158094a054126ffa" and "0565f309f891e7da7467f5b752fe671b7e503294" have entirely different histories.
61be3345be
...
0565f309f8
@ -33,7 +33,7 @@ class CorpusAnalysisConcordance {
|
||||
|
||||
async submitForm(queryModeId) {
|
||||
this.app.disableActionElements();
|
||||
let queryBuilderQuery = nopaque.Utils.unescape(document.querySelector('#corpus-analysis-concordance-query-preview').innerHTML.trim());
|
||||
let queryBuilderQuery = Utils.unescape(document.querySelector('#corpus-analysis-concordance-query-preview').innerHTML.trim());
|
||||
let expertModeQuery = this.elements.expertModeForm.query.value.trim();
|
||||
let query = queryModeId === 'corpus-analysis-concordance-expert-mode-form' ? expertModeQuery : queryBuilderQuery;
|
||||
let form = queryModeId === 'corpus-analysis-concordance-expert-mode-form' ? this.elements.expertModeForm : this.elements.queryBuilderForm;
|
||||
@ -171,11 +171,11 @@ class CorpusAnalysisConcordance {
|
||||
this.elements.subcorpusActions.querySelector('.subcorpus-export-trigger').addEventListener('click', (event) => {
|
||||
event.preventDefault();
|
||||
let subcorpus = this.data.subcorpora[this.settings.selectedSubcorpus];
|
||||
let modalElementId = nopaque.Utils.generateElementId('export-subcorpus-modal-');
|
||||
let exportFormatSelectElementId = nopaque.Utils.generateElementId('export-format-select-');
|
||||
let exportSelectedMatchesOnlyCheckboxElementId = nopaque.Utils.generateElementId('export-selected-matches-only-checkbox-');
|
||||
let exportFileNameInputElementId = nopaque.Utils.generateElementId('export-file-name-input-');
|
||||
let modalElement = nopaque.Utils.HTMLToElement(
|
||||
let modalElementId = Utils.generateElementId('export-subcorpus-modal-');
|
||||
let exportFormatSelectElementId = Utils.generateElementId('export-format-select-');
|
||||
let exportSelectedMatchesOnlyCheckboxElementId = Utils.generateElementId('export-selected-matches-only-checkbox-');
|
||||
let exportFileNameInputElementId = Utils.generateElementId('export-file-name-input-');
|
||||
let modalElement = Utils.HTMLToElement(
|
||||
`
|
||||
<div class="modal" id="${modalElementId}">
|
||||
<div class="modal-content">
|
||||
|
@ -112,7 +112,7 @@ class CorpusAnalysisReader {
|
||||
if (this.data.corpus.p.pages === 0) {return;}
|
||||
let pageElement;
|
||||
// First page button. Disables first page button if on first page
|
||||
pageElement = nopaque.Utils.HTMLToElement(
|
||||
pageElement = Utils.HTMLToElement(
|
||||
`
|
||||
<li class="${this.data.corpus.p.page === 1 ? 'disabled' : 'waves-effect'}">
|
||||
<a class="corpus-analysis-action pagination-trigger" ${this.data.corpus.p.page === 1 ? '' : 'data-target="1"'}>
|
||||
@ -123,7 +123,7 @@ class CorpusAnalysisReader {
|
||||
);
|
||||
this.elements.corpusPagination.appendChild(pageElement);
|
||||
// Previous page button. Disables previous page button if on first page
|
||||
pageElement = nopaque.Utils.HTMLToElement(
|
||||
pageElement = Utils.HTMLToElement(
|
||||
`
|
||||
<li class="${this.data.corpus.p.has_prev ? 'waves-effect' : 'disabled'}">
|
||||
<a class="corpus-analysis-action pagination-trigger" ${this.data.corpus.p.has_prev ? 'data-target="' + this.data.corpus.p.prev_num + '"' : ''}>
|
||||
@ -135,7 +135,7 @@ class CorpusAnalysisReader {
|
||||
this.elements.corpusPagination.appendChild(pageElement);
|
||||
// First page as number. Hides first page button if on first page
|
||||
if (this.data.corpus.p.page > 6) {
|
||||
pageElement = nopaque.Utils.HTMLToElement(
|
||||
pageElement = Utils.HTMLToElement(
|
||||
`
|
||||
<li class="waves-effect">
|
||||
<a class="corpus-analysis-action pagination-trigger" data-target="1">1</a>
|
||||
@ -143,14 +143,14 @@ class CorpusAnalysisReader {
|
||||
`
|
||||
);
|
||||
this.elements.corpusPagination.appendChild(pageElement);
|
||||
pageElement = nopaque.Utils.HTMLToElement("<li style='margin-top: 5px;'>…</li>");
|
||||
pageElement = Utils.HTMLToElement("<li style='margin-top: 5px;'>…</li>");
|
||||
this.elements.corpusPagination.appendChild(pageElement);
|
||||
}
|
||||
|
||||
// render page buttons (5 before and 5 after current page)
|
||||
for (let i = this.data.corpus.p.page - this.settings.pagination.innerWindow; i <= this.data.corpus.p.page; i++) {
|
||||
if (i <= 0) {continue;}
|
||||
pageElement = nopaque.Utils.HTMLToElement(
|
||||
pageElement = Utils.HTMLToElement(
|
||||
`
|
||||
<li class="${i === this.data.corpus.p.page ? 'active' : 'waves-effect'}">
|
||||
<a class="corpus-analysis-action pagination-trigger" ${i === this.data.corpus.p.page ? '' : 'data-target="' + i + '"'}>${i}</a>
|
||||
@ -161,7 +161,7 @@ class CorpusAnalysisReader {
|
||||
};
|
||||
for (let i = this.data.corpus.p.page +1; i <= this.data.corpus.p.page + this.settings.pagination.innerWindow; i++) {
|
||||
if (i > this.data.corpus.p.pages) {break;}
|
||||
pageElement = nopaque.Utils.HTMLToElement(
|
||||
pageElement = Utils.HTMLToElement(
|
||||
`
|
||||
<li class="${i === this.data.corpus.p.page ? 'active' : 'waves-effect'}">
|
||||
<a class="corpus-analysis-action pagination-trigger" ${i === this.data.corpus.p.page ? '' : 'data-target="' + i + '"'}>${i}</a>
|
||||
@ -172,9 +172,9 @@ class CorpusAnalysisReader {
|
||||
};
|
||||
// Last page as number. Hides last page button if on last page
|
||||
if (this.data.corpus.p.page < this.data.corpus.p.pages - 6) {
|
||||
pageElement = nopaque.Utils.HTMLToElement("<li style='margin-top: 5px;'>…</li>");
|
||||
pageElement = Utils.HTMLToElement("<li style='margin-top: 5px;'>…</li>");
|
||||
this.elements.corpusPagination.appendChild(pageElement);
|
||||
pageElement = nopaque.Utils.HTMLToElement(
|
||||
pageElement = Utils.HTMLToElement(
|
||||
`
|
||||
<li class="waves-effect">
|
||||
<a class="corpus-analysis-action pagination-trigger" data-target="${this.data.corpus.p.pages}">${this.data.corpus.p.pages}</a>
|
||||
@ -184,7 +184,7 @@ class CorpusAnalysisReader {
|
||||
this.elements.corpusPagination.appendChild(pageElement);
|
||||
}
|
||||
// Next page button. Disables next page button if on last page
|
||||
pageElement = nopaque.Utils.HTMLToElement(
|
||||
pageElement = Utils.HTMLToElement(
|
||||
`
|
||||
<li class="${this.data.corpus.p.has_next ? 'waves-effect' : 'disabled'}">
|
||||
<a class="corpus-analysis-action pagination-trigger" ${this.data.corpus.p.has_next ? 'data-target="' + this.data.corpus.p.next_num + '"' : ''}>
|
||||
@ -195,7 +195,7 @@ class CorpusAnalysisReader {
|
||||
);
|
||||
this.elements.corpusPagination.appendChild(pageElement);
|
||||
// Last page button. Disables last page button if on last page
|
||||
pageElement = nopaque.Utils.HTMLToElement(
|
||||
pageElement = Utils.HTMLToElement(
|
||||
`
|
||||
<li class="${this.data.corpus.p.page === this.data.corpus.p.pages ? 'disabled' : 'waves-effect'}">
|
||||
<a class="corpus-analysis-action pagination-trigger" ${this.data.corpus.p.page === this.data.corpus.p.pages ? '' : 'data-target="' + this.data.corpus.p.pages + '"'}>
|
||||
|
@ -75,7 +75,7 @@ class CorpusAnalysisStaticVisualization {
|
||||
|
||||
getStopwords() {
|
||||
this.data.promises.getStopwords = new Promise((resolve, reject) => {
|
||||
nopaque.requests.corpora.entity.getStopwords()
|
||||
Requests.corpora.entity.getStopwords()
|
||||
.then((response) => {
|
||||
response.json()
|
||||
.then((json) => {
|
||||
@ -104,7 +104,7 @@ class CorpusAnalysisStaticVisualization {
|
||||
renderTextInfoList() {
|
||||
let corpusData = this.data.corpus.o.staticData;
|
||||
let corpusTextInfoListElement = document.querySelector('.corpus-text-info-list');
|
||||
let corpusTextInfoList = new nopaque.resource_lists.CorpusTextInfoList(corpusTextInfoListElement);
|
||||
let corpusTextInfoList = new ResourceLists.CorpusTextInfoList(corpusTextInfoListElement);
|
||||
let texts = corpusData.s_attrs.text.lexicon;
|
||||
let textData = [];
|
||||
for (let i = 0; i < Object.entries(texts).length; i++) {
|
||||
@ -213,7 +213,7 @@ class CorpusAnalysisStaticVisualization {
|
||||
|
||||
async renderTokenList() {
|
||||
let corpusTokenListElement = document.querySelector('.corpus-token-list');
|
||||
let corpusTokenList = new nopaque.resource_lists.CorpusTokenList(corpusTokenListElement);
|
||||
let corpusTokenList = new ResourceLists.CorpusTokenList(corpusTokenListElement);
|
||||
let filteredData = this.filterData();
|
||||
let stopwords = this.data.stopwords;
|
||||
if (this.data.stopwords === undefined) {
|
||||
@ -358,7 +358,7 @@ class CorpusAnalysisStaticVisualization {
|
||||
if (stopwordLanguageSelection.children.length === 0) {
|
||||
Object.keys(stopwords).forEach(language => {
|
||||
if (language !== 'user_stopwords') {
|
||||
let optionElement = nopaque.Utils.HTMLToElement(`<option value="${language}" ${language === 'english' ? 'selected' : ''}>${language}</option>`);
|
||||
let optionElement = Utils.HTMLToElement(`<option value="${language}" ${language === 'english' ? 'selected' : ''}>${language}</option>`);
|
||||
stopwordLanguageSelection.appendChild(optionElement);
|
||||
}
|
||||
});
|
||||
@ -367,7 +367,7 @@ class CorpusAnalysisStaticVisualization {
|
||||
// Render user stopwords over input field.
|
||||
if (this.data.stopwords['user_stopwords'].length > 0) {
|
||||
for (let word of this.data.stopwords['user_stopwords']) {
|
||||
let chipElement = nopaque.Utils.HTMLToElement(`<div class="chip">${word}<i class="close material-icons">close</i></div>`);
|
||||
let chipElement = Utils.HTMLToElement(`<div class="chip">${word}<i class="close material-icons">close</i></div>`);
|
||||
chipElement.addEventListener('click', (event) => {
|
||||
let removedListItem = event.target.closest('.chip').firstChild.textContent;
|
||||
this.data.stopwords['user_stopwords'] = structuredClone(this.data.stopwords['user_stopwords'].filter(item => item !== removedListItem));
|
||||
@ -433,7 +433,7 @@ class CorpusAnalysisStaticVisualization {
|
||||
let stopwordLanguageChipList = document.querySelector('#stopword-language-chip-list');
|
||||
stopwordLanguageChipList.innerHTML = '';
|
||||
for (let word of stopwords) {
|
||||
let chipElement = nopaque.Utils.HTMLToElement(`<div class="chip">${word}<i class="close material-icons">close</i></div>`);
|
||||
let chipElement = Utils.HTMLToElement(`<div class="chip">${word}<i class="close material-icons">close</i></div>`);
|
||||
chipElement.addEventListener('click', (event) => {
|
||||
let removedListItem = event.target.closest('.chip').firstChild.textContent;
|
||||
this.data.stopwords[language] = structuredClone(this.data.stopwords[language].filter(item => item !== removedListItem));
|
||||
|
@ -28,7 +28,7 @@ class GeneralQueryBuilderFunctions {
|
||||
}
|
||||
|
||||
addPlaceholder() {
|
||||
let placeholder = nopaque.Utils.HTMLToElement('<span id="corpus-analysis-concordance-query-builder-input-field-placeholder">Click on a button to add a query component</span>');
|
||||
let placeholder = Utils.HTMLToElement('<span id="corpus-analysis-concordance-query-builder-input-field-placeholder">Click on a button to add a query component</span>');
|
||||
this.elements.queryInputField.appendChild(placeholder);
|
||||
}
|
||||
|
||||
@ -58,9 +58,9 @@ class GeneralQueryBuilderFunctions {
|
||||
|
||||
queryChipFactory(dataType, prettyQueryText, queryText, index = null, isClosingTag = false, isEditable = false) {
|
||||
// Creates a new query chip element, adds Eventlisteners for selection, deletion and drag and drop and appends it to the query input field.
|
||||
queryText = nopaque.Utils.escape(queryText);
|
||||
prettyQueryText = nopaque.Utils.escape(prettyQueryText);
|
||||
let queryChipElement = nopaque.Utils.HTMLToElement(
|
||||
queryText = Utils.escape(queryText);
|
||||
prettyQueryText = Utils.escape(prettyQueryText);
|
||||
let queryChipElement = Utils.HTMLToElement(
|
||||
`
|
||||
<span class="chip query-component" data-type="${dataType}" data-query="${queryText}" draggable="true" data-closing-tag="${isClosingTag}">
|
||||
${prettyQueryText}${isEditable ? '<i class="material-icons chip-action-button" data-chip-action="edit" style="padding-left:5px; font-size:18px; cursor:pointer;">edit</i>': ''}
|
||||
@ -276,7 +276,7 @@ class GeneralQueryBuilderFunctions {
|
||||
queryChips = this.elements.queryInputField.querySelectorAll('.query-component[data-type="token"]');
|
||||
}
|
||||
setTimeout(() => {
|
||||
let targetChipElement = nopaque.Utils.HTMLToElement('<span class="chip drop-target">Drop here</span>');
|
||||
let targetChipElement = Utils.HTMLToElement('<span class="chip drop-target">Drop here</span>');
|
||||
for (let element of queryChips) {
|
||||
if (element === this.elements.queryInputField.querySelectorAll('.query-component')[0]) {
|
||||
let secondTargetChipClone = targetChipElement.cloneNode(true);
|
||||
@ -324,7 +324,7 @@ class GeneralQueryBuilderFunctions {
|
||||
this.elements.queryChipElements.forEach(element => {
|
||||
let queryElement = element.dataset.query;
|
||||
if (queryElement !== undefined) {
|
||||
queryElement = nopaque.Utils.escape(queryElement);
|
||||
queryElement = Utils.escape(queryElement);
|
||||
}
|
||||
queryInputFieldContent.push(queryElement);
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
nopaque.forms.BaseForm = class BaseForm {
|
||||
Forms.BaseForm = class BaseForm {
|
||||
static htmlClass;
|
||||
|
||||
constructor(formElement) {
|
||||
@ -28,7 +28,7 @@ nopaque.forms.BaseForm = class BaseForm {
|
||||
|
||||
submit(event) {
|
||||
let request = new XMLHttpRequest();
|
||||
let modalElement = nopaque.Utils.HTMLToElement(
|
||||
let modalElement = Utils.HTMLToElement(
|
||||
`
|
||||
<div class="modal">
|
||||
<div class="modal-content">
|
||||
@ -67,7 +67,7 @@ nopaque.forms.BaseForm = class BaseForm {
|
||||
for (let selectElement of this.formElement.querySelectorAll('select')) {
|
||||
if (selectElement.value === '') {
|
||||
let inputFieldElement = selectElement.closest('.input-field');
|
||||
let errorHelperTextElement = nopaque.Utils.HTMLToElement(
|
||||
let errorHelperTextElement = Utils.HTMLToElement(
|
||||
'<span class="helper-text error-color-text" data-helper-text-type="error">Please select an option.</span>'
|
||||
);
|
||||
inputFieldElement.appendChild(errorHelperTextElement);
|
||||
@ -93,7 +93,7 @@ nopaque.forms.BaseForm = class BaseForm {
|
||||
.querySelector(`input[name$="${inputName}"], select[name$="${inputName}"]`)
|
||||
.closest('.input-field');
|
||||
for (let inputError of inputErrors) {
|
||||
let errorHelperTextElement = nopaque.Utils.HTMLToElement(
|
||||
let errorHelperTextElement = Utils.HTMLToElement(
|
||||
`<span class="helper-text error-color-text" data-helper-type="error">${inputError}</span>`
|
||||
);
|
||||
inputFieldElement.appendChild(errorHelperTextElement);
|
||||
|
@ -1,4 +1,4 @@
|
||||
nopaque.forms.CreateContributionForm = class CreateContributionForm extends nopaque.forms.BaseForm {
|
||||
Forms.CreateContributionForm = class CreateContributionForm extends Forms.BaseForm {
|
||||
static htmlClass = 'create-contribution-form';
|
||||
|
||||
constructor(formElement) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
nopaque.forms.CreateCorpusFileForm = class CreateCorpusFileForm extends nopaque.forms.BaseForm {
|
||||
Forms.CreateCorpusFileForm = class CreateCorpusFileForm extends Forms.BaseForm {
|
||||
static htmlClass = 'create-corpus-file-form';
|
||||
|
||||
constructor(formElement) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
nopaque.forms.CreateJobForm = class CreateJobForm extends nopaque.forms.BaseForm {
|
||||
Forms.CreateJobForm = class CreateJobForm extends Forms.BaseForm {
|
||||
static htmlClass = 'create-job-form';
|
||||
|
||||
constructor(formElement) {
|
||||
|
@ -1,11 +1,11 @@
|
||||
nopaque.forms = {};
|
||||
var Forms = {};
|
||||
|
||||
nopaque.forms.AutoInit = () => {
|
||||
for (let propertyName in nopaque.forms) {
|
||||
let property = nopaque.forms[propertyName];
|
||||
// Call autoInit of all properties that are subclasses of nopaque.forms.BaseForm.
|
||||
// This does not include nopaque.forms.BaseForm itself.
|
||||
if (property.prototype instanceof nopaque.forms.BaseForm) {
|
||||
Forms.AutoInit = () => {
|
||||
for (let propertyName in Forms) {
|
||||
let property = Forms[propertyName];
|
||||
// Call autoInit of all properties that are subclasses of Forms.BaseForm.
|
||||
// This does not include Forms.BaseForm itself.
|
||||
if (property.prototype instanceof Forms.BaseForm) {
|
||||
// Check if the static htmlClass property is defined.
|
||||
if (property.htmlClass === undefined) {return;}
|
||||
// Gather all HTML elements that have the `this.htmlClass` class
|
||||
|
@ -1,5 +0,0 @@
|
||||
/*
|
||||
* This object functions as a global namespace for nopaque.
|
||||
* All components of nopaque should be attached to this object.
|
||||
*/
|
||||
var nopaque = {};
|
@ -179,7 +179,7 @@ nopaque.App = class App {
|
||||
{
|
||||
dismissible: false,
|
||||
onCloseEnd: (modalElement) => {
|
||||
nopaque.requests.users.entity.acceptTermsOfUse();
|
||||
Requests.users.entity.acceptTermsOfUse();
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -188,9 +188,9 @@ nopaque.App = class App {
|
||||
|
||||
/* Initialize nopaque Components */
|
||||
// #region
|
||||
nopaque.resource_displays.AutoInit();
|
||||
nopaque.resource_lists.AutoInit();
|
||||
nopaque.forms.AutoInit();
|
||||
ResourceDisplays.AutoInit();
|
||||
ResourceLists.AutoInit();
|
||||
Forms.AutoInit();
|
||||
// #endregion
|
||||
}
|
||||
};
|
1
app/static/js/nopaque/index.js
Normal file
1
app/static/js/nopaque/index.js
Normal file
@ -0,0 +1 @@
|
||||
var nopaque = {};
|
@ -1,19 +1,19 @@
|
||||
/*****************************************************************************
|
||||
* Requests for /admin routes *
|
||||
*****************************************************************************/
|
||||
nopaque.requests.admin = {};
|
||||
Requests.admin = {};
|
||||
|
||||
nopaque.requests.admin.users = {};
|
||||
Requests.admin.users = {};
|
||||
|
||||
nopaque.requests.admin.users.entity = {};
|
||||
Requests.admin.users.entity = {};
|
||||
|
||||
nopaque.requests.admin.users.entity.confirmed = {};
|
||||
Requests.admin.users.entity.confirmed = {};
|
||||
|
||||
nopaque.requests.admin.users.entity.confirmed.update = (userId, value) => {
|
||||
Requests.admin.users.entity.confirmed.update = (userId, value) => {
|
||||
let input = `/admin/users/${userId}/confirmed`;
|
||||
let init = {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(value)
|
||||
};
|
||||
return nopaque.requests.JSONfetch(input, init);
|
||||
return Requests.JSONfetch(input, init);
|
||||
};
|
||||
|
@ -1,58 +1,58 @@
|
||||
/*****************************************************************************
|
||||
* Requests for /contributions routes *
|
||||
*****************************************************************************/
|
||||
nopaque.requests.contributions = {};
|
||||
Requests.contributions = {};
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Requests for /contributions/spacy-nlp-pipeline-models routes *
|
||||
*****************************************************************************/
|
||||
nopaque.requests.contributions.spacy_nlp_pipeline_models = {};
|
||||
Requests.contributions.spacy_nlp_pipeline_models = {};
|
||||
|
||||
nopaque.requests.contributions.spacy_nlp_pipeline_models.entity = {};
|
||||
Requests.contributions.spacy_nlp_pipeline_models.entity = {};
|
||||
|
||||
nopaque.requests.contributions.spacy_nlp_pipeline_models.entity.delete = (spacyNlpPipelineModelId) => {
|
||||
Requests.contributions.spacy_nlp_pipeline_models.entity.delete = (spacyNlpPipelineModelId) => {
|
||||
let input = `/contributions/spacy-nlp-pipeline-models/${spacyNlpPipelineModelId}`;
|
||||
let init = {
|
||||
method: 'DELETE'
|
||||
};
|
||||
return nopaque.requests.JSONfetch(input, init);
|
||||
return Requests.JSONfetch(input, init);
|
||||
};
|
||||
|
||||
nopaque.requests.contributions.spacy_nlp_pipeline_models.entity.isPublic = {};
|
||||
Requests.contributions.spacy_nlp_pipeline_models.entity.isPublic = {};
|
||||
|
||||
nopaque.requests.contributions.spacy_nlp_pipeline_models.entity.isPublic.update = (spacyNlpPipelineModelId, value) => {
|
||||
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 nopaque.requests.JSONfetch(input, init);
|
||||
return Requests.JSONfetch(input, init);
|
||||
};
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Requests for /contributions/tesseract-ocr-pipeline-models routes *
|
||||
*****************************************************************************/
|
||||
nopaque.requests.contributions.tesseract_ocr_pipeline_models = {};
|
||||
Requests.contributions.tesseract_ocr_pipeline_models = {};
|
||||
|
||||
nopaque.requests.contributions.tesseract_ocr_pipeline_models.entity = {};
|
||||
Requests.contributions.tesseract_ocr_pipeline_models.entity = {};
|
||||
|
||||
nopaque.requests.contributions.tesseract_ocr_pipeline_models.entity.delete = (tesseractOcrPipelineModelId) => {
|
||||
Requests.contributions.tesseract_ocr_pipeline_models.entity.delete = (tesseractOcrPipelineModelId) => {
|
||||
let input = `/contributions/tesseract-ocr-pipeline-models/${tesseractOcrPipelineModelId}`;
|
||||
let init = {
|
||||
method: 'DELETE'
|
||||
};
|
||||
return nopaque.requests.JSONfetch(input, init);
|
||||
return Requests.JSONfetch(input, init);
|
||||
};
|
||||
|
||||
nopaque.requests.contributions.tesseract_ocr_pipeline_models.entity.isPublic = {};
|
||||
Requests.contributions.tesseract_ocr_pipeline_models.entity.isPublic = {};
|
||||
|
||||
nopaque.requests.contributions.tesseract_ocr_pipeline_models.entity.isPublic.update = (tesseractOcrPipelineModelId, value) => {
|
||||
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 nopaque.requests.JSONfetch(input, init);
|
||||
return Requests.JSONfetch(input, init);
|
||||
};
|
||||
|
@ -1,102 +1,102 @@
|
||||
/*****************************************************************************
|
||||
* Requests for /corpora routes *
|
||||
*****************************************************************************/
|
||||
nopaque.requests.corpora = {};
|
||||
Requests.corpora = {};
|
||||
|
||||
nopaque.requests.corpora.entity = {};
|
||||
Requests.corpora.entity = {};
|
||||
|
||||
nopaque.requests.corpora.entity.delete = (corpusId) => {
|
||||
Requests.corpora.entity.delete = (corpusId) => {
|
||||
let input = `/corpora/${corpusId}`;
|
||||
let init = {
|
||||
method: 'DELETE'
|
||||
};
|
||||
return nopaque.requests.JSONfetch(input, init);
|
||||
return Requests.JSONfetch(input, init);
|
||||
};
|
||||
|
||||
nopaque.requests.corpora.entity.build = (corpusId) => {
|
||||
Requests.corpora.entity.build = (corpusId) => {
|
||||
let input = `/corpora/${corpusId}/build`;
|
||||
let init = {
|
||||
method: 'POST',
|
||||
};
|
||||
return nopaque.requests.JSONfetch(input, init);
|
||||
return Requests.JSONfetch(input, init);
|
||||
};
|
||||
|
||||
nopaque.requests.corpora.entity.generateShareLink = (corpusId, role, expiration) => {
|
||||
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 nopaque.requests.JSONfetch(input, init);
|
||||
return Requests.JSONfetch(input, init);
|
||||
};
|
||||
|
||||
nopaque.requests.corpora.entity.getStopwords = () => {
|
||||
Requests.corpora.entity.getStopwords = () => {
|
||||
let input = `/corpora/stopwords`;
|
||||
let init = {
|
||||
method: 'GET'
|
||||
};
|
||||
return nopaque.requests.JSONfetch(input, init);
|
||||
return Requests.JSONfetch(input, init);
|
||||
};
|
||||
|
||||
nopaque.requests.corpora.entity.isPublic = {};
|
||||
Requests.corpora.entity.isPublic = {};
|
||||
|
||||
nopaque.requests.corpora.entity.isPublic.update = (corpusId, isPublic) => {
|
||||
Requests.corpora.entity.isPublic.update = (corpusId, isPublic) => {
|
||||
let input = `/corpora/${corpusId}/is_public`;
|
||||
let init = {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(isPublic)
|
||||
};
|
||||
return nopaque.requests.JSONfetch(input, init);
|
||||
return Requests.JSONfetch(input, init);
|
||||
};
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Requests for /corpora/<entity>/files routes *
|
||||
*****************************************************************************/
|
||||
nopaque.requests.corpora.entity.files = {};
|
||||
Requests.corpora.entity.files = {};
|
||||
|
||||
nopaque.requests.corpora.entity.files.ent = {};
|
||||
Requests.corpora.entity.files.ent = {};
|
||||
|
||||
nopaque.requests.corpora.entity.files.ent.delete = (corpusId, corpusFileId) => {
|
||||
Requests.corpora.entity.files.ent.delete = (corpusId, corpusFileId) => {
|
||||
let input = `/corpora/${corpusId}/files/${corpusFileId}`;
|
||||
let init = {
|
||||
method: 'DELETE',
|
||||
};
|
||||
return nopaque.requests.JSONfetch(input, init);
|
||||
return Requests.JSONfetch(input, init);
|
||||
};
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Requests for /corpora/<entity>/followers routes *
|
||||
*****************************************************************************/
|
||||
nopaque.requests.corpora.entity.followers = {};
|
||||
Requests.corpora.entity.followers = {};
|
||||
|
||||
nopaque.requests.corpora.entity.followers.add = (corpusId, usernames) => {
|
||||
Requests.corpora.entity.followers.add = (corpusId, usernames) => {
|
||||
let input = `/corpora/${corpusId}/followers`;
|
||||
let init = {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(usernames)
|
||||
};
|
||||
return nopaque.requests.JSONfetch(input, init);
|
||||
return Requests.JSONfetch(input, init);
|
||||
};
|
||||
|
||||
nopaque.requests.corpora.entity.followers.entity = {};
|
||||
Requests.corpora.entity.followers.entity = {};
|
||||
|
||||
nopaque.requests.corpora.entity.followers.entity.delete = (corpusId, followerId) => {
|
||||
Requests.corpora.entity.followers.entity.delete = (corpusId, followerId) => {
|
||||
let input = `/corpora/${corpusId}/followers/${followerId}`;
|
||||
let init = {
|
||||
method: 'DELETE',
|
||||
};
|
||||
return nopaque.requests.JSONfetch(input, init);
|
||||
return Requests.JSONfetch(input, init);
|
||||
};
|
||||
|
||||
nopaque.requests.corpora.entity.followers.entity.role = {};
|
||||
Requests.corpora.entity.followers.entity.role = {};
|
||||
|
||||
nopaque.requests.corpora.entity.followers.entity.role.update = (corpusId, followerId, value) => {
|
||||
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 nopaque.requests.JSONfetch(input, init);
|
||||
return Requests.JSONfetch(input, init);
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
nopaque.requests = {};
|
||||
var Requests = {};
|
||||
|
||||
nopaque.requests.JSONfetch = (input, init={}) => {
|
||||
Requests.JSONfetch = (input, init={}) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let fixedInit = {};
|
||||
fixedInit.headers = {};
|
||||
@ -8,7 +8,7 @@ nopaque.requests.JSONfetch = (input, init={}) => {
|
||||
if (init.hasOwnProperty('body')) {
|
||||
fixedInit.headers['Content-Type'] = 'application/json';
|
||||
}
|
||||
fetch(input, nopaque.Utils.mergeObjectsDeep(init, fixedInit))
|
||||
fetch(input, Utils.mergeObjectsDeep(init, fixedInit))
|
||||
.then(
|
||||
(response) => {
|
||||
if (response.ok) {
|
||||
|
@ -1,30 +1,30 @@
|
||||
/*****************************************************************************
|
||||
* Requests for /jobs routes *
|
||||
*****************************************************************************/
|
||||
nopaque.requests.jobs = {};
|
||||
Requests.jobs = {};
|
||||
|
||||
nopaque.requests.jobs.entity = {};
|
||||
Requests.jobs.entity = {};
|
||||
|
||||
nopaque.requests.jobs.entity.delete = (jobId) => {
|
||||
Requests.jobs.entity.delete = (jobId) => {
|
||||
let input = `/jobs/${jobId}`;
|
||||
let init = {
|
||||
method: 'DELETE'
|
||||
};
|
||||
return nopaque.requests.JSONfetch(input, init);
|
||||
return Requests.JSONfetch(input, init);
|
||||
};
|
||||
|
||||
nopaque.requests.jobs.entity.log = (jobId) => {
|
||||
Requests.jobs.entity.log = (jobId) => {
|
||||
let input = `/jobs/${jobId}/log`;
|
||||
let init = {
|
||||
method: 'GET'
|
||||
};
|
||||
return nopaque.requests.JSONfetch(input, init);
|
||||
return Requests.JSONfetch(input, init);
|
||||
};
|
||||
|
||||
nopaque.requests.jobs.entity.restart = (jobId) => {
|
||||
Requests.jobs.entity.restart = (jobId) => {
|
||||
let input = `/jobs/${jobId}/restart`;
|
||||
let init = {
|
||||
method: 'POST'
|
||||
};
|
||||
return nopaque.requests.JSONfetch(input, init);
|
||||
return Requests.JSONfetch(input, init);
|
||||
};
|
||||
|
@ -2,50 +2,50 @@
|
||||
* Users *
|
||||
* Fetch requests for /users routes *
|
||||
*****************************************************************************/
|
||||
nopaque.requests.users = {};
|
||||
Requests.users = {};
|
||||
|
||||
nopaque.requests.users.entity = {};
|
||||
Requests.users.entity = {};
|
||||
|
||||
nopaque.requests.users.entity.delete = (userId) => {
|
||||
Requests.users.entity.delete = (userId) => {
|
||||
let input = `/users/${userId}`;
|
||||
let init = {
|
||||
method: 'DELETE'
|
||||
};
|
||||
return nopaque.requests.JSONfetch(input, init);
|
||||
return Requests.JSONfetch(input, init);
|
||||
};
|
||||
|
||||
nopaque.requests.users.entity.acceptTermsOfUse = () => {
|
||||
Requests.users.entity.acceptTermsOfUse = () => {
|
||||
let input = `/users/accept-terms-of-use`;
|
||||
let init = {
|
||||
method: 'POST'
|
||||
};
|
||||
return nopaque.requests.JSONfetch(input, init);
|
||||
return Requests.JSONfetch(input, init);
|
||||
};
|
||||
|
||||
nopaque.requests.users.entity.avatar = {};
|
||||
Requests.users.entity.avatar = {};
|
||||
|
||||
nopaque.requests.users.entity.avatar.delete = (userId) => {
|
||||
Requests.users.entity.avatar.delete = (userId) => {
|
||||
let input = `/users/${userId}/avatar`;
|
||||
let init = {
|
||||
method: 'DELETE'
|
||||
};
|
||||
return nopaque.requests.JSONfetch(input, init);
|
||||
return Requests.JSONfetch(input, init);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Requests for /users/<entity>/settings routes *
|
||||
*****************************************************************************/
|
||||
nopaque.requests.users.entity.settings = {};
|
||||
Requests.users.entity.settings = {};
|
||||
|
||||
nopaque.requests.users.entity.settings.profilePrivacy = {};
|
||||
Requests.users.entity.settings.profilePrivacy = {};
|
||||
|
||||
nopaque.requests.users.entity.settings.profilePrivacy.update = (userId, profilePrivacySetting, enabled) => {
|
||||
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 nopaque.requests.JSONfetch(input, init);
|
||||
return Requests.JSONfetch(input, init);
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
nopaque.resource_displays.CorpusDisplay = class CorpusDisplay extends nopaque.resource_displays.ResourceDisplay {
|
||||
ResourceDisplays.CorpusDisplay = class CorpusDisplay extends ResourceDisplays.ResourceDisplay {
|
||||
static htmlClass = 'corpus-display';
|
||||
|
||||
constructor(displayElement) {
|
||||
@ -7,7 +7,7 @@ nopaque.resource_displays.CorpusDisplay = class CorpusDisplay extends nopaque.re
|
||||
this.displayElement
|
||||
.querySelector('.action-button[data-action="build-request"]')
|
||||
.addEventListener('click', (event) => {
|
||||
nopaque.requests.corpora.entity.build(this.corpusId);
|
||||
Requests.corpora.entity.build(this.corpusId);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
nopaque.resource_displays = {};
|
||||
var ResourceDisplays = {};
|
||||
|
||||
nopaque.resource_displays.AutoInit = () => {
|
||||
for (let propertyName in nopaque.resource_displays) {
|
||||
let property = nopaque.resource_displays[propertyName];
|
||||
// Call autoInit of all properties that are subclasses of `nopaque.resource_displays.ResourceDisplay`.
|
||||
// This does not include `nopaque.resource_displays.ResourceDisplay` itself.
|
||||
if (property.prototype instanceof nopaque.resource_displays.ResourceDisplay) {
|
||||
ResourceDisplays.AutoInit = () => {
|
||||
for (let propertyName in ResourceDisplays) {
|
||||
let property = ResourceDisplays[propertyName];
|
||||
// Call autoInit of all properties that are subclasses of `ResourceDisplays.ResourceDisplay`.
|
||||
// This does not include `ResourceDisplays.ResourceDisplay` itself.
|
||||
if (property.prototype instanceof ResourceDisplays.ResourceDisplay) {
|
||||
// Check if the static `htmlClass` property is defined.
|
||||
if (property.htmlClass === undefined) {return;}
|
||||
// Gather all HTML elements that have the `this.htmlClass` class
|
||||
|
@ -1,4 +1,4 @@
|
||||
nopaque.resource_displays.JobDisplay = class JobDisplay extends nopaque.resource_displays.ResourceDisplay {
|
||||
ResourceDisplays.JobDisplay = class JobDisplay extends ResourceDisplays.ResourceDisplay {
|
||||
static htmlClass = 'job-display';
|
||||
|
||||
constructor(displayElement) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
nopaque.resource_displays.ResourceDisplay = class ResourceDisplay {
|
||||
ResourceDisplays.ResourceDisplay = class ResourceDisplay {
|
||||
static htmlClass;
|
||||
|
||||
constructor(displayElement) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
nopaque.resource_lists.AdminUserList = class AdminUserList extends nopaque.resource_lists.ResourceList {
|
||||
ResourceLists.AdminUserList = class AdminUserList extends ResourceLists.ResourceList {
|
||||
static htmlClass = 'admin-user-list';
|
||||
|
||||
constructor(listContainerElement, options = {}) {
|
||||
@ -37,9 +37,9 @@ nopaque.resource_lists.AdminUserList = class AdminUserList extends nopaque.resou
|
||||
|
||||
initListContainerElement() {
|
||||
if (!this.listContainerElement.hasAttribute('id')) {
|
||||
this.listContainerElement.id = nopaque.Utils.generateElementId('user-list-');
|
||||
this.listContainerElement.id = Utils.generateElementId('user-list-');
|
||||
}
|
||||
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
this.listContainerElement.innerHTML = `
|
||||
<div class="input-field">
|
||||
<i class="material-icons prefix">search</i>
|
||||
@ -87,7 +87,7 @@ nopaque.resource_lists.AdminUserList = class AdminUserList extends nopaque.resou
|
||||
let listAction = listActionElement === null ? 'view' : listActionElement.dataset.listAction;
|
||||
switch (listAction) {
|
||||
case 'delete': {
|
||||
nopaque.requests.users.entity.delete(itemId);
|
||||
Requests.users.entity.delete(itemId);
|
||||
if (itemId === currentUserId) {window.location.href = '/';}
|
||||
break;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
nopaque.resource_lists.CorpusFileList = class CorpusFileList extends nopaque.resource_lists.ResourceList {
|
||||
ResourceLists.CorpusFileList = class CorpusFileList extends ResourceLists.ResourceList {
|
||||
static htmlClass = 'corpus-file-list';
|
||||
|
||||
constructor(listContainerElement, options = {}) {
|
||||
@ -62,9 +62,9 @@ nopaque.resource_lists.CorpusFileList = class CorpusFileList extends nopaque.res
|
||||
|
||||
initListContainerElement() {
|
||||
if (!this.listContainerElement.hasAttribute('id')) {
|
||||
this.listContainerElement.id = nopaque.Utils.generateElementId('corpus-file-list-');
|
||||
this.listContainerElement.id = Utils.generateElementId('corpus-file-list-');
|
||||
}
|
||||
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
this.listContainerElement.innerHTML = `
|
||||
<div class="input-field">
|
||||
<i class="material-icons prefix">search</i>
|
||||
@ -121,7 +121,7 @@ nopaque.resource_lists.CorpusFileList = class CorpusFileList extends nopaque.res
|
||||
switch (listAction) {
|
||||
case 'delete': {
|
||||
let values = this.listjs.get('id', itemId)[0].values();
|
||||
let modalElement = nopaque.Utils.HTMLToElement(
|
||||
let modalElement = Utils.HTMLToElement(
|
||||
`
|
||||
<div class="modal">
|
||||
<div class="modal-content">
|
||||
@ -149,12 +149,12 @@ nopaque.resource_lists.CorpusFileList = class CorpusFileList extends nopaque.res
|
||||
let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]');
|
||||
confirmElement.addEventListener('click', (event) => {
|
||||
if (currentUserId != this.userId) {
|
||||
nopaque.requests.corpora.entity.files.ent.delete(this.corpusId, itemId)
|
||||
Requests.corpora.entity.files.ent.delete(this.corpusId, itemId)
|
||||
.then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
} else {
|
||||
nopaque.requests.corpora.entity.files.ent.delete(this.corpusId, itemId)
|
||||
Requests.corpora.entity.files.ent.delete(this.corpusId, itemId)
|
||||
}
|
||||
});
|
||||
modal.open();
|
||||
@ -208,7 +208,7 @@ nopaque.resource_lists.CorpusFileList = class CorpusFileList extends nopaque.res
|
||||
break;
|
||||
}
|
||||
case 'delete': {
|
||||
let modalElement = nopaque.Utils.HTMLToElement(
|
||||
let modalElement = Utils.HTMLToElement(
|
||||
`
|
||||
<div class="modal">
|
||||
<div class="modal-content">
|
||||
@ -229,7 +229,7 @@ nopaque.resource_lists.CorpusFileList = class CorpusFileList extends nopaque.res
|
||||
this.selectedItemIds.forEach(selectedItemId => {
|
||||
let listItem = this.listjs.get('id', selectedItemId)[0].elm;
|
||||
let values = this.listjs.get('id', listItem.dataset.id)[0].values();
|
||||
let itemElement = nopaque.Utils.HTMLToElement(`<li> - ${values.title}</li>`);
|
||||
let itemElement = Utils.HTMLToElement(`<li> - ${values.title}</li>`);
|
||||
itemList.appendChild(itemElement);
|
||||
});
|
||||
let modal = M.Modal.init(
|
||||
@ -246,12 +246,12 @@ nopaque.resource_lists.CorpusFileList = class CorpusFileList extends nopaque.res
|
||||
confirmElement.addEventListener('click', (event) => {
|
||||
this.selectedItemIds.forEach(selectedItemId => {
|
||||
if (currentUserId != this.userId) {
|
||||
nopaque.requests.corpora.entity.files.ent.delete(this.corpusId, selectedItemId)
|
||||
Requests.corpora.entity.files.ent.delete(this.corpusId, selectedItemId)
|
||||
.then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
} else {
|
||||
nopaque.requests.corpora.entity.files.ent.delete(this.corpusId, selectedItemId);
|
||||
Requests.corpora.entity.files.ent.delete(this.corpusId, selectedItemId);
|
||||
}
|
||||
});
|
||||
this.selectedItemIds.clear();
|
||||
|
@ -1,4 +1,4 @@
|
||||
nopaque.resource_lists.CorpusFollowerList = class CorpusFollowerList extends nopaque.resource_lists.ResourceList {
|
||||
ResourceLists.CorpusFollowerList = class CorpusFollowerList extends ResourceLists.ResourceList {
|
||||
static htmlClass = 'corpus-follower-list';
|
||||
|
||||
constructor(listContainerElement, options = {}) {
|
||||
@ -68,9 +68,9 @@ nopaque.resource_lists.CorpusFollowerList = class CorpusFollowerList extends nop
|
||||
|
||||
initListContainerElement() {
|
||||
if (!this.listContainerElement.hasAttribute('id')) {
|
||||
this.listContainerElement.id = nopaque.Utils.generateElementId('corpus-follower-list-');
|
||||
this.listContainerElement.id = Utils.generateElementId('corpus-follower-list-');
|
||||
}
|
||||
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
this.listContainerElement.innerHTML = `
|
||||
<div class="input-field">
|
||||
<i class="material-icons prefix">search</i>
|
||||
@ -120,7 +120,7 @@ nopaque.resource_lists.CorpusFollowerList = class CorpusFollowerList extends nop
|
||||
case 'update-role': {
|
||||
let followerId = listItemElement.dataset.followerId;
|
||||
let roleName = event.target.value;
|
||||
nopaque.requests.corpora.entity.followers.entity.role.update(this.corpusId, followerId, roleName);
|
||||
Requests.corpora.entity.followers.entity.role.update(this.corpusId, followerId, roleName);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@ -140,12 +140,12 @@ nopaque.resource_lists.CorpusFollowerList = class CorpusFollowerList extends nop
|
||||
case 'unfollow-request': {
|
||||
let followerId = listItemElement.dataset.followerId;
|
||||
if (currentUserId != this.userId) {
|
||||
nopaque.requests.corpora.entity.followers.entity.delete(this.corpusId, followerId)
|
||||
Requests.corpora.entity.followers.entity.delete(this.corpusId, followerId)
|
||||
.then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
} else {
|
||||
nopaque.requests.corpora.entity.followers.entity.delete(this.corpusId, followerId);
|
||||
Requests.corpora.entity.followers.entity.delete(this.corpusId, followerId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
nopaque.resource_lists.CorpusList = class CorpusList extends nopaque.resource_lists.ResourceList {
|
||||
ResourceLists.CorpusList = class CorpusList extends ResourceLists.ResourceList {
|
||||
static htmlClass = 'corpus-list';
|
||||
|
||||
constructor(listContainerElement, options = {}) {
|
||||
@ -93,9 +93,9 @@ nopaque.resource_lists.CorpusList = class CorpusList extends nopaque.resource_li
|
||||
|
||||
initListContainerElement() {
|
||||
if (!this.listContainerElement.hasAttribute('id')) {
|
||||
this.listContainerElement.id = nopaque.Utils.generateElementId('corpus-list-');
|
||||
this.listContainerElement.id = Utils.generateElementId('corpus-list-');
|
||||
}
|
||||
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
this.listContainerElement.innerHTML = `
|
||||
<div class="input-field">
|
||||
<i class="material-icons prefix">search</i>
|
||||
@ -139,7 +139,7 @@ nopaque.resource_lists.CorpusList = class CorpusList extends nopaque.resource_li
|
||||
switch (listAction) {
|
||||
case 'delete-request': {
|
||||
let values = this.listjs.get('id', itemId)[0].values();
|
||||
let modalElement = nopaque.Utils.HTMLToElement(
|
||||
let modalElement = Utils.HTMLToElement(
|
||||
`
|
||||
<div class="modal">
|
||||
<div class="modal-content">
|
||||
@ -167,12 +167,12 @@ nopaque.resource_lists.CorpusList = class CorpusList extends nopaque.resource_li
|
||||
let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]');
|
||||
confirmElement.addEventListener('click', (event) => {
|
||||
if (!values['is-owner']) {
|
||||
nopaque.requests.corpora.entity.followers.entity.delete(itemId, currentUserId)
|
||||
Requests.corpora.entity.followers.entity.delete(itemId, currentUserId)
|
||||
.then((response) => {
|
||||
window.location.reload();
|
||||
});
|
||||
} else {
|
||||
nopaque.requests.corpora.entity.delete(itemId);
|
||||
Requests.corpora.entity.delete(itemId);
|
||||
}
|
||||
});
|
||||
modal.open();
|
||||
@ -224,7 +224,7 @@ nopaque.resource_lists.CorpusList = class CorpusList extends nopaque.resource_li
|
||||
// Saved for future use:
|
||||
// <p class="hide">Do you really want to unfollow this Corpora?</p>
|
||||
// <ul id="selected-unfollow-items-list"></ul>
|
||||
let modalElement = nopaque.Utils.HTMLToElement(
|
||||
let modalElement = Utils.HTMLToElement(
|
||||
`
|
||||
<div class="modal">
|
||||
<div class="modal-content">
|
||||
@ -245,7 +245,7 @@ nopaque.resource_lists.CorpusList = class CorpusList extends nopaque.resource_li
|
||||
this.selectedItemIds.forEach(selectedItemId => {
|
||||
let listItem = this.listjs.get('id', selectedItemId)[0].elm;
|
||||
let values = this.listjs.get('id', listItem.dataset.id)[0].values();
|
||||
let itemElement = nopaque.Utils.HTMLToElement(`<li> - ${values.title}</li>`);
|
||||
let itemElement = Utils.HTMLToElement(`<li> - ${values.title}</li>`);
|
||||
// if (!values['is-owner']) {
|
||||
// itemUnfollowList.appendChild(itemElement);
|
||||
// } else {
|
||||
@ -268,9 +268,9 @@ nopaque.resource_lists.CorpusList = class CorpusList extends nopaque.resource_li
|
||||
let listItem = this.listjs.get('id', selectedItemId)[0].elm;
|
||||
let values = this.listjs.get('id', listItem.dataset.id)[0].values();
|
||||
if (values['is-owner']) {
|
||||
nopaque.requests.corpora.entity.delete(selectedItemId);
|
||||
Requests.corpora.entity.delete(selectedItemId);
|
||||
} else {
|
||||
nopaque.requests.corpora.entity.followers.entity.delete(selectedItemId, currentUserId);
|
||||
Requests.corpora.entity.followers.entity.delete(selectedItemId, currentUserId);
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 1000);
|
||||
|
@ -1,4 +1,4 @@
|
||||
nopaque.resource_lists.CorpusTextInfoList = class CorpusTextInfoList extends nopaque.resource_lists.ResourceList {
|
||||
ResourceLists.CorpusTextInfoList = class CorpusTextInfoList extends ResourceLists.ResourceList {
|
||||
static htmlClass = 'corpus-text-info-list';
|
||||
|
||||
static defaultOptions = {
|
||||
@ -6,8 +6,8 @@ nopaque.resource_lists.CorpusTextInfoList = class CorpusTextInfoList extends nop
|
||||
};
|
||||
|
||||
constructor(listContainerElement, options = {}) {
|
||||
let _options = nopaque.Utils.mergeObjectsDeep(
|
||||
nopaque.resource_lists.CorpusTextInfoList.defaultOptions,
|
||||
let _options = Utils.mergeObjectsDeep(
|
||||
ResourceLists.CorpusTextInfoList.defaultOptions,
|
||||
options
|
||||
);
|
||||
super(listContainerElement, _options);
|
||||
@ -49,9 +49,9 @@ nopaque.resource_lists.CorpusTextInfoList = class CorpusTextInfoList extends nop
|
||||
|
||||
initListContainerElement() {
|
||||
if (!this.listContainerElement.hasAttribute('id')) {
|
||||
this.listContainerElement.id = nopaque.Utils.generateElementId('corpus-file-list-');
|
||||
this.listContainerElement.id = Utils.generateElementId('corpus-file-list-');
|
||||
}
|
||||
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
this.listContainerElement.innerHTML = `
|
||||
<div class="input-field">
|
||||
<i class="material-icons prefix">search</i>
|
||||
|
@ -1,4 +1,4 @@
|
||||
nopaque.resource_lists.CorpusTokenList = class CorpusTokenList extends nopaque.resource_lists.ResourceList {
|
||||
ResourceLists.CorpusTokenList = class CorpusTokenList extends ResourceLists.ResourceList {
|
||||
static htmlClass = 'corpus-token-list';
|
||||
|
||||
static defaultOptions = {
|
||||
@ -6,8 +6,8 @@ nopaque.resource_lists.CorpusTokenList = class CorpusTokenList extends nopaque.r
|
||||
};
|
||||
|
||||
constructor(listContainerElement, options = {}) {
|
||||
let _options = nopaque.Utils.mergeObjectsDeep(
|
||||
nopaque.resource_lists.CorpusTokenList.defaultOptions,
|
||||
let _options = Utils.mergeObjectsDeep(
|
||||
ResourceLists.CorpusTokenList.defaultOptions,
|
||||
options
|
||||
);
|
||||
super(listContainerElement, _options);
|
||||
@ -72,9 +72,9 @@ nopaque.resource_lists.CorpusTokenList = class CorpusTokenList extends nopaque.r
|
||||
|
||||
initListContainerElement() {
|
||||
if (!this.listContainerElement.hasAttribute('id')) {
|
||||
this.listContainerElement.id = nopaque.Utils.generateElementId('corpus-token-list-');
|
||||
this.listContainerElement.id = Utils.generateElementId('corpus-token-list-');
|
||||
}
|
||||
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
this.listContainerElement.innerHTML = `
|
||||
<div class="input-field">
|
||||
<i class="material-icons prefix">search</i>
|
||||
|
@ -1,4 +1,4 @@
|
||||
nopaque.resource_lists.DetailedPublicCorpusList = class DetailedPublicCorpusList extends nopaque.resource_lists.ResourceList {
|
||||
ResourceLists.DetailedPublicCorpusList = class DetailedPublicCorpusList extends ResourceLists.ResourceList {
|
||||
static htmlClass = 'detailed-public-corpus-list';
|
||||
|
||||
get item() {
|
||||
@ -32,9 +32,9 @@ nopaque.resource_lists.DetailedPublicCorpusList = class DetailedPublicCorpusList
|
||||
|
||||
initListContainerElement() {
|
||||
if (!this.listContainerElement.hasAttribute('id')) {
|
||||
this.listContainerElement.id = nopaque.Utils.generateElementId('corpus-list-');
|
||||
this.listContainerElement.id = Utils.generateElementId('corpus-list-');
|
||||
}
|
||||
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
this.listContainerElement.innerHTML = `
|
||||
<div class="input-field">
|
||||
<i class="material-icons prefix">search</i>
|
||||
|
@ -1,11 +1,11 @@
|
||||
nopaque.resource_lists = {};
|
||||
var ResourceLists = {};
|
||||
|
||||
nopaque.resource_lists.AutoInit = () => {
|
||||
for (let propertyName in nopaque.resource_lists) {
|
||||
let property = nopaque.resource_lists[propertyName];
|
||||
// Call autoInit of all properties that are subclasses of `nopaque.resource_lists.ResourceList`.
|
||||
// This does not include `nopaque.resource_lists.ResourceList` itself.
|
||||
if (property.prototype instanceof nopaque.resource_lists.ResourceList) {
|
||||
ResourceLists.AutoInit = () => {
|
||||
for (let propertyName in ResourceLists) {
|
||||
let property = ResourceLists[propertyName];
|
||||
// Call autoInit of all properties that are subclasses of `ResourceLists.ResourceList`.
|
||||
// This does not include `ResourceLists.ResourceList` itself.
|
||||
if (property.prototype instanceof ResourceLists.ResourceList) {
|
||||
// Check if the static `htmlClass` property is defined.
|
||||
if (property.htmlClass === undefined) {return;}
|
||||
// Gather all HTML elements that have the `this.htmlClass` class
|
||||
|
@ -1,4 +1,4 @@
|
||||
nopaque.resource_lists.JobInputList = class JobInputList extends nopaque.resource_lists.ResourceList {
|
||||
ResourceLists.JobInputList = class JobInputList extends ResourceLists.ResourceList {
|
||||
static htmlClass = 'job-input-list';
|
||||
|
||||
constructor(listContainerElement, options = {}) {
|
||||
@ -36,9 +36,9 @@ nopaque.resource_lists.JobInputList = class JobInputList extends nopaque.resourc
|
||||
|
||||
initListContainerElement() {
|
||||
if (!this.listContainerElement.hasAttribute('id')) {
|
||||
this.listContainerElement.id = nopaque.Utils.generateElementId('job-input-list-');
|
||||
this.listContainerElement.id = Utils.generateElementId('job-input-list-');
|
||||
}
|
||||
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
this.listContainerElement.innerHTML = `
|
||||
<div class="input-field">
|
||||
<i class="material-icons prefix">search</i>
|
||||
|
@ -1,4 +1,4 @@
|
||||
nopaque.resource_lists.JobList = class JobList extends nopaque.resource_lists.ResourceList {
|
||||
ResourceLists.JobList = class JobList extends ResourceLists.ResourceList {
|
||||
static htmlClass = 'job-list';
|
||||
|
||||
constructor(listContainerElement, options = {}) {
|
||||
@ -56,9 +56,9 @@ nopaque.resource_lists.JobList = class JobList extends nopaque.resource_lists.Re
|
||||
|
||||
initListContainerElement() {
|
||||
if (!this.listContainerElement.hasAttribute('id')) {
|
||||
this.listContainerElement.id = nopaque.Utils.generateElementId('job-list-');
|
||||
this.listContainerElement.id = Utils.generateElementId('job-list-');
|
||||
}
|
||||
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
this.listContainerElement.innerHTML = `
|
||||
<div class="input-field">
|
||||
<i class="material-icons prefix">search</i>
|
||||
@ -112,7 +112,7 @@ nopaque.resource_lists.JobList = class JobList extends nopaque.resource_lists.Re
|
||||
switch (listAction) {
|
||||
case 'delete-request': {
|
||||
let values = this.listjs.get('id', itemId)[0].values();
|
||||
let modalElement = nopaque.Utils.HTMLToElement(
|
||||
let modalElement = Utils.HTMLToElement(
|
||||
`
|
||||
<div class="modal">
|
||||
<div class="modal-content">
|
||||
@ -139,7 +139,7 @@ nopaque.resource_lists.JobList = class JobList extends nopaque.resource_lists.Re
|
||||
);
|
||||
let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]');
|
||||
confirmElement.addEventListener('click', (event) => {
|
||||
nopaque.requests.jobs.entity.delete(itemId);
|
||||
Requests.jobs.entity.delete(itemId);
|
||||
});
|
||||
modal.open();
|
||||
break;
|
||||
@ -187,7 +187,7 @@ nopaque.resource_lists.JobList = class JobList extends nopaque.resource_lists.Re
|
||||
break;
|
||||
}
|
||||
case 'delete': {
|
||||
let modalElement = nopaque.Utils.HTMLToElement(
|
||||
let modalElement = Utils.HTMLToElement(
|
||||
`
|
||||
<div class="modal">
|
||||
<div class="modal-content">
|
||||
@ -208,7 +208,7 @@ nopaque.resource_lists.JobList = class JobList extends nopaque.resource_lists.Re
|
||||
this.selectedItemIds.forEach(selectedItemId => {
|
||||
let listItem = this.listjs.get('id', selectedItemId)[0].elm;
|
||||
let values = this.listjs.get('id', listItem.dataset.id)[0].values();
|
||||
let itemElement = nopaque.Utils.HTMLToElement(`<li> - ${values.title}</li>`);
|
||||
let itemElement = Utils.HTMLToElement(`<li> - ${values.title}</li>`);
|
||||
itemList.appendChild(itemElement);
|
||||
});
|
||||
let modal = M.Modal.init(
|
||||
@ -224,7 +224,7 @@ nopaque.resource_lists.JobList = class JobList extends nopaque.resource_lists.Re
|
||||
let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]');
|
||||
confirmElement.addEventListener('click', (event) => {
|
||||
this.selectedItemIds.forEach(selectedItemId => {
|
||||
nopaque.requests.jobs.entity.delete(selectedItemId);
|
||||
Requests.jobs.entity.delete(selectedItemId);
|
||||
});
|
||||
this.selectedItemIds.clear();
|
||||
this.renderingItemSelection();
|
||||
|
@ -1,4 +1,4 @@
|
||||
nopaque.resource_lists.JobResultList = class JobResultList extends nopaque.resource_lists.ResourceList {
|
||||
ResourceLists.JobResultList = class JobResultList extends ResourceLists.ResourceList {
|
||||
static htmlClass = 'job-result-list';
|
||||
|
||||
constructor(listContainerElement, options = {}) {
|
||||
@ -42,9 +42,9 @@ nopaque.resource_lists.JobResultList = class JobResultList extends nopaque.resou
|
||||
|
||||
initListContainerElement() {
|
||||
if (!this.listContainerElement.hasAttribute('id')) {
|
||||
this.listContainerElement.id = nopaque.Utils.generateElementId('job-result-list-');
|
||||
this.listContainerElement.id = Utils.generateElementId('job-result-list-');
|
||||
}
|
||||
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
this.listContainerElement.innerHTML = `
|
||||
<div class="input-field">
|
||||
<i class="material-icons prefix">search</i>
|
||||
|
@ -1,4 +1,4 @@
|
||||
nopaque.resource_lists.PublicCorpusList = class PublicCorpusList extends nopaque.resource_lists.ResourceList {
|
||||
ResourceLists.PublicCorpusList = class PublicCorpusList extends ResourceLists.ResourceList {
|
||||
static htmlClass = 'public-corpus-list';
|
||||
|
||||
constructor(listContainerElement, options = {}) {
|
||||
@ -49,9 +49,9 @@ nopaque.resource_lists.PublicCorpusList = class PublicCorpusList extends nopaque
|
||||
|
||||
initListContainerElement() {
|
||||
if (!this.listContainerElement.hasAttribute('id')) {
|
||||
this.listContainerElement.id = nopaque.Utils.generateElementId('corpus-list-');
|
||||
this.listContainerElement.id = Utils.generateElementId('corpus-list-');
|
||||
}
|
||||
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
this.listContainerElement.innerHTML = `
|
||||
<div class="input-field">
|
||||
<i class="material-icons prefix">search</i>
|
||||
|
@ -1,4 +1,4 @@
|
||||
nopaque.resource_lists.PublicUserList = class PublicUserList extends nopaque.resource_lists.ResourceList {
|
||||
ResourceLists.PublicUserList = class PublicUserList extends ResourceLists.ResourceList {
|
||||
static htmlClass = 'public-user-list';
|
||||
|
||||
constructor(listContainerElement, options = {}) {
|
||||
@ -37,9 +37,9 @@ nopaque.resource_lists.PublicUserList = class PublicUserList extends nopaque.res
|
||||
|
||||
initListContainerElement() {
|
||||
if (!this.listContainerElement.hasAttribute('id')) {
|
||||
this.listContainerElement.id = nopaque.Utils.generateElementId('user-list-');
|
||||
this.listContainerElement.id = Utils.generateElementId('user-list-');
|
||||
}
|
||||
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
this.listContainerElement.innerHTML = `
|
||||
<div class="input-field">
|
||||
<i class="material-icons prefix">search</i>
|
||||
|
@ -1,4 +1,4 @@
|
||||
nopaque.resource_lists.ResourceList = class ResourceList {
|
||||
ResourceLists.ResourceList = class ResourceList {
|
||||
/* A wrapper class for the list.js list.
|
||||
* This class is not meant to be used directly, instead it should be used as
|
||||
* a base class for concrete resource list implementations.
|
||||
@ -21,9 +21,9 @@ nopaque.resource_lists.ResourceList = class ResourceList {
|
||||
if ('valueNames' in options) {
|
||||
throw '"valueNames" is not supported as an option, define it as a getter in the list class';
|
||||
}
|
||||
let _options = nopaque.Utils.mergeObjectsDeep(
|
||||
let _options = Utils.mergeObjectsDeep(
|
||||
{item: this.item, valueNames: this.valueNames},
|
||||
nopaque.resource_lists.ResourceList.defaultOptions,
|
||||
ResourceLists.ResourceList.defaultOptions,
|
||||
options
|
||||
);
|
||||
this.listContainerElement = listContainerElement;
|
||||
|
@ -1,4 +1,4 @@
|
||||
nopaque.resource_lists.SpaCyNLPPipelineModelList = class SpaCyNLPPipelineModelList extends nopaque.resource_lists.ResourceList {
|
||||
ResourceLists.SpaCyNLPPipelineModelList = class SpaCyNLPPipelineModelList extends ResourceLists.ResourceList {
|
||||
static htmlClass = 'spacy-nlp-pipeline-model-list';
|
||||
|
||||
constructor(listContainerElement, options = {}) {
|
||||
@ -60,9 +60,9 @@ nopaque.resource_lists.SpaCyNLPPipelineModelList = class SpaCyNLPPipelineModelLi
|
||||
|
||||
initListContainerElement() {
|
||||
if (!this.listContainerElement.hasAttribute('id')) {
|
||||
this.listContainerElement.id = nopaque.Utils.generateElementId('spacy-nlp-pipeline-model-list-');
|
||||
this.listContainerElement.id = Utils.generateElementId('spacy-nlp-pipeline-model-list-');
|
||||
}
|
||||
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
this.listContainerElement.innerHTML = `
|
||||
<div class="input-field">
|
||||
<i class="material-icons prefix">search</i>
|
||||
@ -116,7 +116,7 @@ nopaque.resource_lists.SpaCyNLPPipelineModelList = class SpaCyNLPPipelineModelLi
|
||||
switch (listAction) {
|
||||
case 'toggle-is-public': {
|
||||
let newIsPublicValue = listActionElement.checked;
|
||||
nopaque.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;
|
||||
});
|
||||
@ -138,7 +138,7 @@ nopaque.resource_lists.SpaCyNLPPipelineModelList = class SpaCyNLPPipelineModelLi
|
||||
switch (listAction) {
|
||||
case 'delete-request': {
|
||||
let values = this.listjs.get('id', itemId)[0].values();
|
||||
let modalElement = nopaque.Utils.HTMLToElement(
|
||||
let modalElement = Utils.HTMLToElement(
|
||||
`
|
||||
<div class="modal">
|
||||
<div class="modal-content">
|
||||
@ -165,7 +165,7 @@ nopaque.resource_lists.SpaCyNLPPipelineModelList = class SpaCyNLPPipelineModelLi
|
||||
);
|
||||
let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]');
|
||||
confirmElement.addEventListener('click', (event) => {
|
||||
nopaque.requests.contributions.spacy_nlp_pipeline_models.entity.delete(itemId);
|
||||
Requests.contributions.spacy_nlp_pipeline_models.entity.delete(itemId);
|
||||
});
|
||||
modal.open();
|
||||
break;
|
||||
|
@ -1,4 +1,4 @@
|
||||
nopaque.resource_lists.TesseractOCRPipelineModelList = class TesseractOCRPipelineModelList extends nopaque.resource_lists.ResourceList {
|
||||
ResourceLists.TesseractOCRPipelineModelList = class TesseractOCRPipelineModelList extends ResourceLists.ResourceList {
|
||||
static htmlClass = 'tesseract-ocr-pipeline-model-list';
|
||||
|
||||
constructor(listContainerElement, options = {}) {
|
||||
@ -69,9 +69,9 @@ nopaque.resource_lists.TesseractOCRPipelineModelList = class TesseractOCRPipelin
|
||||
|
||||
initListContainerElement() {
|
||||
if (!this.listContainerElement.hasAttribute('id')) {
|
||||
this.listContainerElement.id = nopaque.Utils.generateElementId('tesseract-ocr-pipeline-model-list-');
|
||||
this.listContainerElement.id = Utils.generateElementId('tesseract-ocr-pipeline-model-list-');
|
||||
}
|
||||
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||
this.listContainerElement.innerHTML = `
|
||||
<div class="input-field">
|
||||
<i class="material-icons prefix">search</i>
|
||||
@ -125,7 +125,7 @@ nopaque.resource_lists.TesseractOCRPipelineModelList = class TesseractOCRPipelin
|
||||
switch (listAction) {
|
||||
case 'toggle-is-public': {
|
||||
let newIsPublicValue = listActionElement.checked;
|
||||
nopaque.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;
|
||||
});
|
||||
@ -147,7 +147,7 @@ nopaque.resource_lists.TesseractOCRPipelineModelList = class TesseractOCRPipelin
|
||||
switch (listAction) {
|
||||
case 'delete-request': {
|
||||
let values = this.listjs.get('id', itemId)[0].values();
|
||||
let modalElement = nopaque.Utils.HTMLToElement(
|
||||
let modalElement = Utils.HTMLToElement(
|
||||
`
|
||||
<div class="modal">
|
||||
<div class="modal-content">
|
||||
@ -174,7 +174,7 @@ nopaque.resource_lists.TesseractOCRPipelineModelList = class TesseractOCRPipelin
|
||||
);
|
||||
let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]');
|
||||
confirmElement.addEventListener('click', (event) => {
|
||||
nopaque.requests.contributions.tesseract_ocr_pipeline_models.entity.delete(itemId);
|
||||
Requests.contributions.tesseract_ocr_pipeline_models.entity.delete(itemId);
|
||||
});
|
||||
modal.open();
|
||||
break;
|
||||
|
@ -1,91 +0,0 @@
|
||||
nopaque.Utils = class Utils {
|
||||
static escape(text) {
|
||||
// https://codereview.stackexchange.com/a/126722
|
||||
let lookup = {
|
||||
'<': 'lt',
|
||||
'>': 'gt',
|
||||
'"': 'quot',
|
||||
'\'': 'apos',
|
||||
'&': 'amp',
|
||||
'\r': '#10',
|
||||
'\n': '#13'
|
||||
};
|
||||
|
||||
return text.toString().replace(/[<>"'\r\n&]/g, (chr) => {
|
||||
return '&' + lookup[chr] + ';';
|
||||
});
|
||||
}
|
||||
|
||||
static unescape(escapedText) {
|
||||
let lookup = {
|
||||
'lt': '<',
|
||||
'gt': '>',
|
||||
'quot': '"',
|
||||
'apos': "'",
|
||||
'amp': '&',
|
||||
'#10': '\r',
|
||||
'#13': '\n'
|
||||
};
|
||||
|
||||
return escapedText.replace(/&(#?\w+);/g, (match, entity) => {
|
||||
if (lookup.hasOwnProperty(entity)) {
|
||||
return lookup[entity];
|
||||
}
|
||||
|
||||
return match;
|
||||
});
|
||||
}
|
||||
|
||||
static HTMLToElement(HTMLString) {
|
||||
let templateElement = document.createElement('template');
|
||||
templateElement.innerHTML = HTMLString.trim();
|
||||
return templateElement.content.firstChild;
|
||||
}
|
||||
|
||||
static generateElementId(prefix='', suffix='') {
|
||||
for (let i = 0; true; i++) {
|
||||
if (document.querySelector(`#${prefix}${i}${suffix}`) !== null) {continue;}
|
||||
return `${prefix}${i}${suffix}`;
|
||||
}
|
||||
}
|
||||
|
||||
static isObject(object) {
|
||||
return object !== null && typeof object === 'object' && !Array.isArray(object);
|
||||
}
|
||||
|
||||
static mergeObjectsDeep(...objects) {
|
||||
let mergedObject = {};
|
||||
if (objects.length === 0) {
|
||||
return mergedObject;
|
||||
}
|
||||
if (!this.isObject(objects[0])) {throw 'Cannot merge non-object';}
|
||||
if (objects.length === 1) {
|
||||
return this.mergeObjectsDeep(mergedObject, objects[0]);
|
||||
}
|
||||
if (!this.isObject(objects[1])) {throw 'Cannot merge non-object';}
|
||||
for (let key in objects[0]) {
|
||||
if (objects[0].hasOwnProperty(key)) {
|
||||
if (objects[1].hasOwnProperty(key)) {
|
||||
if (this.isObject(objects[0][key]) && this.isObject(objects[1][key])) {
|
||||
mergedObject[key] = this.mergeObjectsDeep(objects[0][key], objects[1][key]);
|
||||
} else {
|
||||
mergedObject[key] = objects[1][key];
|
||||
}
|
||||
} else {
|
||||
mergedObject[key] = objects[0][key];
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let key in objects[1]) {
|
||||
if (objects[1].hasOwnProperty(key)) {
|
||||
if (!objects[0].hasOwnProperty(key)) {
|
||||
mergedObject[key] = objects[1][key];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (objects.length === 2) {
|
||||
return mergedObject;
|
||||
}
|
||||
return this.mergeObjectsDeep(mergedObject, ...objects.slice(2));
|
||||
}
|
||||
}
|
1
app/static/js/utils/index.js
Normal file
1
app/static/js/utils/index.js
Normal file
@ -0,0 +1 @@
|
||||
Utils = {};
|
89
app/static/js/utils/utils.js
Normal file
89
app/static/js/utils/utils.js
Normal file
@ -0,0 +1,89 @@
|
||||
Utils.escape = (text) => {
|
||||
// https://codereview.stackexchange.com/a/126722
|
||||
var table = {
|
||||
'<': 'lt',
|
||||
'>': 'gt',
|
||||
'"': 'quot',
|
||||
'\'': 'apos',
|
||||
'&': 'amp',
|
||||
'\r': '#10',
|
||||
'\n': '#13'
|
||||
};
|
||||
|
||||
return text.toString().replace(/[<>"'\r\n&]/g, (chr) => {
|
||||
return '&' + table[chr] + ';';
|
||||
});
|
||||
};
|
||||
|
||||
Utils.unescape = (escapedText) => {
|
||||
var table = {
|
||||
'lt': '<',
|
||||
'gt': '>',
|
||||
'quot': '"',
|
||||
'apos': "'",
|
||||
'amp': '&',
|
||||
'#10': '\r',
|
||||
'#13': '\n'
|
||||
};
|
||||
|
||||
return escapedText.replace(/&(#?\w+);/g, (match, entity) => {
|
||||
if (table.hasOwnProperty(entity)) {
|
||||
return table[entity];
|
||||
}
|
||||
|
||||
return match;
|
||||
});
|
||||
};
|
||||
|
||||
Utils.HTMLToElement = (HTMLString) => {
|
||||
let templateElement = document.createElement('template');
|
||||
templateElement.innerHTML = HTMLString.trim();
|
||||
return templateElement.content.firstChild;
|
||||
};
|
||||
|
||||
Utils.generateElementId = (prefix='', suffix='') => {
|
||||
for (let i = 0; true; i++) {
|
||||
if (document.querySelector(`#${prefix}${i}${suffix}`) !== null) {continue;}
|
||||
return `${prefix}${i}${suffix}`;
|
||||
}
|
||||
};
|
||||
|
||||
Utils.isObject = (object) => {
|
||||
return object !== null && typeof object === 'object' && !Array.isArray(object);
|
||||
};
|
||||
|
||||
Utils.mergeObjectsDeep = (...objects) => {
|
||||
let mergedObject = {};
|
||||
if (objects.length === 0) {
|
||||
return mergedObject;
|
||||
}
|
||||
if (!Utils.isObject(objects[0])) {throw 'Cannot merge non-object';}
|
||||
if (objects.length === 1) {
|
||||
return Utils.mergeObjectsDeep(mergedObject, objects[0]);
|
||||
}
|
||||
if (!Utils.isObject(objects[1])) {throw 'Cannot merge non-object';}
|
||||
for (let key in objects[0]) {
|
||||
if (objects[0].hasOwnProperty(key)) {
|
||||
if (objects[1].hasOwnProperty(key)) {
|
||||
if (Utils.isObject(objects[0][key]) && Utils.isObject(objects[1][key])) {
|
||||
mergedObject[key] = Utils.mergeObjectsDeep(objects[0][key], objects[1][key]);
|
||||
} else {
|
||||
mergedObject[key] = objects[1][key];
|
||||
}
|
||||
} else {
|
||||
mergedObject[key] = objects[0][key];
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let key in objects[1]) {
|
||||
if (objects[1].hasOwnProperty(key)) {
|
||||
if (!objects[0].hasOwnProperty(key)) {
|
||||
mergedObject[key] = objects[1][key];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (objects.length === 2) {
|
||||
return mergedObject;
|
||||
}
|
||||
return Utils.mergeObjectsDeep(mergedObject, ...objects.slice(2));
|
||||
};
|
@ -7,9 +7,17 @@
|
||||
{%- assets
|
||||
filters='rjsmin',
|
||||
output='gen/app.%(version)s.js',
|
||||
'js/index.js',
|
||||
'js/app.js',
|
||||
'js/utils.js'
|
||||
'js/nopaque/index.js',
|
||||
'js/nopaque/app.js'
|
||||
%}
|
||||
<script src="{{ ASSET_URL }}"></script>
|
||||
{%- endassets %}
|
||||
|
||||
{%- assets
|
||||
filters='rjsmin',
|
||||
output='gen/utils.%(version)s.js',
|
||||
'js/utils/index.js',
|
||||
'js/utils/utils.js'
|
||||
%}
|
||||
<script src="{{ ASSET_URL }}"></script>
|
||||
{%- endassets %}
|
||||
|
@ -17,7 +17,7 @@
|
||||
{{ super() }}
|
||||
<script>
|
||||
let corpusListElement = document.querySelector('#corpus-list');
|
||||
let corpusList = new nopaque.resource_lists.CorpusList(corpusListElement);
|
||||
let corpusList = new ResourceLists.CorpusList(corpusListElement);
|
||||
corpusList.add(
|
||||
[
|
||||
{% for corpus in corpora %}
|
||||
|
@ -57,7 +57,7 @@
|
||||
let userConfirmedSwitchElement = document.querySelector('#user-confirmed-switch');
|
||||
userConfirmedSwitchElement.addEventListener('change', (event) => {
|
||||
let newConfirmed = userConfirmedSwitchElement.checked;
|
||||
nopaque.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;
|
||||
});
|
||||
|
@ -22,7 +22,7 @@
|
||||
{{ super() }}
|
||||
<script>
|
||||
let adminUserListElement = document.querySelector('#admin-user-list');
|
||||
let adminUserList = new nopaque.resource_lists.AdminUserList(adminUserListElement);
|
||||
let adminUserList = new ResourceLists.AdminUserList(adminUserListElement);
|
||||
adminUserList.add(
|
||||
[
|
||||
{% for user in users %}
|
||||
|
@ -240,7 +240,7 @@
|
||||
{% if current_user.is_following_corpus(corpus) %}
|
||||
let unfollowRequestElement = document.querySelector('.action-button[data-action="unfollow-request"]');
|
||||
unfollowRequestElement.addEventListener('click', () => {
|
||||
nopaque.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();
|
||||
});
|
||||
@ -252,7 +252,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)
|
||||
Requests.corpora.entity.isPublic.update({{ corpus.hashid|tojson }}, newIsPublic)
|
||||
.catch((response) => {
|
||||
publishingModalIsPublicSwitchElement.checked = !newIsPublic;
|
||||
});
|
||||
@ -262,7 +262,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 }})
|
||||
Requests.corpora.entity.delete({{ corpus.hashid|tojson }})
|
||||
.then((response) => {
|
||||
window.location.href = {{ url_for('main.dashboard')|tojson }};
|
||||
});
|
||||
@ -312,7 +312,7 @@ M.Modal.init(
|
||||
|
||||
inviteUserModalInviteButtonElement.addEventListener('click', (event) => {
|
||||
let usernames = inviteUserModalSearch.chipsData.map((chipData) => chipData.tag);
|
||||
nopaque.requests.corpora.entity.followers.add({{ corpus.hashid|tojson }}, usernames);
|
||||
Requests.corpora.entity.followers.add({{ corpus.hashid|tojson }}, usernames);
|
||||
});
|
||||
// #endregion Invite user
|
||||
|
||||
@ -357,7 +357,7 @@ 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)
|
||||
Requests.corpora.entity.generateShareLink({{ corpus.hashid|tojson }}, role, expiration)
|
||||
.then((response) => {
|
||||
response.json()
|
||||
.then((json) => {
|
||||
|
@ -242,7 +242,7 @@
|
||||
{{ super() }}
|
||||
<script>
|
||||
|
||||
let publicCorpusFileList = new nopaque.resource_lists.CorpusFileList(document.querySelector('#corpus-file-list'));
|
||||
let publicCorpusFileList = new ResourceLists.CorpusFileList(document.querySelector('#corpus-file-list'));
|
||||
publicCorpusFileList.add(
|
||||
[
|
||||
{% for corpus_file in corpus.files %}
|
||||
@ -259,7 +259,7 @@ refreshButton.addEventListener('click', () => {
|
||||
{% endif %}
|
||||
|
||||
{% if cfr.has_permission('MANAGE_FOLLOWERS') %}
|
||||
let publicCorpusFollowerList = new nopaque.resource_lists.CorpusFollowerList(document.querySelector('.corpus-follower-list'));
|
||||
let publicCorpusFollowerList = new ResourceLists.CorpusFollowerList(document.querySelector('.corpus-follower-list'));
|
||||
publicCorpusFollowerList.add(
|
||||
[
|
||||
{% for cfa in cfas %}
|
||||
|
@ -50,6 +50,7 @@
|
||||
<p>Find public corpora.</p>
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<span class="card-title">Public Corpora</span>
|
||||
<div id="public-corpus-list"></div>
|
||||
</div>
|
||||
</div>
|
||||
@ -62,7 +63,7 @@
|
||||
{{ super() }}
|
||||
<script>
|
||||
let publicUserListElement = document.querySelector('#public-user-list');
|
||||
let publicUserList = new nopaque.resource_lists.PublicUserList(publicUserListElement);
|
||||
let publicUserList = new ResourceLists.PublicUserList(publicUserListElement);
|
||||
publicUserList.add(
|
||||
[
|
||||
{% for user in users %}
|
||||
@ -72,7 +73,7 @@
|
||||
);
|
||||
|
||||
let publicCorpusListElement = document.querySelector('#public-corpus-list');
|
||||
let publicCorpusList = new nopaque.resource_lists.PublicCorpusList(publicCorpusListElement);
|
||||
let publicCorpusList = new ResourceLists.PublicCorpusList(publicCorpusListElement);
|
||||
publicCorpusList.add(
|
||||
[
|
||||
{% for corpus in corpora %}
|
||||
|
@ -221,7 +221,7 @@ avatarUploadElement.addEventListener('change', () => {
|
||||
});
|
||||
|
||||
document.querySelector('#delete-avatar').addEventListener('click', () => {
|
||||
nopaque.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) => {
|
||||
nopaque.requests.users.entity.delete({{ user.hashid|tojson }})
|
||||
Requests.users.entity.delete({{ user.hashid|tojson }})
|
||||
.then((response) => {window.location.href = '/';});
|
||||
});
|
||||
|
||||
@ -255,7 +255,7 @@ let profileIsPublicSwitchElement = document.querySelector('#profile-is-public-sw
|
||||
let profilePrivacySettingCheckboxElements = document.querySelectorAll('.profile-privacy-setting-checkbox');
|
||||
profileIsPublicSwitchElement.addEventListener('change', (event) => {
|
||||
let newEnabled = profileIsPublicSwitchElement.checked;
|
||||
nopaque.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;
|
||||
nopaque.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;
|
||||
});
|
||||
|
@ -122,7 +122,7 @@
|
||||
{% block scripts %}
|
||||
{{ super() }}
|
||||
<script>
|
||||
let followedCorpusList = new nopaque.resource_lists.PublicCorpusList(document.querySelector('.followed-corpus-list'));
|
||||
let followedCorpusList = new ResourceLists.PublicCorpusList(document.querySelector('.followed-corpus-list'));
|
||||
followedCorpusList.add(
|
||||
[
|
||||
{% for corpus in user.followed_corpora %}
|
||||
@ -132,7 +132,7 @@ followedCorpusList.add(
|
||||
{% endfor %}
|
||||
]
|
||||
);
|
||||
let publicCorpusList = new nopaque.resource_lists.PublicCorpusList(document.querySelector('.public-corpus-list'));
|
||||
let publicCorpusList = new ResourceLists.PublicCorpusList(document.querySelector('.public-corpus-list'));
|
||||
publicCorpusList.add(
|
||||
[
|
||||
{% for corpus in user.corpora %}
|
||||
|
Loading…
Reference in New Issue
Block a user