Unify job input tables

This commit is contained in:
Stephan Porada
2020-07-08 11:35:47 +02:00
parent 0fff7801fd
commit 43f79291aa
4 changed files with 82 additions and 63 deletions

View File

@ -1,6 +1,6 @@
class RessourceList extends List {
constructor(idOrElement, subscriberList, type, options={}) {
if (!["corpus", "job", "result", "user"].includes(type)) {
if (!["corpus", "job", "result", "user", "job_input"].includes(type)) {
console.error("Unknown Type!");
return;
}
@ -63,6 +63,15 @@ class RessourceList extends List {
RessourceList.dataMapper = {
// ### Mapping Genera Info
//The Mapping describes entitys rendered per row. One key value pair holds
// the data to be rendered in the list.js table. Key has to correspond
// with the ValueNames defined below in RessourceList.options ValueNames.
// Links are declared with double ticks(") around them. The key for links
// have to correspond with the class of an <a> element in the
// RessourceList.options item blueprint.
// Mapping for corpus entities shown in the dashboard table.
corpus: corpus => ({creation_date: corpus.creation_date,
description: corpus.description,
id: corpus.id,
@ -70,6 +79,7 @@ RessourceList.dataMapper = {
"edit-link": `/corpora/${corpus.id}`,
status: corpus.status,
title: corpus.title}),
// Mapping for job entities shown in the dashboard table.
job: job => ({creation_date: job.creation_date,
description: job.description,
id: job.id,
@ -77,6 +87,12 @@ RessourceList.dataMapper = {
service: job.service,
status: job.status,
title: job.title}),
// Mapping for job input files shown in table on every job page
job_input: job_input => ({filename: job_input.filename,
id: job_input.job_id,
"download-link": `${job_input.job_id}/inputs/${job_input.id}/download`}),
// Mapping for imported result entities from corpus analysis.
// Shown in imported results table
result: result => ({ query: result.query,
match_count: result.match_count,
corpus_name: result.corpus_name,
@ -86,6 +102,7 @@ RessourceList.dataMapper = {
"details-link": `${result.id}/details`,
"inspect-link": `${result.id}/inspect`,
"delete-modal": `delete-result-${result.id}-modal`}),
// Mapping for user entities shown in admin table
user: user => ({username: user.username,
email: user.email,
role_id: user.role_id,
@ -96,7 +113,9 @@ RessourceList.dataMapper = {
RessourceList.options = {
// common list.js options for 4 rows per page etc.
common: {page: 4, pagination: {innerWindow: 8, outerWindow: 1}},
// extended list.js options for 10 rows per page etc.
extended: {page: 10,
pagination: [
{
@ -111,6 +130,8 @@ RessourceList.options = {
outerWindow: 1
}
]},
// Corpus entity blueprint setting html strucuture per entity per row
// Link classes have to correspond with Links defined in the Mapping process
corpus: {item: `<tr>
<td>
<a class="btn-floating disabled">
@ -134,11 +155,18 @@ RessourceList.options = {
</a>
</td>
</tr>`,
valueNames: ["creation_date", "description", "title",
// Corpus Value Names per column. Have to correspond with the keys from the
// Mapping step above.
valueNames: ["creation_date",
"description",
"title",
{data: ["id"]},
{name: "analyse-link", attr: "href"},
{name: "edit-link", attr: "href"},
{name: "status", attr: "data-status"}]},
{name: "status", attr: "data-status"}]
},
// Job entity blueprint setting html strucuture per entity per row
// Link classes have to correspond with Links defined in the Mapping process
job: {item: `<tr>
<td>
<a class="btn-floating disabled">
@ -158,11 +186,30 @@ RessourceList.options = {
</a>
</td>
</tr>`,
valueNames: ["creation_date", "description", "title",
// Job Value Names per column. Have to correspond with the keys from the
// Mapping step above.
valueNames: ["creation_date",
"description",
"title",
{data: ["id"]},
{name: "link", attr: "href"},
{name: "service", attr: "data-service"},
{name: "status", attr: "data-status"}]},
{name: "status", attr: "data-status"}]
},
job_input: {item : `<tr>
<td class="filename"></td>
<td class="actions">
<a class="btn-floating download-link waves-effect waves-light"><i class="material-icons">file_download</i>
</a>
</td>
</tr>`,
valueNames: ["filename",
"id",
{name: "download-link", attr: "href"}]
},
// Result (imported from corpus analysis) entity blueprint setting html
// strucuture per entity per row
// Link classes have to correspond with Links defined in the Mapping process
result: {item: `<tr>
<td class="query"></td>
<td class="match_count"></td>
@ -179,6 +226,8 @@ RessourceList.options = {
</a>
</td>
</tr>`,
// Result Value Names per column. Have to correspond with keys from the
// Mapping step above.
valueNames: ["query",
"match_count",
"corpus_name",
@ -187,7 +236,10 @@ RessourceList.options = {
"corpus_type",
{name: "details-link", attr: "href"},
{name: "inspect-link", attr: "href"},
{name: "delete-modal", attr: "data-target"}]},
{name: "delete-modal", attr: "data-target"}]
},
// User entity blueprint setting html strucuture per entity per row
// Link classes have to correspond with Links defined in the Mapping process
user: {item: `<tr>
<td class="username"></td>
<td class="email"></td>
@ -199,12 +251,15 @@ RessourceList.options = {
</a>
</td>
</tr>`,
// User Value Names per column. Have to correspond with keys from the
// Mapping step above.
valueNames: ["username",
"email",
"role_id",
"confirmed",
"id",
{name: "profile-link", attr: "href"}]}
{name: "profile-link", attr: "href"}]
}
};