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 {
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!");
return;
}
@ -87,8 +87,8 @@ RessourceList.dataMapper = {
// 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,
// Mapping for Corpus entities shown in the dashboard table.
Corpus: corpus => ({creation_date: corpus.creation_date,
description: corpus.description,
id: corpus.id,
"analyse-link": ["analysing", "prepared", "start analysis"].includes(corpus.status) ? `/corpora/${corpus.id}/analyse` : "",
@ -96,15 +96,15 @@ RessourceList.dataMapper = {
status: corpus.status,
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`}),
CorpusFile: 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,
Job: job => ({creation_date: job.creation_date,
description: job.description,
id: job.id,
link: `/jobs/${job.id}`,
@ -112,15 +112,16 @@ RessourceList.dataMapper = {
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`}),
JobInput: 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
query_result: query_result => ({description: query_result.description,
id: query_result.id,
link: `/query_results/${query_result.id}`,
title: query_result.title}),
QueryResult: query_result => ({description: query_result.description,
"download-link": `/query_results/${query_result.id}/download`,
id: query_result.id,
link: `/query_results/${query_result.id}`,
title: query_result.title}),
result: result => ({query: result.query,
match_count: result.match_count,
corpus_name: result.corpus_name,
@ -132,7 +133,7 @@ RessourceList.dataMapper = {
"download-link": `${result.id}/file/${result.file_id}/download`,
"delete-modal": `delete-result-${result.id}-modal`}),
// Mapping for user entities shown in admin table
user: user => ({username: user.username,
User: user => ({username: user.username,
email: user.email,
role_id: user.role_id,
confirmed: user.confirmed,
@ -146,22 +147,19 @@ RessourceList.options = {
common: {page: 4, pagination: {innerWindow: 8, outerWindow: 1}},
// extended list.js options for 10 rows per page etc.
extended: {page: 10,
pagination: [
{
name: "paginationTop",
paginationClass: "paginationTop",
innerWindow: 8,
outerWindow: 1
},
{
paginationClass: "paginationBottom",
innerWindow: 8,
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>
pagination: [{name: "paginationTop",
paginationClass: "paginationTop",
innerWindow: 8,
outerWindow: 1},
{paginationClass: "paginationBottom",
innerWindow: 8,
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.
* item: https://listjs.com/api/#item
* valueNames: https://listjs.com/api/#valueNames
*/
Corpus: {item: `<tr>
<td>
<a class="btn-floating disabled">
<i class="material-icons service">book</i>
@ -176,69 +174,46 @@ RessourceList.options = {
</span>
</td>
<td class="actions right-align">
<a class="btn-floating tooltipped edit-link waves-effect
waves-light"
data-position="top"
data-tooltip="Edit">
<a class="btn-floating tooltipped waves-effect waves-light edit-link" data-position="top" data-tooltip="Edit">
<i class="material-icons">edit</i>
</a>
<a class="btn-floating tooltipped analyse-link
waves-effect waves-light"
data-position="top"
data-tooltip="Analyse">
<a class="btn-floating tooltipped waves-effect waves-light analyse-link" data-position="top" data-tooltip="Analyse">
<i class="material-icons">search</i>
</a>
</td>
</tr>`,
// 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"}]
},
// 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>
{name: "status", attr: "data-status"}]},
CorpusFile: {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 right-align">
<a class="btn-floating tooltipped edit-link
waves-effect waves-light"
data-position="top"
data-tooltip="Edit">
<a class="btn-floating tooltipped waves-effect waves-light edit-link" 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">
<a class="btn-floating tooltipped waves-effect waves-light download-link" 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">
<a class="btn-floating modal-trigger red tooltipped waves-effect waves-light delete-modal" data-position="top" data-tooltip="Delete">
<i class="material-icons">delete</i>
</a>
</td>
</tr>`,
valueNames: ["filename",
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>
{name: "delete-modal", attr: "data-target"}]},
Job: {item: `<tr>
<td>
<a class="btn-floating disabled">
<i class="material-icons service"></i>
@ -252,65 +227,49 @@ RessourceList.options = {
<span class="badge new status" data-badge-caption=""></span>
</td>
<td class="actions right-align">
<a class="btn-floating tooltipped link waves-effect
waves-light"
data-position="top"
data-tooltip="Go to Job">
<i class="material-icons">send</i>
<a class="btn-floating tooltipped waves-effect waves-light link" data-position="top" data-tooltip="Go to Job">
<i class="material-icons">send</i>
</a>
</td>
</tr>`,
// 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"}]
},
job_input: {item : `<tr>
<td class="filename"></td>
<td class="actions right-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>`,
valueNames: ["filename",
"id",
{name: "download-link", attr: "href"}]
},
query_result: {item: `<tr>
<td>
<a class="btn-floating disabled">
<i class="material-icons service">book</i>
</a>
</td>
<td>
<b class="title"></b><br>
<i class="description"></i>
</td>
<td class="actions right-align">
<a class="btn-floating tooltipped link waves-effect
waves-light"
data-position="top"
data-tooltip="Go to query result">
<i class="material-icons">send</i>
{name: "status", attr: "data-status"}]},
JobInput: {item : `<tr>
<td class="filename"></td>
<td class="actions right-align">
<a class="btn-floating tooltipped waves-effect waves-light download-link" data-position="top" data-tooltip="Download">
<i class="material-icons">file_download</i>
</a>
</td>
</tr>`,
// Job Value Names per column. Have to correspond with the keys from the
// Mapping step above.
valueNames: ["description",
"title",
{data: ["id"]},
{name: "link", attr: "href"}]
},
</td>
</tr>`,
valueNames: ["filename",
"id",
{name: "download-link", attr: "href"}]},
QueryResult: {item: `<tr>
<td>
<a class="btn-floating disabled">
<i class="material-icons service">book</i>
</a>
</td>
<td>
<b class="title"></b><br>
<i class="description"></i>
</td>
<td class="actions right-align">
<a class="btn-floating tooltipped link waves-effect waves-light" data-position="top" data-tooltip="Go to query result">
<i class="material-icons">send</i>
</a>
</td>
</tr>`,
valueNames: ["description",
"title",
{data: ["id"]},
{name: "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
@ -363,30 +322,24 @@ RessourceList.options = {
},
// 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>
User: {item: `<tr>
<td class="username"></td>
<td class="email"></td>
<td class="role_id"></td>
<td class="confirmed"></td>
<td class="id"></td>
<td class="actions right-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>
<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>`,
// 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"}]}
};

View File

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

View File

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

View File

@ -124,7 +124,7 @@
<script>
// create corpus file table
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);
RessourceList.modifyTooltips();

View File

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

View File

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

View File

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