Merge branch 'development' of gitlab.ub.uni-bielefeld.de:sfb1288inf/nopaque into development

This commit is contained in:
Stephan Porada 2020-07-15 11:02:14 +02:00
commit 323b8b82ee
7 changed files with 90 additions and 137 deletions

View File

@ -1,6 +1,6 @@
class RessourceList extends List { class RessourceList extends List {
constructor(idOrElement, subscriberList, type, options={}) { constructor(idOrElement, subscriberList, type, options={}) {
if (!["corpus", "corpus_file", "job", "job_input", "query_result", "result", "user"].includes(type)) { if (!["Corpus", "CorpusFile", "Job", "JobInput", "QueryResult", "User", "result"].includes(type)) {
console.error("Unknown Type!"); console.error("Unknown Type!");
return; return;
} }
@ -87,8 +87,8 @@ RessourceList.dataMapper = {
// have to correspond with the class of an <a> element in the // have to correspond with the class of an <a> element in the
// RessourceList.options item blueprint. // RessourceList.options item blueprint.
// Mapping for corpus entities shown in the dashboard table. // Mapping for Corpus entities shown in the dashboard table.
corpus: corpus => ({creation_date: corpus.creation_date, Corpus: corpus => ({creation_date: corpus.creation_date,
description: corpus.description, description: corpus.description,
id: corpus.id, id: corpus.id,
"analyse-link": ["analysing", "prepared", "start analysis"].includes(corpus.status) ? `/corpora/${corpus.id}/analyse` : "", "analyse-link": ["analysing", "prepared", "start analysis"].includes(corpus.status) ? `/corpora/${corpus.id}/analyse` : "",
@ -96,7 +96,7 @@ RessourceList.dataMapper = {
status: corpus.status, status: corpus.status,
title: corpus.title}), title: corpus.title}),
// Mapping for corpus file entities shown in the corpus overview // Mapping for corpus file entities shown in the corpus overview
corpus_file: corpus_file => ({filename: corpus_file.filename, CorpusFile: corpus_file => ({filename: corpus_file.filename,
author: corpus_file.author, author: corpus_file.author,
title: corpus_file.title, title: corpus_file.title,
publishing_year: corpus_file.publishing_year, publishing_year: corpus_file.publishing_year,
@ -104,7 +104,7 @@ RessourceList.dataMapper = {
"download-link": `${corpus_file.corpus_id}/files/${corpus_file.id}/download`, "download-link": `${corpus_file.corpus_id}/files/${corpus_file.id}/download`,
"delete-modal": `delete-corpus-file-${corpus_file.id}-modal`}), "delete-modal": `delete-corpus-file-${corpus_file.id}-modal`}),
// Mapping for job entities shown in the dashboard table. // Mapping for job entities shown in the dashboard table.
job: job => ({creation_date: job.creation_date, Job: job => ({creation_date: job.creation_date,
description: job.description, description: job.description,
id: job.id, id: job.id,
link: `/jobs/${job.id}`, link: `/jobs/${job.id}`,
@ -112,12 +112,13 @@ RessourceList.dataMapper = {
status: job.status, status: job.status,
title: job.title}), title: job.title}),
// Mapping for job input files shown in table on every job page // Mapping for job input files shown in table on every job page
job_input: job_input => ({filename: job_input.filename, JobInput: job_input => ({filename: job_input.filename,
id: job_input.job_id, 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. // Mapping for imported result entities from corpus analysis.
// Shown in imported results table // Shown in imported results table
query_result: query_result => ({description: query_result.description, QueryResult: query_result => ({description: query_result.description,
"download-link": `/query_results/${query_result.id}/download`,
id: query_result.id, id: query_result.id,
link: `/query_results/${query_result.id}`, link: `/query_results/${query_result.id}`,
title: query_result.title}), title: query_result.title}),
@ -132,7 +133,7 @@ RessourceList.dataMapper = {
"download-link": `${result.id}/file/${result.file_id}/download`, "download-link": `${result.id}/file/${result.file_id}/download`,
"delete-modal": `delete-result-${result.id}-modal`}), "delete-modal": `delete-result-${result.id}-modal`}),
// Mapping for user entities shown in admin table // Mapping for user entities shown in admin table
user: user => ({username: user.username, User: user => ({username: user.username,
email: user.email, email: user.email,
role_id: user.role_id, role_id: user.role_id,
confirmed: user.confirmed, confirmed: user.confirmed,
@ -146,22 +147,19 @@ RessourceList.options = {
common: {page: 4, pagination: {innerWindow: 8, outerWindow: 1}}, common: {page: 4, pagination: {innerWindow: 8, outerWindow: 1}},
// extended list.js options for 10 rows per page etc. // extended list.js options for 10 rows per page etc.
extended: {page: 10, extended: {page: 10,
pagination: [ pagination: [{name: "paginationTop",
{
name: "paginationTop",
paginationClass: "paginationTop", paginationClass: "paginationTop",
innerWindow: 8, innerWindow: 8,
outerWindow: 1 outerWindow: 1},
}, {paginationClass: "paginationBottom",
{
paginationClass: "paginationBottom",
innerWindow: 8, innerWindow: 8,
outerWindow: 1 outerWindow: 1}]},
} /* Type specific List.js options. Usually only "item" and "valueNames" gets
]}, * defined here but it is possible to define other List.js options.
// Corpus entity blueprint setting html strucuture per entity per row * item: https://listjs.com/api/#item
// Link classes have to correspond with Links defined in the Mapping process * valueNames: https://listjs.com/api/#valueNames
corpus: {item: `<tr> */
Corpus: {item: `<tr>
<td> <td>
<a class="btn-floating disabled"> <a class="btn-floating disabled">
<i class="material-icons service">book</i> <i class="material-icons service">book</i>
@ -176,54 +174,34 @@ RessourceList.options = {
</span> </span>
</td> </td>
<td class="actions right-align"> <td class="actions right-align">
<a class="btn-floating tooltipped edit-link waves-effect <a class="btn-floating tooltipped waves-effect waves-light edit-link" data-position="top" data-tooltip="Edit">
waves-light"
data-position="top"
data-tooltip="Edit">
<i class="material-icons">edit</i> <i class="material-icons">edit</i>
</a> </a>
<a class="btn-floating tooltipped analyse-link <a class="btn-floating tooltipped waves-effect waves-light analyse-link" data-position="top" data-tooltip="Analyse">
waves-effect waves-light"
data-position="top"
data-tooltip="Analyse">
<i class="material-icons">search</i> <i class="material-icons">search</i>
</a> </a>
</td> </td>
</tr>`, </tr>`,
// Corpus Value Names per column. Have to correspond with the keys from the
// Mapping step above.
valueNames: ["creation_date", valueNames: ["creation_date",
"description", "description",
"title", "title",
{data: ["id"]}, {data: ["id"]},
{name: "analyse-link", attr: "href"}, {name: "analyse-link", attr: "href"},
{name: "edit-link", attr: "href"}, {name: "edit-link", attr: "href"},
{name: "status", attr: "data-status"}] {name: "status", attr: "data-status"}]},
}, CorpusFile: {item: `<tr>
// 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="filename" style="word-break: break-word;"></td>
<td class="author" 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="title" style="word-break: break-word;"></td>
<td class="publishing_year" style="word-break: break-word;"></td> <td class="publishing_year" style="word-break: break-word;"></td>
<td class="actions right-align"> <td class="actions right-align">
<a class="btn-floating tooltipped edit-link <a class="btn-floating tooltipped waves-effect waves-light edit-link" data-position="top" data-tooltip="Edit">
waves-effect waves-light"
data-position="top"
data-tooltip="Edit">
<i class="material-icons">edit</i> <i class="material-icons">edit</i>
</a> </a>
<a class="btn-floating tooltipped download-link <a class="btn-floating tooltipped waves-effect waves-light download-link" data-position="top" data-tooltip="Download">
waves-effect waves-light"
data-position="top"
data-tooltip="Download">
<i class="material-icons">file_download</i> <i class="material-icons">file_download</i>
</a> </a>
<a class="btn-floating tooltipped modal-trigger red <a class="btn-floating modal-trigger red tooltipped waves-effect waves-light delete-modal" data-position="top" data-tooltip="Delete">
waves-effect waves-light delete-modal"
data-position="top"
data-tooltip="Delete">
<i class="material-icons">delete</i> <i class="material-icons">delete</i>
</a> </a>
</td> </td>
@ -234,11 +212,8 @@ RessourceList.options = {
"publishing_year", "publishing_year",
{name: "edit-link", attr: "href"}, {name: "edit-link", attr: "href"},
{name: "download-link", attr: "href"}, {name: "download-link", attr: "href"},
{name: "delete-modal", attr: "data-target"}] {name: "delete-modal", attr: "data-target"}]},
}, Job: {item: `<tr>
// 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> <td>
<a class="btn-floating disabled"> <a class="btn-floating disabled">
<i class="material-icons service"></i> <i class="material-icons service"></i>
@ -252,40 +227,30 @@ RessourceList.options = {
<span class="badge new status" data-badge-caption=""></span> <span class="badge new status" data-badge-caption=""></span>
</td> </td>
<td class="actions right-align"> <td class="actions right-align">
<a class="btn-floating tooltipped link waves-effect <a class="btn-floating tooltipped waves-effect waves-light link" data-position="top" data-tooltip="Go to Job">
waves-light"
data-position="top"
data-tooltip="Go to Job">
<i class="material-icons">send</i> <i class="material-icons">send</i>
</a> </a>
</td> </td>
</tr>`, </tr>`,
// Job Value Names per column. Have to correspond with the keys from the
// Mapping step above.
valueNames: ["creation_date", valueNames: ["creation_date",
"description", "description",
"title", "title",
{data: ["id"]}, {data: ["id"]},
{name: "link", attr: "href"}, {name: "link", attr: "href"},
{name: "service", attr: "data-service"}, {name: "service", attr: "data-service"},
{name: "status", attr: "data-status"}] {name: "status", attr: "data-status"}]},
}, JobInput: {item : `<tr>
job_input: {item : `<tr>
<td class="filename"></td> <td class="filename"></td>
<td class="actions right-align"> <td class="actions right-align">
<a class="btn-floating tooltipped download-link <a class="btn-floating tooltipped waves-effect waves-light download-link" data-position="top" data-tooltip="Download">
waves-effect waves-light"
data-position="top"
data-tooltip="Download">
<i class="material-icons">file_download</i> <i class="material-icons">file_download</i>
</a> </a>
</td> </td>
</tr>`, </tr>`,
valueNames: ["filename", valueNames: ["filename",
"id", "id",
{name: "download-link", attr: "href"}] {name: "download-link", attr: "href"}]},
}, QueryResult: {item: `<tr>
query_result: {item: `<tr>
<td> <td>
<a class="btn-floating disabled"> <a class="btn-floating disabled">
<i class="material-icons service">book</i> <i class="material-icons service">book</i>
@ -296,21 +261,15 @@ RessourceList.options = {
<i class="description"></i> <i class="description"></i>
</td> </td>
<td class="actions right-align"> <td class="actions right-align">
<a class="btn-floating tooltipped link waves-effect <a class="btn-floating tooltipped link waves-effect waves-light" data-position="top" data-tooltip="Go to query result">
waves-light"
data-position="top"
data-tooltip="Go to query result">
<i class="material-icons">send</i> <i class="material-icons">send</i>
</a> </a>
</td> </td>
</tr>`, </tr>`,
// Job Value Names per column. Have to correspond with the keys from the
// Mapping step above.
valueNames: ["description", valueNames: ["description",
"title", "title",
{data: ["id"]}, {data: ["id"]},
{name: "link", attr: "href"}] {name: "link", attr: "href"}]},
},
// Result (imported from corpus analysis) entity blueprint setting html // Result (imported from corpus analysis) entity blueprint setting html
// strucuture per entity per row // strucuture per entity per row
// Link classes have to correspond with Links defined in the Mapping process // Link classes have to correspond with Links defined in the Mapping process
@ -363,30 +322,24 @@ RessourceList.options = {
}, },
// User entity blueprint setting html strucuture per entity per row // User entity blueprint setting html strucuture per entity per row
// Link classes have to correspond with Links defined in the Mapping process // Link classes have to correspond with Links defined in the Mapping process
user: {item: `<tr> User: {item: `<tr>
<td class="username"></td> <td class="username"></td>
<td class="email"></td> <td class="email"></td>
<td class="role_id"></td> <td class="role_id"></td>
<td class="confirmed"></td> <td class="confirmed"></td>
<td class="id"></td> <td class="id"></td>
<td class="actions right-align"> <td class="actions right-align">
<a class="btn-floating tooltipped profile-link waves-effect <a class="btn-floating tooltipped profile-link waves-effect waves-light" data-position="top" data-tooltip="Edit User">
waves-light"
data-position="top"
data-tooltip="Edit User">
<i class="material-icons">edit</i> <i class="material-icons">edit</i>
</a> </a>
</td> </td>
</tr>`, </tr>`,
// User Value Names per column. Have to correspond with keys from the
// Mapping step above.
valueNames: ["username", valueNames: ["username",
"email", "email",
"role_id", "role_id",
"confirmed", "confirmed",
"id", "id",
{name: "profile-link", attr: "href"}] {name: "profile-link", attr: "href"}]}
}
}; };

View File

@ -34,7 +34,7 @@
<script> <script>
var ressources = {{ users|tojson|safe }}; var ressources = {{ users|tojson|safe }};
var userList = new RessourceList('users', null, "user"); var userList = new RessourceList('users', null, "User");
userList.addRessources(ressources); userList.addRessources(ressources);
RessourceList.modifyTooltips(); RessourceList.modifyTooltips();
</script> </script>

View File

@ -101,8 +101,8 @@
<script> <script>
var corpusList = new RessourceList("corpora", nopaque.foreignCorporaSubscribers, "corpus"); var corpusList = new RessourceList("corpora", nopaque.foreignCorporaSubscribers, "Corpus");
var jobList = new RessourceList("jobs", nopaque.foreignJobsSubscribers, "job"); var jobList = new RessourceList("jobs", nopaque.foreignJobsSubscribers, "Job");
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
nopaque.socket.emit("foreign_user_data_stream_init", {{ user.id }}); nopaque.socket.emit("foreign_user_data_stream_init", {{ user.id }});
}); });

View File

@ -124,7 +124,7 @@
<script> <script>
// create corpus file table // create corpus file table
var ressources = {{ corpus_files|tojson|safe }}; var ressources = {{ corpus_files|tojson|safe }};
var corpusFilesList = new RessourceList("corpus-files", null, "corpus_file"); var corpusFilesList = new RessourceList("corpus-files", null, "CorpusFile");
corpusFilesList.addRessources(ressources); corpusFilesList.addRessources(ressources);
RessourceList.modifyTooltips(); RessourceList.modifyTooltips();

View File

@ -160,7 +160,7 @@
<script> <script>
// job_input_table code // job_input_table code
var ressources = {{ job_inputs|tojson|safe }}; var ressources = {{ job_inputs|tojson|safe }};
var jobInputsList = new RessourceList("inputs", null, "job_input"); var jobInputsList = new RessourceList("inputs", null, "JobInput");
jobInputsList.addRessources(ressources); jobInputsList.addRessources(ressources);
RessourceList.modifyTooltips(); RessourceList.modifyTooltips();

View File

@ -107,7 +107,7 @@
<script> <script>
var corpusList = new RessourceList("corpora", nopaque.corporaSubscribers, var corpusList = new RessourceList("corpora", nopaque.corporaSubscribers,
"corpus"); "Corpus");
var jobList = new RessourceList("jobs", nopaque.jobsSubscribers, "job"); var jobList = new RessourceList("jobs", nopaque.jobsSubscribers, "Job");
</script> </script>
{% endblock %} {% endblock %}

View File

@ -84,9 +84,9 @@
<script> <script>
var corpusList = new RessourceList("corpora", nopaque.corporaSubscribers, var corpusList = new RessourceList("corpora", nopaque.corporaSubscribers,
"corpus", {page: 10}); "Corpus", {page: 10});
var queryResultList = new RessourceList("query-results", var queryResultList = new RessourceList("query-results",
nopaque.queryResultsSubscribers, nopaque.queryResultsSubscribers,
"query_result", {page: 10}); "QueryResult", {page: 10});
</script> </script>
{% endblock %} {% endblock %}