2021-01-11 12:36:45 +00:00
|
|
|
class JobInputList extends RessourceList {
|
2021-12-02 15:25:48 +00:00
|
|
|
static options = {
|
|
|
|
item: `
|
2021-12-08 10:25:52 +00:00
|
|
|
<tr class="hoverable">
|
2021-12-02 15:25:48 +00:00
|
|
|
<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(),
|
2021-12-03 11:01:50 +00:00
|
|
|
ressourceMapper: jobInput => {
|
|
|
|
return {
|
2022-02-08 11:26:20 +00:00
|
|
|
'id': jobInput.id,
|
|
|
|
'creation-date': jobInput.creation_date,
|
|
|
|
'filename': jobInput.filename
|
2021-12-03 11:01:50 +00:00
|
|
|
};
|
|
|
|
},
|
2022-02-08 11:26:20 +00:00
|
|
|
sortValueName: 'creation-date',
|
|
|
|
valueNames: [
|
|
|
|
{data: ['id']},
|
|
|
|
{data: ['creation-date']},
|
|
|
|
'filename'
|
|
|
|
]
|
2021-12-02 15:25:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-01-11 12:36:45 +00:00
|
|
|
constructor(listElement, options = {}) {
|
|
|
|
super(listElement, {...JobInputList.options, ...options});
|
2021-02-01 08:57:10 +00:00
|
|
|
this.jobId = listElement.dataset.jobId;
|
2021-01-11 12:36:45 +00:00
|
|
|
}
|
|
|
|
|
2021-11-30 15:22:16 +00:00
|
|
|
init(user) {
|
|
|
|
this._init(user.jobs[this.jobId].inputs);
|
2021-01-11 12:36:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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]');
|
2021-01-11 12:36:45 +00:00
|
|
|
if (actionButtonElement === null) {return;}
|
2021-12-01 13:15:20 +00:00
|
|
|
action = actionButtonElement.dataset.action;
|
2021-01-11 12:36:45 +00:00
|
|
|
switch (action) {
|
|
|
|
case 'download':
|
2021-11-30 15:22:16 +00:00
|
|
|
window.location.href = `/jobs/${this.jobId}/inputs/${jobInputId}/download`;
|
2021-01-11 12:36:45 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-04 12:09:17 +00:00
|
|
|
onPATCH(patch) {return;}
|
2021-01-11 12:36:45 +00:00
|
|
|
}
|