Results import fixes and additions. Table creation rework.

This commit is contained in:
Stephan Porada
2020-07-07 15:08:15 +02:00
parent 5867871de2
commit 7648149584
13 changed files with 296 additions and 167 deletions

View File

@ -1,14 +1,21 @@
class RessourceList extends List {
constructor(idOrElement, subscriberList, type, options={}) {
if (!['corpus', 'job'].includes(type)) {
if (!["corpus", "job", "result"].includes(type)) {
console.error("Unknown Type!");
return;
}
if (subscriberList) {
super(idOrElement, {...RessourceList.options['common'],
...RessourceList.options[type],
...options});
this.type = type;
subscriberList.push(this);
} else {
super(idOrElement, {...RessourceList.options['extended'],
...RessourceList.options[type],
...options});
this.type = type;
}
}
@ -53,6 +60,8 @@ class RessourceList extends List {
this.add(ressources.map(x => RessourceList.dataMapper[this.type](x)));
}
}
RessourceList.dataMapper = {
corpus: corpus => ({creation_date: corpus.creation_date,
description: corpus.description,
@ -67,10 +76,35 @@ RessourceList.dataMapper = {
link: `/jobs/${job.id}`,
service: job.service,
status: job.status,
title: job.title})
title: job.title}),
result : result => ({ query: result.query,
match_count: result.match_count,
corpus_name: result.corpus_name,
corpus_creation_date: result.corpus_creation_date,
corpus_analysis_date: result.corpus_analysis_date,
corpus_type : result.corpus_type,
"details-link": `${result.id}/details`,
"inspect-link": `${result.id}/inspect`,
"delete-modal": `delete-result-${result.id}-modal`})
};
RessourceList.options = {
common: {page: 4, pagination: {innerWindow: 8, outerWindow: 1}},
extended: {page: 10,
pagination: [
{
name: "paginationTop",
paginationClass: "paginationTop",
innerWindow: 8,
outerWindow: 1
},
{
paginationClass: "paginationBottom",
innerWindow: 8,
outerWindow: 1
}
]},
corpus: {item: `<tr>
<td>
<a class="btn-floating disabled">
@ -122,7 +156,33 @@ RessourceList.options = {
{data: ["id"]},
{name: "link", attr: "href"},
{name: "service", attr: "data-service"},
{name: "status", attr: "data-status"}]}
{name: "status", attr: "data-status"}]},
result : {item: `<tr>
<td class="query"></td>
<td class="match_count"></td>
<td class="corpus_name"></td>
<td class="corpus_creation_date"></td>
<td class="corpus_analysis_date"></td>
<td class="corpus_type"></td>
<td class="actions right-align">
<a class="btn-floating details-link waves-effect waves-light"><i class="material-icons">info_outline</i>
</a>
<a class="btn-floating inspect-link waves-effect waves-light"><i class="material-icons">search</i>
</a>
<a class="btn-floating red delete-modal waves-effect waves-light modal-trigger"><i class="material-icons">delete</i>
</a>
</td>
</tr>`,
valueNames: ["query",
"match_count",
"corpus_name",
"corpus_creation_date",
"corpus_analysis_date",
"corpus_type",
{name: "details-link", attr: "href"},
{name: "inspect-link", attr: "href"},
{name: "delete-modal", attr: "data-target"}]
}
};