nopaque/app/static/js/nopaque/RessourceLists/JobInputList.js

48 lines
1.4 KiB
JavaScript
Raw Normal View History

class JobInputList extends RessourceList {
constructor(listElement, options = {}) {
super(listElement, {...JobInputList.options, ...options});
this.jobId = listElement.dataset.jobId;
}
2021-11-30 15:22:16 +00:00
init(user) {
this._init(user.jobs[this.jobId].inputs);
}
onclick(event) {
2021-11-30 15:22:16 +00:00
let jobInputElement = event.target.closest('tr[data-id]');
if (jobInputElement === null) {return;}
let jobInputId = jobInputElement.dataset.id;
let actionButtonElement = event.target.closest('.action-button[data-action]');
if (actionButtonElement === null) {return;}
let action = actionButtonElement.dataset.action;
switch (action) {
case 'download':
2021-11-30 15:22:16 +00:00
window.location.href = `/jobs/${this.jobId}/inputs/${jobInputId}/download`;
break;
default:
break;
}
}
2021-11-30 15:22:16 +00:00
usersPatchHandler(patch) {return;}
preprocessRessource(jobInput) {
2021-11-30 15:22:16 +00:00
return {
id: jobInput.id,
creationDate: jobInput.creation_date,
filename: jobInput.filename
};
}
}
JobInputList.options = {
2021-11-30 15:22:16 +00:00
item: `
<tr>
<td><span class="filename"></span></td>
<td class="right-align">
<a class="action-button btn-floating tooltipped waves-effect waves-light" data-action="download" data-position="top" data-tooltip="View"><i class="material-icons">file_download</i></a>
</td>
</tr>
`.trim(),
valueNames: [{data: ['id']}, 'filename']
};