mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-13 17:40:40 +00:00
Fix url issues and remove unused modules
This commit is contained in:
@ -1,134 +0,0 @@
|
||||
class QueryResultList extends RessourceList {
|
||||
static autoInit() {
|
||||
for (let queryResultListElement of document.querySelectorAll('.query-result-list:not(.no-autoinit)')) {
|
||||
new QueryResultList(queryResultListElement);
|
||||
}
|
||||
}
|
||||
|
||||
static options = {
|
||||
item: `
|
||||
<tr class="hoverable">
|
||||
<td><b class="title"></b><br><i class="description"></i><br></td>
|
||||
<td><span class="corpus-title"></span><br><span class="query"></span></td>
|
||||
<td class="right-align">
|
||||
<a class="action-button btn-floating red waves-effect waves-light" data-action="delete"><i class="material-icons">delete</i></a>
|
||||
<a class="action-button btn-floating waves-effect waves-light" data-action="view"><i class="material-icons">send</i></a>
|
||||
</td>
|
||||
</tr>
|
||||
`.trim(),
|
||||
ressourceMapper: queryResult => {
|
||||
return {
|
||||
'id': queryResult.id,
|
||||
'corpus-title': queryResult.corpus_title,
|
||||
'creation-date': queryResult.creation_date,
|
||||
'description': queryResult.description,
|
||||
'query': queryResult.query,
|
||||
'title': queryResult.title
|
||||
};
|
||||
},
|
||||
sortArgs: ['creation-date', {order: 'desc'}],
|
||||
valueNames: [
|
||||
{data: ['id']},
|
||||
{data: ['creation-date']},
|
||||
'corpus-title',
|
||||
'description',
|
||||
'query',
|
||||
'title'
|
||||
]
|
||||
};
|
||||
|
||||
constructor(listElement, options = {}) {
|
||||
super(listElement, {...QueryResultList.options, ...options});
|
||||
}
|
||||
|
||||
init(user) {
|
||||
super._init(user.query_results);
|
||||
}
|
||||
|
||||
onclick(event) {
|
||||
let action;
|
||||
let actionButtonElement;
|
||||
let deleteModal;
|
||||
let deleteModalElement;
|
||||
let queryResultElement;
|
||||
let queryResultId;
|
||||
let tmp;
|
||||
|
||||
queryResultElement = event.target.closest('tr[data-id]');
|
||||
if (queryResultElement === null) {return;}
|
||||
queryResultId = queryResultElement.dataset.id;
|
||||
actionButtonElement = event.target.closest('.action-button[data-action]');
|
||||
action = actionButtonElement === null ? 'view' : actionButtonElement.dataset.action;
|
||||
switch (action) {
|
||||
case 'delete':
|
||||
tmp = document.createElement('div');
|
||||
tmp.innerHTML = `
|
||||
<div class="modal">
|
||||
<div class="modal-content">
|
||||
<h4>Confirm query result deletion</h4>
|
||||
<p>Do you really want to delete the query result <b>${app.users[this.userId].query_results[queryResultId].title}</b>? It will be permanently deleted!</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#!" class="btn modal-close waves-effect waves-light">Cancel</a>
|
||||
<a class="btn modal-close red waves-effect waves-light" href="/query_results/${queryResultId}/delete"><i class="material-icons left">delete</i>Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
`.trim();
|
||||
deleteModalElement = document.querySelector('#modals').appendChild(tmp.firstChild);
|
||||
deleteModal = M.Modal.init(
|
||||
deleteModalElement,
|
||||
{
|
||||
onCloseEnd: () => {
|
||||
deleteModal.destroy();
|
||||
deleteModalElement.remove();
|
||||
}
|
||||
}
|
||||
);
|
||||
deleteModal.open();
|
||||
break;
|
||||
case 'view':
|
||||
window.location.href = `/query_results/${queryResultId}`;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
onPATCH(patch) {
|
||||
let filteredPatch;
|
||||
let match;
|
||||
let operation;
|
||||
let queryResultId;
|
||||
let re;
|
||||
let valueName;
|
||||
|
||||
re = new RegExp(`^/users/${this.userId}/query_results/([A-Za-z0-9]*)`);
|
||||
filteredPatch = patch.filter(operation => re.test(operation.path));
|
||||
for (operation of filteredPatch) {
|
||||
switch(operation.op) {
|
||||
case 'add':
|
||||
re = new RegExp(`^/users/${this.userId}/query_results/([A-Za-z0-9]*)$`);
|
||||
if (re.test(operation.path)) {
|
||||
this.add(operation.value);
|
||||
}
|
||||
break;
|
||||
case 'remove':
|
||||
re = new RegExp(`^/users/${this.userId}/query_results/([A-Za-z0-9]*)$`);
|
||||
if (re.test(operation.path)) {
|
||||
[match, queryResultId] = operation.path.match(re);
|
||||
this.remove(queryResultId);
|
||||
}
|
||||
break;
|
||||
case 'replace':
|
||||
re = new RegExp(`^/users/${this.userId}/query_results/([A-Za-z0-9]*)/(corpus_title|description|query|title)$`);
|
||||
if (re.test(operation.path)) {
|
||||
[match, queryResultId, valueName] = operation.path.match(re);
|
||||
this.replace(queryResultId, valueName.replace('_', '-'), operation.value);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -10,9 +10,8 @@ class RessourceList {
|
||||
JobList.autoInit();
|
||||
JobInputList.autoInit();
|
||||
JobResultList.autoInit();
|
||||
SpacyNLPPipelineModelList.autoInit();
|
||||
SpaCyNLPPipelineModelList.autoInit();
|
||||
TesseractOCRPipelineModelList.autoInit();
|
||||
QueryResultList.autoInit();
|
||||
UserList.autoInit();
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
class SpacyNLPPipelineModelList extends RessourceList {
|
||||
class SpaCyNLPPipelineModelList extends RessourceList {
|
||||
static autoInit() {
|
||||
for (let spaCyNLPPipelineModelListElement of document.querySelectorAll('.spacy-nlp-pipeline-model-list:not(.no-autoinit)')) {
|
||||
new SpacyNLPPipelineModelList(spaCyNLPPipelineModelListElement);
|
||||
new SpaCyNLPPipelineModelList(spaCyNLPPipelineModelListElement);
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ class SpacyNLPPipelineModelList extends RessourceList {
|
||||
};
|
||||
|
||||
constructor(listElement, options = {}) {
|
||||
super(listElement, {...SpacyNLPPipelineModelList.options, ...options});
|
||||
super(listElement, {...SpaCyNLPPipelineModelList.options, ...options});
|
||||
}
|
||||
|
||||
init (user) {
|
||||
|
@ -33,8 +33,8 @@ class Utils {
|
||||
`
|
||||
<div class="modal">
|
||||
<div class="modal-content">
|
||||
<h4>Confirm job deletion</h4>
|
||||
<p>Do you really want to delete the job <b>${corpus.title}</b>? All files will be permanently deleted!</p>
|
||||
<h4>Confirm Corpus deletion</h4>
|
||||
<p>Do you really want to delete the Corpus <b>${corpus.title}</b>? All files will be permanently deleted!</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a class="action-button btn modal-close waves-effect waves-light" data-action="cancel">Cancel</a>
|
||||
@ -230,8 +230,8 @@ class Utils {
|
||||
`
|
||||
<div class="modal">
|
||||
<div class="modal-content">
|
||||
<h4>Confirm job deletion</h4>
|
||||
<p>Do you really want to delete the job <b>${job.title}</b>? All files will be permanently deleted!</p>
|
||||
<h4>Confirm Job deletion</h4>
|
||||
<p>Do you really want to delete the Job <b>${job.title}</b>? All files will be permanently deleted!</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a class="action-button btn modal-close waves-effect waves-light" data-action="cancel">Cancel</a>
|
||||
@ -327,8 +327,8 @@ class Utils {
|
||||
`
|
||||
<div class="modal">
|
||||
<div class="modal-content">
|
||||
<h4>Confirm job restart</h4>
|
||||
<p>Do you really want to restart the job <b>${job.title}</b>? All log and result files will be permanently deleted.</p>
|
||||
<h4>Confirm Job restart</h4>
|
||||
<p>Do you really want to restart the Job <b>${job.title}</b>? All Job Results will be permanently deleted.</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a class="action-button btn modal-close waves-effect waves-light" data-action="cancel">Cancel</a>
|
||||
@ -378,8 +378,8 @@ class Utils {
|
||||
`
|
||||
<div class="modal">
|
||||
<div class="modal-content">
|
||||
<h4>Confirm job deletion</h4>
|
||||
<p>Do you really want to delete the user <b>${user.username}</b>? All files will be permanently deleted!</p>
|
||||
<h4>Confirm User deletion</h4>
|
||||
<p>Do you really want to delete the User <b>${user.username}</b>? All files will be permanently deleted!</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a class="action-button btn modal-close waves-effect waves-light" data-action="cancel">Cancel</a>
|
||||
|
Reference in New Issue
Block a user