mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-14 16:55:42 +00:00
Merge branch 'query-builder' of gitlab.ub.uni-bielefeld.de:sfb1288inf/nopaque into query-builder
This commit is contained in:
commit
bf8b22fb58
@ -30,7 +30,7 @@ class CorpusAnalysisApp {
|
|||||||
// Setup CQi over SocketIO connection and gather data from the CQPServer
|
// Setup CQi over SocketIO connection and gather data from the CQPServer
|
||||||
const statusTextElement = this.elements.initModal.querySelector('.status-text');
|
const statusTextElement = this.elements.initModal.querySelector('.status-text');
|
||||||
statusTextElement.innerText = 'Creating CQi over SocketIO client...';
|
statusTextElement.innerText = 'Creating CQi over SocketIO client...';
|
||||||
const cqiClient = new cqi.Client('/cqi_over_sio');
|
const cqiClient = new nopaque.corpus_analysis.cqi.Client('/cqi_over_sio');
|
||||||
statusTextElement.innerText += ' Done';
|
statusTextElement.innerText += ' Done';
|
||||||
statusTextElement.innerHTML = 'Waiting for the CQP server...';
|
statusTextElement.innerHTML = 'Waiting for the CQP server...';
|
||||||
const response = await cqiClient.api.socket.emitWithAck('init', this.corpusId);
|
const response = await cqiClient.api.socket.emitWithAck('init', this.corpusId);
|
||||||
|
@ -33,7 +33,7 @@ class CorpusAnalysisConcordance {
|
|||||||
|
|
||||||
async submitForm(queryModeId) {
|
async submitForm(queryModeId) {
|
||||||
this.app.disableActionElements();
|
this.app.disableActionElements();
|
||||||
let queryBuilderQuery = Utils.unescape(document.querySelector('#corpus-analysis-concordance-query-preview').innerHTML.trim());
|
let queryBuilderQuery = nopaque.Utils.unescape(document.querySelector('#corpus-analysis-concordance-query-preview').innerHTML.trim());
|
||||||
let expertModeQuery = this.elements.expertModeForm.query.value.trim();
|
let expertModeQuery = this.elements.expertModeForm.query.value.trim();
|
||||||
let query = queryModeId === 'corpus-analysis-concordance-expert-mode-form' ? expertModeQuery : queryBuilderQuery;
|
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;
|
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) => {
|
this.elements.subcorpusActions.querySelector('.subcorpus-export-trigger').addEventListener('click', (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
let subcorpus = this.data.subcorpora[this.settings.selectedSubcorpus];
|
let subcorpus = this.data.subcorpora[this.settings.selectedSubcorpus];
|
||||||
let modalElementId = Utils.generateElementId('export-subcorpus-modal-');
|
let modalElementId = nopaque.Utils.generateElementId('export-subcorpus-modal-');
|
||||||
let exportFormatSelectElementId = Utils.generateElementId('export-format-select-');
|
let exportFormatSelectElementId = nopaque.Utils.generateElementId('export-format-select-');
|
||||||
let exportSelectedMatchesOnlyCheckboxElementId = Utils.generateElementId('export-selected-matches-only-checkbox-');
|
let exportSelectedMatchesOnlyCheckboxElementId = nopaque.Utils.generateElementId('export-selected-matches-only-checkbox-');
|
||||||
let exportFileNameInputElementId = Utils.generateElementId('export-file-name-input-');
|
let exportFileNameInputElementId = nopaque.Utils.generateElementId('export-file-name-input-');
|
||||||
let modalElement = Utils.HTMLToElement(
|
let modalElement = nopaque.Utils.HTMLToElement(
|
||||||
`
|
`
|
||||||
<div class="modal" id="${modalElementId}">
|
<div class="modal" id="${modalElementId}">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
@ -112,7 +112,7 @@ class CorpusAnalysisReader {
|
|||||||
if (this.data.corpus.p.pages === 0) {return;}
|
if (this.data.corpus.p.pages === 0) {return;}
|
||||||
let pageElement;
|
let pageElement;
|
||||||
// First page button. Disables first page button if on first page
|
// First page button. Disables first page button if on first page
|
||||||
pageElement = Utils.HTMLToElement(
|
pageElement = nopaque.Utils.HTMLToElement(
|
||||||
`
|
`
|
||||||
<li class="${this.data.corpus.p.page === 1 ? 'disabled' : 'waves-effect'}">
|
<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"'}>
|
<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);
|
this.elements.corpusPagination.appendChild(pageElement);
|
||||||
// Previous page button. Disables previous page button if on first page
|
// Previous page button. Disables previous page button if on first page
|
||||||
pageElement = Utils.HTMLToElement(
|
pageElement = nopaque.Utils.HTMLToElement(
|
||||||
`
|
`
|
||||||
<li class="${this.data.corpus.p.has_prev ? 'waves-effect' : 'disabled'}">
|
<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 + '"' : ''}>
|
<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);
|
this.elements.corpusPagination.appendChild(pageElement);
|
||||||
// First page as number. Hides first page button if on first page
|
// First page as number. Hides first page button if on first page
|
||||||
if (this.data.corpus.p.page > 6) {
|
if (this.data.corpus.p.page > 6) {
|
||||||
pageElement = Utils.HTMLToElement(
|
pageElement = nopaque.Utils.HTMLToElement(
|
||||||
`
|
`
|
||||||
<li class="waves-effect">
|
<li class="waves-effect">
|
||||||
<a class="corpus-analysis-action pagination-trigger" data-target="1">1</a>
|
<a class="corpus-analysis-action pagination-trigger" data-target="1">1</a>
|
||||||
@ -143,14 +143,14 @@ class CorpusAnalysisReader {
|
|||||||
`
|
`
|
||||||
);
|
);
|
||||||
this.elements.corpusPagination.appendChild(pageElement);
|
this.elements.corpusPagination.appendChild(pageElement);
|
||||||
pageElement = Utils.HTMLToElement("<li style='margin-top: 5px;'>…</li>");
|
pageElement = nopaque.Utils.HTMLToElement("<li style='margin-top: 5px;'>…</li>");
|
||||||
this.elements.corpusPagination.appendChild(pageElement);
|
this.elements.corpusPagination.appendChild(pageElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
// render page buttons (5 before and 5 after current page)
|
// 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++) {
|
for (let i = this.data.corpus.p.page - this.settings.pagination.innerWindow; i <= this.data.corpus.p.page; i++) {
|
||||||
if (i <= 0) {continue;}
|
if (i <= 0) {continue;}
|
||||||
pageElement = Utils.HTMLToElement(
|
pageElement = nopaque.Utils.HTMLToElement(
|
||||||
`
|
`
|
||||||
<li class="${i === this.data.corpus.p.page ? 'active' : 'waves-effect'}">
|
<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>
|
<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++) {
|
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;}
|
if (i > this.data.corpus.p.pages) {break;}
|
||||||
pageElement = Utils.HTMLToElement(
|
pageElement = nopaque.Utils.HTMLToElement(
|
||||||
`
|
`
|
||||||
<li class="${i === this.data.corpus.p.page ? 'active' : 'waves-effect'}">
|
<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>
|
<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
|
// Last page as number. Hides last page button if on last page
|
||||||
if (this.data.corpus.p.page < this.data.corpus.p.pages - 6) {
|
if (this.data.corpus.p.page < this.data.corpus.p.pages - 6) {
|
||||||
pageElement = Utils.HTMLToElement("<li style='margin-top: 5px;'>…</li>");
|
pageElement = nopaque.Utils.HTMLToElement("<li style='margin-top: 5px;'>…</li>");
|
||||||
this.elements.corpusPagination.appendChild(pageElement);
|
this.elements.corpusPagination.appendChild(pageElement);
|
||||||
pageElement = Utils.HTMLToElement(
|
pageElement = nopaque.Utils.HTMLToElement(
|
||||||
`
|
`
|
||||||
<li class="waves-effect">
|
<li class="waves-effect">
|
||||||
<a class="corpus-analysis-action pagination-trigger" data-target="${this.data.corpus.p.pages}">${this.data.corpus.p.pages}</a>
|
<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);
|
this.elements.corpusPagination.appendChild(pageElement);
|
||||||
}
|
}
|
||||||
// Next page button. Disables next page button if on last page
|
// Next page button. Disables next page button if on last page
|
||||||
pageElement = Utils.HTMLToElement(
|
pageElement = nopaque.Utils.HTMLToElement(
|
||||||
`
|
`
|
||||||
<li class="${this.data.corpus.p.has_next ? 'waves-effect' : 'disabled'}">
|
<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 + '"' : ''}>
|
<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);
|
this.elements.corpusPagination.appendChild(pageElement);
|
||||||
// Last page button. Disables last page button if on last page
|
// Last page button. Disables last page button if on last page
|
||||||
pageElement = Utils.HTMLToElement(
|
pageElement = nopaque.Utils.HTMLToElement(
|
||||||
`
|
`
|
||||||
<li class="${this.data.corpus.p.page === this.data.corpus.p.pages ? 'disabled' : 'waves-effect'}">
|
<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 + '"'}>
|
<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() {
|
getStopwords() {
|
||||||
this.data.promises.getStopwords = new Promise((resolve, reject) => {
|
this.data.promises.getStopwords = new Promise((resolve, reject) => {
|
||||||
Requests.corpora.entity.getStopwords()
|
nopaque.requests.corpora.entity.getStopwords()
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
response.json()
|
response.json()
|
||||||
.then((json) => {
|
.then((json) => {
|
||||||
@ -104,7 +104,7 @@ class CorpusAnalysisStaticVisualization {
|
|||||||
renderTextInfoList() {
|
renderTextInfoList() {
|
||||||
let corpusData = this.data.corpus.o.staticData;
|
let corpusData = this.data.corpus.o.staticData;
|
||||||
let corpusTextInfoListElement = document.querySelector('.corpus-text-info-list');
|
let corpusTextInfoListElement = document.querySelector('.corpus-text-info-list');
|
||||||
let corpusTextInfoList = new ResourceLists.CorpusTextInfoList(corpusTextInfoListElement);
|
let corpusTextInfoList = new nopaque.resource_lists.CorpusTextInfoList(corpusTextInfoListElement);
|
||||||
let texts = corpusData.s_attrs.text.lexicon;
|
let texts = corpusData.s_attrs.text.lexicon;
|
||||||
let textData = [];
|
let textData = [];
|
||||||
for (let i = 0; i < Object.entries(texts).length; i++) {
|
for (let i = 0; i < Object.entries(texts).length; i++) {
|
||||||
@ -213,7 +213,7 @@ class CorpusAnalysisStaticVisualization {
|
|||||||
|
|
||||||
async renderTokenList() {
|
async renderTokenList() {
|
||||||
let corpusTokenListElement = document.querySelector('.corpus-token-list');
|
let corpusTokenListElement = document.querySelector('.corpus-token-list');
|
||||||
let corpusTokenList = new ResourceLists.CorpusTokenList(corpusTokenListElement);
|
let corpusTokenList = new nopaque.resource_lists.CorpusTokenList(corpusTokenListElement);
|
||||||
let filteredData = this.filterData();
|
let filteredData = this.filterData();
|
||||||
let stopwords = this.data.stopwords;
|
let stopwords = this.data.stopwords;
|
||||||
if (this.data.stopwords === undefined) {
|
if (this.data.stopwords === undefined) {
|
||||||
@ -358,7 +358,7 @@ class CorpusAnalysisStaticVisualization {
|
|||||||
if (stopwordLanguageSelection.children.length === 0) {
|
if (stopwordLanguageSelection.children.length === 0) {
|
||||||
Object.keys(stopwords).forEach(language => {
|
Object.keys(stopwords).forEach(language => {
|
||||||
if (language !== 'user_stopwords') {
|
if (language !== 'user_stopwords') {
|
||||||
let optionElement = Utils.HTMLToElement(`<option value="${language}" ${language === 'english' ? 'selected' : ''}>${language}</option>`);
|
let optionElement = nopaque.Utils.HTMLToElement(`<option value="${language}" ${language === 'english' ? 'selected' : ''}>${language}</option>`);
|
||||||
stopwordLanguageSelection.appendChild(optionElement);
|
stopwordLanguageSelection.appendChild(optionElement);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -367,7 +367,7 @@ class CorpusAnalysisStaticVisualization {
|
|||||||
// Render user stopwords over input field.
|
// Render user stopwords over input field.
|
||||||
if (this.data.stopwords['user_stopwords'].length > 0) {
|
if (this.data.stopwords['user_stopwords'].length > 0) {
|
||||||
for (let word of this.data.stopwords['user_stopwords']) {
|
for (let word of this.data.stopwords['user_stopwords']) {
|
||||||
let chipElement = Utils.HTMLToElement(`<div class="chip">${word}<i class="close material-icons">close</i></div>`);
|
let chipElement = nopaque.Utils.HTMLToElement(`<div class="chip">${word}<i class="close material-icons">close</i></div>`);
|
||||||
chipElement.addEventListener('click', (event) => {
|
chipElement.addEventListener('click', (event) => {
|
||||||
let removedListItem = event.target.closest('.chip').firstChild.textContent;
|
let removedListItem = event.target.closest('.chip').firstChild.textContent;
|
||||||
this.data.stopwords['user_stopwords'] = structuredClone(this.data.stopwords['user_stopwords'].filter(item => item !== removedListItem));
|
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');
|
let stopwordLanguageChipList = document.querySelector('#stopword-language-chip-list');
|
||||||
stopwordLanguageChipList.innerHTML = '';
|
stopwordLanguageChipList.innerHTML = '';
|
||||||
for (let word of stopwords) {
|
for (let word of stopwords) {
|
||||||
let chipElement = Utils.HTMLToElement(`<div class="chip">${word}<i class="close material-icons">close</i></div>`);
|
let chipElement = nopaque.Utils.HTMLToElement(`<div class="chip">${word}<i class="close material-icons">close</i></div>`);
|
||||||
chipElement.addEventListener('click', (event) => {
|
chipElement.addEventListener('click', (event) => {
|
||||||
let removedListItem = event.target.closest('.chip').firstChild.textContent;
|
let removedListItem = event.target.closest('.chip').firstChild.textContent;
|
||||||
this.data.stopwords[language] = structuredClone(this.data.stopwords[language].filter(item => item !== removedListItem));
|
this.data.stopwords[language] = structuredClone(this.data.stopwords[language].filter(item => item !== removedListItem));
|
||||||
|
@ -1,53 +0,0 @@
|
|||||||
/**
|
|
||||||
* @param {cqi.models.corpora.Corpus} corpus
|
|
||||||
* @param {number[]} cposList
|
|
||||||
* @returns {Promise<object>}
|
|
||||||
*/
|
|
||||||
async function lookupsByCpos(corpus, cposList) {
|
|
||||||
let lookups = {};
|
|
||||||
lookups['cpos_lookup'] = {};
|
|
||||||
for (let cpos in cposList) {
|
|
||||||
lookups['cpos_lookup'][cpos] = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
let pAttrs = await corpus.positionalAttributes.list();
|
|
||||||
for (let attr in pAttrs) {
|
|
||||||
let values = await attr.valuesByCpos(cposList);
|
|
||||||
for (let i = 0; i < cposList.length; i++) {
|
|
||||||
let cpos = cposList[i];
|
|
||||||
let value = values[i];
|
|
||||||
lookups['cpos_lookup'][cpos][attr.name] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let sAttrs = await corpus.structuralAttributes.list();
|
|
||||||
for (let attr in sAttrs) {
|
|
||||||
// We only want to iterate over non subattributes, identifiable by
|
|
||||||
// sAttr.hasValues == false
|
|
||||||
if (attr.hasValues) {continue;}
|
|
||||||
|
|
||||||
let idList = await attr.idsByCpos(cposList);
|
|
||||||
for (let i = 0; i < cposList.length; i++) {
|
|
||||||
let cpos = cposList[i];
|
|
||||||
let id = idList[i];
|
|
||||||
if (id == -1) {continue;}
|
|
||||||
lookups['cpos_lookup'][cpos][attr.name] = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
let occuredIdList = Array.from(new Set(idList.filter(x => x != -1)));
|
|
||||||
if (occuredIdList.length == 0) {continue;}
|
|
||||||
|
|
||||||
let subattrs = sAttrs.filter(x => x.name.startsWith(`${attr.name}_`));
|
|
||||||
if (subattrs.length == 0) {continue;}
|
|
||||||
|
|
||||||
let lookupName = `${attr.name}_lookup`;
|
|
||||||
lookups[lookupName] = {};
|
|
||||||
for (let id in occuredIdList) {
|
|
||||||
lookups[lookupName][id] = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return lookups;
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
cqi.api.Client = class Client {
|
nopaque.corpus_analysis.cqi.api.Client = class Client {
|
||||||
/**
|
/**
|
||||||
* @param {string} host
|
* @param {string} host
|
||||||
* @param {number} [timeout=60] timeout
|
* @param {number} [timeout=60] timeout
|
||||||
@ -30,10 +30,10 @@ cqi.api.Client = class Client {
|
|||||||
} else if (response.code === 500) {
|
} else if (response.code === 500) {
|
||||||
throw new Error(`[${response.code}] ${response.msg}`);
|
throw new Error(`[${response.code}] ${response.msg}`);
|
||||||
} else if (response.code === 502) {
|
} else if (response.code === 502) {
|
||||||
if (response.payload.code in cqi.errors.lookup) {
|
if (response.payload.code in nopaque.corpus_analysis.cqi.errors.lookup) {
|
||||||
throw new cqi.errors.lookup[response.payload.code]();
|
throw new nopaque.corpus_analysis.cqi.errors.lookup[response.payload.code]();
|
||||||
} else {
|
} else {
|
||||||
throw new cqi.errors.CQiError();
|
throw new nopaque.corpus_analysis.cqi.errors.CQiError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -41,22 +41,22 @@ cqi.api.Client = class Client {
|
|||||||
/**
|
/**
|
||||||
* @param {string} username
|
* @param {string} username
|
||||||
* @param {string} password
|
* @param {string} password
|
||||||
* @returns {Promise<cqi.status.StatusConnectOk>}
|
* @returns {Promise<nopaque.corpus_analysis.cqi.status.StatusConnectOk>}
|
||||||
*/
|
*/
|
||||||
async ctrl_connect(username, password) {
|
async ctrl_connect(username, password) {
|
||||||
const fn_name = 'ctrl_connect';
|
const fn_name = 'ctrl_connect';
|
||||||
const fn_args = {username: username, password: password};
|
const fn_args = {username: username, password: password};
|
||||||
let payload = await this.#request(fn_name, fn_args);
|
let payload = await this.#request(fn_name, fn_args);
|
||||||
return new cqi.status.lookup[payload.code]();
|
return new nopaque.corpus_analysis.cqi.status.lookup[payload.code]();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Promise<cqi.status.StatusByeOk>}
|
* @returns {Promise<nopaque.corpus_analysis.cqi.status.StatusByeOk>}
|
||||||
*/
|
*/
|
||||||
async ctrl_bye() {
|
async ctrl_bye() {
|
||||||
const fn_name = 'ctrl_bye';
|
const fn_name = 'ctrl_bye';
|
||||||
let payload = await this.#request(fn_name);
|
let payload = await this.#request(fn_name);
|
||||||
return new cqi.status.lookup[payload.code]();
|
return new nopaque.corpus_analysis.cqi.status.lookup[payload.code]();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,12 +68,12 @@ cqi.api.Client = class Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Promise<cqi.status.StatusPingOk>}
|
* @returns {Promise<nopaque.corpus_analysis.cqi.status.StatusPingOk>}
|
||||||
*/
|
*/
|
||||||
async ctrl_ping() {
|
async ctrl_ping() {
|
||||||
const fn_name = 'ctrl_ping';
|
const fn_name = 'ctrl_ping';
|
||||||
let payload = await this.#request(fn_name);
|
let payload = await this.#request(fn_name);
|
||||||
return new cqi.status.lookup[payload.code]();
|
return new nopaque.corpus_analysis.cqi.status.lookup[payload.code]();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -208,13 +208,13 @@ cqi.api.Client = class Client {
|
|||||||
* try to unload a corpus and all its attributes from memory
|
* try to unload a corpus and all its attributes from memory
|
||||||
*
|
*
|
||||||
* @param {string} corpus
|
* @param {string} corpus
|
||||||
* @returns {Promise<cqi.status.StatusOk>}
|
* @returns {Promise<nopaque.corpus_analysis.cqi.status.StatusOk>}
|
||||||
*/
|
*/
|
||||||
async corpus_drop_corpus(corpus) {
|
async corpus_drop_corpus(corpus) {
|
||||||
const fn_name = 'corpus_drop_corpus';
|
const fn_name = 'corpus_drop_corpus';
|
||||||
const fn_args = {corpus: corpus};
|
const fn_args = {corpus: corpus};
|
||||||
let payload = await this.#request(fn_name, fn_args);
|
let payload = await this.#request(fn_name, fn_args);
|
||||||
return new cqi.status.lookup[payload.code]();
|
return new nopaque.corpus_analysis.cqi.status.lookup[payload.code]();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -250,13 +250,13 @@ cqi.api.Client = class Client {
|
|||||||
* unload attribute from memory
|
* unload attribute from memory
|
||||||
*
|
*
|
||||||
* @param {string} attribute
|
* @param {string} attribute
|
||||||
* @returns {Promise<cqi.status.StatusOk>}
|
* @returns {Promise<nopaque.corpus_analysis.cqi.status.StatusOk>}
|
||||||
*/
|
*/
|
||||||
async cl_drop_attribute(attribute) {
|
async cl_drop_attribute(attribute) {
|
||||||
const fn_name = 'cl_drop_attribute';
|
const fn_name = 'cl_drop_attribute';
|
||||||
const fn_args = {attribute: attribute};
|
const fn_args = {attribute: attribute};
|
||||||
let payload = await this.#request(fn_name, fn_args);
|
let payload = await this.#request(fn_name, fn_args);
|
||||||
return new cqi.status.lookup[payload.code]();
|
return new nopaque.corpus_analysis.cqi.status.lookup[payload.code]();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -482,13 +482,13 @@ cqi.api.Client = class Client {
|
|||||||
* @param {string} mother_corpus
|
* @param {string} mother_corpus
|
||||||
* @param {string} subcorpus_name
|
* @param {string} subcorpus_name
|
||||||
* @param {string} query
|
* @param {string} query
|
||||||
* @returns {Promise<cqi.status.StatusOk>}
|
* @returns {Promise<nopaque.corpus_analysis.cqi.status.StatusOk>}
|
||||||
*/
|
*/
|
||||||
async cqp_query(mother_corpus, subcorpus_name, query) {
|
async cqp_query(mother_corpus, subcorpus_name, query) {
|
||||||
const fn_name = 'cqp_query';
|
const fn_name = 'cqp_query';
|
||||||
const fn_args = {mother_corpus: mother_corpus, subcorpus_name: subcorpus_name, query: query};
|
const fn_args = {mother_corpus: mother_corpus, subcorpus_name: subcorpus_name, query: query};
|
||||||
let payload = await this.#request(fn_name, fn_args);
|
let payload = await this.#request(fn_name, fn_args);
|
||||||
return new cqi.status.lookup[payload.code]();
|
return new nopaque.corpus_analysis.cqi.status.lookup[payload.code]();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -524,7 +524,7 @@ cqi.api.Client = class Client {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump the values of <field> for match ranges <first> .. <last>
|
* Dump the values of <field> for match ranges <first> .. <last>
|
||||||
* in <subcorpus>. <field> is one of the cqi.constants.FIELD_* constants.
|
* in <subcorpus>. <field> is one of the nopaque.corpus_analysis.cqi.constants.FIELD_* constants.
|
||||||
*
|
*
|
||||||
* @param {string} subcorpus
|
* @param {string} subcorpus
|
||||||
* @param {number} field
|
* @param {number} field
|
||||||
@ -542,13 +542,13 @@ cqi.api.Client = class Client {
|
|||||||
* delete a subcorpus from memory
|
* delete a subcorpus from memory
|
||||||
*
|
*
|
||||||
* @param {string} subcorpus
|
* @param {string} subcorpus
|
||||||
* @returns {Promise<cqi.status.StatusOk>}
|
* @returns {Promise<nopaque.corpus_analysis.cqi.status.StatusOk>}
|
||||||
*/
|
*/
|
||||||
async cqp_drop_subcorpus(subcorpus) {
|
async cqp_drop_subcorpus(subcorpus) {
|
||||||
const fn_name = 'cqp_drop_subcorpus';
|
const fn_name = 'cqp_drop_subcorpus';
|
||||||
const fn_args = {subcorpus: subcorpus};
|
const fn_args = {subcorpus: subcorpus};
|
||||||
let payload = await this.#request(fn_name, fn_args);
|
let payload = await this.#request(fn_name, fn_args);
|
||||||
return new cqi.status.lookup[payload.code]();
|
return new nopaque.corpus_analysis.cqi.status.lookup[payload.code]();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -561,9 +561,9 @@ cqi.api.Client = class Client {
|
|||||||
*
|
*
|
||||||
* returns <n> (id, frequency) pairs flattened into a list of size 2*<n>
|
* returns <n> (id, frequency) pairs flattened into a list of size 2*<n>
|
||||||
* field is one of
|
* field is one of
|
||||||
* - cqi.constants.FIELD_MATCH
|
* - nopaque.corpus_analysis.cqi.constants.FIELD_MATCH
|
||||||
* - cqi.constants.FIELD_TARGET
|
* - nopaque.corpus_analysis.cqi.constants.FIELD_TARGET
|
||||||
* - cqi.constants.FIELD_KEYWORD
|
* - nopaque.corpus_analysis.cqi.constants.FIELD_KEYWORD
|
||||||
*
|
*
|
||||||
* NB: pairs are sorted by frequency desc.
|
* NB: pairs are sorted by frequency desc.
|
||||||
*
|
*
|
||||||
@ -610,13 +610,13 @@ cqi.api.Client = class Client {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} corpus
|
* @param {string} corpus
|
||||||
* @returns {Promise<cqi.status.StatusOk>}
|
* @returns {Promise<nopaque.corpus_analysis.cqi.status.StatusOk>}
|
||||||
*/
|
*/
|
||||||
async ext_corpus_update_db(corpus) {
|
async ext_corpus_update_db(corpus) {
|
||||||
const fn_name = 'ext_corpus_update_db';
|
const fn_name = 'ext_corpus_update_db';
|
||||||
const fn_args = {corpus: corpus};
|
const fn_args = {corpus: corpus};
|
||||||
let payload = await this.#request(fn_name, fn_args);
|
let payload = await this.#request(fn_name, fn_args);
|
||||||
return new cqi.status.lookup[payload.code]();
|
return new nopaque.corpus_analysis.cqi.status.lookup[payload.code]();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
1
app/static/js/CorpusAnalysis/cqi/api/index.js
Normal file
1
app/static/js/CorpusAnalysis/cqi/api/index.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
nopaque.corpus_analysis.cqi.api = {};
|
@ -1,23 +1,23 @@
|
|||||||
cqi.Client = class Client {
|
nopaque.corpus_analysis.cqi.Client = class Client {
|
||||||
/**
|
/**
|
||||||
* @param {string} host
|
* @param {string} host
|
||||||
* @param {number} [timeout=60] timeout
|
* @param {number} [timeout=60] timeout
|
||||||
* @param {string} [version=0.1] version
|
* @param {string} [version=0.1] version
|
||||||
*/
|
*/
|
||||||
constructor(host, timeout = 60, version = '0.1') {
|
constructor(host, timeout = 60, version = '0.1') {
|
||||||
/** @type {cqi.api.Client} */
|
/** @type {nopaque.corpus_analysis.cqi.api.Client} */
|
||||||
this.api = new cqi.api.Client(host, timeout, version);
|
this.api = new nopaque.corpus_analysis.cqi.api.Client(host, timeout, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {cqi.models.corpora.CorpusCollection}
|
* @returns {nopaque.corpus_analysis.cqi.models.corpora.CorpusCollection}
|
||||||
*/
|
*/
|
||||||
get corpora() {
|
get corpora() {
|
||||||
return new cqi.models.corpora.CorpusCollection(this);
|
return new nopaque.corpus_analysis.cqi.models.corpora.CorpusCollection(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Promise<cqi.status.StatusByeOk>}
|
* @returns {Promise<nopaque.corpus_analysis.cqi.status.StatusByeOk>}
|
||||||
*/
|
*/
|
||||||
async bye() {
|
async bye() {
|
||||||
return await this.api.ctrl_bye();
|
return await this.api.ctrl_bye();
|
||||||
@ -26,14 +26,14 @@ cqi.Client = class Client {
|
|||||||
/**
|
/**
|
||||||
* @param {string} username
|
* @param {string} username
|
||||||
* @param {string} password
|
* @param {string} password
|
||||||
* @returns {Promise<cqi.status.StatusConnectOk>}
|
* @returns {Promise<nopaque.corpus_analysis.cqi.status.StatusConnectOk>}
|
||||||
*/
|
*/
|
||||||
async connect(username, password) {
|
async connect(username, password) {
|
||||||
return await this.api.ctrl_connect(username, password);
|
return await this.api.ctrl_connect(username, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Promise<cqi.status.StatusPingOk>}
|
* @returns {Promise<nopaque.corpus_analysis.cqi.status.StatusPingOk>}
|
||||||
*/
|
*/
|
||||||
async ping() {
|
async ping() {
|
||||||
return await this.api.ctrl_ping();
|
return await this.api.ctrl_ping();
|
||||||
@ -49,7 +49,7 @@ cqi.Client = class Client {
|
|||||||
/**
|
/**
|
||||||
* Alias for "bye" method
|
* Alias for "bye" method
|
||||||
*
|
*
|
||||||
* @returns {Promise<cqi.status.StatusByeOk>}
|
* @returns {Promise<nopaque.corpus_analysis.cqi.status.StatusByeOk>}
|
||||||
*/
|
*/
|
||||||
async disconnect() {
|
async disconnect() {
|
||||||
return await this.api.ctrl_bye();
|
return await this.api.ctrl_bye();
|
43
app/static/js/CorpusAnalysis/cqi/constants.js
Normal file
43
app/static/js/CorpusAnalysis/cqi/constants.js
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
nopaque.corpus_analysis.cqi.constants = {};
|
||||||
|
|
||||||
|
/** @type {number} */
|
||||||
|
nopaque.corpus_analysis.cqi.constants.FIELD_KEYWORD = 9;
|
||||||
|
|
||||||
|
/** @type {number} */
|
||||||
|
nopaque.corpus_analysis.cqi.constants.FIELD_MATCH = 16;
|
||||||
|
|
||||||
|
/** @type {number} */
|
||||||
|
nopaque.corpus_analysis.cqi.constants.FIELD_MATCHEND = 17;
|
||||||
|
|
||||||
|
/** @type {number} */
|
||||||
|
nopaque.corpus_analysis.cqi.constants.FIELD_TARGET = 0;
|
||||||
|
|
||||||
|
/** @type {number} */
|
||||||
|
nopaque.corpus_analysis.cqi.constants.FIELD_TARGET_0 = 0;
|
||||||
|
|
||||||
|
/** @type {number} */
|
||||||
|
nopaque.corpus_analysis.cqi.constants.FIELD_TARGET_1 = 1;
|
||||||
|
|
||||||
|
/** @type {number} */
|
||||||
|
nopaque.corpus_analysis.cqi.constants.FIELD_TARGET_2 = 2;
|
||||||
|
|
||||||
|
/** @type {number} */
|
||||||
|
nopaque.corpus_analysis.cqi.constants.FIELD_TARGET_3 = 3;
|
||||||
|
|
||||||
|
/** @type {number} */
|
||||||
|
nopaque.corpus_analysis.cqi.constants.FIELD_TARGET_4 = 4;
|
||||||
|
|
||||||
|
/** @type {number} */
|
||||||
|
nopaque.corpus_analysis.cqi.constants.FIELD_TARGET_5 = 5;
|
||||||
|
|
||||||
|
/** @type {number} */
|
||||||
|
nopaque.corpus_analysis.cqi.constants.FIELD_TARGET_6 = 6;
|
||||||
|
|
||||||
|
/** @type {number} */
|
||||||
|
nopaque.corpus_analysis.cqi.constants.FIELD_TARGET_7 = 7;
|
||||||
|
|
||||||
|
/** @type {number} */
|
||||||
|
nopaque.corpus_analysis.cqi.constants.FIELD_TARGET_8 = 8;
|
||||||
|
|
||||||
|
/** @type {number} */
|
||||||
|
nopaque.corpus_analysis.cqi.constants.FIELD_TARGET_9 = 9;
|
185
app/static/js/CorpusAnalysis/cqi/errors.js
Normal file
185
app/static/js/CorpusAnalysis/cqi/errors.js
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
nopaque.corpus_analysis.cqi.errors = {};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A base class from which all other errors inherit.
|
||||||
|
* If you want to catch all errors that the CQi package might throw,
|
||||||
|
* catch this base error.
|
||||||
|
*/
|
||||||
|
nopaque.corpus_analysis.cqi.errors.CQiError = class CQiError extends Error {
|
||||||
|
constructor(message) {
|
||||||
|
super(message);
|
||||||
|
this.code = undefined;
|
||||||
|
this.description = undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
nopaque.corpus_analysis.cqi.errors.Error = class Error extends nopaque.corpus_analysis.cqi.errors.CQiError {
|
||||||
|
constructor(message) {
|
||||||
|
super(message);
|
||||||
|
this.code = 2;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
nopaque.corpus_analysis.cqi.errors.ErrorGeneralError = class ErrorGeneralError extends nopaque.corpus_analysis.cqi.errors.Error {
|
||||||
|
constructor(message) {
|
||||||
|
super(message);
|
||||||
|
this.code = 513;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
nopaque.corpus_analysis.cqi.errors.ErrorConnectRefused = class ErrorConnectRefused extends nopaque.corpus_analysis.cqi.errors.Error {
|
||||||
|
constructor(message) {
|
||||||
|
super(message);
|
||||||
|
this.code = 514;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
nopaque.corpus_analysis.cqi.errors.ErrorUserAbort = class ErrorUserAbort extends nopaque.corpus_analysis.cqi.errors.Error {
|
||||||
|
constructor(message) {
|
||||||
|
super(message);
|
||||||
|
this.code = 515;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
nopaque.corpus_analysis.cqi.errors.ErrorSyntaxError = class ErrorSyntaxError extends nopaque.corpus_analysis.cqi.errors.Error {
|
||||||
|
constructor(message) {
|
||||||
|
super(message);
|
||||||
|
this.code = 516;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
nopaque.corpus_analysis.cqi.errors.CLError = class Error extends nopaque.corpus_analysis.cqi.errors.CQiError {
|
||||||
|
constructor(message) {
|
||||||
|
super(message);
|
||||||
|
this.code = 4;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
nopaque.corpus_analysis.cqi.errors.CLErrorNoSuchAttribute = class CLErrorNoSuchAttribute extends nopaque.corpus_analysis.cqi.errors.CLError {
|
||||||
|
constructor(message) {
|
||||||
|
super(message);
|
||||||
|
this.code = 1025;
|
||||||
|
this.description = "CQi server couldn't open attribute";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
nopaque.corpus_analysis.cqi.errors.CLErrorWrongAttributeType = class CLErrorWrongAttributeType extends nopaque.corpus_analysis.cqi.errors.CLError {
|
||||||
|
constructor(message) {
|
||||||
|
super(message);
|
||||||
|
this.code = 1026;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
nopaque.corpus_analysis.cqi.errors.CLErrorOutOfRange = class CLErrorOutOfRange extends nopaque.corpus_analysis.cqi.errors.CLError {
|
||||||
|
constructor(message) {
|
||||||
|
super(message);
|
||||||
|
this.code = 1027;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
nopaque.corpus_analysis.cqi.errors.CLErrorRegex = class CLErrorRegex extends nopaque.corpus_analysis.cqi.errors.CLError {
|
||||||
|
constructor(message) {
|
||||||
|
super(message);
|
||||||
|
this.code = 1028;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
nopaque.corpus_analysis.cqi.errors.CLErrorCorpusAccess = class CLErrorCorpusAccess extends nopaque.corpus_analysis.cqi.errors.CLError {
|
||||||
|
constructor(message) {
|
||||||
|
super(message);
|
||||||
|
this.code = 1029;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
nopaque.corpus_analysis.cqi.errors.CLErrorOutOfMemory = class CLErrorOutOfMemory extends nopaque.corpus_analysis.cqi.errors.CLError {
|
||||||
|
constructor(message) {
|
||||||
|
super(message);
|
||||||
|
this.code = 1030;
|
||||||
|
this.description = 'CQi server has run out of memory; try discarding some other corpora and/or subcorpora';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
nopaque.corpus_analysis.cqi.errors.CLErrorInternal = class CLErrorInternal extends nopaque.corpus_analysis.cqi.errors.CLError {
|
||||||
|
constructor(message) {
|
||||||
|
super(message);
|
||||||
|
this.code = 1031;
|
||||||
|
this.description = "The classical 'please contact technical support' error";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
nopaque.corpus_analysis.cqi.errors.CQPError = class Error extends nopaque.corpus_analysis.cqi.errors.CQiError {
|
||||||
|
constructor(message) {
|
||||||
|
super(message);
|
||||||
|
this.code = 5;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
nopaque.corpus_analysis.cqi.errors.CQPErrorGeneral = class CQPErrorGeneral extends nopaque.corpus_analysis.cqi.errors.CQPError {
|
||||||
|
constructor(message) {
|
||||||
|
super(message);
|
||||||
|
this.code = 1281;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
nopaque.corpus_analysis.cqi.errors.CQPErrorNoSuchCorpus = class CQPErrorNoSuchCorpus extends nopaque.corpus_analysis.cqi.errors.CQPError {
|
||||||
|
constructor(message) {
|
||||||
|
super(message);
|
||||||
|
this.code = 1282;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
nopaque.corpus_analysis.cqi.errors.CQPErrorInvalidField = class CQPErrorInvalidField extends nopaque.corpus_analysis.cqi.errors.CQPError {
|
||||||
|
constructor(message) {
|
||||||
|
super(message);
|
||||||
|
this.code = 1283;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
nopaque.corpus_analysis.cqi.errors.CQPErrorOutOfRange = class CQPErrorOutOfRange extends nopaque.corpus_analysis.cqi.errors.CQPError {
|
||||||
|
constructor(message) {
|
||||||
|
super(message);
|
||||||
|
this.code = 1284;
|
||||||
|
this.description = 'A number is out of range';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
nopaque.corpus_analysis.cqi.errors.lookup = {
|
||||||
|
2: nopaque.corpus_analysis.cqi.errors.Error,
|
||||||
|
513: nopaque.corpus_analysis.cqi.errors.ErrorGeneralError,
|
||||||
|
514: nopaque.corpus_analysis.cqi.errors.ErrorConnectRefused,
|
||||||
|
515: nopaque.corpus_analysis.cqi.errors.ErrorUserAbort,
|
||||||
|
516: nopaque.corpus_analysis.cqi.errors.ErrorSyntaxError,
|
||||||
|
4: nopaque.corpus_analysis.cqi.errors.CLError,
|
||||||
|
1025: nopaque.corpus_analysis.cqi.errors.CLErrorNoSuchAttribute,
|
||||||
|
1026: nopaque.corpus_analysis.cqi.errors.CLErrorWrongAttributeType,
|
||||||
|
1027: nopaque.corpus_analysis.cqi.errors.CLErrorOutOfRange,
|
||||||
|
1028: nopaque.corpus_analysis.cqi.errors.CLErrorRegex,
|
||||||
|
1029: nopaque.corpus_analysis.cqi.errors.CLErrorCorpusAccess,
|
||||||
|
1030: nopaque.corpus_analysis.cqi.errors.CLErrorOutOfMemory,
|
||||||
|
1031: nopaque.corpus_analysis.cqi.errors.CLErrorInternal,
|
||||||
|
5: nopaque.corpus_analysis.cqi.errors.CQPError,
|
||||||
|
1281: nopaque.corpus_analysis.cqi.errors.CQPErrorGeneral,
|
||||||
|
1282: nopaque.corpus_analysis.cqi.errors.CQPErrorNoSuchCorpus,
|
||||||
|
1283: nopaque.corpus_analysis.cqi.errors.CQPErrorInvalidField,
|
||||||
|
1284: nopaque.corpus_analysis.cqi.errors.CQPErrorOutOfRange
|
||||||
|
};
|
1
app/static/js/CorpusAnalysis/cqi/index.js
Normal file
1
app/static/js/CorpusAnalysis/cqi/index.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
nopaque.corpus_analysis.cqi = {};
|
@ -1,7 +1,7 @@
|
|||||||
cqi.models.attributes = {};
|
nopaque.corpus_analysis.cqi.models.attributes = {};
|
||||||
|
|
||||||
|
|
||||||
cqi.models.attributes.Attribute = class Attribute extends cqi.models.resource.Model {
|
nopaque.corpus_analysis.cqi.models.attributes.Attribute = class Attribute extends nopaque.corpus_analysis.cqi.models.resource.Model {
|
||||||
/**
|
/**
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
@ -24,7 +24,7 @@ cqi.models.attributes.Attribute = class Attribute extends cqi.models.resource.Mo
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Promise<cqi.status.StatusOk>}
|
* @returns {Promise<nopaque.corpus_analysis.cqi.status.StatusOk>}
|
||||||
*/
|
*/
|
||||||
async drop() {
|
async drop() {
|
||||||
return await this.client.api.cl_drop_attribute(this.apiName);
|
return await this.client.api.cl_drop_attribute(this.apiName);
|
||||||
@ -32,17 +32,17 @@ cqi.models.attributes.Attribute = class Attribute extends cqi.models.resource.Mo
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
cqi.models.attributes.AttributeCollection = class AttributeCollection extends cqi.models.resource.Collection {
|
nopaque.corpus_analysis.cqi.models.attributes.AttributeCollection = class AttributeCollection extends nopaque.corpus_analysis.cqi.models.resource.Collection {
|
||||||
/** @type{typeof cqi.models.attributes.Attribute} */
|
/** @type{typeof nopaque.corpus_analysis.cqi.models.attributes.Attribute} */
|
||||||
static model = cqi.models.attributes.Attribute;
|
static model = nopaque.corpus_analysis.cqi.models.attributes.Attribute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {cqi.Client} client
|
* @param {nopaque.corpus_analysis.cqi.Client} client
|
||||||
* @param {cqi.models.corpora.Corpus} corpus
|
* @param {nopaque.corpus_analysis.cqi.models.corpora.Corpus} corpus
|
||||||
*/
|
*/
|
||||||
constructor(client, corpus) {
|
constructor(client, corpus) {
|
||||||
super(client);
|
super(client);
|
||||||
/** @type {cqi.models.corpora.Corpus} */
|
/** @type {nopaque.corpus_analysis.cqi.models.corpora.Corpus} */
|
||||||
this.corpus = corpus;
|
this.corpus = corpus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ cqi.models.attributes.AttributeCollection = class AttributeCollection extends cq
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} attributeName
|
* @param {string} attributeName
|
||||||
* @returns {Promise<cqi.models.attributes.Attribute>}
|
* @returns {Promise<nopaque.corpus_analysis.cqi.models.attributes.Attribute>}
|
||||||
*/
|
*/
|
||||||
async get(attributeName) {
|
async get(attributeName) {
|
||||||
return this.prepareModel(await this._get(attributeName));
|
return this.prepareModel(await this._get(attributeName));
|
||||||
@ -70,7 +70,7 @@ cqi.models.attributes.AttributeCollection = class AttributeCollection extends cq
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
cqi.models.attributes.AlignmentAttribute = class AlignmentAttribute extends cqi.models.attributes.Attribute {
|
nopaque.corpus_analysis.cqi.models.attributes.AlignmentAttribute = class AlignmentAttribute extends nopaque.corpus_analysis.cqi.models.attributes.Attribute {
|
||||||
/**
|
/**
|
||||||
* @param {number} id
|
* @param {number} id
|
||||||
* @returns {Promise<[number, number, number, number]>}
|
* @returns {Promise<[number, number, number, number]>}
|
||||||
@ -89,17 +89,17 @@ cqi.models.attributes.AlignmentAttribute = class AlignmentAttribute extends cqi.
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
cqi.models.attributes.AlignmentAttributeCollection = class AlignmentAttributeCollection extends cqi.models.attributes.AttributeCollection {
|
nopaque.corpus_analysis.cqi.models.attributes.AlignmentAttributeCollection = class AlignmentAttributeCollection extends nopaque.corpus_analysis.cqi.models.attributes.AttributeCollection {
|
||||||
/** @type{typeof cqi.models.attributes.AlignmentAttribute} */
|
/** @type{typeof nopaque.corpus_analysis.cqi.models.attributes.AlignmentAttribute} */
|
||||||
static model = cqi.models.attributes.AlignmentAttribute;
|
static model = nopaque.corpus_analysis.cqi.models.attributes.AlignmentAttribute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Promise<cqi.models.attributes.AlignmentAttribute[]>}
|
* @returns {Promise<nopaque.corpus_analysis.cqi.models.attributes.AlignmentAttribute[]>}
|
||||||
*/
|
*/
|
||||||
async list() {
|
async list() {
|
||||||
/** @type {string[]} */
|
/** @type {string[]} */
|
||||||
let alignmentAttributeNames = await this.client.api.corpus_alignment_attributes(this.corpus.apiName);
|
let alignmentAttributeNames = await this.client.api.corpus_alignment_attributes(this.corpus.apiName);
|
||||||
/** @type {cqi.models.attributes.AlignmentAttribute[]} */
|
/** @type {nopaque.corpus_analysis.cqi.models.attributes.AlignmentAttribute[]} */
|
||||||
let alignmentAttributes = [];
|
let alignmentAttributes = [];
|
||||||
for (let alignmentAttributeName of alignmentAttributeNames) {
|
for (let alignmentAttributeName of alignmentAttributeNames) {
|
||||||
alignmentAttributes.push(await this.get(alignmentAttributeName));
|
alignmentAttributes.push(await this.get(alignmentAttributeName));
|
||||||
@ -109,7 +109,7 @@ cqi.models.attributes.AlignmentAttributeCollection = class AlignmentAttributeCol
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
cqi.models.attributes.PositionalAttribute = class PositionalAttribute extends cqi.models.attributes.Attribute {
|
nopaque.corpus_analysis.cqi.models.attributes.PositionalAttribute = class PositionalAttribute extends nopaque.corpus_analysis.cqi.models.attributes.Attribute {
|
||||||
/**
|
/**
|
||||||
* @returns {number}
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
@ -183,9 +183,9 @@ cqi.models.attributes.PositionalAttribute = class PositionalAttribute extends cq
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
cqi.models.attributes.PositionalAttributeCollection = class PositionalAttributeCollection extends cqi.models.attributes.AttributeCollection {
|
nopaque.corpus_analysis.cqi.models.attributes.PositionalAttributeCollection = class PositionalAttributeCollection extends nopaque.corpus_analysis.cqi.models.attributes.AttributeCollection {
|
||||||
/** @type{typeof cqi.models.attributes.PositionalAttribute} */
|
/** @type{typeof nopaque.corpus_analysis.cqi.models.attributes.PositionalAttribute} */
|
||||||
static model = cqi.models.attributes.PositionalAttribute;
|
static model = nopaque.corpus_analysis.cqi.models.attributes.PositionalAttribute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} positionalAttributeName
|
* @param {string} positionalAttributeName
|
||||||
@ -198,7 +198,7 @@ cqi.models.attributes.PositionalAttributeCollection = class PositionalAttributeC
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Promise<cqi.models.attributes.PositionalAttribute[]>}
|
* @returns {Promise<nopaque.corpus_analysis.cqi.models.attributes.PositionalAttribute[]>}
|
||||||
*/
|
*/
|
||||||
async list() {
|
async list() {
|
||||||
let positionalAttributeNames = await this.client.api.corpus_positional_attributes(this.corpus.apiName);
|
let positionalAttributeNames = await this.client.api.corpus_positional_attributes(this.corpus.apiName);
|
||||||
@ -211,7 +211,7 @@ cqi.models.attributes.PositionalAttributeCollection = class PositionalAttributeC
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
cqi.models.attributes.StructuralAttribute = class StructuralAttribute extends cqi.models.attributes.Attribute {
|
nopaque.corpus_analysis.cqi.models.attributes.StructuralAttribute = class StructuralAttribute extends nopaque.corpus_analysis.cqi.models.attributes.Attribute {
|
||||||
/**
|
/**
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
@ -261,9 +261,9 @@ cqi.models.attributes.StructuralAttribute = class StructuralAttribute extends cq
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
cqi.models.attributes.StructuralAttributeCollection = class StructuralAttributeCollection extends cqi.models.attributes.AttributeCollection {
|
nopaque.corpus_analysis.cqi.models.attributes.StructuralAttributeCollection = class StructuralAttributeCollection extends nopaque.corpus_analysis.cqi.models.attributes.AttributeCollection {
|
||||||
/** @type{typeof cqi.models.attributes.StructuralAttribute} */
|
/** @type{typeof nopaque.corpus_analysis.cqi.models.attributes.StructuralAttribute} */
|
||||||
static model = cqi.models.attributes.StructuralAttribute;
|
static model = nopaque.corpus_analysis.cqi.models.attributes.StructuralAttribute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} structuralAttributeName
|
* @param {string} structuralAttributeName
|
||||||
@ -276,7 +276,7 @@ cqi.models.attributes.StructuralAttributeCollection = class StructuralAttributeC
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Promise<cqi.models.attributes.StructuralAttribute[]>}
|
* @returns {Promise<nopaque.corpus_analysis.cqi.models.attributes.StructuralAttribute[]>}
|
||||||
*/
|
*/
|
||||||
async list() {
|
async list() {
|
||||||
let structuralAttributeNames = await this.client.api.corpus_structural_attributes(this.corpus.apiName);
|
let structuralAttributeNames = await this.client.api.corpus_structural_attributes(this.corpus.apiName);
|
@ -1,7 +1,7 @@
|
|||||||
cqi.models.corpora = {};
|
nopaque.corpus_analysis.cqi.models.corpora = {};
|
||||||
|
|
||||||
|
|
||||||
cqi.models.corpora.Corpus = class Corpus extends cqi.models.resource.Model {
|
nopaque.corpus_analysis.cqi.models.corpora.Corpus = class Corpus extends nopaque.corpus_analysis.cqi.models.resource.Model {
|
||||||
/**
|
/**
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
@ -38,35 +38,35 @@ cqi.models.corpora.Corpus = class Corpus extends cqi.models.resource.Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {cqi.models.attributes.AlignmentAttributeCollection}
|
* @returns {nopaque.corpus_analysis.cqi.models.attributes.AlignmentAttributeCollection}
|
||||||
*/
|
*/
|
||||||
get alignmentAttributes() {
|
get alignmentAttributes() {
|
||||||
return new cqi.models.attributes.AlignmentAttributeCollection(this.client, this);
|
return new nopaque.corpus_analysis.cqi.models.attributes.AlignmentAttributeCollection(this.client, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {cqi.models.attributes.PositionalAttributeCollection}
|
* @returns {nopaque.corpus_analysis.cqi.models.attributes.PositionalAttributeCollection}
|
||||||
*/
|
*/
|
||||||
get positionalAttributes() {
|
get positionalAttributes() {
|
||||||
return new cqi.models.attributes.PositionalAttributeCollection(this.client, this);
|
return new nopaque.corpus_analysis.cqi.models.attributes.PositionalAttributeCollection(this.client, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {cqi.models.attributes.StructuralAttributeCollection}
|
* @returns {nopaque.corpus_analysis.cqi.models.attributes.StructuralAttributeCollection}
|
||||||
*/
|
*/
|
||||||
get structuralAttributes() {
|
get structuralAttributes() {
|
||||||
return new cqi.models.attributes.StructuralAttributeCollection(this.client, this);
|
return new nopaque.corpus_analysis.cqi.models.attributes.StructuralAttributeCollection(this.client, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {cqi.models.subcorpora.SubcorpusCollection}
|
* @returns {nopaque.corpus_analysis.cqi.models.subcorpora.SubcorpusCollection}
|
||||||
*/
|
*/
|
||||||
get subcorpora() {
|
get subcorpora() {
|
||||||
return new cqi.models.subcorpora.SubcorpusCollection(this.client, this);
|
return new nopaque.corpus_analysis.cqi.models.subcorpora.SubcorpusCollection(this.client, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Promise<cqi.status.StatusOk>}
|
* @returns {Promise<nopaque.corpus_analysis.cqi.status.StatusOk>}
|
||||||
*/
|
*/
|
||||||
async drop() {
|
async drop() {
|
||||||
return await this.client.api.corpus_drop_corpus(this.apiName);
|
return await this.client.api.corpus_drop_corpus(this.apiName);
|
||||||
@ -75,7 +75,7 @@ cqi.models.corpora.Corpus = class Corpus extends cqi.models.resource.Model {
|
|||||||
/**
|
/**
|
||||||
* @param {string} subcorpusName
|
* @param {string} subcorpusName
|
||||||
* @param {string} query
|
* @param {string} query
|
||||||
* @returns {Promise<cqi.status.StatusOk>}
|
* @returns {Promise<nopaque.corpus_analysis.cqi.status.StatusOk>}
|
||||||
*/
|
*/
|
||||||
async query(subcorpusName, query) {
|
async query(subcorpusName, query) {
|
||||||
return await this.client.api.cqp_query(this.apiName, subcorpusName, query);
|
return await this.client.api.cqp_query(this.apiName, subcorpusName, query);
|
||||||
@ -96,7 +96,7 @@ cqi.models.corpora.Corpus = class Corpus extends cqi.models.resource.Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {cqi.status.StatusOk}
|
* @returns {nopaque.corpus_analysis.cqi.status.StatusOk}
|
||||||
*/
|
*/
|
||||||
async updateDb() {
|
async updateDb() {
|
||||||
return await this.client.api.ext_corpus_update_db(this.apiName);
|
return await this.client.api.ext_corpus_update_db(this.apiName);
|
||||||
@ -113,9 +113,9 @@ cqi.models.corpora.Corpus = class Corpus extends cqi.models.resource.Model {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
cqi.models.corpora.CorpusCollection = class CorpusCollection extends cqi.models.resource.Collection {
|
nopaque.corpus_analysis.cqi.models.corpora.CorpusCollection = class CorpusCollection extends nopaque.corpus_analysis.cqi.models.resource.Collection {
|
||||||
/** @type {typeof cqi.models.corpora.Corpus} */
|
/** @type {typeof nopaque.corpus_analysis.cqi.models.corpora.Corpus} */
|
||||||
static model = cqi.models.corpora.Corpus;
|
static model = nopaque.corpus_analysis.cqi.models.corpora.Corpus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} corpusName
|
* @param {string} corpusName
|
||||||
@ -144,19 +144,19 @@ cqi.models.corpora.CorpusCollection = class CorpusCollection extends cqi.models.
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} corpusName
|
* @param {string} corpusName
|
||||||
* @returns {Promise<cqi.models.corpora.Corpus>}
|
* @returns {Promise<nopaque.corpus_analysis.cqi.models.corpora.Corpus>}
|
||||||
*/
|
*/
|
||||||
async get(corpusName) {
|
async get(corpusName) {
|
||||||
return this.prepareModel(await this._get(corpusName));
|
return this.prepareModel(await this._get(corpusName));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Promise<cqi.models.corpora.Corpus[]>}
|
* @returns {Promise<nopaque.corpus_analysis.cqi.models.corpora.Corpus[]>}
|
||||||
*/
|
*/
|
||||||
async list() {
|
async list() {
|
||||||
/** @type {string[]} */
|
/** @type {string[]} */
|
||||||
let corpusNames = await this.client.api.corpus_list_corpora();
|
let corpusNames = await this.client.api.corpus_list_corpora();
|
||||||
/** @type {cqi.models.corpora.Corpus[]} */
|
/** @type {nopaque.corpus_analysis.cqi.models.corpora.Corpus[]} */
|
||||||
let corpora = [];
|
let corpora = [];
|
||||||
for (let corpusName of corpusNames) {
|
for (let corpusName of corpusNames) {
|
||||||
corpora.push(await this.get(corpusName));
|
corpora.push(await this.get(corpusName));
|
1
app/static/js/CorpusAnalysis/cqi/models/index.js
Normal file
1
app/static/js/CorpusAnalysis/cqi/models/index.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
nopaque.corpus_analysis.cqi.models = {};
|
@ -1,26 +1,26 @@
|
|||||||
cqi.models.resource = {};
|
nopaque.corpus_analysis.cqi.models.resource = {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A base class for representing a single object on the server.
|
* A base class for representing a single object on the server.
|
||||||
*/
|
*/
|
||||||
cqi.models.resource.Model = class Model {
|
nopaque.corpus_analysis.cqi.models.resource.Model = class Model {
|
||||||
/**
|
/**
|
||||||
* @param {object} attrs
|
* @param {object} attrs
|
||||||
* @param {cqi.CQiClient} client
|
* @param {nopaque.corpus_analysis.cqi.CQiClient} client
|
||||||
* @param {cqi.models.resource.Collection} collection
|
* @param {nopaque.corpus_analysis.cqi.models.resource.Collection} collection
|
||||||
*/
|
*/
|
||||||
constructor(attrs, client, collection) {
|
constructor(attrs, client, collection) {
|
||||||
/**
|
/**
|
||||||
* A client pointing at the server that this object is on.
|
* A client pointing at the server that this object is on.
|
||||||
*
|
*
|
||||||
* @type {cqi.CQiClient}
|
* @type {nopaque.corpus_analysis.cqi.CQiClient}
|
||||||
*/
|
*/
|
||||||
this.client = client;
|
this.client = client;
|
||||||
/**
|
/**
|
||||||
* The collection that this model is part of.
|
* The collection that this model is part of.
|
||||||
*
|
*
|
||||||
* @type {cqi.models.resource.Collection}
|
* @type {nopaque.corpus_analysis.cqi.models.resource.Collection}
|
||||||
*/
|
*/
|
||||||
this.collection = collection;
|
this.collection = collection;
|
||||||
/**
|
/**
|
||||||
@ -50,22 +50,22 @@ cqi.models.resource.Model = class Model {
|
|||||||
/**
|
/**
|
||||||
* A base class for representing all objects of a particular type on the server.
|
* A base class for representing all objects of a particular type on the server.
|
||||||
*/
|
*/
|
||||||
cqi.models.resource.Collection = class Collection {
|
nopaque.corpus_analysis.cqi.models.resource.Collection = class Collection {
|
||||||
/**
|
/**
|
||||||
* The type of object this collection represents, set by subclasses
|
* The type of object this collection represents, set by subclasses
|
||||||
*
|
*
|
||||||
* @type {typeof cqi.models.resource.Model}
|
* @type {typeof nopaque.corpus_analysis.cqi.models.resource.Model}
|
||||||
*/
|
*/
|
||||||
static model;
|
static model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {cqi.CQiClient} client
|
* @param {nopaque.corpus_analysis.cqi.CQiClient} client
|
||||||
*/
|
*/
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
/**
|
/**
|
||||||
* A client pointing at the server that this object is on.
|
* A client pointing at the server that this object is on.
|
||||||
*
|
*
|
||||||
* @type {cqi.CQiClient}
|
* @type {nopaque.corpus_analysis.cqi.CQiClient}
|
||||||
*/
|
*/
|
||||||
this.client = client;
|
this.client = client;
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ cqi.models.resource.Collection = class Collection {
|
|||||||
* Create a model from a set of attributes.
|
* Create a model from a set of attributes.
|
||||||
*
|
*
|
||||||
* @param {object} attrs
|
* @param {object} attrs
|
||||||
* @returns {cqi.models.resource.Model}
|
* @returns {nopaque.corpus_analysis.cqi.models.resource.Model}
|
||||||
*/
|
*/
|
||||||
prepareModel(attrs) {
|
prepareModel(attrs) {
|
||||||
return new this.constructor.model(attrs, this.client, this);
|
return new this.constructor.model(attrs, this.client, this);
|
@ -1,7 +1,7 @@
|
|||||||
cqi.models.subcorpora = {};
|
nopaque.corpus_analysis.cqi.models.subcorpora = {};
|
||||||
|
|
||||||
|
|
||||||
cqi.models.subcorpora.Subcorpus = class Subcorpus extends cqi.models.resource.Model {
|
nopaque.corpus_analysis.cqi.models.subcorpora.Subcorpus = class Subcorpus extends nopaque.corpus_analysis.cqi.models.resource.Model {
|
||||||
/**
|
/**
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
@ -31,7 +31,7 @@ cqi.models.subcorpora.Subcorpus = class Subcorpus extends cqi.models.resource.Mo
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Promise<cqi.status.StatusOk>}
|
* @returns {Promise<nopaque.corpus_analysis.cqi.status.StatusOk>}
|
||||||
*/
|
*/
|
||||||
async drop() {
|
async drop() {
|
||||||
return await this.client.api.cqp_drop_subcorpus(this.apiName);
|
return await this.client.api.cqp_drop_subcorpus(this.apiName);
|
||||||
@ -55,7 +55,7 @@ cqi.models.subcorpora.Subcorpus = class Subcorpus extends cqi.models.resource.Mo
|
|||||||
/**
|
/**
|
||||||
* @param {number} cutoff
|
* @param {number} cutoff
|
||||||
* @param {number} field
|
* @param {number} field
|
||||||
* @param {cqi.models.attributes.PositionalAttribute} attribute
|
* @param {nopaque.corpus_analysis.cqi.models.attributes.PositionalAttribute} attribute
|
||||||
* @returns {Promise<number[]>}
|
* @returns {Promise<number[]>}
|
||||||
*/
|
*/
|
||||||
async fdist1(cutoff, field, attribute) {
|
async fdist1(cutoff, field, attribute) {
|
||||||
@ -70,9 +70,9 @@ cqi.models.subcorpora.Subcorpus = class Subcorpus extends cqi.models.resource.Mo
|
|||||||
/**
|
/**
|
||||||
* @param {number} cutoff
|
* @param {number} cutoff
|
||||||
* @param {number} field1
|
* @param {number} field1
|
||||||
* @param {cqi.models.attributes.PositionalAttribute} attribute1
|
* @param {nopaque.corpus_analysis.cqi.models.attributes.PositionalAttribute} attribute1
|
||||||
* @param {number} field2
|
* @param {number} field2
|
||||||
* @param {cqi.models.attributes.PositionalAttribute} attribute2
|
* @param {nopaque.corpus_analysis.cqi.models.attributes.PositionalAttribute} attribute2
|
||||||
* @returns {Promise<number[]>}
|
* @returns {Promise<number[]>}
|
||||||
*/
|
*/
|
||||||
async fdist2(cutoff, field1, attribute1, field2, attribute2) {
|
async fdist2(cutoff, field1, attribute1, field2, attribute2) {
|
||||||
@ -122,17 +122,17 @@ cqi.models.subcorpora.Subcorpus = class Subcorpus extends cqi.models.resource.Mo
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
cqi.models.subcorpora.SubcorpusCollection = class SubcorpusCollection extends cqi.models.resource.Collection {
|
nopaque.corpus_analysis.cqi.models.subcorpora.SubcorpusCollection = class SubcorpusCollection extends nopaque.corpus_analysis.cqi.models.resource.Collection {
|
||||||
/** @type {typeof cqi.models.subcorpora.Subcorpus} */
|
/** @type {typeof nopaque.corpus_analysis.cqi.models.subcorpora.Subcorpus} */
|
||||||
static model = cqi.models.subcorpora.Subcorpus;
|
static model = nopaque.corpus_analysis.cqi.models.subcorpora.Subcorpus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {cqi.CQiClient} client
|
* @param {nopaque.corpus_analysis.cqi.CQiClient} client
|
||||||
* @param {cqi.models.corpora.Corpus} corpus
|
* @param {nopaque.corpus_analysis.cqi.models.corpora.Corpus} corpus
|
||||||
*/
|
*/
|
||||||
constructor(client, corpus) {
|
constructor(client, corpus) {
|
||||||
super(client);
|
super(client);
|
||||||
/** @type {cqi.models.corpora.Corpus} */
|
/** @type {nopaque.corpus_analysis.cqi.models.corpora.Corpus} */
|
||||||
this.corpus = corpus;
|
this.corpus = corpus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,17 +145,17 @@ cqi.models.subcorpora.SubcorpusCollection = class SubcorpusCollection extends cq
|
|||||||
let apiName = `${this.corpus.apiName}:${subcorpusName}`;
|
let apiName = `${this.corpus.apiName}:${subcorpusName}`;
|
||||||
/** @type {object} */
|
/** @type {object} */
|
||||||
let fields = {};
|
let fields = {};
|
||||||
if (await this.client.api.cqp_subcorpus_has_field(apiName, cqi.constants.FIELD_MATCH)) {
|
if (await this.client.api.cqp_subcorpus_has_field(apiName, nopaque.corpus_analysis.cqi.constants.FIELD_MATCH)) {
|
||||||
fields.match = cqi.constants.FIELD_MATCH;
|
fields.match = nopaque.corpus_analysis.cqi.constants.FIELD_MATCH;
|
||||||
}
|
}
|
||||||
if (await this.client.api.cqp_subcorpus_has_field(apiName, cqi.constants.FIELD_MATCHEND)) {
|
if (await this.client.api.cqp_subcorpus_has_field(apiName, nopaque.corpus_analysis.cqi.constants.FIELD_MATCHEND)) {
|
||||||
fields.matchend = cqi.constants.FIELD_MATCHEND
|
fields.matchend = nopaque.corpus_analysis.cqi.constants.FIELD_MATCHEND
|
||||||
}
|
}
|
||||||
if (await this.client.api.cqp_subcorpus_has_field(apiName, cqi.constants.FIELD_TARGET)) {
|
if (await this.client.api.cqp_subcorpus_has_field(apiName, nopaque.corpus_analysis.cqi.constants.FIELD_TARGET)) {
|
||||||
fields.target = cqi.constants.FIELD_TARGET
|
fields.target = nopaque.corpus_analysis.cqi.constants.FIELD_TARGET
|
||||||
}
|
}
|
||||||
if (await this.client.api.cqp_subcorpus_has_field(apiName, cqi.constants.FIELD_KEYWORD)) {
|
if (await this.client.api.cqp_subcorpus_has_field(apiName, nopaque.corpus_analysis.cqi.constants.FIELD_KEYWORD)) {
|
||||||
fields.keyword = cqi.constants.FIELD_KEYWORD
|
fields.keyword = nopaque.corpus_analysis.cqi.constants.FIELD_KEYWORD
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
api_name: apiName,
|
api_name: apiName,
|
||||||
@ -167,19 +167,19 @@ cqi.models.subcorpora.SubcorpusCollection = class SubcorpusCollection extends cq
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} subcorpusName
|
* @param {string} subcorpusName
|
||||||
* @returns {Promise<cqi.models.subcorpora.Subcorpus>}
|
* @returns {Promise<nopaque.corpus_analysis.cqi.models.subcorpora.Subcorpus>}
|
||||||
*/
|
*/
|
||||||
async get(subcorpusName) {
|
async get(subcorpusName) {
|
||||||
return this.prepareModel(await this._get(subcorpusName));
|
return this.prepareModel(await this._get(subcorpusName));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Promise<cqi.models.subcorpora.Subcorpus[]>}
|
* @returns {Promise<nopaque.corpus_analysis.cqi.models.subcorpora.Subcorpus[]>}
|
||||||
*/
|
*/
|
||||||
async list() {
|
async list() {
|
||||||
/** @type {string[]} */
|
/** @type {string[]} */
|
||||||
let subcorpusNames = await this.client.api.cqp_list_subcorpora(this.corpus.apiName);
|
let subcorpusNames = await this.client.api.cqp_list_subcorpora(this.corpus.apiName);
|
||||||
/** @type {cqi.models.subcorpora.Subcorpus[]} */
|
/** @type {nopaque.corpus_analysis.cqi.models.subcorpora.Subcorpus[]} */
|
||||||
let subcorpora = [];
|
let subcorpora = [];
|
||||||
for (let subcorpusName of subcorpusNames) {
|
for (let subcorpusName of subcorpusNames) {
|
||||||
subcorpora.push(await this.get(subcorpusName));
|
subcorpora.push(await this.get(subcorpusName));
|
51
app/static/js/CorpusAnalysis/cqi/status.js
Normal file
51
app/static/js/CorpusAnalysis/cqi/status.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
nopaque.corpus_analysis.cqi.status = {};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A base class from which all other status inherit.
|
||||||
|
*/
|
||||||
|
nopaque.corpus_analysis.cqi.status.CQiStatus = class CQiStatus {
|
||||||
|
constructor() {
|
||||||
|
this.code = undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
nopaque.corpus_analysis.cqi.status.StatusOk = class StatusOk extends nopaque.corpus_analysis.cqi.status.CQiStatus {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.code = 257;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
nopaque.corpus_analysis.cqi.status.StatusConnectOk = class StatusConnectOk extends nopaque.corpus_analysis.cqi.status.CQiStatus {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.code = 258;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
nopaque.corpus_analysis.cqi.status.StatusByeOk = class StatusByeOk extends nopaque.corpus_analysis.cqi.status.CQiStatus {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.code = 259;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
nopaque.corpus_analysis.cqi.status.StatusPingOk = class StatusPingOk extends nopaque.corpus_analysis.cqi.status.CQiStatus {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.code = 260;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
nopaque.corpus_analysis.cqi.status.lookup = {
|
||||||
|
257: nopaque.corpus_analysis.cqi.status.StatusOk,
|
||||||
|
258: nopaque.corpus_analysis.cqi.status.StatusConnectOk,
|
||||||
|
259: nopaque.corpus_analysis.cqi.status.StatusByeOk,
|
||||||
|
260: nopaque.corpus_analysis.cqi.status.StatusPingOk
|
||||||
|
};
|
1
app/static/js/CorpusAnalysis/index.js
Normal file
1
app/static/js/CorpusAnalysis/index.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
nopaque.corpus_analysis = {};
|
@ -51,7 +51,7 @@ class GeneralQueryBuilderFunctions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addPlaceholder() {
|
addPlaceholder() {
|
||||||
let placeholder = Utils.HTMLToElement('<span id="corpus-analysis-concordance-query-builder-input-field-placeholder">Click on a button to add a query component</span>');
|
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>');
|
||||||
this.elements.queryInputField.appendChild(placeholder);
|
this.elements.queryInputField.appendChild(placeholder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,9 +81,9 @@ class GeneralQueryBuilderFunctions {
|
|||||||
|
|
||||||
queryChipFactory(dataType, prettyQueryText, queryText, index = null, isClosingTag = false, isEditable = false) {
|
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.
|
// Creates a new query chip element, adds Eventlisteners for selection, deletion and drag and drop and appends it to the query input field.
|
||||||
queryText = Utils.escape(queryText);
|
queryText = nopaque.Utils.escape(queryText);
|
||||||
prettyQueryText = Utils.escape(prettyQueryText);
|
prettyQueryText = nopaque.Utils.escape(prettyQueryText);
|
||||||
let queryChipElement = Utils.HTMLToElement(
|
let queryChipElement = nopaque.Utils.HTMLToElement(
|
||||||
`
|
`
|
||||||
<span class="chip query-component" data-type="${dataType}" data-query="${queryText}" draggable="true" data-closing-tag="${isClosingTag}">
|
<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>': ''}
|
${prettyQueryText}${isEditable ? '<i class="material-icons chip-action-button" data-chip-action="edit" style="padding-left:5px; font-size:18px; cursor:pointer;">edit</i>': ''}
|
||||||
@ -213,7 +213,7 @@ class GeneralQueryBuilderFunctions {
|
|||||||
queryChips = this.elements.queryInputField.querySelectorAll('.query-component[data-type="token"]');
|
queryChips = this.elements.queryInputField.querySelectorAll('.query-component[data-type="token"]');
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
let targetChipElement = Utils.HTMLToElement('<span class="chip drop-target">Drop here</span>');
|
let targetChipElement = nopaque.Utils.HTMLToElement('<span class="chip drop-target">Drop here</span>');
|
||||||
for (let element of queryChips) {
|
for (let element of queryChips) {
|
||||||
if (element === this.elements.queryInputField.querySelectorAll('.query-component')[0]) {
|
if (element === this.elements.queryInputField.querySelectorAll('.query-component')[0]) {
|
||||||
let secondTargetChipClone = targetChipElement.cloneNode(true);
|
let secondTargetChipClone = targetChipElement.cloneNode(true);
|
||||||
@ -261,7 +261,7 @@ class GeneralQueryBuilderFunctions {
|
|||||||
this.elements.queryChipElements.forEach(element => {
|
this.elements.queryChipElements.forEach(element => {
|
||||||
let queryElement = element.dataset.query;
|
let queryElement = element.dataset.query;
|
||||||
if (queryElement !== undefined) {
|
if (queryElement !== undefined) {
|
||||||
queryElement = Utils.escape(queryElement);
|
queryElement = nopaque.Utils.escape(queryElement);
|
||||||
}
|
}
|
||||||
queryInputFieldContent.push(queryElement);
|
queryInputFieldContent.push(queryElement);
|
||||||
});
|
});
|
||||||
|
@ -179,7 +179,7 @@ nopaque.App = class App {
|
|||||||
{
|
{
|
||||||
dismissible: false,
|
dismissible: false,
|
||||||
onCloseEnd: (modalElement) => {
|
onCloseEnd: (modalElement) => {
|
||||||
Requests.users.entity.acceptTermsOfUse();
|
nopaque.requests.users.entity.acceptTermsOfUse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -188,9 +188,9 @@ nopaque.App = class App {
|
|||||||
|
|
||||||
/* Initialize nopaque Components */
|
/* Initialize nopaque Components */
|
||||||
// #region
|
// #region
|
||||||
ResourceDisplays.AutoInit();
|
nopaque.resource_displays.AutoInit();
|
||||||
ResourceLists.AutoInit();
|
nopaque.resource_lists.AutoInit();
|
||||||
Forms.AutoInit();
|
nopaque.forms.AutoInit();
|
||||||
// #endregion
|
// #endregion
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -1 +0,0 @@
|
|||||||
cqi.api = {};
|
|
@ -1,43 +0,0 @@
|
|||||||
cqi.constants = {};
|
|
||||||
|
|
||||||
/** @type {number} */
|
|
||||||
cqi.constants.FIELD_KEYWORD = 9;
|
|
||||||
|
|
||||||
/** @type {number} */
|
|
||||||
cqi.constants.FIELD_MATCH = 16;
|
|
||||||
|
|
||||||
/** @type {number} */
|
|
||||||
cqi.constants.FIELD_MATCHEND = 17;
|
|
||||||
|
|
||||||
/** @type {number} */
|
|
||||||
cqi.constants.FIELD_TARGET = 0;
|
|
||||||
|
|
||||||
/** @type {number} */
|
|
||||||
cqi.constants.FIELD_TARGET_0 = 0;
|
|
||||||
|
|
||||||
/** @type {number} */
|
|
||||||
cqi.constants.FIELD_TARGET_1 = 1;
|
|
||||||
|
|
||||||
/** @type {number} */
|
|
||||||
cqi.constants.FIELD_TARGET_2 = 2;
|
|
||||||
|
|
||||||
/** @type {number} */
|
|
||||||
cqi.constants.FIELD_TARGET_3 = 3;
|
|
||||||
|
|
||||||
/** @type {number} */
|
|
||||||
cqi.constants.FIELD_TARGET_4 = 4;
|
|
||||||
|
|
||||||
/** @type {number} */
|
|
||||||
cqi.constants.FIELD_TARGET_5 = 5;
|
|
||||||
|
|
||||||
/** @type {number} */
|
|
||||||
cqi.constants.FIELD_TARGET_6 = 6;
|
|
||||||
|
|
||||||
/** @type {number} */
|
|
||||||
cqi.constants.FIELD_TARGET_7 = 7;
|
|
||||||
|
|
||||||
/** @type {number} */
|
|
||||||
cqi.constants.FIELD_TARGET_8 = 8;
|
|
||||||
|
|
||||||
/** @type {number} */
|
|
||||||
cqi.constants.FIELD_TARGET_9 = 9;
|
|
@ -1,185 +0,0 @@
|
|||||||
cqi.errors = {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A base class from which all other errors inherit.
|
|
||||||
* If you want to catch all errors that the CQi package might throw,
|
|
||||||
* catch this base error.
|
|
||||||
*/
|
|
||||||
cqi.errors.CQiError = class CQiError extends Error {
|
|
||||||
constructor(message) {
|
|
||||||
super(message);
|
|
||||||
this.code = undefined;
|
|
||||||
this.description = undefined;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
cqi.errors.Error = class Error extends cqi.errors.CQiError {
|
|
||||||
constructor(message) {
|
|
||||||
super(message);
|
|
||||||
this.code = 2;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
cqi.errors.ErrorGeneralError = class ErrorGeneralError extends cqi.errors.Error {
|
|
||||||
constructor(message) {
|
|
||||||
super(message);
|
|
||||||
this.code = 513;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
cqi.errors.ErrorConnectRefused = class ErrorConnectRefused extends cqi.errors.Error {
|
|
||||||
constructor(message) {
|
|
||||||
super(message);
|
|
||||||
this.code = 514;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
cqi.errors.ErrorUserAbort = class ErrorUserAbort extends cqi.errors.Error {
|
|
||||||
constructor(message) {
|
|
||||||
super(message);
|
|
||||||
this.code = 515;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
cqi.errors.ErrorSyntaxError = class ErrorSyntaxError extends cqi.errors.Error {
|
|
||||||
constructor(message) {
|
|
||||||
super(message);
|
|
||||||
this.code = 516;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
cqi.errors.CLError = class Error extends cqi.errors.CQiError {
|
|
||||||
constructor(message) {
|
|
||||||
super(message);
|
|
||||||
this.code = 4;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
cqi.errors.CLErrorNoSuchAttribute = class CLErrorNoSuchAttribute extends cqi.errors.CLError {
|
|
||||||
constructor(message) {
|
|
||||||
super(message);
|
|
||||||
this.code = 1025;
|
|
||||||
this.description = "CQi server couldn't open attribute";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
cqi.errors.CLErrorWrongAttributeType = class CLErrorWrongAttributeType extends cqi.errors.CLError {
|
|
||||||
constructor(message) {
|
|
||||||
super(message);
|
|
||||||
this.code = 1026;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
cqi.errors.CLErrorOutOfRange = class CLErrorOutOfRange extends cqi.errors.CLError {
|
|
||||||
constructor(message) {
|
|
||||||
super(message);
|
|
||||||
this.code = 1027;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
cqi.errors.CLErrorRegex = class CLErrorRegex extends cqi.errors.CLError {
|
|
||||||
constructor(message) {
|
|
||||||
super(message);
|
|
||||||
this.code = 1028;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
cqi.errors.CLErrorCorpusAccess = class CLErrorCorpusAccess extends cqi.errors.CLError {
|
|
||||||
constructor(message) {
|
|
||||||
super(message);
|
|
||||||
this.code = 1029;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
cqi.errors.CLErrorOutOfMemory = class CLErrorOutOfMemory extends cqi.errors.CLError {
|
|
||||||
constructor(message) {
|
|
||||||
super(message);
|
|
||||||
this.code = 1030;
|
|
||||||
this.description = 'CQi server has run out of memory; try discarding some other corpora and/or subcorpora';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
cqi.errors.CLErrorInternal = class CLErrorInternal extends cqi.errors.CLError {
|
|
||||||
constructor(message) {
|
|
||||||
super(message);
|
|
||||||
this.code = 1031;
|
|
||||||
this.description = "The classical 'please contact technical support' error";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
cqi.errors.CQPError = class Error extends cqi.errors.CQiError {
|
|
||||||
constructor(message) {
|
|
||||||
super(message);
|
|
||||||
this.code = 5;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
cqi.errors.CQPErrorGeneral = class CQPErrorGeneral extends cqi.errors.CQPError {
|
|
||||||
constructor(message) {
|
|
||||||
super(message);
|
|
||||||
this.code = 1281;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
cqi.errors.CQPErrorNoSuchCorpus = class CQPErrorNoSuchCorpus extends cqi.errors.CQPError {
|
|
||||||
constructor(message) {
|
|
||||||
super(message);
|
|
||||||
this.code = 1282;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
cqi.errors.CQPErrorInvalidField = class CQPErrorInvalidField extends cqi.errors.CQPError {
|
|
||||||
constructor(message) {
|
|
||||||
super(message);
|
|
||||||
this.code = 1283;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
cqi.errors.CQPErrorOutOfRange = class CQPErrorOutOfRange extends cqi.errors.CQPError {
|
|
||||||
constructor(message) {
|
|
||||||
super(message);
|
|
||||||
this.code = 1284;
|
|
||||||
this.description = 'A number is out of range';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
cqi.errors.lookup = {
|
|
||||||
2: cqi.errors.Error,
|
|
||||||
513: cqi.errors.ErrorGeneralError,
|
|
||||||
514: cqi.errors.ErrorConnectRefused,
|
|
||||||
515: cqi.errors.ErrorUserAbort,
|
|
||||||
516: cqi.errors.ErrorSyntaxError,
|
|
||||||
4: cqi.errors.CLError,
|
|
||||||
1025: cqi.errors.CLErrorNoSuchAttribute,
|
|
||||||
1026: cqi.errors.CLErrorWrongAttributeType,
|
|
||||||
1027: cqi.errors.CLErrorOutOfRange,
|
|
||||||
1028: cqi.errors.CLErrorRegex,
|
|
||||||
1029: cqi.errors.CLErrorCorpusAccess,
|
|
||||||
1030: cqi.errors.CLErrorOutOfMemory,
|
|
||||||
1031: cqi.errors.CLErrorInternal,
|
|
||||||
5: cqi.errors.CQPError,
|
|
||||||
1281: cqi.errors.CQPErrorGeneral,
|
|
||||||
1282: cqi.errors.CQPErrorNoSuchCorpus,
|
|
||||||
1283: cqi.errors.CQPErrorInvalidField,
|
|
||||||
1284: cqi.errors.CQPErrorOutOfRange
|
|
||||||
};
|
|
@ -1 +0,0 @@
|
|||||||
var cqi = {};
|
|
@ -1 +0,0 @@
|
|||||||
cqi.models = {};
|
|
@ -1,51 +0,0 @@
|
|||||||
cqi.status = {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A base class from which all other status inherit.
|
|
||||||
*/
|
|
||||||
cqi.status.CQiStatus = class CQiStatus {
|
|
||||||
constructor() {
|
|
||||||
this.code = undefined;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
cqi.status.StatusOk = class StatusOk extends cqi.status.CQiStatus {
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
this.code = 257;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
cqi.status.StatusConnectOk = class StatusConnectOk extends cqi.status.CQiStatus {
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
this.code = 258;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
cqi.status.StatusByeOk = class StatusByeOk extends cqi.status.CQiStatus {
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
this.code = 259;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
cqi.status.StatusPingOk = class StatusPingOk extends cqi.status.CQiStatus {
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
this.code = 260;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
cqi.status.lookup = {
|
|
||||||
257: cqi.status.StatusOk,
|
|
||||||
258: cqi.status.StatusConnectOk,
|
|
||||||
259: cqi.status.StatusByeOk,
|
|
||||||
260: cqi.status.StatusPingOk
|
|
||||||
};
|
|
@ -1,4 +1,4 @@
|
|||||||
Forms.BaseForm = class BaseForm {
|
nopaque.forms.BaseForm = class BaseForm {
|
||||||
static htmlClass;
|
static htmlClass;
|
||||||
|
|
||||||
constructor(formElement) {
|
constructor(formElement) {
|
||||||
@ -28,7 +28,7 @@ Forms.BaseForm = class BaseForm {
|
|||||||
|
|
||||||
submit(event) {
|
submit(event) {
|
||||||
let request = new XMLHttpRequest();
|
let request = new XMLHttpRequest();
|
||||||
let modalElement = Utils.HTMLToElement(
|
let modalElement = nopaque.Utils.HTMLToElement(
|
||||||
`
|
`
|
||||||
<div class="modal">
|
<div class="modal">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@ -67,7 +67,7 @@ Forms.BaseForm = class BaseForm {
|
|||||||
for (let selectElement of this.formElement.querySelectorAll('select')) {
|
for (let selectElement of this.formElement.querySelectorAll('select')) {
|
||||||
if (selectElement.value === '') {
|
if (selectElement.value === '') {
|
||||||
let inputFieldElement = selectElement.closest('.input-field');
|
let inputFieldElement = selectElement.closest('.input-field');
|
||||||
let errorHelperTextElement = Utils.HTMLToElement(
|
let errorHelperTextElement = nopaque.Utils.HTMLToElement(
|
||||||
'<span class="helper-text error-color-text" data-helper-text-type="error">Please select an option.</span>'
|
'<span class="helper-text error-color-text" data-helper-text-type="error">Please select an option.</span>'
|
||||||
);
|
);
|
||||||
inputFieldElement.appendChild(errorHelperTextElement);
|
inputFieldElement.appendChild(errorHelperTextElement);
|
||||||
@ -93,7 +93,7 @@ Forms.BaseForm = class BaseForm {
|
|||||||
.querySelector(`input[name$="${inputName}"], select[name$="${inputName}"]`)
|
.querySelector(`input[name$="${inputName}"], select[name$="${inputName}"]`)
|
||||||
.closest('.input-field');
|
.closest('.input-field');
|
||||||
for (let inputError of inputErrors) {
|
for (let inputError of inputErrors) {
|
||||||
let errorHelperTextElement = Utils.HTMLToElement(
|
let errorHelperTextElement = nopaque.Utils.HTMLToElement(
|
||||||
`<span class="helper-text error-color-text" data-helper-type="error">${inputError}</span>`
|
`<span class="helper-text error-color-text" data-helper-type="error">${inputError}</span>`
|
||||||
);
|
);
|
||||||
inputFieldElement.appendChild(errorHelperTextElement);
|
inputFieldElement.appendChild(errorHelperTextElement);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
Forms.CreateContributionForm = class CreateContributionForm extends Forms.BaseForm {
|
nopaque.forms.CreateContributionForm = class CreateContributionForm extends nopaque.forms.BaseForm {
|
||||||
static htmlClass = 'create-contribution-form';
|
static htmlClass = 'create-contribution-form';
|
||||||
|
|
||||||
constructor(formElement) {
|
constructor(formElement) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
Forms.CreateCorpusFileForm = class CreateCorpusFileForm extends Forms.BaseForm {
|
nopaque.forms.CreateCorpusFileForm = class CreateCorpusFileForm extends nopaque.forms.BaseForm {
|
||||||
static htmlClass = 'create-corpus-file-form';
|
static htmlClass = 'create-corpus-file-form';
|
||||||
|
|
||||||
constructor(formElement) {
|
constructor(formElement) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
Forms.CreateJobForm = class CreateJobForm extends Forms.BaseForm {
|
nopaque.forms.CreateJobForm = class CreateJobForm extends nopaque.forms.BaseForm {
|
||||||
static htmlClass = 'create-job-form';
|
static htmlClass = 'create-job-form';
|
||||||
|
|
||||||
constructor(formElement) {
|
constructor(formElement) {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
var Forms = {};
|
nopaque.forms = {};
|
||||||
|
|
||||||
Forms.AutoInit = () => {
|
nopaque.forms.AutoInit = () => {
|
||||||
for (let propertyName in Forms) {
|
for (let propertyName in nopaque.forms) {
|
||||||
let property = Forms[propertyName];
|
let property = nopaque.forms[propertyName];
|
||||||
// Call autoInit of all properties that are subclasses of Forms.BaseForm.
|
// Initialize properties that are subclasses of nopaque.forms.BaseForm.
|
||||||
// This does not include Forms.BaseForm itself.
|
// This does not include nopaque.forms.BaseForm itself.
|
||||||
if (property.prototype instanceof Forms.BaseForm) {
|
if (property.prototype instanceof nopaque.forms.BaseForm) {
|
||||||
// Check if the static htmlClass property is defined.
|
// Check if the static htmlClass property is defined.
|
||||||
if (property.htmlClass === undefined) {return;}
|
if (property.htmlClass === undefined) {return;}
|
||||||
// Gather all HTML elements that have the `this.htmlClass` class
|
// Gather all HTML elements that have the `this.htmlClass` class
|
||||||
|
5
app/static/js/index.js
Normal file
5
app/static/js/index.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
/*
|
||||||
|
* This object functions as a global namespace for nopaque.
|
||||||
|
* All components of nopaque should be attached to this object.
|
||||||
|
*/
|
||||||
|
var nopaque = {};
|
@ -1 +0,0 @@
|
|||||||
var nopaque = {};
|
|
@ -1,19 +1,19 @@
|
|||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Requests for /admin routes *
|
* Requests for /admin routes *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
Requests.admin = {};
|
nopaque.requests.admin = {};
|
||||||
|
|
||||||
Requests.admin.users = {};
|
nopaque.requests.admin.users = {};
|
||||||
|
|
||||||
Requests.admin.users.entity = {};
|
nopaque.requests.admin.users.entity = {};
|
||||||
|
|
||||||
Requests.admin.users.entity.confirmed = {};
|
nopaque.requests.admin.users.entity.confirmed = {};
|
||||||
|
|
||||||
Requests.admin.users.entity.confirmed.update = (userId, value) => {
|
nopaque.requests.admin.users.entity.confirmed.update = (userId, value) => {
|
||||||
let input = `/admin/users/${userId}/confirmed`;
|
let input = `/admin/users/${userId}/confirmed`;
|
||||||
let init = {
|
let init = {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
body: JSON.stringify(value)
|
body: JSON.stringify(value)
|
||||||
};
|
};
|
||||||
return Requests.JSONfetch(input, init);
|
return nopaque.requests.JSONfetch(input, init);
|
||||||
};
|
};
|
||||||
|
@ -1,58 +1,58 @@
|
|||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Requests for /contributions routes *
|
* Requests for /contributions routes *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
Requests.contributions = {};
|
nopaque.requests.contributions = {};
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Requests for /contributions/spacy-nlp-pipeline-models routes *
|
* Requests for /contributions/spacy-nlp-pipeline-models routes *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
Requests.contributions.spacy_nlp_pipeline_models = {};
|
nopaque.requests.contributions.spacy_nlp_pipeline_models = {};
|
||||||
|
|
||||||
Requests.contributions.spacy_nlp_pipeline_models.entity = {};
|
nopaque.requests.contributions.spacy_nlp_pipeline_models.entity = {};
|
||||||
|
|
||||||
Requests.contributions.spacy_nlp_pipeline_models.entity.delete = (spacyNlpPipelineModelId) => {
|
nopaque.requests.contributions.spacy_nlp_pipeline_models.entity.delete = (spacyNlpPipelineModelId) => {
|
||||||
let input = `/contributions/spacy-nlp-pipeline-models/${spacyNlpPipelineModelId}`;
|
let input = `/contributions/spacy-nlp-pipeline-models/${spacyNlpPipelineModelId}`;
|
||||||
let init = {
|
let init = {
|
||||||
method: 'DELETE'
|
method: 'DELETE'
|
||||||
};
|
};
|
||||||
return Requests.JSONfetch(input, init);
|
return nopaque.requests.JSONfetch(input, init);
|
||||||
};
|
};
|
||||||
|
|
||||||
Requests.contributions.spacy_nlp_pipeline_models.entity.isPublic = {};
|
nopaque.requests.contributions.spacy_nlp_pipeline_models.entity.isPublic = {};
|
||||||
|
|
||||||
Requests.contributions.spacy_nlp_pipeline_models.entity.isPublic.update = (spacyNlpPipelineModelId, value) => {
|
nopaque.requests.contributions.spacy_nlp_pipeline_models.entity.isPublic.update = (spacyNlpPipelineModelId, value) => {
|
||||||
let input = `/contributions/spacy-nlp-pipeline-models/${spacyNlpPipelineModelId}/is_public`;
|
let input = `/contributions/spacy-nlp-pipeline-models/${spacyNlpPipelineModelId}/is_public`;
|
||||||
let init = {
|
let init = {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
body: JSON.stringify(value)
|
body: JSON.stringify(value)
|
||||||
};
|
};
|
||||||
return Requests.JSONfetch(input, init);
|
return nopaque.requests.JSONfetch(input, init);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Requests for /contributions/tesseract-ocr-pipeline-models routes *
|
* Requests for /contributions/tesseract-ocr-pipeline-models routes *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
Requests.contributions.tesseract_ocr_pipeline_models = {};
|
nopaque.requests.contributions.tesseract_ocr_pipeline_models = {};
|
||||||
|
|
||||||
Requests.contributions.tesseract_ocr_pipeline_models.entity = {};
|
nopaque.requests.contributions.tesseract_ocr_pipeline_models.entity = {};
|
||||||
|
|
||||||
Requests.contributions.tesseract_ocr_pipeline_models.entity.delete = (tesseractOcrPipelineModelId) => {
|
nopaque.requests.contributions.tesseract_ocr_pipeline_models.entity.delete = (tesseractOcrPipelineModelId) => {
|
||||||
let input = `/contributions/tesseract-ocr-pipeline-models/${tesseractOcrPipelineModelId}`;
|
let input = `/contributions/tesseract-ocr-pipeline-models/${tesseractOcrPipelineModelId}`;
|
||||||
let init = {
|
let init = {
|
||||||
method: 'DELETE'
|
method: 'DELETE'
|
||||||
};
|
};
|
||||||
return Requests.JSONfetch(input, init);
|
return nopaque.requests.JSONfetch(input, init);
|
||||||
};
|
};
|
||||||
|
|
||||||
Requests.contributions.tesseract_ocr_pipeline_models.entity.isPublic = {};
|
nopaque.requests.contributions.tesseract_ocr_pipeline_models.entity.isPublic = {};
|
||||||
|
|
||||||
Requests.contributions.tesseract_ocr_pipeline_models.entity.isPublic.update = (tesseractOcrPipelineModelId, value) => {
|
nopaque.requests.contributions.tesseract_ocr_pipeline_models.entity.isPublic.update = (tesseractOcrPipelineModelId, value) => {
|
||||||
let input = `/contributions/tesseract-ocr-pipeline-models/${tesseractOcrPipelineModelId}/is_public`;
|
let input = `/contributions/tesseract-ocr-pipeline-models/${tesseractOcrPipelineModelId}/is_public`;
|
||||||
let init = {
|
let init = {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
body: JSON.stringify(value)
|
body: JSON.stringify(value)
|
||||||
};
|
};
|
||||||
return Requests.JSONfetch(input, init);
|
return nopaque.requests.JSONfetch(input, init);
|
||||||
};
|
};
|
||||||
|
@ -1,102 +1,102 @@
|
|||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Requests for /corpora routes *
|
* Requests for /corpora routes *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
Requests.corpora = {};
|
nopaque.requests.corpora = {};
|
||||||
|
|
||||||
Requests.corpora.entity = {};
|
nopaque.requests.corpora.entity = {};
|
||||||
|
|
||||||
Requests.corpora.entity.delete = (corpusId) => {
|
nopaque.requests.corpora.entity.delete = (corpusId) => {
|
||||||
let input = `/corpora/${corpusId}`;
|
let input = `/corpora/${corpusId}`;
|
||||||
let init = {
|
let init = {
|
||||||
method: 'DELETE'
|
method: 'DELETE'
|
||||||
};
|
};
|
||||||
return Requests.JSONfetch(input, init);
|
return nopaque.requests.JSONfetch(input, init);
|
||||||
};
|
};
|
||||||
|
|
||||||
Requests.corpora.entity.build = (corpusId) => {
|
nopaque.requests.corpora.entity.build = (corpusId) => {
|
||||||
let input = `/corpora/${corpusId}/build`;
|
let input = `/corpora/${corpusId}/build`;
|
||||||
let init = {
|
let init = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
};
|
};
|
||||||
return Requests.JSONfetch(input, init);
|
return nopaque.requests.JSONfetch(input, init);
|
||||||
};
|
};
|
||||||
|
|
||||||
Requests.corpora.entity.generateShareLink = (corpusId, role, expiration) => {
|
nopaque.requests.corpora.entity.generateShareLink = (corpusId, role, expiration) => {
|
||||||
let input = `/corpora/${corpusId}/generate-share-link`;
|
let input = `/corpora/${corpusId}/generate-share-link`;
|
||||||
let init = {
|
let init = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({role: role, expiration: expiration})
|
body: JSON.stringify({role: role, expiration: expiration})
|
||||||
};
|
};
|
||||||
return Requests.JSONfetch(input, init);
|
return nopaque.requests.JSONfetch(input, init);
|
||||||
};
|
};
|
||||||
|
|
||||||
Requests.corpora.entity.getStopwords = () => {
|
nopaque.requests.corpora.entity.getStopwords = () => {
|
||||||
let input = `/corpora/stopwords`;
|
let input = `/corpora/stopwords`;
|
||||||
let init = {
|
let init = {
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
};
|
};
|
||||||
return Requests.JSONfetch(input, init);
|
return nopaque.requests.JSONfetch(input, init);
|
||||||
};
|
};
|
||||||
|
|
||||||
Requests.corpora.entity.isPublic = {};
|
nopaque.requests.corpora.entity.isPublic = {};
|
||||||
|
|
||||||
Requests.corpora.entity.isPublic.update = (corpusId, isPublic) => {
|
nopaque.requests.corpora.entity.isPublic.update = (corpusId, isPublic) => {
|
||||||
let input = `/corpora/${corpusId}/is_public`;
|
let input = `/corpora/${corpusId}/is_public`;
|
||||||
let init = {
|
let init = {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
body: JSON.stringify(isPublic)
|
body: JSON.stringify(isPublic)
|
||||||
};
|
};
|
||||||
return Requests.JSONfetch(input, init);
|
return nopaque.requests.JSONfetch(input, init);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Requests for /corpora/<entity>/files routes *
|
* Requests for /corpora/<entity>/files routes *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
Requests.corpora.entity.files = {};
|
nopaque.requests.corpora.entity.files = {};
|
||||||
|
|
||||||
Requests.corpora.entity.files.ent = {};
|
nopaque.requests.corpora.entity.files.ent = {};
|
||||||
|
|
||||||
Requests.corpora.entity.files.ent.delete = (corpusId, corpusFileId) => {
|
nopaque.requests.corpora.entity.files.ent.delete = (corpusId, corpusFileId) => {
|
||||||
let input = `/corpora/${corpusId}/files/${corpusFileId}`;
|
let input = `/corpora/${corpusId}/files/${corpusFileId}`;
|
||||||
let init = {
|
let init = {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
};
|
};
|
||||||
return Requests.JSONfetch(input, init);
|
return nopaque.requests.JSONfetch(input, init);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Requests for /corpora/<entity>/followers routes *
|
* Requests for /corpora/<entity>/followers routes *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
Requests.corpora.entity.followers = {};
|
nopaque.requests.corpora.entity.followers = {};
|
||||||
|
|
||||||
Requests.corpora.entity.followers.add = (corpusId, usernames) => {
|
nopaque.requests.corpora.entity.followers.add = (corpusId, usernames) => {
|
||||||
let input = `/corpora/${corpusId}/followers`;
|
let input = `/corpora/${corpusId}/followers`;
|
||||||
let init = {
|
let init = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(usernames)
|
body: JSON.stringify(usernames)
|
||||||
};
|
};
|
||||||
return Requests.JSONfetch(input, init);
|
return nopaque.requests.JSONfetch(input, init);
|
||||||
};
|
};
|
||||||
|
|
||||||
Requests.corpora.entity.followers.entity = {};
|
nopaque.requests.corpora.entity.followers.entity = {};
|
||||||
|
|
||||||
Requests.corpora.entity.followers.entity.delete = (corpusId, followerId) => {
|
nopaque.requests.corpora.entity.followers.entity.delete = (corpusId, followerId) => {
|
||||||
let input = `/corpora/${corpusId}/followers/${followerId}`;
|
let input = `/corpora/${corpusId}/followers/${followerId}`;
|
||||||
let init = {
|
let init = {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
};
|
};
|
||||||
return Requests.JSONfetch(input, init);
|
return nopaque.requests.JSONfetch(input, init);
|
||||||
};
|
};
|
||||||
|
|
||||||
Requests.corpora.entity.followers.entity.role = {};
|
nopaque.requests.corpora.entity.followers.entity.role = {};
|
||||||
|
|
||||||
Requests.corpora.entity.followers.entity.role.update = (corpusId, followerId, value) => {
|
nopaque.requests.corpora.entity.followers.entity.role.update = (corpusId, followerId, value) => {
|
||||||
let input = `/corpora/${corpusId}/followers/${followerId}/role`;
|
let input = `/corpora/${corpusId}/followers/${followerId}/role`;
|
||||||
let init = {
|
let init = {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
body: JSON.stringify(value)
|
body: JSON.stringify(value)
|
||||||
};
|
};
|
||||||
return Requests.JSONfetch(input, init);
|
return nopaque.requests.JSONfetch(input, init);
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
var Requests = {};
|
nopaque.requests = {};
|
||||||
|
|
||||||
Requests.JSONfetch = (input, init={}) => {
|
nopaque.requests.JSONfetch = (input, init={}) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let fixedInit = {};
|
let fixedInit = {};
|
||||||
fixedInit.headers = {};
|
fixedInit.headers = {};
|
||||||
@ -8,7 +8,7 @@ Requests.JSONfetch = (input, init={}) => {
|
|||||||
if (init.hasOwnProperty('body')) {
|
if (init.hasOwnProperty('body')) {
|
||||||
fixedInit.headers['Content-Type'] = 'application/json';
|
fixedInit.headers['Content-Type'] = 'application/json';
|
||||||
}
|
}
|
||||||
fetch(input, Utils.mergeObjectsDeep(init, fixedInit))
|
fetch(input, nopaque.Utils.mergeObjectsDeep(init, fixedInit))
|
||||||
.then(
|
.then(
|
||||||
(response) => {
|
(response) => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
|
@ -1,30 +1,30 @@
|
|||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Requests for /jobs routes *
|
* Requests for /jobs routes *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
Requests.jobs = {};
|
nopaque.requests.jobs = {};
|
||||||
|
|
||||||
Requests.jobs.entity = {};
|
nopaque.requests.jobs.entity = {};
|
||||||
|
|
||||||
Requests.jobs.entity.delete = (jobId) => {
|
nopaque.requests.jobs.entity.delete = (jobId) => {
|
||||||
let input = `/jobs/${jobId}`;
|
let input = `/jobs/${jobId}`;
|
||||||
let init = {
|
let init = {
|
||||||
method: 'DELETE'
|
method: 'DELETE'
|
||||||
};
|
};
|
||||||
return Requests.JSONfetch(input, init);
|
return nopaque.requests.JSONfetch(input, init);
|
||||||
};
|
};
|
||||||
|
|
||||||
Requests.jobs.entity.log = (jobId) => {
|
nopaque.requests.jobs.entity.log = (jobId) => {
|
||||||
let input = `/jobs/${jobId}/log`;
|
let input = `/jobs/${jobId}/log`;
|
||||||
let init = {
|
let init = {
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
};
|
};
|
||||||
return Requests.JSONfetch(input, init);
|
return nopaque.requests.JSONfetch(input, init);
|
||||||
};
|
};
|
||||||
|
|
||||||
Requests.jobs.entity.restart = (jobId) => {
|
nopaque.requests.jobs.entity.restart = (jobId) => {
|
||||||
let input = `/jobs/${jobId}/restart`;
|
let input = `/jobs/${jobId}/restart`;
|
||||||
let init = {
|
let init = {
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
};
|
};
|
||||||
return Requests.JSONfetch(input, init);
|
return nopaque.requests.JSONfetch(input, init);
|
||||||
};
|
};
|
||||||
|
@ -2,50 +2,50 @@
|
|||||||
* Users *
|
* Users *
|
||||||
* Fetch requests for /users routes *
|
* Fetch requests for /users routes *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
Requests.users = {};
|
nopaque.requests.users = {};
|
||||||
|
|
||||||
Requests.users.entity = {};
|
nopaque.requests.users.entity = {};
|
||||||
|
|
||||||
Requests.users.entity.delete = (userId) => {
|
nopaque.requests.users.entity.delete = (userId) => {
|
||||||
let input = `/users/${userId}`;
|
let input = `/users/${userId}`;
|
||||||
let init = {
|
let init = {
|
||||||
method: 'DELETE'
|
method: 'DELETE'
|
||||||
};
|
};
|
||||||
return Requests.JSONfetch(input, init);
|
return nopaque.requests.JSONfetch(input, init);
|
||||||
};
|
};
|
||||||
|
|
||||||
Requests.users.entity.acceptTermsOfUse = () => {
|
nopaque.requests.users.entity.acceptTermsOfUse = () => {
|
||||||
let input = `/users/accept-terms-of-use`;
|
let input = `/users/accept-terms-of-use`;
|
||||||
let init = {
|
let init = {
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
};
|
};
|
||||||
return Requests.JSONfetch(input, init);
|
return nopaque.requests.JSONfetch(input, init);
|
||||||
};
|
};
|
||||||
|
|
||||||
Requests.users.entity.avatar = {};
|
nopaque.requests.users.entity.avatar = {};
|
||||||
|
|
||||||
Requests.users.entity.avatar.delete = (userId) => {
|
nopaque.requests.users.entity.avatar.delete = (userId) => {
|
||||||
let input = `/users/${userId}/avatar`;
|
let input = `/users/${userId}/avatar`;
|
||||||
let init = {
|
let init = {
|
||||||
method: 'DELETE'
|
method: 'DELETE'
|
||||||
};
|
};
|
||||||
return Requests.JSONfetch(input, init);
|
return nopaque.requests.JSONfetch(input, init);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Requests for /users/<entity>/settings routes *
|
* Requests for /users/<entity>/settings routes *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
Requests.users.entity.settings = {};
|
nopaque.requests.users.entity.settings = {};
|
||||||
|
|
||||||
Requests.users.entity.settings.profilePrivacy = {};
|
nopaque.requests.users.entity.settings.profilePrivacy = {};
|
||||||
|
|
||||||
Requests.users.entity.settings.profilePrivacy.update = (userId, profilePrivacySetting, enabled) => {
|
nopaque.requests.users.entity.settings.profilePrivacy.update = (userId, profilePrivacySetting, enabled) => {
|
||||||
let input = `/users/${userId}/settings/profile-privacy/${profilePrivacySetting}`;
|
let input = `/users/${userId}/settings/profile-privacy/${profilePrivacySetting}`;
|
||||||
let init = {
|
let init = {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
body: JSON.stringify(enabled)
|
body: JSON.stringify(enabled)
|
||||||
};
|
};
|
||||||
return Requests.JSONfetch(input, init);
|
return nopaque.requests.JSONfetch(input, init);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
ResourceDisplays.CorpusDisplay = class CorpusDisplay extends ResourceDisplays.ResourceDisplay {
|
nopaque.resource_displays.CorpusDisplay = class CorpusDisplay extends nopaque.resource_displays.ResourceDisplay {
|
||||||
static htmlClass = 'corpus-display';
|
static htmlClass = 'corpus-display';
|
||||||
|
|
||||||
constructor(displayElement) {
|
constructor(displayElement) {
|
||||||
@ -7,7 +7,7 @@ ResourceDisplays.CorpusDisplay = class CorpusDisplay extends ResourceDisplays.Re
|
|||||||
this.displayElement
|
this.displayElement
|
||||||
.querySelector('.action-button[data-action="build-request"]')
|
.querySelector('.action-button[data-action="build-request"]')
|
||||||
.addEventListener('click', (event) => {
|
.addEventListener('click', (event) => {
|
||||||
Requests.corpora.entity.build(this.corpusId);
|
nopaque.requests.corpora.entity.build(this.corpusId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
var ResourceDisplays = {};
|
nopaque.resource_displays = {};
|
||||||
|
|
||||||
ResourceDisplays.AutoInit = () => {
|
nopaque.resource_displays.AutoInit = () => {
|
||||||
for (let propertyName in ResourceDisplays) {
|
for (let propertyName in nopaque.resource_displays) {
|
||||||
let property = ResourceDisplays[propertyName];
|
let property = nopaque.resource_displays[propertyName];
|
||||||
// Call autoInit of all properties that are subclasses of `ResourceDisplays.ResourceDisplay`.
|
// Initialize properties that are subclasses of `nopaque.resource_displays.ResourceDisplay`.
|
||||||
// This does not include `ResourceDisplays.ResourceDisplay` itself.
|
// This does not include `nopaque.resource_displays.ResourceDisplay` itself.
|
||||||
if (property.prototype instanceof ResourceDisplays.ResourceDisplay) {
|
if (property.prototype instanceof nopaque.resource_displays.ResourceDisplay) {
|
||||||
// Check if the static `htmlClass` property is defined.
|
// Check if the static `htmlClass` property is defined.
|
||||||
if (property.htmlClass === undefined) {return;}
|
if (property.htmlClass === undefined) {return;}
|
||||||
// Gather all HTML elements that have the `this.htmlClass` class
|
// Gather all HTML elements that have the `this.htmlClass` class
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
ResourceDisplays.JobDisplay = class JobDisplay extends ResourceDisplays.ResourceDisplay {
|
nopaque.resource_displays.JobDisplay = class JobDisplay extends nopaque.resource_displays.ResourceDisplay {
|
||||||
static htmlClass = 'job-display';
|
static htmlClass = 'job-display';
|
||||||
|
|
||||||
constructor(displayElement) {
|
constructor(displayElement) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
ResourceDisplays.ResourceDisplay = class ResourceDisplay {
|
nopaque.resource_displays.ResourceDisplay = class ResourceDisplay {
|
||||||
static htmlClass;
|
static htmlClass;
|
||||||
|
|
||||||
constructor(displayElement) {
|
constructor(displayElement) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
ResourceLists.AdminUserList = class AdminUserList extends ResourceLists.ResourceList {
|
nopaque.resource_lists.AdminUserList = class AdminUserList extends nopaque.resource_lists.ResourceList {
|
||||||
static htmlClass = 'admin-user-list';
|
static htmlClass = 'admin-user-list';
|
||||||
|
|
||||||
constructor(listContainerElement, options = {}) {
|
constructor(listContainerElement, options = {}) {
|
||||||
@ -37,9 +37,9 @@ ResourceLists.AdminUserList = class AdminUserList extends ResourceLists.Resource
|
|||||||
|
|
||||||
initListContainerElement() {
|
initListContainerElement() {
|
||||||
if (!this.listContainerElement.hasAttribute('id')) {
|
if (!this.listContainerElement.hasAttribute('id')) {
|
||||||
this.listContainerElement.id = Utils.generateElementId('user-list-');
|
this.listContainerElement.id = nopaque.Utils.generateElementId('user-list-');
|
||||||
}
|
}
|
||||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||||
this.listContainerElement.innerHTML = `
|
this.listContainerElement.innerHTML = `
|
||||||
<div class="input-field">
|
<div class="input-field">
|
||||||
<i class="material-icons prefix">search</i>
|
<i class="material-icons prefix">search</i>
|
||||||
@ -87,7 +87,7 @@ ResourceLists.AdminUserList = class AdminUserList extends ResourceLists.Resource
|
|||||||
let listAction = listActionElement === null ? 'view' : listActionElement.dataset.listAction;
|
let listAction = listActionElement === null ? 'view' : listActionElement.dataset.listAction;
|
||||||
switch (listAction) {
|
switch (listAction) {
|
||||||
case 'delete': {
|
case 'delete': {
|
||||||
Requests.users.entity.delete(itemId);
|
nopaque.requests.users.entity.delete(itemId);
|
||||||
if (itemId === currentUserId) {window.location.href = '/';}
|
if (itemId === currentUserId) {window.location.href = '/';}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
ResourceLists.CorpusFileList = class CorpusFileList extends ResourceLists.ResourceList {
|
nopaque.resource_lists.CorpusFileList = class CorpusFileList extends nopaque.resource_lists.ResourceList {
|
||||||
static htmlClass = 'corpus-file-list';
|
static htmlClass = 'corpus-file-list';
|
||||||
|
|
||||||
constructor(listContainerElement, options = {}) {
|
constructor(listContainerElement, options = {}) {
|
||||||
@ -62,9 +62,9 @@ ResourceLists.CorpusFileList = class CorpusFileList extends ResourceLists.Resour
|
|||||||
|
|
||||||
initListContainerElement() {
|
initListContainerElement() {
|
||||||
if (!this.listContainerElement.hasAttribute('id')) {
|
if (!this.listContainerElement.hasAttribute('id')) {
|
||||||
this.listContainerElement.id = Utils.generateElementId('corpus-file-list-');
|
this.listContainerElement.id = nopaque.Utils.generateElementId('corpus-file-list-');
|
||||||
}
|
}
|
||||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||||
this.listContainerElement.innerHTML = `
|
this.listContainerElement.innerHTML = `
|
||||||
<div class="input-field">
|
<div class="input-field">
|
||||||
<i class="material-icons prefix">search</i>
|
<i class="material-icons prefix">search</i>
|
||||||
@ -121,7 +121,7 @@ ResourceLists.CorpusFileList = class CorpusFileList extends ResourceLists.Resour
|
|||||||
switch (listAction) {
|
switch (listAction) {
|
||||||
case 'delete': {
|
case 'delete': {
|
||||||
let values = this.listjs.get('id', itemId)[0].values();
|
let values = this.listjs.get('id', itemId)[0].values();
|
||||||
let modalElement = Utils.HTMLToElement(
|
let modalElement = nopaque.Utils.HTMLToElement(
|
||||||
`
|
`
|
||||||
<div class="modal">
|
<div class="modal">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@ -149,12 +149,12 @@ ResourceLists.CorpusFileList = class CorpusFileList extends ResourceLists.Resour
|
|||||||
let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]');
|
let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]');
|
||||||
confirmElement.addEventListener('click', (event) => {
|
confirmElement.addEventListener('click', (event) => {
|
||||||
if (currentUserId != this.userId) {
|
if (currentUserId != this.userId) {
|
||||||
Requests.corpora.entity.files.ent.delete(this.corpusId, itemId)
|
nopaque.requests.corpora.entity.files.ent.delete(this.corpusId, itemId)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Requests.corpora.entity.files.ent.delete(this.corpusId, itemId)
|
nopaque.requests.corpora.entity.files.ent.delete(this.corpusId, itemId)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
modal.open();
|
modal.open();
|
||||||
@ -208,7 +208,7 @@ ResourceLists.CorpusFileList = class CorpusFileList extends ResourceLists.Resour
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'delete': {
|
case 'delete': {
|
||||||
let modalElement = Utils.HTMLToElement(
|
let modalElement = nopaque.Utils.HTMLToElement(
|
||||||
`
|
`
|
||||||
<div class="modal">
|
<div class="modal">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@ -229,7 +229,7 @@ ResourceLists.CorpusFileList = class CorpusFileList extends ResourceLists.Resour
|
|||||||
this.selectedItemIds.forEach(selectedItemId => {
|
this.selectedItemIds.forEach(selectedItemId => {
|
||||||
let listItem = this.listjs.get('id', selectedItemId)[0].elm;
|
let listItem = this.listjs.get('id', selectedItemId)[0].elm;
|
||||||
let values = this.listjs.get('id', listItem.dataset.id)[0].values();
|
let values = this.listjs.get('id', listItem.dataset.id)[0].values();
|
||||||
let itemElement = Utils.HTMLToElement(`<li> - ${values.title}</li>`);
|
let itemElement = nopaque.Utils.HTMLToElement(`<li> - ${values.title}</li>`);
|
||||||
itemList.appendChild(itemElement);
|
itemList.appendChild(itemElement);
|
||||||
});
|
});
|
||||||
let modal = M.Modal.init(
|
let modal = M.Modal.init(
|
||||||
@ -246,12 +246,12 @@ ResourceLists.CorpusFileList = class CorpusFileList extends ResourceLists.Resour
|
|||||||
confirmElement.addEventListener('click', (event) => {
|
confirmElement.addEventListener('click', (event) => {
|
||||||
this.selectedItemIds.forEach(selectedItemId => {
|
this.selectedItemIds.forEach(selectedItemId => {
|
||||||
if (currentUserId != this.userId) {
|
if (currentUserId != this.userId) {
|
||||||
Requests.corpora.entity.files.ent.delete(this.corpusId, selectedItemId)
|
nopaque.requests.corpora.entity.files.ent.delete(this.corpusId, selectedItemId)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Requests.corpora.entity.files.ent.delete(this.corpusId, selectedItemId);
|
nopaque.requests.corpora.entity.files.ent.delete(this.corpusId, selectedItemId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.selectedItemIds.clear();
|
this.selectedItemIds.clear();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
ResourceLists.CorpusFollowerList = class CorpusFollowerList extends ResourceLists.ResourceList {
|
nopaque.resource_lists.CorpusFollowerList = class CorpusFollowerList extends nopaque.resource_lists.ResourceList {
|
||||||
static htmlClass = 'corpus-follower-list';
|
static htmlClass = 'corpus-follower-list';
|
||||||
|
|
||||||
constructor(listContainerElement, options = {}) {
|
constructor(listContainerElement, options = {}) {
|
||||||
@ -68,9 +68,9 @@ ResourceLists.CorpusFollowerList = class CorpusFollowerList extends ResourceList
|
|||||||
|
|
||||||
initListContainerElement() {
|
initListContainerElement() {
|
||||||
if (!this.listContainerElement.hasAttribute('id')) {
|
if (!this.listContainerElement.hasAttribute('id')) {
|
||||||
this.listContainerElement.id = Utils.generateElementId('corpus-follower-list-');
|
this.listContainerElement.id = nopaque.Utils.generateElementId('corpus-follower-list-');
|
||||||
}
|
}
|
||||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||||
this.listContainerElement.innerHTML = `
|
this.listContainerElement.innerHTML = `
|
||||||
<div class="input-field">
|
<div class="input-field">
|
||||||
<i class="material-icons prefix">search</i>
|
<i class="material-icons prefix">search</i>
|
||||||
@ -120,7 +120,7 @@ ResourceLists.CorpusFollowerList = class CorpusFollowerList extends ResourceList
|
|||||||
case 'update-role': {
|
case 'update-role': {
|
||||||
let followerId = listItemElement.dataset.followerId;
|
let followerId = listItemElement.dataset.followerId;
|
||||||
let roleName = event.target.value;
|
let roleName = event.target.value;
|
||||||
Requests.corpora.entity.followers.entity.role.update(this.corpusId, followerId, roleName);
|
nopaque.requests.corpora.entity.followers.entity.role.update(this.corpusId, followerId, roleName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@ -140,12 +140,12 @@ ResourceLists.CorpusFollowerList = class CorpusFollowerList extends ResourceList
|
|||||||
case 'unfollow-request': {
|
case 'unfollow-request': {
|
||||||
let followerId = listItemElement.dataset.followerId;
|
let followerId = listItemElement.dataset.followerId;
|
||||||
if (currentUserId != this.userId) {
|
if (currentUserId != this.userId) {
|
||||||
Requests.corpora.entity.followers.entity.delete(this.corpusId, followerId)
|
nopaque.requests.corpora.entity.followers.entity.delete(this.corpusId, followerId)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Requests.corpora.entity.followers.entity.delete(this.corpusId, followerId);
|
nopaque.requests.corpora.entity.followers.entity.delete(this.corpusId, followerId);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
ResourceLists.CorpusList = class CorpusList extends ResourceLists.ResourceList {
|
nopaque.resource_lists.CorpusList = class CorpusList extends nopaque.resource_lists.ResourceList {
|
||||||
static htmlClass = 'corpus-list';
|
static htmlClass = 'corpus-list';
|
||||||
|
|
||||||
constructor(listContainerElement, options = {}) {
|
constructor(listContainerElement, options = {}) {
|
||||||
@ -93,9 +93,9 @@ ResourceLists.CorpusList = class CorpusList extends ResourceLists.ResourceList {
|
|||||||
|
|
||||||
initListContainerElement() {
|
initListContainerElement() {
|
||||||
if (!this.listContainerElement.hasAttribute('id')) {
|
if (!this.listContainerElement.hasAttribute('id')) {
|
||||||
this.listContainerElement.id = Utils.generateElementId('corpus-list-');
|
this.listContainerElement.id = nopaque.Utils.generateElementId('corpus-list-');
|
||||||
}
|
}
|
||||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||||
this.listContainerElement.innerHTML = `
|
this.listContainerElement.innerHTML = `
|
||||||
<div class="input-field">
|
<div class="input-field">
|
||||||
<i class="material-icons prefix">search</i>
|
<i class="material-icons prefix">search</i>
|
||||||
@ -139,7 +139,7 @@ ResourceLists.CorpusList = class CorpusList extends ResourceLists.ResourceList {
|
|||||||
switch (listAction) {
|
switch (listAction) {
|
||||||
case 'delete-request': {
|
case 'delete-request': {
|
||||||
let values = this.listjs.get('id', itemId)[0].values();
|
let values = this.listjs.get('id', itemId)[0].values();
|
||||||
let modalElement = Utils.HTMLToElement(
|
let modalElement = nopaque.Utils.HTMLToElement(
|
||||||
`
|
`
|
||||||
<div class="modal">
|
<div class="modal">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@ -167,12 +167,12 @@ ResourceLists.CorpusList = class CorpusList extends ResourceLists.ResourceList {
|
|||||||
let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]');
|
let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]');
|
||||||
confirmElement.addEventListener('click', (event) => {
|
confirmElement.addEventListener('click', (event) => {
|
||||||
if (!values['is-owner']) {
|
if (!values['is-owner']) {
|
||||||
Requests.corpora.entity.followers.entity.delete(itemId, currentUserId)
|
nopaque.requests.corpora.entity.followers.entity.delete(itemId, currentUserId)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Requests.corpora.entity.delete(itemId);
|
nopaque.requests.corpora.entity.delete(itemId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
modal.open();
|
modal.open();
|
||||||
@ -224,7 +224,7 @@ ResourceLists.CorpusList = class CorpusList extends ResourceLists.ResourceList {
|
|||||||
// Saved for future use:
|
// Saved for future use:
|
||||||
// <p class="hide">Do you really want to unfollow this Corpora?</p>
|
// <p class="hide">Do you really want to unfollow this Corpora?</p>
|
||||||
// <ul id="selected-unfollow-items-list"></ul>
|
// <ul id="selected-unfollow-items-list"></ul>
|
||||||
let modalElement = Utils.HTMLToElement(
|
let modalElement = nopaque.Utils.HTMLToElement(
|
||||||
`
|
`
|
||||||
<div class="modal">
|
<div class="modal">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@ -245,7 +245,7 @@ ResourceLists.CorpusList = class CorpusList extends ResourceLists.ResourceList {
|
|||||||
this.selectedItemIds.forEach(selectedItemId => {
|
this.selectedItemIds.forEach(selectedItemId => {
|
||||||
let listItem = this.listjs.get('id', selectedItemId)[0].elm;
|
let listItem = this.listjs.get('id', selectedItemId)[0].elm;
|
||||||
let values = this.listjs.get('id', listItem.dataset.id)[0].values();
|
let values = this.listjs.get('id', listItem.dataset.id)[0].values();
|
||||||
let itemElement = Utils.HTMLToElement(`<li> - ${values.title}</li>`);
|
let itemElement = nopaque.Utils.HTMLToElement(`<li> - ${values.title}</li>`);
|
||||||
// if (!values['is-owner']) {
|
// if (!values['is-owner']) {
|
||||||
// itemUnfollowList.appendChild(itemElement);
|
// itemUnfollowList.appendChild(itemElement);
|
||||||
// } else {
|
// } else {
|
||||||
@ -268,9 +268,9 @@ ResourceLists.CorpusList = class CorpusList extends ResourceLists.ResourceList {
|
|||||||
let listItem = this.listjs.get('id', selectedItemId)[0].elm;
|
let listItem = this.listjs.get('id', selectedItemId)[0].elm;
|
||||||
let values = this.listjs.get('id', listItem.dataset.id)[0].values();
|
let values = this.listjs.get('id', listItem.dataset.id)[0].values();
|
||||||
if (values['is-owner']) {
|
if (values['is-owner']) {
|
||||||
Requests.corpora.entity.delete(selectedItemId);
|
nopaque.requests.corpora.entity.delete(selectedItemId);
|
||||||
} else {
|
} else {
|
||||||
Requests.corpora.entity.followers.entity.delete(selectedItemId, currentUserId);
|
nopaque.requests.corpora.entity.followers.entity.delete(selectedItemId, currentUserId);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
ResourceLists.CorpusTextInfoList = class CorpusTextInfoList extends ResourceLists.ResourceList {
|
nopaque.resource_lists.CorpusTextInfoList = class CorpusTextInfoList extends nopaque.resource_lists.ResourceList {
|
||||||
static htmlClass = 'corpus-text-info-list';
|
static htmlClass = 'corpus-text-info-list';
|
||||||
|
|
||||||
static defaultOptions = {
|
static defaultOptions = {
|
||||||
@ -6,8 +6,8 @@ ResourceLists.CorpusTextInfoList = class CorpusTextInfoList extends ResourceList
|
|||||||
};
|
};
|
||||||
|
|
||||||
constructor(listContainerElement, options = {}) {
|
constructor(listContainerElement, options = {}) {
|
||||||
let _options = Utils.mergeObjectsDeep(
|
let _options = nopaque.Utils.mergeObjectsDeep(
|
||||||
ResourceLists.CorpusTextInfoList.defaultOptions,
|
nopaque.resource_lists.CorpusTextInfoList.defaultOptions,
|
||||||
options
|
options
|
||||||
);
|
);
|
||||||
super(listContainerElement, _options);
|
super(listContainerElement, _options);
|
||||||
@ -49,9 +49,9 @@ ResourceLists.CorpusTextInfoList = class CorpusTextInfoList extends ResourceList
|
|||||||
|
|
||||||
initListContainerElement() {
|
initListContainerElement() {
|
||||||
if (!this.listContainerElement.hasAttribute('id')) {
|
if (!this.listContainerElement.hasAttribute('id')) {
|
||||||
this.listContainerElement.id = Utils.generateElementId('corpus-file-list-');
|
this.listContainerElement.id = nopaque.Utils.generateElementId('corpus-file-list-');
|
||||||
}
|
}
|
||||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||||
this.listContainerElement.innerHTML = `
|
this.listContainerElement.innerHTML = `
|
||||||
<div class="input-field">
|
<div class="input-field">
|
||||||
<i class="material-icons prefix">search</i>
|
<i class="material-icons prefix">search</i>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
ResourceLists.CorpusTokenList = class CorpusTokenList extends ResourceLists.ResourceList {
|
nopaque.resource_lists.CorpusTokenList = class CorpusTokenList extends nopaque.resource_lists.ResourceList {
|
||||||
static htmlClass = 'corpus-token-list';
|
static htmlClass = 'corpus-token-list';
|
||||||
|
|
||||||
static defaultOptions = {
|
static defaultOptions = {
|
||||||
@ -6,8 +6,8 @@ ResourceLists.CorpusTokenList = class CorpusTokenList extends ResourceLists.Reso
|
|||||||
};
|
};
|
||||||
|
|
||||||
constructor(listContainerElement, options = {}) {
|
constructor(listContainerElement, options = {}) {
|
||||||
let _options = Utils.mergeObjectsDeep(
|
let _options = nopaque.Utils.mergeObjectsDeep(
|
||||||
ResourceLists.CorpusTokenList.defaultOptions,
|
nopaque.resource_lists.CorpusTokenList.defaultOptions,
|
||||||
options
|
options
|
||||||
);
|
);
|
||||||
super(listContainerElement, _options);
|
super(listContainerElement, _options);
|
||||||
@ -72,9 +72,9 @@ ResourceLists.CorpusTokenList = class CorpusTokenList extends ResourceLists.Reso
|
|||||||
|
|
||||||
initListContainerElement() {
|
initListContainerElement() {
|
||||||
if (!this.listContainerElement.hasAttribute('id')) {
|
if (!this.listContainerElement.hasAttribute('id')) {
|
||||||
this.listContainerElement.id = Utils.generateElementId('corpus-token-list-');
|
this.listContainerElement.id = nopaque.Utils.generateElementId('corpus-token-list-');
|
||||||
}
|
}
|
||||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||||
this.listContainerElement.innerHTML = `
|
this.listContainerElement.innerHTML = `
|
||||||
<div class="input-field">
|
<div class="input-field">
|
||||||
<i class="material-icons prefix">search</i>
|
<i class="material-icons prefix">search</i>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
ResourceLists.DetailedPublicCorpusList = class DetailedPublicCorpusList extends ResourceLists.ResourceList {
|
nopaque.resource_lists.DetailedPublicCorpusList = class DetailedPublicCorpusList extends nopaque.resource_lists.ResourceList {
|
||||||
static htmlClass = 'detailed-public-corpus-list';
|
static htmlClass = 'detailed-public-corpus-list';
|
||||||
|
|
||||||
get item() {
|
get item() {
|
||||||
@ -32,9 +32,9 @@ ResourceLists.DetailedPublicCorpusList = class DetailedPublicCorpusList extends
|
|||||||
|
|
||||||
initListContainerElement() {
|
initListContainerElement() {
|
||||||
if (!this.listContainerElement.hasAttribute('id')) {
|
if (!this.listContainerElement.hasAttribute('id')) {
|
||||||
this.listContainerElement.id = Utils.generateElementId('corpus-list-');
|
this.listContainerElement.id = nopaque.Utils.generateElementId('corpus-list-');
|
||||||
}
|
}
|
||||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||||
this.listContainerElement.innerHTML = `
|
this.listContainerElement.innerHTML = `
|
||||||
<div class="input-field">
|
<div class="input-field">
|
||||||
<i class="material-icons prefix">search</i>
|
<i class="material-icons prefix">search</i>
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
var ResourceLists = {};
|
nopaque.resource_lists = {};
|
||||||
|
|
||||||
ResourceLists.AutoInit = () => {
|
nopaque.resource_lists.AutoInit = () => {
|
||||||
for (let propertyName in ResourceLists) {
|
for (let propertyName in nopaque.resource_lists) {
|
||||||
let property = ResourceLists[propertyName];
|
let property = nopaque.resource_lists[propertyName];
|
||||||
// Call autoInit of all properties that are subclasses of `ResourceLists.ResourceList`.
|
// Initialize properties that are subclasses of `nopaque.resource_lists.ResourceList`.
|
||||||
// This does not include `ResourceLists.ResourceList` itself.
|
// This does not include `nopaque.resource_lists.ResourceList` itself.
|
||||||
if (property.prototype instanceof ResourceLists.ResourceList) {
|
if (property.prototype instanceof nopaque.resource_lists.ResourceList) {
|
||||||
// Check if the static `htmlClass` property is defined.
|
// Check if the static `htmlClass` property is defined.
|
||||||
if (property.htmlClass === undefined) {return;}
|
if (property.htmlClass === undefined) {return;}
|
||||||
// Gather all HTML elements that have the `this.htmlClass` class
|
// Gather all HTML elements that have the `this.htmlClass` class
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
ResourceLists.JobInputList = class JobInputList extends ResourceLists.ResourceList {
|
nopaque.resource_lists.JobInputList = class JobInputList extends nopaque.resource_lists.ResourceList {
|
||||||
static htmlClass = 'job-input-list';
|
static htmlClass = 'job-input-list';
|
||||||
|
|
||||||
constructor(listContainerElement, options = {}) {
|
constructor(listContainerElement, options = {}) {
|
||||||
@ -36,9 +36,9 @@ ResourceLists.JobInputList = class JobInputList extends ResourceLists.ResourceLi
|
|||||||
|
|
||||||
initListContainerElement() {
|
initListContainerElement() {
|
||||||
if (!this.listContainerElement.hasAttribute('id')) {
|
if (!this.listContainerElement.hasAttribute('id')) {
|
||||||
this.listContainerElement.id = Utils.generateElementId('job-input-list-');
|
this.listContainerElement.id = nopaque.Utils.generateElementId('job-input-list-');
|
||||||
}
|
}
|
||||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||||
this.listContainerElement.innerHTML = `
|
this.listContainerElement.innerHTML = `
|
||||||
<div class="input-field">
|
<div class="input-field">
|
||||||
<i class="material-icons prefix">search</i>
|
<i class="material-icons prefix">search</i>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
ResourceLists.JobList = class JobList extends ResourceLists.ResourceList {
|
nopaque.resource_lists.JobList = class JobList extends nopaque.resource_lists.ResourceList {
|
||||||
static htmlClass = 'job-list';
|
static htmlClass = 'job-list';
|
||||||
|
|
||||||
constructor(listContainerElement, options = {}) {
|
constructor(listContainerElement, options = {}) {
|
||||||
@ -56,9 +56,9 @@ ResourceLists.JobList = class JobList extends ResourceLists.ResourceList {
|
|||||||
|
|
||||||
initListContainerElement() {
|
initListContainerElement() {
|
||||||
if (!this.listContainerElement.hasAttribute('id')) {
|
if (!this.listContainerElement.hasAttribute('id')) {
|
||||||
this.listContainerElement.id = Utils.generateElementId('job-list-');
|
this.listContainerElement.id = nopaque.Utils.generateElementId('job-list-');
|
||||||
}
|
}
|
||||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||||
this.listContainerElement.innerHTML = `
|
this.listContainerElement.innerHTML = `
|
||||||
<div class="input-field">
|
<div class="input-field">
|
||||||
<i class="material-icons prefix">search</i>
|
<i class="material-icons prefix">search</i>
|
||||||
@ -112,7 +112,7 @@ ResourceLists.JobList = class JobList extends ResourceLists.ResourceList {
|
|||||||
switch (listAction) {
|
switch (listAction) {
|
||||||
case 'delete-request': {
|
case 'delete-request': {
|
||||||
let values = this.listjs.get('id', itemId)[0].values();
|
let values = this.listjs.get('id', itemId)[0].values();
|
||||||
let modalElement = Utils.HTMLToElement(
|
let modalElement = nopaque.Utils.HTMLToElement(
|
||||||
`
|
`
|
||||||
<div class="modal">
|
<div class="modal">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@ -139,7 +139,7 @@ ResourceLists.JobList = class JobList extends ResourceLists.ResourceList {
|
|||||||
);
|
);
|
||||||
let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]');
|
let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]');
|
||||||
confirmElement.addEventListener('click', (event) => {
|
confirmElement.addEventListener('click', (event) => {
|
||||||
Requests.jobs.entity.delete(itemId);
|
nopaque.requests.jobs.entity.delete(itemId);
|
||||||
});
|
});
|
||||||
modal.open();
|
modal.open();
|
||||||
break;
|
break;
|
||||||
@ -187,7 +187,7 @@ ResourceLists.JobList = class JobList extends ResourceLists.ResourceList {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'delete': {
|
case 'delete': {
|
||||||
let modalElement = Utils.HTMLToElement(
|
let modalElement = nopaque.Utils.HTMLToElement(
|
||||||
`
|
`
|
||||||
<div class="modal">
|
<div class="modal">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@ -208,7 +208,7 @@ ResourceLists.JobList = class JobList extends ResourceLists.ResourceList {
|
|||||||
this.selectedItemIds.forEach(selectedItemId => {
|
this.selectedItemIds.forEach(selectedItemId => {
|
||||||
let listItem = this.listjs.get('id', selectedItemId)[0].elm;
|
let listItem = this.listjs.get('id', selectedItemId)[0].elm;
|
||||||
let values = this.listjs.get('id', listItem.dataset.id)[0].values();
|
let values = this.listjs.get('id', listItem.dataset.id)[0].values();
|
||||||
let itemElement = Utils.HTMLToElement(`<li> - ${values.title}</li>`);
|
let itemElement = nopaque.Utils.HTMLToElement(`<li> - ${values.title}</li>`);
|
||||||
itemList.appendChild(itemElement);
|
itemList.appendChild(itemElement);
|
||||||
});
|
});
|
||||||
let modal = M.Modal.init(
|
let modal = M.Modal.init(
|
||||||
@ -224,7 +224,7 @@ ResourceLists.JobList = class JobList extends ResourceLists.ResourceList {
|
|||||||
let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]');
|
let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]');
|
||||||
confirmElement.addEventListener('click', (event) => {
|
confirmElement.addEventListener('click', (event) => {
|
||||||
this.selectedItemIds.forEach(selectedItemId => {
|
this.selectedItemIds.forEach(selectedItemId => {
|
||||||
Requests.jobs.entity.delete(selectedItemId);
|
nopaque.requests.jobs.entity.delete(selectedItemId);
|
||||||
});
|
});
|
||||||
this.selectedItemIds.clear();
|
this.selectedItemIds.clear();
|
||||||
this.renderingItemSelection();
|
this.renderingItemSelection();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
ResourceLists.JobResultList = class JobResultList extends ResourceLists.ResourceList {
|
nopaque.resource_lists.JobResultList = class JobResultList extends nopaque.resource_lists.ResourceList {
|
||||||
static htmlClass = 'job-result-list';
|
static htmlClass = 'job-result-list';
|
||||||
|
|
||||||
constructor(listContainerElement, options = {}) {
|
constructor(listContainerElement, options = {}) {
|
||||||
@ -42,9 +42,9 @@ ResourceLists.JobResultList = class JobResultList extends ResourceLists.Resource
|
|||||||
|
|
||||||
initListContainerElement() {
|
initListContainerElement() {
|
||||||
if (!this.listContainerElement.hasAttribute('id')) {
|
if (!this.listContainerElement.hasAttribute('id')) {
|
||||||
this.listContainerElement.id = Utils.generateElementId('job-result-list-');
|
this.listContainerElement.id = nopaque.Utils.generateElementId('job-result-list-');
|
||||||
}
|
}
|
||||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||||
this.listContainerElement.innerHTML = `
|
this.listContainerElement.innerHTML = `
|
||||||
<div class="input-field">
|
<div class="input-field">
|
||||||
<i class="material-icons prefix">search</i>
|
<i class="material-icons prefix">search</i>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
ResourceLists.PublicCorpusList = class PublicCorpusList extends ResourceLists.ResourceList {
|
nopaque.resource_lists.PublicCorpusList = class PublicCorpusList extends nopaque.resource_lists.ResourceList {
|
||||||
static htmlClass = 'public-corpus-list';
|
static htmlClass = 'public-corpus-list';
|
||||||
|
|
||||||
constructor(listContainerElement, options = {}) {
|
constructor(listContainerElement, options = {}) {
|
||||||
@ -49,9 +49,9 @@ ResourceLists.PublicCorpusList = class PublicCorpusList extends ResourceLists.Re
|
|||||||
|
|
||||||
initListContainerElement() {
|
initListContainerElement() {
|
||||||
if (!this.listContainerElement.hasAttribute('id')) {
|
if (!this.listContainerElement.hasAttribute('id')) {
|
||||||
this.listContainerElement.id = Utils.generateElementId('corpus-list-');
|
this.listContainerElement.id = nopaque.Utils.generateElementId('corpus-list-');
|
||||||
}
|
}
|
||||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||||
this.listContainerElement.innerHTML = `
|
this.listContainerElement.innerHTML = `
|
||||||
<div class="input-field">
|
<div class="input-field">
|
||||||
<i class="material-icons prefix">search</i>
|
<i class="material-icons prefix">search</i>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
ResourceLists.PublicUserList = class PublicUserList extends ResourceLists.ResourceList {
|
nopaque.resource_lists.PublicUserList = class PublicUserList extends nopaque.resource_lists.ResourceList {
|
||||||
static htmlClass = 'public-user-list';
|
static htmlClass = 'public-user-list';
|
||||||
|
|
||||||
constructor(listContainerElement, options = {}) {
|
constructor(listContainerElement, options = {}) {
|
||||||
@ -37,9 +37,9 @@ ResourceLists.PublicUserList = class PublicUserList extends ResourceLists.Resour
|
|||||||
|
|
||||||
initListContainerElement() {
|
initListContainerElement() {
|
||||||
if (!this.listContainerElement.hasAttribute('id')) {
|
if (!this.listContainerElement.hasAttribute('id')) {
|
||||||
this.listContainerElement.id = Utils.generateElementId('user-list-');
|
this.listContainerElement.id = nopaque.Utils.generateElementId('user-list-');
|
||||||
}
|
}
|
||||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||||
this.listContainerElement.innerHTML = `
|
this.listContainerElement.innerHTML = `
|
||||||
<div class="input-field">
|
<div class="input-field">
|
||||||
<i class="material-icons prefix">search</i>
|
<i class="material-icons prefix">search</i>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
ResourceLists.ResourceList = class ResourceList {
|
nopaque.resource_lists.ResourceList = class ResourceList {
|
||||||
/* A wrapper class for the list.js list.
|
/* A wrapper class for the list.js list.
|
||||||
* This class is not meant to be used directly, instead it should be used as
|
* This class is not meant to be used directly, instead it should be used as
|
||||||
* a base class for concrete resource list implementations.
|
* a base class for concrete resource list implementations.
|
||||||
@ -21,9 +21,9 @@ ResourceLists.ResourceList = class ResourceList {
|
|||||||
if ('valueNames' in options) {
|
if ('valueNames' in options) {
|
||||||
throw '"valueNames" is not supported as an option, define it as a getter in the list class';
|
throw '"valueNames" is not supported as an option, define it as a getter in the list class';
|
||||||
}
|
}
|
||||||
let _options = Utils.mergeObjectsDeep(
|
let _options = nopaque.Utils.mergeObjectsDeep(
|
||||||
{item: this.item, valueNames: this.valueNames},
|
{item: this.item, valueNames: this.valueNames},
|
||||||
ResourceLists.ResourceList.defaultOptions,
|
nopaque.resource_lists.ResourceList.defaultOptions,
|
||||||
options
|
options
|
||||||
);
|
);
|
||||||
this.listContainerElement = listContainerElement;
|
this.listContainerElement = listContainerElement;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
ResourceLists.SpaCyNLPPipelineModelList = class SpaCyNLPPipelineModelList extends ResourceLists.ResourceList {
|
nopaque.resource_lists.SpaCyNLPPipelineModelList = class SpaCyNLPPipelineModelList extends nopaque.resource_lists.ResourceList {
|
||||||
static htmlClass = 'spacy-nlp-pipeline-model-list';
|
static htmlClass = 'spacy-nlp-pipeline-model-list';
|
||||||
|
|
||||||
constructor(listContainerElement, options = {}) {
|
constructor(listContainerElement, options = {}) {
|
||||||
@ -60,9 +60,9 @@ ResourceLists.SpaCyNLPPipelineModelList = class SpaCyNLPPipelineModelList extend
|
|||||||
|
|
||||||
initListContainerElement() {
|
initListContainerElement() {
|
||||||
if (!this.listContainerElement.hasAttribute('id')) {
|
if (!this.listContainerElement.hasAttribute('id')) {
|
||||||
this.listContainerElement.id = Utils.generateElementId('spacy-nlp-pipeline-model-list-');
|
this.listContainerElement.id = nopaque.Utils.generateElementId('spacy-nlp-pipeline-model-list-');
|
||||||
}
|
}
|
||||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||||
this.listContainerElement.innerHTML = `
|
this.listContainerElement.innerHTML = `
|
||||||
<div class="input-field">
|
<div class="input-field">
|
||||||
<i class="material-icons prefix">search</i>
|
<i class="material-icons prefix">search</i>
|
||||||
@ -116,7 +116,7 @@ ResourceLists.SpaCyNLPPipelineModelList = class SpaCyNLPPipelineModelList extend
|
|||||||
switch (listAction) {
|
switch (listAction) {
|
||||||
case 'toggle-is-public': {
|
case 'toggle-is-public': {
|
||||||
let newIsPublicValue = listActionElement.checked;
|
let newIsPublicValue = listActionElement.checked;
|
||||||
Requests.contributions.spacy_nlp_pipeline_models.entity.isPublic.update(itemId, newIsPublicValue)
|
nopaque.requests.contributions.spacy_nlp_pipeline_models.entity.isPublic.update(itemId, newIsPublicValue)
|
||||||
.catch((response) => {
|
.catch((response) => {
|
||||||
listActionElement.checked = !newIsPublicValue;
|
listActionElement.checked = !newIsPublicValue;
|
||||||
});
|
});
|
||||||
@ -138,7 +138,7 @@ ResourceLists.SpaCyNLPPipelineModelList = class SpaCyNLPPipelineModelList extend
|
|||||||
switch (listAction) {
|
switch (listAction) {
|
||||||
case 'delete-request': {
|
case 'delete-request': {
|
||||||
let values = this.listjs.get('id', itemId)[0].values();
|
let values = this.listjs.get('id', itemId)[0].values();
|
||||||
let modalElement = Utils.HTMLToElement(
|
let modalElement = nopaque.Utils.HTMLToElement(
|
||||||
`
|
`
|
||||||
<div class="modal">
|
<div class="modal">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@ -165,7 +165,7 @@ ResourceLists.SpaCyNLPPipelineModelList = class SpaCyNLPPipelineModelList extend
|
|||||||
);
|
);
|
||||||
let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]');
|
let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]');
|
||||||
confirmElement.addEventListener('click', (event) => {
|
confirmElement.addEventListener('click', (event) => {
|
||||||
Requests.contributions.spacy_nlp_pipeline_models.entity.delete(itemId);
|
nopaque.requests.contributions.spacy_nlp_pipeline_models.entity.delete(itemId);
|
||||||
});
|
});
|
||||||
modal.open();
|
modal.open();
|
||||||
break;
|
break;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
ResourceLists.TesseractOCRPipelineModelList = class TesseractOCRPipelineModelList extends ResourceLists.ResourceList {
|
nopaque.resource_lists.TesseractOCRPipelineModelList = class TesseractOCRPipelineModelList extends nopaque.resource_lists.ResourceList {
|
||||||
static htmlClass = 'tesseract-ocr-pipeline-model-list';
|
static htmlClass = 'tesseract-ocr-pipeline-model-list';
|
||||||
|
|
||||||
constructor(listContainerElement, options = {}) {
|
constructor(listContainerElement, options = {}) {
|
||||||
@ -69,9 +69,9 @@ ResourceLists.TesseractOCRPipelineModelList = class TesseractOCRPipelineModelLis
|
|||||||
|
|
||||||
initListContainerElement() {
|
initListContainerElement() {
|
||||||
if (!this.listContainerElement.hasAttribute('id')) {
|
if (!this.listContainerElement.hasAttribute('id')) {
|
||||||
this.listContainerElement.id = Utils.generateElementId('tesseract-ocr-pipeline-model-list-');
|
this.listContainerElement.id = nopaque.Utils.generateElementId('tesseract-ocr-pipeline-model-list-');
|
||||||
}
|
}
|
||||||
let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
let listSearchElementId = nopaque.Utils.generateElementId(`${this.listContainerElement.id}-search-`);
|
||||||
this.listContainerElement.innerHTML = `
|
this.listContainerElement.innerHTML = `
|
||||||
<div class="input-field">
|
<div class="input-field">
|
||||||
<i class="material-icons prefix">search</i>
|
<i class="material-icons prefix">search</i>
|
||||||
@ -125,7 +125,7 @@ ResourceLists.TesseractOCRPipelineModelList = class TesseractOCRPipelineModelLis
|
|||||||
switch (listAction) {
|
switch (listAction) {
|
||||||
case 'toggle-is-public': {
|
case 'toggle-is-public': {
|
||||||
let newIsPublicValue = listActionElement.checked;
|
let newIsPublicValue = listActionElement.checked;
|
||||||
Requests.contributions.tesseract_ocr_pipeline_models.entity.isPublic.update(itemId, newIsPublicValue)
|
nopaque.requests.contributions.tesseract_ocr_pipeline_models.entity.isPublic.update(itemId, newIsPublicValue)
|
||||||
.catch((response) => {
|
.catch((response) => {
|
||||||
listActionElement.checked = !newIsPublicValue;
|
listActionElement.checked = !newIsPublicValue;
|
||||||
});
|
});
|
||||||
@ -147,7 +147,7 @@ ResourceLists.TesseractOCRPipelineModelList = class TesseractOCRPipelineModelLis
|
|||||||
switch (listAction) {
|
switch (listAction) {
|
||||||
case 'delete-request': {
|
case 'delete-request': {
|
||||||
let values = this.listjs.get('id', itemId)[0].values();
|
let values = this.listjs.get('id', itemId)[0].values();
|
||||||
let modalElement = Utils.HTMLToElement(
|
let modalElement = nopaque.Utils.HTMLToElement(
|
||||||
`
|
`
|
||||||
<div class="modal">
|
<div class="modal">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@ -174,7 +174,7 @@ ResourceLists.TesseractOCRPipelineModelList = class TesseractOCRPipelineModelLis
|
|||||||
);
|
);
|
||||||
let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]');
|
let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]');
|
||||||
confirmElement.addEventListener('click', (event) => {
|
confirmElement.addEventListener('click', (event) => {
|
||||||
Requests.contributions.tesseract_ocr_pipeline_models.entity.delete(itemId);
|
nopaque.requests.contributions.tesseract_ocr_pipeline_models.entity.delete(itemId);
|
||||||
});
|
});
|
||||||
modal.open();
|
modal.open();
|
||||||
break;
|
break;
|
||||||
|
91
app/static/js/utils.js
Normal file
91
app/static/js/utils.js
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
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 +0,0 @@
|
|||||||
Utils = {};
|
|
@ -1,89 +0,0 @@
|
|||||||
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,36 +7,9 @@
|
|||||||
{%- assets
|
{%- assets
|
||||||
filters='rjsmin',
|
filters='rjsmin',
|
||||||
output='gen/app.%(version)s.js',
|
output='gen/app.%(version)s.js',
|
||||||
'js/nopaque/index.js',
|
'js/index.js',
|
||||||
'js/nopaque/app.js'
|
'js/app.js',
|
||||||
%}
|
'js/utils.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 %}
|
|
||||||
|
|
||||||
{%- assets
|
|
||||||
filters='rjsmin',
|
|
||||||
output='gen/cqi.%(version)s.js',
|
|
||||||
'js/cqi/index.js',
|
|
||||||
'js/cqi/constants.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'
|
|
||||||
%}
|
%}
|
||||||
<script src="{{ ASSET_URL }}"></script>
|
<script src="{{ ASSET_URL }}"></script>
|
||||||
{%- endassets %}
|
{%- endassets %}
|
||||||
@ -102,7 +75,20 @@
|
|||||||
|
|
||||||
{%- assets
|
{%- assets
|
||||||
filters='rjsmin',
|
filters='rjsmin',
|
||||||
output='gen/CorpusAnalysis.%(version)s.js',
|
output='gen/corpus-analysis.%(version)s.js',
|
||||||
|
'js/CorpusAnalysis/index.js',
|
||||||
|
'js/CorpusAnalysis/cqi/index.js',
|
||||||
|
'js/CorpusAnalysis/cqi/constants.js',
|
||||||
|
'js/CorpusAnalysis/cqi/errors.js',
|
||||||
|
'js/CorpusAnalysis/cqi/status.js',
|
||||||
|
'js/CorpusAnalysis/cqi/api/index.js',
|
||||||
|
'js/CorpusAnalysis/cqi/api/client.js',
|
||||||
|
'js/CorpusAnalysis/cqi/models/index.js',
|
||||||
|
'js/CorpusAnalysis/cqi/models/resource.js',
|
||||||
|
'js/CorpusAnalysis/cqi/models/attributes.js',
|
||||||
|
'js/CorpusAnalysis/cqi/models/subcorpora.js',
|
||||||
|
'js/CorpusAnalysis/cqi/models/corpora.js',
|
||||||
|
'js/CorpusAnalysis/cqi/client.js',
|
||||||
'js/CorpusAnalysis/query-builder/index.js',
|
'js/CorpusAnalysis/query-builder/index.js',
|
||||||
'js/CorpusAnalysis/query-builder/element-references.js',
|
'js/CorpusAnalysis/query-builder/element-references.js',
|
||||||
'js/CorpusAnalysis/query-builder/general-query-builder-functions.js',
|
'js/CorpusAnalysis/query-builder/general-query-builder-functions.js',
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
{{ super() }}
|
{{ super() }}
|
||||||
<script>
|
<script>
|
||||||
let corpusListElement = document.querySelector('#corpus-list');
|
let corpusListElement = document.querySelector('#corpus-list');
|
||||||
let corpusList = new ResourceLists.CorpusList(corpusListElement);
|
let corpusList = new nopaque.resource_lists.CorpusList(corpusListElement);
|
||||||
corpusList.add(
|
corpusList.add(
|
||||||
[
|
[
|
||||||
{% for corpus in corpora %}
|
{% for corpus in corpora %}
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
let userConfirmedSwitchElement = document.querySelector('#user-confirmed-switch');
|
let userConfirmedSwitchElement = document.querySelector('#user-confirmed-switch');
|
||||||
userConfirmedSwitchElement.addEventListener('change', (event) => {
|
userConfirmedSwitchElement.addEventListener('change', (event) => {
|
||||||
let newConfirmed = userConfirmedSwitchElement.checked;
|
let newConfirmed = userConfirmedSwitchElement.checked;
|
||||||
Requests.admin.users.entity.confirmed.update({{ user.hashid|tojson }}, newConfirmed)
|
nopaque.requests.admin.users.entity.confirmed.update({{ user.hashid|tojson }}, newConfirmed)
|
||||||
.catch((response) => {
|
.catch((response) => {
|
||||||
userConfirmedSwitchElement.checked = !userConfirmedSwitchElement;
|
userConfirmedSwitchElement.checked = !userConfirmedSwitchElement;
|
||||||
});
|
});
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
{{ super() }}
|
{{ super() }}
|
||||||
<script>
|
<script>
|
||||||
let adminUserListElement = document.querySelector('#admin-user-list');
|
let adminUserListElement = document.querySelector('#admin-user-list');
|
||||||
let adminUserList = new ResourceLists.AdminUserList(adminUserListElement);
|
let adminUserList = new nopaque.resource_lists.AdminUserList(adminUserListElement);
|
||||||
adminUserList.add(
|
adminUserList.add(
|
||||||
[
|
[
|
||||||
{% for user in users %}
|
{% for user in users %}
|
||||||
|
@ -240,7 +240,7 @@
|
|||||||
{% if current_user.is_following_corpus(corpus) %}
|
{% if current_user.is_following_corpus(corpus) %}
|
||||||
let unfollowRequestElement = document.querySelector('.action-button[data-action="unfollow-request"]');
|
let unfollowRequestElement = document.querySelector('.action-button[data-action="unfollow-request"]');
|
||||||
unfollowRequestElement.addEventListener('click', () => {
|
unfollowRequestElement.addEventListener('click', () => {
|
||||||
Requests.corpora.entity.followers.entity.delete({{ corpus.hashid|tojson }}, {{ current_user.hashid|tojson }})
|
nopaque.requests.corpora.entity.followers.entity.delete({{ corpus.hashid|tojson }}, {{ current_user.hashid|tojson }})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
@ -252,7 +252,7 @@
|
|||||||
let publishingModalIsPublicSwitchElement = document.querySelector('#publishing-modal-is-public-switch');
|
let publishingModalIsPublicSwitchElement = document.querySelector('#publishing-modal-is-public-switch');
|
||||||
publishingModalIsPublicSwitchElement.addEventListener('change', (event) => {
|
publishingModalIsPublicSwitchElement.addEventListener('change', (event) => {
|
||||||
let newIsPublic = publishingModalIsPublicSwitchElement.checked;
|
let newIsPublic = publishingModalIsPublicSwitchElement.checked;
|
||||||
Requests.corpora.entity.isPublic.update({{ corpus.hashid|tojson }}, newIsPublic)
|
nopaque.requests.corpora.entity.isPublic.update({{ corpus.hashid|tojson }}, newIsPublic)
|
||||||
.catch((response) => {
|
.catch((response) => {
|
||||||
publishingModalIsPublicSwitchElement.checked = !newIsPublic;
|
publishingModalIsPublicSwitchElement.checked = !newIsPublic;
|
||||||
});
|
});
|
||||||
@ -262,7 +262,7 @@ publishingModalIsPublicSwitchElement.addEventListener('change', (event) => {
|
|||||||
// #region Delete
|
// #region Delete
|
||||||
let deleteModalDeleteButtonElement = document.querySelector('#delete-modal-delete-button');
|
let deleteModalDeleteButtonElement = document.querySelector('#delete-modal-delete-button');
|
||||||
deleteModalDeleteButtonElement.addEventListener('click', (event) => {
|
deleteModalDeleteButtonElement.addEventListener('click', (event) => {
|
||||||
Requests.corpora.entity.delete({{ corpus.hashid|tojson }})
|
nopaque.requests.corpora.entity.delete({{ corpus.hashid|tojson }})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
window.location.href = {{ url_for('main.dashboard')|tojson }};
|
window.location.href = {{ url_for('main.dashboard')|tojson }};
|
||||||
});
|
});
|
||||||
@ -312,7 +312,7 @@ M.Modal.init(
|
|||||||
|
|
||||||
inviteUserModalInviteButtonElement.addEventListener('click', (event) => {
|
inviteUserModalInviteButtonElement.addEventListener('click', (event) => {
|
||||||
let usernames = inviteUserModalSearch.chipsData.map((chipData) => chipData.tag);
|
let usernames = inviteUserModalSearch.chipsData.map((chipData) => chipData.tag);
|
||||||
Requests.corpora.entity.followers.add({{ corpus.hashid|tojson }}, usernames);
|
nopaque.requests.corpora.entity.followers.add({{ corpus.hashid|tojson }}, usernames);
|
||||||
});
|
});
|
||||||
// #endregion Invite user
|
// #endregion Invite user
|
||||||
|
|
||||||
@ -357,7 +357,7 @@ M.Modal.init(
|
|||||||
shareLinkModalCreateButtonElement.addEventListener('click', (event) => {
|
shareLinkModalCreateButtonElement.addEventListener('click', (event) => {
|
||||||
let role = shareLinkModalCorpusFollowerRoleSelectElement.value;
|
let role = shareLinkModalCorpusFollowerRoleSelectElement.value;
|
||||||
let expiration = shareLinkModalExpirationDateDatepickerElement.value
|
let expiration = shareLinkModalExpirationDateDatepickerElement.value
|
||||||
Requests.corpora.entity.generateShareLink({{ corpus.hashid|tojson }}, role, expiration)
|
nopaque.requests.corpora.entity.generateShareLink({{ corpus.hashid|tojson }}, role, expiration)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
response.json()
|
response.json()
|
||||||
.then((json) => {
|
.then((json) => {
|
||||||
|
@ -242,7 +242,7 @@
|
|||||||
{{ super() }}
|
{{ super() }}
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
let publicCorpusFileList = new ResourceLists.CorpusFileList(document.querySelector('#corpus-file-list'));
|
let publicCorpusFileList = new nopaque.resource_lists.CorpusFileList(document.querySelector('#corpus-file-list'));
|
||||||
publicCorpusFileList.add(
|
publicCorpusFileList.add(
|
||||||
[
|
[
|
||||||
{% for corpus_file in corpus.files %}
|
{% for corpus_file in corpus.files %}
|
||||||
@ -259,7 +259,7 @@ refreshButton.addEventListener('click', () => {
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if cfr.has_permission('MANAGE_FOLLOWERS') %}
|
{% if cfr.has_permission('MANAGE_FOLLOWERS') %}
|
||||||
let publicCorpusFollowerList = new ResourceLists.CorpusFollowerList(document.querySelector('.corpus-follower-list'));
|
let publicCorpusFollowerList = new nopaque.resource_lists.CorpusFollowerList(document.querySelector('.corpus-follower-list'));
|
||||||
publicCorpusFollowerList.add(
|
publicCorpusFollowerList.add(
|
||||||
[
|
[
|
||||||
{% for cfa in cfas %}
|
{% for cfa in cfas %}
|
||||||
|
@ -50,7 +50,6 @@
|
|||||||
<p>Find public corpora.</p>
|
<p>Find public corpora.</p>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<span class="card-title">Public Corpora</span>
|
|
||||||
<div id="public-corpus-list"></div>
|
<div id="public-corpus-list"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -63,7 +62,7 @@
|
|||||||
{{ super() }}
|
{{ super() }}
|
||||||
<script>
|
<script>
|
||||||
let publicUserListElement = document.querySelector('#public-user-list');
|
let publicUserListElement = document.querySelector('#public-user-list');
|
||||||
let publicUserList = new ResourceLists.PublicUserList(publicUserListElement);
|
let publicUserList = new nopaque.resource_lists.PublicUserList(publicUserListElement);
|
||||||
publicUserList.add(
|
publicUserList.add(
|
||||||
[
|
[
|
||||||
{% for user in users %}
|
{% for user in users %}
|
||||||
@ -73,7 +72,7 @@
|
|||||||
);
|
);
|
||||||
|
|
||||||
let publicCorpusListElement = document.querySelector('#public-corpus-list');
|
let publicCorpusListElement = document.querySelector('#public-corpus-list');
|
||||||
let publicCorpusList = new ResourceLists.PublicCorpusList(publicCorpusListElement);
|
let publicCorpusList = new nopaque.resource_lists.PublicCorpusList(publicCorpusListElement);
|
||||||
publicCorpusList.add(
|
publicCorpusList.add(
|
||||||
[
|
[
|
||||||
{% for corpus in corpora %}
|
{% for corpus in corpora %}
|
||||||
|
@ -221,7 +221,7 @@ avatarUploadElement.addEventListener('change', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
document.querySelector('#delete-avatar').addEventListener('click', () => {
|
document.querySelector('#delete-avatar').addEventListener('click', () => {
|
||||||
Requests.users.entity.avatar.delete({{ user.hashid|tojson }})
|
nopaque.requests.users.entity.avatar.delete({{ user.hashid|tojson }})
|
||||||
.then(
|
.then(
|
||||||
(response) => {
|
(response) => {
|
||||||
avatarPreviewElement.src = {{ url_for('static', filename='images/user_avatar.png')|tojson }};
|
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) => {
|
document.querySelector('#delete-user').addEventListener('click', (event) => {
|
||||||
Requests.users.entity.delete({{ user.hashid|tojson }})
|
nopaque.requests.users.entity.delete({{ user.hashid|tojson }})
|
||||||
.then((response) => {window.location.href = '/';});
|
.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');
|
let profilePrivacySettingCheckboxElements = document.querySelectorAll('.profile-privacy-setting-checkbox');
|
||||||
profileIsPublicSwitchElement.addEventListener('change', (event) => {
|
profileIsPublicSwitchElement.addEventListener('change', (event) => {
|
||||||
let newEnabled = profileIsPublicSwitchElement.checked;
|
let newEnabled = profileIsPublicSwitchElement.checked;
|
||||||
Requests.users.entity.settings.profilePrivacy.update({{ user.hashid|tojson }}, 'is-public', newEnabled)
|
nopaque.requests.users.entity.settings.profilePrivacy.update({{ user.hashid|tojson }}, 'is-public', newEnabled)
|
||||||
.then(
|
.then(
|
||||||
(response) => {
|
(response) => {
|
||||||
for (let profilePrivacySettingCheckboxElement of document.querySelectorAll('.profile-privacy-setting-checkbox')) {
|
for (let profilePrivacySettingCheckboxElement of document.querySelectorAll('.profile-privacy-setting-checkbox')) {
|
||||||
@ -271,7 +271,7 @@ for (let profilePrivacySettingCheckboxElement of profilePrivacySettingCheckboxEl
|
|||||||
profilePrivacySettingCheckboxElement.addEventListener('change', (event) => {
|
profilePrivacySettingCheckboxElement.addEventListener('change', (event) => {
|
||||||
let newEnabled = profilePrivacySettingCheckboxElement.checked;
|
let newEnabled = profilePrivacySettingCheckboxElement.checked;
|
||||||
let valueName = profilePrivacySettingCheckboxElement.dataset.profilePrivacySettingName;
|
let valueName = profilePrivacySettingCheckboxElement.dataset.profilePrivacySettingName;
|
||||||
Requests.users.entity.settings.profilePrivacy.update({{ user.hashid|tojson }}, valueName, newEnabled)
|
nopaque.requests.users.entity.settings.profilePrivacy.update({{ user.hashid|tojson }}, valueName, newEnabled)
|
||||||
.catch((response) => {
|
.catch((response) => {
|
||||||
profilePrivacySettingCheckboxElement.checked = !newEnabled;
|
profilePrivacySettingCheckboxElement.checked = !newEnabled;
|
||||||
});
|
});
|
||||||
|
@ -122,7 +122,7 @@
|
|||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
<script>
|
<script>
|
||||||
let followedCorpusList = new ResourceLists.PublicCorpusList(document.querySelector('.followed-corpus-list'));
|
let followedCorpusList = new nopaque.resource_lists.PublicCorpusList(document.querySelector('.followed-corpus-list'));
|
||||||
followedCorpusList.add(
|
followedCorpusList.add(
|
||||||
[
|
[
|
||||||
{% for corpus in user.followed_corpora %}
|
{% for corpus in user.followed_corpora %}
|
||||||
@ -132,7 +132,7 @@ followedCorpusList.add(
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
let publicCorpusList = new ResourceLists.PublicCorpusList(document.querySelector('.public-corpus-list'));
|
let publicCorpusList = new nopaque.resource_lists.PublicCorpusList(document.querySelector('.public-corpus-list'));
|
||||||
publicCorpusList.add(
|
publicCorpusList.add(
|
||||||
[
|
[
|
||||||
{% for corpus in user.corpora %}
|
{% for corpus in user.corpora %}
|
||||||
|
Loading…
Reference in New Issue
Block a user