class JobInputList extends ResourceList { static autoInit() { for (let jobInputListElement of document.querySelectorAll('.job-input-list:not(.no-autoinit)')) { new JobInputList(jobInputListElement); } } constructor(listContainerElement, options = {}) { super(listContainerElement, options); this.listjs.list.addEventListener('click', (event) => {this.onClick(event)}); this.isInitialized = false; this.userId = listContainerElement.dataset.userId; this.jobId = listContainerElement.dataset.jobId; app.subscribeUser(this.userId).then((response) => { app.socket.on('PATCH', (patch) => { if (this.isInitialized) {this.onPatch(patch);} }); }); app.getUser(this.userId).then((user) => { this.add(Object.values(user.jobs[this.jobId].inputs)); this.isInitialized = true; }); } get item() { return ` file_download `.trim(); } get valueNames() { return [ {data: ['id']}, {data: ['creation-date']}, 'filename' ]; } initListContainerElement() { if (!this.listContainerElement.hasAttribute('id')) { this.listContainerElement.id = Utils.generateElementId('job-input-list-'); } let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`); this.listContainerElement.innerHTML = `
search
Filename
`.trim(); } mapResourceToValue(jobInput) { return { 'id': jobInput.id, 'creation-date': jobInput.creation_date, 'filename': jobInput.filename }; } sort() { this.listjs.sort('filename', {order: 'asc'}); } onClick(event) { let listItemElement = event.target.closest('.list-item[data-id]'); if (listItemElement === null) {return;} let itemId = listItemElement.dataset.id; let listActionElement = event.target.closest('.list-action-trigger[data-list-action]'); let listAction = listActionElement === null ? 'download' : listActionElement.dataset.listAction; switch (listAction) { case 'download': { window.location.href = `/jobs/${this.jobId}/inputs/${itemId}/download`; break; } default: { break; } } } }