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

55 lines
1.5 KiB
JavaScript
Raw Normal View History

class JobInputList extends RessourceList {
static options = {
item: `
2021-12-08 10:25:52 +00:00
<tr class="hoverable">
<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(),
ressourceMapper: jobInput => {
return {
id: jobInput.id,
creationDate: jobInput.creation_date,
filename: jobInput.filename
};
},
sortValueName: 'creationDate',
valueNames: [{data: ['id']}, {data: ['creationDate']}, 'filename']
};
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-12-01 13:15:20 +00:00
let jobInputElement;
let jobInputId;
let action;
let actionButtonElement;
jobInputElement = event.target.closest('tr[data-id]');
2021-11-30 15:22:16 +00:00
if (jobInputElement === null) {return;}
2021-12-01 13:15:20 +00:00
jobInputId = jobInputElement.dataset.id;
actionButtonElement = event.target.closest('.action-button[data-action]');
if (actionButtonElement === null) {return;}
2021-12-01 13:15:20 +00:00
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;}
}