Unify more tables (Corpus: corpus files view)

This commit is contained in:
Stephan Porada
2020-07-08 15:24:18 +02:00
parent 43f79291aa
commit ea7bb82661
7 changed files with 134 additions and 51 deletions

View File

@ -1,6 +1,7 @@
class RessourceList extends List {
constructor(idOrElement, subscriberList, type, options={}) {
if (!["corpus", "job", "result", "user", "job_input"].includes(type)) {
if (!["corpus", "job", "result", "user", "job_input",
"corpus_file"].includes(type)) {
console.error("Unknown Type!");
return;
}
@ -78,7 +79,17 @@ RessourceList.dataMapper = {
"analyse-link": ["analysing", "prepared", "start analysis"].includes(corpus.status) ? `/corpora/${corpus.id}/analyse` : "",
"edit-link": `/corpora/${corpus.id}`,
status: corpus.status,
title: corpus.title}),
title: corpus.title
}),
// Mapping for corpus file entities shown in the corpus overview
corpus_file: corpus_file => ({filename: corpus_file.filename,
author: corpus_file.author,
title: corpus_file.title,
publishing_year: corpus_file.publishing_year,
"edit-link": `${corpus_file.corpus_id}/files/${corpus_file.id}/edit`,
"download-link": `${corpus_file.corpus_id}/files/${corpus_file.id}/download`,
"delete-modal": `delete-corpus-file-${corpus_file.id}-modal`
}),
// Mapping for job entities shown in the dashboard table.
job: job => ({creation_date: job.creation_date,
description: job.description,
@ -86,11 +97,13 @@ RessourceList.dataMapper = {
link: `/jobs/${job.id}`,
service: job.service,
status: job.status,
title: job.title}),
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`}),
"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,
@ -101,14 +114,16 @@ RessourceList.dataMapper = {
corpus_type : result.corpus_type,
"details-link": `${result.id}/details`,
"inspect-link": `${result.id}/inspect`,
"delete-modal": `delete-result-${result.id}-modal`}),
"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,
confirmed: user.confirmed,
id: user.id,
"profile-link": `user/${user.id}`})
"profile-link": `user/${user.id}`
})
};
@ -146,12 +161,12 @@ RessourceList.options = {
<span class="badge new status" data-badge-caption="">
</span>
</td>
<td class="right-align">
<a class="btn-floating edit-link waves-effect waves-light">
<td class="actions center-align">
<a class="btn-floating edit-link waves-effect waves-light" data-tooltip="Edit">
<i class="material-icons">edit</i>
</a>
<a class="btn-floating analyse-link waves-effect waves-light">
<i class="material-icons right">search</i>
<i class="material-icons">search</i>
</a>
</td>
</tr>`,
@ -165,6 +180,42 @@ RessourceList.options = {
{name: "edit-link", attr: "href"},
{name: "status", attr: "data-status"}]
},
// Corpus file entity blueprint setting html strucuture per entity per row
// Link classes have to correspond with Links defined in the Mapping process
corpus_file: {item: `<tr>
<td class="filename" style="word-break: break-word;"></td>
<td class="author" style="word-break: break-word;"></td>
<td class="title" style="word-break: break-word;"></td>
<td class="publishing_year" style="word-break: break-word;"></td>
<td class="actions center-align">
<a class="btn-floating tooltipped edit-link
waves-effect waves-light"
data-position="top"
data-tooltip="Edit">
<i class="material-icons">edit</i>
</a>
<a class="btn-floating tooltipped download-link
waves-effect waves-light"
data-position="top"
data-tooltip="Download">
<i class="material-icons">file_download</i>
</a>
<a class="btn-floating tooltipped modal-trigger red
waves-effect waves-light delete-modal"
data-position="top"
data-tooltip="Delete">
<i class="material-icons">delete</i>
</a>
</td>
</tr>`,
valueNames: ["filename",
"author",
"title",
"publishing_year",
{name: "edit-link", attr: "href"},
{name: "download-link", attr: "href"},
{name: "delete-modal", attr: "data-target"}]
},
// 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>
@ -180,9 +231,9 @@ RessourceList.options = {
<td>
<span class="badge new status" data-badge-caption=""></span>
</td>
<td class="right-align">
<td class="actions center-align">
<a class="btn-floating link waves-effect waves-light">
<i class="material-icons right">send</i>
<i class="material-icons">send</i>
</a>
</td>
</tr>`,
@ -198,8 +249,12 @@ RessourceList.options = {
},
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>
<td class="actions center-align">
<a class="btn-floating tooltipped download-link
waves-effect waves-light"
data-position="top"
data-tooltip="Download">
<i class="material-icons">file_download</i>
</a>
</td>
</tr>`,
@ -217,12 +272,24 @@ RessourceList.options = {
<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>
<td class="actions center-align">
<a class="btn-floating tooltipped details-link
waves-effect waves-light"
data-position="top"
data-tooltip="Metadata Info">
<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 class="btn-floating tooltipped inspect-link
waves-effect waves-light"
data-position="top"
data-tooltip="View Results">
<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 class="btn-floating tooltipped red delete-modal
waves-effect waves-light modal-trigger"
data-position="top"
data-tooltip="Delete">
<i class="material-icons">delete</i>
</a>
</td>
</tr>`,
@ -246,8 +313,12 @@ RessourceList.options = {
<td class="role_id"></td>
<td class="confirmed"></td>
<td class="id"></td>
<td class="actions">
<a class="btn-floating profile-link waves-effect waves-light"><i class="material-icons">edit</i>
<td class="actions center-align">
<a class="btn-floating tooltipped profile-link waves-effect
waves-light"
data-position="top"
data-tooltip="Edit User">
<i class="material-icons">edit</i>
</a>
</td>
</tr>`,